-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindow.hpp
More file actions
68 lines (46 loc) · 1.88 KB
/
Copy pathWindow.hpp
File metadata and controls
68 lines (46 loc) · 1.88 KB
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
// SPDX-License-Identifier: GPL-3.0-or-later
/*
* gtk-sfml - a set of widgets for integrating SFML into gtkmm3.
* Copyright (C) 2023 Daniel K. O.
*/
#ifndef GTKSFML_WINDOW_HPP
#define GTKSFML_WINDOW_HPP
#include <SFML/Graphics/RenderWindow.hpp>
#include <gtkmm/builder.h>
#include <gtkmm/window.h>
namespace gtksfml {
class Window : public Gtk::Window,
public sf::RenderWindow {
bool auto_update_state = false;
guint tick_id;
// hide this method, use on_event() instead
using sf::RenderWindow::pollEvent;
void init();
protected:
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) override;
bool on_focus_in_event(GdkEventFocus* event) override;
bool on_focus_out_event(GdkEventFocus* event) override;
bool on_key_press_event(GdkEventKey* event) override;
bool on_key_release_event(GdkEventKey* event) override;
bool on_motion_notify_event(GdkEventMotion* event) override;
bool on_button_press_event(GdkEventButton* event) override;
bool on_button_release_event(GdkEventButton* event) override;
bool on_scroll_event(GdkEventScroll* event) override;
void on_realize() override;
void on_unrealize() override;
bool on_tick(const Glib::RefPtr<Gdk::FrameClock>& clock);
// user should override these
virtual void on_event(const sf::Event& event);
virtual void on_render() = 0;
virtual void on_update();
public:
Window(Gtk::WindowType type = Gtk::WindowType::WINDOW_TOPLEVEL);
Window(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
// enable to call on_update() and on_render() periodically.
void set_auto_update(bool enable);
bool get_auto_update() const;
using sf::RenderWindow::draw;
using Gtk::Window::close;
};
}
#endif