blob: b33605b78531384934d084eadca690a96c231705 (
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
|
#pragma once
#include "ChatWindow.hpp"
#include "LoginWindow.hpp"
#include "WindowNotification.hpp"
#include <gtkmm/window.h>
#include <gtkmm/stack.h>
#include <gtkmm/overlay.h>
#include <dchat/Room.hpp>
#include <mutex>
#include <random>
#include <vector>
#include <future>
#include <glibmm/dispatcher.h>
namespace dchat
{
class Window : public Gtk::Window
{
public:
Window();
virtual ~Window();
std::shared_ptr<Rooms> rooms;
WindowNotification *windowNotification;
private:
using DispatcherHandler = std::function<void()>;
bool drawBackground(const Cairo::RefPtr<Cairo::Context> &cairo);
void dispatchFunction(DispatcherHandler func);
private:
class OverlayDrawable : public Gtk::Overlay
{
public:
void draw(const Cairo::RefPtr<Cairo::Context> &cairo) { Gtk::Overlay::draw(cairo); }
};
std::thread::id mainThreadId;
std::mutex databaseCallbackMutex;
OverlayDrawable overlay;
Gtk::Stack stack;
LoginWindow loginWindow;
ChatWindow chatWindow;
struct Node
{
double radius;
double originalPosX;
double originalPosY;
double currentPosX;
double currentPosY;
double targetPosX;
double targetPosY;
};
std::mt19937 backgroundRng;
std::vector<Node> backgroundNodes;
int prevTimeMillis;
sigc::connection drawBackgroundConnection;
Glib::Dispatcher dispatcher;
std::recursive_mutex dispatcherMutex;
std::vector<DispatcherHandler> dispatcherHandlers;
};
}
|