aboutsummaryrefslogtreecommitdiff
path: root/include/ChatWindow.hpp
blob: 832154dd929859cc1ce7036aa8169591d2166454 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once

#include "ImageButton.hpp"
#include "RoomSettingsWindow.hpp"
#include "RoomNotificationsWindow.hpp"
#include "UserSettingsWindow.hpp"
#include <dchat/Room.hpp>
#include <gtkmm/label.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/grid.h>
#include <gtkmm/entry.h>
#include "ResponsivePaned.hpp"
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/stack.h>
#include <gtkmm/textview.h>
#include <gtkmm/stacksidebar.h>
#include <odhtdb/Hash.hpp>
#include <odhtdb/Signature.hpp>

namespace dchat
{
    class ChatMessage;
    class Window;
    class Topbar;

    class ChatWindow : public Gtk::Grid
    {
    public:
        ChatWindow(Window *window);
        ~ChatWindow();
        void addRoom(std::shared_ptr<Room> room);
        void addMessage(const RoomAddMessageRequest &request);
        void addUser(const RoomAddUserRequest &request);
        void setUserNickname(const UserChangeNicknameRequest &request);
        void setUserAvatar(const UserChangeAvatarRequest &request);
        void changeRoomName(const RoomChangeNameRequest &request);
        void addInviteRequest(const InviteUserRequest &request);
        void scrollToBottom();

        Topbar *topbar;
        Gtk::Stack stack;
        Gtk::Grid chatPage;
        RoomSettingsWindow roomSettingsWindow;
        RoomNotificationsWindow roomNotificationsWindow;
        UserSettingsWindow userSettingsWindow;
        Window *window;
        std::shared_ptr<Room> currentRoom;
    private:
        void setupTopbar();
        void setupLeftPanel(Gtk::ResponsivePaned *sidePanels);
        void setupMessageArea(Gtk::Grid *rightPanel);
        void setupChatInput(Gtk::Grid *rightPanel);

        void setCurrentRoom(std::shared_ptr<Room> room);
    private:
        //Gtk::Grid leftPanelChannels;
        Gtk::StackSidebar leftPanelChannels;
        Gtk::Stack leftPanelUsersStack;
        ImageButton createRoomButton;
        ImageButton joinRoomButton;
        ImageButton userSettingsButton;
        Gtk::Stack messageAreaStack;
        Gtk::TextView chatInput;

        struct RoomData
        {
            Gtk::Grid *leftPanelUsersLayout;
            Gtk::Grid *messageAreaLayout;
            uint numMessages;
            uint numUsers;
            Gtk::RadioButton *button;
        };

        odhtdb::MapHash<RoomData*> roomDataById;
        odhtdb::MapHash<ChatMessage*> messageById;
        int chatPrevNumLines;
        int roomCount;
        RoomData *currentRoomData;
        bool chatInputShowPlaceholder;
        bool chatInputChangeByPlaceholder;
    };
}