aboutsummaryrefslogtreecommitdiff
path: root/include/ChatWindow.hpp
blob: d457b7d73b3bf7c1db1fd944ed67233bc325d902 (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
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#include "ImageButton.hpp"
#include <dchat/Room.hpp>
#include <gtkmm/label.h>
#include <gtkmm/togglebutton.h>
#include <gtkmm/grid.h>
#include <gtkmm/entry.h>
#include <gtkmm/paned.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/stack.h>
#include <gtkmm/textview.h>
#include <odhtdb/Hash.hpp>
#include <odhtdb/Signature.hpp>

namespace dchat
{
    class ChatMessage;
    class Window;

    class ChatWindow : public Gtk::Grid
    {
    public:
        ChatWindow(Window *window);
        ~ChatWindow();
        void addRoom(std::shared_ptr<Room> room);
        void addMessage(const RoomAddMessageRequest &request);
        void addUser(std::shared_ptr<Room> room, std::shared_ptr<User> user);
        void setUserNickname(const UserChangeNicknameRequest &request);
        void changeRoomName(const RoomChangeNameRequest &request);
        void scrollToBottom();
    private:
        void setupTopBar();
        void setupLeftPanel(Gtk::Paned *sidePanels);
        void setupMessageArea(Gtk::Grid *rightPanel);
        void setupChatInput(Gtk::Grid *rightPanel);

        void setCurrentRoom(std::shared_ptr<Room> room);
    private:
        Gtk::Grid topbar;
        Gtk::Entry topbarSearchBar;
        Gtk::Grid leftPanelChannels;
        Gtk::Stack leftPanelUsersStack;
        ImageButton addRoomButton;
        Gtk::Label currentChannelTitle;
        Gtk::ScrolledWindow messageArea;
        Gtk::Stack messageAreaStack;
        Gtk::TextView chatInput;

        struct RoomData
        {
            Gtk::Grid *leftPanelUsersLayout;
            Gtk::Grid *messageAreaLayout;
            Gtk::ToggleButton *button;
        };

        odhtdb::MapHash<RoomData*> roomDataById;
        odhtdb::MapHash<ChatMessage*> messageById;
        int chatPrevNumLines;
        int roomCount;
        RoomData *currentRoomData;
        std::shared_ptr<Room> currentRoom;
        Window *window;
    };
}