istereo2
view libs/goatkit/widget.h @ 20:2b85d05df3f2
animation controls for easier screenshot grabbing
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 02 Oct 2015 04:54:55 +0300 |
parents | 3bccfc7d10fe |
children |
line source
1 /*
2 GoatKit - a themable/animated widget toolkit for games
3 Copyright (C) 2014 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef GOATKIT_WIDGET_H_
19 #define GOATKIT_WIDGET_H_
21 #include "vec.h"
22 #include "event.h"
24 namespace goatkit {
26 struct BBox {
27 Vec2 bmin, bmax;
28 };
30 class Screen;
31 class Widget;
32 struct WidgetImpl;
34 typedef void (*EventCallback)(Widget*, const Event &ev, void *cls);
36 class Widget {
37 protected:
38 WidgetImpl *widget;
40 virtual void set_screen(Screen *scr);
41 Screen *get_screen() const;
43 public:
44 Widget();
45 virtual ~Widget();
47 virtual const char *get_type_name() const;
49 virtual void set_name(const char *name);
50 virtual const char *get_name() const;
52 virtual void set_text(const char *text);
53 virtual const char *get_text() const;
55 virtual void show();
56 virtual void hide();
57 virtual float get_visibility() const;
58 virtual bool is_visible() const;
59 virtual void set_visibility_transition(long msec);
60 virtual long get_visibility_transition() const;
62 virtual void activate();
63 virtual void deactivate();
64 virtual float get_active() const;
65 virtual bool is_active() const;
66 virtual void set_active_transition(long msec);
67 virtual long get_active_transition() const;
69 virtual void press();
70 virtual void release();
71 virtual float get_pressed() const;
72 virtual bool is_pressed() const;
73 virtual void set_press_transition(long msec);
74 virtual long get_press_transition() const;
76 virtual void mousein();
77 virtual void mouseout();
78 virtual float get_under_mouse() const;
79 virtual bool is_under_mouse() const;
80 virtual void set_hover_transition(long msec);
81 virtual long get_hover_transition() const;
83 // input focus, managed by the screen
84 virtual bool can_focus() const;
85 virtual void focusin();
86 virtual void focusout();
87 virtual float get_focus() const;
88 virtual bool is_focused() const;
89 virtual void set_focus_transition(long msec);
90 virtual long get_focus_transition() const;
92 virtual void set_position(float x, float y);
93 virtual void set_position(const Vec2 &pos);
94 virtual const Vec2 &get_position() const;
96 virtual void set_size(float x, float y);
97 virtual void set_size(const Vec2 &size);
98 virtual const Vec2 get_size() const;
100 virtual const BBox &get_box() const;
102 virtual bool hit_test(const Vec2 &pt) const;
104 virtual void draw() const;
106 // low level events
107 virtual void on_mouse_button(const ButtonEvent &ev);
108 virtual void on_mouse_motion(const MotionEvent &ev);
109 virtual void on_mouse_focus(const FocusEvent &ev);
110 virtual void on_key(const KeyEvent &ev);
112 // high level events
113 virtual void on_click();
114 virtual void on_double_click();
115 virtual void on_change();
116 //virtual void on_drag_move(int bn, const Vec2 &pt);
117 //virtual void on_drag_release(int bn, const Vec2 &pt);
119 // event dispatcher
120 virtual void handle_event(const Event &ev);
122 // external callback setting
123 virtual void set_callback(EventType evtype, EventCallback func, void *cls = 0);
125 friend class Screen;
126 };
128 }
130 #endif // GOATKIT_WIDGET_H_