-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.hpp
58 lines (46 loc) · 1.33 KB
/
gui.hpp
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
#ifndef _GUI_HPP
#define _GUI_HPP
#ifdef GUI_MODE
#include "config.hpp"
#include "gtkmm/alignment.h"
#include "gtkmm/box.h"
#include "gtkmm/container.h"
#include "gtkmm/image.h"
#include "gtkmm/label.h"
#include "gtkmm/overlay.h"
#include "gtkmm/window.h"
namespace GUI
{
class Window : public Gtk::Window
{
public:
Window(const Config& config, const colors_t& colors, const std::string_view path);
virtual ~Window();
private:
Gtk::Overlay m_overlay;
Gtk::Box m_box;
Gtk::Alignment m_alignment;
Gtk::Label m_label;
Gtk::Image *m_img, m_bg_image;
Glib::RefPtr<Gdk::Pixbuf> m_original_pixbuf;
void update_background_image(int width, int height)
{
if (m_original_pixbuf)
{
Glib::RefPtr<Gdk::Pixbuf> scaled_pixbuf =
m_original_pixbuf->scale_simple(width, height, Gdk::INTERP_BILINEAR);
m_bg_image.set(scaled_pixbuf);
}
}
// Signal handler for window resize
void on_window_resized(Gtk::Allocation& allocation)
{
int new_width = allocation.get_width();
int new_height = allocation.get_height();
// Update the background image with the new dimensions
update_background_image(new_width, new_height);
}
};
} // namespace GUI
#endif // GUI_MODE
#endif // _GUI_HPP