summaryrefslogtreecommitdiff
path: root/components/chatwindow.hpp
blob: 9b4a16d287efa51eebaa9d1d3e9dd9393d8480cc (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
#pragma once
#include <gtkmm.h>
#include <queue>
#include <mutex>
#include "../discord/discord.hpp"

class ChatWindow {
public:
    ChatWindow();
    Gtk::Widget *GetRoot() const;
    void SetActiveChannel(Snowflake id);
    Snowflake GetActiveChannel() const;
    void SetMessages(std::unordered_set<const MessageData *> msgs);

protected:
    void ScrollToBottom();
    void SetMessagesInternal();
    Gtk::ListBoxRow *CreateChatEntryComponentText(const MessageData *data);
    Gtk::ListBoxRow *CreateChatEntryComponent(const MessageData *data);

    Glib::Dispatcher m_update_dispatcher;
    std::queue<std::unordered_set<const MessageData *>> m_update_queue;
    std::mutex m_update_mutex;

    Snowflake m_active_channel;

    Gtk::Box *m_main;
    Gtk::ListBox *m_listbox;
    Gtk::Viewport *m_viewport;
    Gtk::ScrolledWindow *m_scroll;
    Gtk::ScrolledWindow *m_entry_scroll;
    Gtk::TextView *m_input;
};