aboutsummaryrefslogtreecommitdiff
path: root/src/Topbar.cpp
blob: e4d5fd43ec94f22ce76db0d4a7493b0854f5f591 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "../include/Topbar.hpp"
#include "../include/DynamicImage.hpp"

namespace dchat
{
    Topbar::Topbar() : 
        roomSettingsButton("images/settings-icon.png", nullptr),
        roomNotificationsButton("images/messages_icon.png", nullptr)
    {
        set_name("top-bar");
        set_hexpand(true);

        Gtk::Grid *topbarLeft = Gtk::manage(new Gtk::Grid());
        topbarLeft->set_name("top-bar-left");
        topbarLeft->set_size_request(180);
        topbarLeft->set_valign(Gtk::ALIGN_CENTER);
        topbarLeft->set_halign(Gtk::ALIGN_CENTER);
        attach(*topbarLeft, 0, 0, 1, 1);

        topbarSearchBar.set_name("top-bar-search");
        topbarSearchBar.set_placeholder_text("Search...");
        topbarSearchBar.set_size_request(180);
        topbarLeft->attach(topbarSearchBar, 0, 0, 1, 1);

        Gtk::Grid *topbarRight = Gtk::manage(new Gtk::Grid());
        topbarRight->set_column_spacing(10);
        topbarRight->set_name("top-bar-right");
        topbarRight->set_hexpand(true);
        topbarRight->set_valign(Gtk::ALIGN_CENTER);
        attach_next_to(*topbarRight, *topbarLeft, Gtk::POS_RIGHT, 1, 1);

        DynamicImage *roomIcon = Gtk::manage(new DynamicImage());
        roomIcon->set_halign(Gtk::ALIGN_START);
        roomIcon->set_valign(Gtk::ALIGN_CENTER);
        roomIcon->set_size_request(30, 30);
        roomIcon->url = "https://discordemoji.com/assets/emoji/PeepoHide.png";
        topbarRight->attach(*roomIcon, 0, 0, 1, 1);

        currentRoomTitle.set_name("current-room-title");
        currentRoomTitle.set_selectable(true);
        currentRoomTitle.set_hexpand(true);
        currentRoomTitle.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
        topbarRight->attach_next_to(currentRoomTitle, *roomIcon, Gtk::POS_RIGHT, 1, 1);

        topbarRight->attach_next_to(roomSettingsButton, currentRoomTitle, Gtk::POS_RIGHT, 1, 1);
        topbarRight->attach_next_to(roomNotificationsButton, roomSettingsButton, Gtk::POS_RIGHT, 1, 1);
    }

    void Topbar::setTitle(const Glib::ustring &title)
    {
        currentRoomTitle.set_text(title);
    }
}