aboutsummaryrefslogtreecommitdiff
path: root/include/Window.hpp
blob: a29ec62b933e89f3e79c4b86bbfa79e5a789b171 (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
#pragma once

#include "ChatWindow.hpp"
#include "LoginWindow.hpp"
#include <gtkmm/window.h>
#include <gtkmm/stack.h>
#include <gtkmm/overlay.h>
#include <dchat/Room.hpp>
#include <mutex>
#include <random>
#include <vector>

namespace dchat
{
    class Window : public Gtk::Window
    {
    public:
        Window();
        virtual ~Window();
    private:
        bool drawBackground(const Cairo::RefPtr<Cairo::Context> &cairo);
    private:
        class OverlayDrawable : public Gtk::Overlay
        {
        public:
            void draw(const Cairo::RefPtr<Cairo::Context> &cairo) { Gtk::Overlay::draw(cairo); }
        };

        std::shared_ptr<Rooms> rooms;
        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;
    };
}