rubygoo 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/Manifest.txt +2 -7
- data/README.txt +1 -8
- data/Rakefile +6 -23
- data/TODO +2 -0
- data/lib/inflections.rb +52 -0
- data/lib/inflector.rb +279 -0
- data/lib/rubygoo/adapters/gosu_render_adapter.rb +22 -0
- data/lib/rubygoo/adapters/rubygame_render_adapter.rb +21 -2
- data/lib/rubygoo/app.rb +9 -4
- data/lib/rubygoo/button.rb +54 -33
- data/lib/rubygoo/check_box.rb +20 -8
- data/lib/rubygoo/container.rb +40 -5
- data/lib/rubygoo/icon.rb +9 -1
- data/lib/rubygoo/label.rb +1 -0
- data/lib/rubygoo/radio_button.rb +2 -2
- data/lib/rubygoo/text_field.rb +7 -6
- data/lib/rubygoo/widget.rb +80 -20
- data/samples/create_gui.rb +6 -14
- data/samples/rubygame_app.rb +1 -0
- data/test/test_setup.rb +1 -0
- data/test/widget_spec.rb +10 -2
- data/themes/default/config.yml +2 -0
- metadata +6 -11
- data/docs/Picture 1.png +0 -0
- data/docs/ui/UI.hpp +0 -425
- data/docs/ui/abutton.png +0 -0
- data/docs/ui/background.png +0 -0
- data/docs/ui/button.png +0 -0
- data/docs/ui/moveable.png +0 -0
- data/docs/ui/textbutton.png +0 -0
data/samples/create_gui.rb
CHANGED
@@ -4,7 +4,7 @@ module CreateGui
|
|
4
4
|
|
5
5
|
label = Label.new "click the button to set the time", :x=>20, :y=>30
|
6
6
|
|
7
|
-
button = Button.new "Click Me!", :x=>70, :y=>80, :
|
7
|
+
button = Button.new "Click Me!", :x=>70, :y=>80, :padding_left=>20, :padding_top=>20, :icon => icon, :enabled => false
|
8
8
|
button.on :pressed do |*opts|
|
9
9
|
label.set_text(Time.now.to_s)
|
10
10
|
end
|
@@ -34,19 +34,17 @@ module CreateGui
|
|
34
34
|
puts "BOO-YAH"
|
35
35
|
end
|
36
36
|
|
37
|
-
modal_button = Button.new "Modal dialogs", :x=>270, :y=>240, :
|
37
|
+
modal_button = Button.new "Modal dialogs", :x=>270, :y=>240, :padding_left=>20, :padding_top=>20
|
38
38
|
modal_button.on :pressed do |*opts|
|
39
|
-
# TODO make some of this stuff relative and/or make Dialog's
|
40
|
-
# constructor take a layout to use
|
41
39
|
modal = Dialog.new :modal => app, :x=>60, :y=>110, :w=>250, :h=>250
|
42
40
|
|
43
|
-
modal.add Label.new("Message Here", :x=>20, :y=>70, :
|
41
|
+
modal.add Label.new("Message Here", :x=>20, :y=>70, :padding_left=>20, :padding_top=>20, :relative=>true)
|
44
42
|
resize_me = Button.new "resize", :relative=>true, :x=>170, :y=>180
|
45
43
|
resize_me.on :pressed do |*opts|
|
46
44
|
modal.resize opts.first
|
47
45
|
end
|
48
46
|
|
49
|
-
ok_butt = Button.new("OK", :x=>70, :y=>180, :
|
47
|
+
ok_butt = Button.new("OK", :x=>70, :y=>180, :padding_left=>20, :padding_top=>20,:relative=>true)
|
50
48
|
ok_butt.on :pressed do |*opts|
|
51
49
|
modal.close
|
52
50
|
end
|
@@ -55,7 +53,7 @@ module CreateGui
|
|
55
53
|
modal.display
|
56
54
|
end
|
57
55
|
|
58
|
-
grp = RadioGroup.new :x=>10, :y=>380, :
|
56
|
+
grp = RadioGroup.new :x=>10, :y=>380, :padding_left=>20, :padding_top=>20, :w=> 500, :h=>80
|
59
57
|
grp_label = Label.new "RadioGroups are fun!", :x=>40, :y=>10, :w=>20, :h=>20, :relative=>true
|
60
58
|
grp_radio_one = RadioButton.new :x=>40, :y=>40, :w=>20, :h=>20, :relative=>true
|
61
59
|
grp_radio_two = RadioButton.new :x=>90, :y=>40, :w=>20, :h=>20, :relative=>true
|
@@ -63,7 +61,7 @@ module CreateGui
|
|
63
61
|
|
64
62
|
grp.add grp_label, grp_radio_one, grp_radio_two, grp_radio_three
|
65
63
|
|
66
|
-
hide_button = Button.new "Hide the radios!", :x=>170, :y=>330, :
|
64
|
+
hide_button = Button.new "Hide the radios!", :x=>170, :y=>330, :padding_left=>10, :padding_top=>10
|
67
65
|
hide_button.on :pressed do |*opts|
|
68
66
|
if grp.visible?
|
69
67
|
grp.hide
|
@@ -79,12 +77,6 @@ module CreateGui
|
|
79
77
|
app.add text_field, label, button, modal_button, grp, hide_button, icon_widget
|
80
78
|
app.add check
|
81
79
|
|
82
|
-
# pulldown = Pulldown.new {:x=>70, :y=>80}
|
83
|
-
# pulldown.on :changed do |*opts|
|
84
|
-
# label.set_text(opts.first)
|
85
|
-
# end
|
86
|
-
#
|
87
|
-
# app.add pulldown
|
88
80
|
app
|
89
81
|
end
|
90
82
|
end
|
data/samples/rubygame_app.rb
CHANGED
data/test/test_setup.rb
CHANGED
data/test/widget_spec.rb
CHANGED
@@ -4,16 +4,24 @@ describe Widget do
|
|
4
4
|
|
5
5
|
describe "basic widget behavior" do
|
6
6
|
before :each do
|
7
|
-
|
7
|
+
@widget = Widget.new
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should merge in defaults for any options not given" do
|
11
|
-
@widget = Widget.new
|
12
11
|
for k,v in Widget::DEFAULT_PARAMS
|
13
12
|
@widget.instance_variable_get("@#{k}").should == v
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
16
|
+
it "should define props methods for each of the default params" do
|
17
|
+
Widget::DEFAULT_PARAMS.keys.each_with_index do |k,i|
|
18
|
+
@widget.should.respond_to? k
|
19
|
+
@widget.send(k,i)
|
20
|
+
@widget.send(k).should == i
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
17
25
|
end
|
18
26
|
|
19
27
|
end
|
data/themes/default/config.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shawn Anderson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-09 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.8.
|
53
|
+
version: 1.8.3
|
54
54
|
version:
|
55
55
|
description: GUI library for use with Gosu or Rubygame
|
56
56
|
email: shawn42@gmail.com
|
@@ -68,14 +68,9 @@ files:
|
|
68
68
|
- README.txt
|
69
69
|
- Rakefile
|
70
70
|
- TODO
|
71
|
-
- docs/Picture 1.png
|
72
|
-
- docs/ui/UI.hpp
|
73
|
-
- docs/ui/abutton.png
|
74
|
-
- docs/ui/background.png
|
75
|
-
- docs/ui/button.png
|
76
|
-
- docs/ui/moveable.png
|
77
|
-
- docs/ui/textbutton.png
|
78
71
|
- lib/code_statistics.rb
|
72
|
+
- lib/inflections.rb
|
73
|
+
- lib/inflector.rb
|
79
74
|
- lib/platform.rb
|
80
75
|
- lib/rubygoo.rb
|
81
76
|
- lib/rubygoo/adapters/adapter_factory.rb
|
@@ -133,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
128
|
requirements: []
|
134
129
|
|
135
130
|
rubyforge_project: rubygoo
|
136
|
-
rubygems_version: 1.
|
131
|
+
rubygems_version: 1.3.1
|
137
132
|
signing_key:
|
138
133
|
specification_version: 2
|
139
134
|
summary: Easy to use gui library for Rubygame or Gosu.
|
data/docs/Picture 1.png
DELETED
Binary file
|
data/docs/ui/UI.hpp
DELETED
@@ -1,425 +0,0 @@
|
|
1
|
-
#ifndef UI_HPP
|
2
|
-
#define UI_HPP
|
3
|
-
|
4
|
-
#include <boost/function.hpp>
|
5
|
-
#include <Gosu/Input.hpp>
|
6
|
-
#include <Gosu/Font.hpp>
|
7
|
-
#include <Gosu/TextInput.hpp>
|
8
|
-
#include <boost/bind.hpp>
|
9
|
-
#include <Gosu/Utility.hpp>
|
10
|
-
#include <Gosu/Graphics.hpp>
|
11
|
-
#include <Gosu/Directories.hpp>
|
12
|
-
|
13
|
-
// Comment out these lines if you're using the same thing anyway.
|
14
|
-
typedef boost::shared_ptr<Gosu::Image> Image; // Ich brauch einen tollen Namen D:
|
15
|
-
typedef std::vector<Image> Animation;
|
16
|
-
enum ZOrder {
|
17
|
-
zBackground,
|
18
|
-
zSomething,
|
19
|
-
zOMG, // sorry about this.
|
20
|
-
zUI,
|
21
|
-
zUIButton,
|
22
|
-
zCursor;
|
23
|
-
};
|
24
|
-
// if you don't, you may want to uncomment these.
|
25
|
-
/*
|
26
|
-
void loadImage(std::wstring filename, Image &loadTo, Gosu::Graphics& graphics, bool hardBorder) {
|
27
|
-
loadTo.reset(new Gosu::Image(graphics, Gosu::sharedResourcePrefix() + L"media/" + filename, hardBorder));
|
28
|
-
}
|
29
|
-
|
30
|
-
void loadAnimation(std::wstring filename, Animation &loadTo, Gosu::Graphics& graphics, int width, int height, bool hardBorder) {
|
31
|
-
Gosu::imagesFromTiledBitmap(graphics, Gosu::sharedResourcePrefix() + L"media/" + filename, width, height, hardBorder, loadTo);
|
32
|
-
}
|
33
|
-
*/
|
34
|
-
|
35
|
-
// Change this.
|
36
|
-
#define WINDOW_WIDTH 800
|
37
|
-
#define WINDOW_HEIGHT 600
|
38
|
-
|
39
|
-
/*
|
40
|
-
For the best usage you define a "Mother-Widget". Example code:
|
41
|
-
|
42
|
-
class GameWindow : public Gosu::Window {
|
43
|
-
protected:
|
44
|
-
Widget widgets, *background, *acontainer, *txtbtn;
|
45
|
-
public:
|
46
|
-
GameWindow()
|
47
|
-
: Gosu::Window(WINDOW_WIDTH, WINDOW_HEIGHT, false, 20) {
|
48
|
-
background = new Widget(L"background.png", graphics(), 0, 0, zBackground);
|
49
|
-
widgets->add(background);
|
50
|
-
Button* btn1 = new Button(L"button.png", graphics(), 20, 20, zUIButton);
|
51
|
-
background->add(btn1);
|
52
|
-
btn1->onLeftClick = boost::bind(&GameWindow::explode, this);
|
53
|
-
AdvButton* btn2 = new AdvButton(L"abutton.png", graphics(), 50, 50, 40, 40, zUIButton);
|
54
|
-
widgets->add(btn2);
|
55
|
-
acontainer = new Moveable(L"moveable.png", graphics(), 200, 200, zUI, 120, 40);
|
56
|
-
txtbtn = new AdvTextButton(L"textbutton.png", graphics(), 205, 250, 132, 22, Gosu::defaultFontName(), L"Hello World", true);
|
57
|
-
txtbtn->onLeftClick = boost::bind(&GameWindow::noWorld, this);
|
58
|
-
acontainer->addWidget(txtbtn);
|
59
|
-
}
|
60
|
-
|
61
|
-
void buttonDown(Gosu::Button btn) {
|
62
|
-
if (btn == Gosu::kbF7) {
|
63
|
-
if (background->isVisible()) background->hide(),
|
64
|
-
else background->show();
|
65
|
-
} else if (btn == Gosu::kbF8) {
|
66
|
-
if (acointainer->isVisible()) acontainer->hide();
|
67
|
-
else acointainer->show();
|
68
|
-
} else if (btn == Gosu::kbF9) {
|
69
|
-
// force txtbtn to show >:[
|
70
|
-
txtbtn->show(true);
|
71
|
-
}
|
72
|
-
widgets.buttonDown(btn, input());
|
73
|
-
}
|
74
|
-
|
75
|
-
void buttonUp(Gosu::Button btn) {
|
76
|
-
widgets.buttonUp(btn, input());
|
77
|
-
}
|
78
|
-
|
79
|
-
void update() {
|
80
|
-
widgets.update(input());
|
81
|
-
}
|
82
|
-
|
83
|
-
void draw() {
|
84
|
-
widgets.draw(input());
|
85
|
-
}
|
86
|
-
|
87
|
-
void explode() {
|
88
|
-
exit(-42);
|
89
|
-
}
|
90
|
-
|
91
|
-
void noWorld() {
|
92
|
-
txtbtn->setText(L":((");
|
93
|
-
background->deactivate();
|
94
|
-
}
|
95
|
-
};
|
96
|
-
|
97
|
-
int main(int argc, char* argv[]) {
|
98
|
-
GameWindow window;
|
99
|
-
window.show();
|
100
|
-
}
|
101
|
-
*/
|
102
|
-
class Widget;
|
103
|
-
typedef std::vector<Widget*> Widgets;
|
104
|
-
|
105
|
-
enum AdvTxtBtnKeep {
|
106
|
-
tbkNone = -1,
|
107
|
-
tbkNormal = 0,
|
108
|
-
tbkHover = 1,
|
109
|
-
tbkPressed = 2,
|
110
|
-
tbkDisabled = 3
|
111
|
-
};
|
112
|
-
/**
|
113
|
-
* Mutter aller Grafikelemente! Kann abgeleitet werden und funktioniert rekursiv bis ~ewig!
|
114
|
-
* X/Y/Z: Selbsterkl�rend
|
115
|
-
* Widgets sind eigentlich nicht zum bewegen geeignet.
|
116
|
-
* Sie k�nnen zwar verschoben werden (setX, setY: nur dieses; move(ox,oy): rekursiv).
|
117
|
-
* widgets k�nnen sich X und Y wiederholen (festlegbar).
|
118
|
-
* Sie sind deaktivierbar und versteckbar. Ersters hat keine Funktion in Widget.
|
119
|
-
*/
|
120
|
-
|
121
|
-
class Widget {
|
122
|
-
protected:
|
123
|
-
Widgets widgets, addQueue;
|
124
|
-
Image image;
|
125
|
-
int x, y;
|
126
|
-
ZOrder z;
|
127
|
-
bool active, visible, noAutoShow, locked;
|
128
|
-
WidgetType type;
|
129
|
-
public:
|
130
|
-
Widget(int x = 0, int y = 0, ZOrder z = zBackground, bool noAutoShow = false) {
|
131
|
-
this->x = x;
|
132
|
-
this->y = y;
|
133
|
-
this->z = z;
|
134
|
-
active = visible = true;
|
135
|
-
locked = false;
|
136
|
-
this->noAutoShow = noAutoShow;
|
137
|
-
type = wtWidget;
|
138
|
-
}
|
139
|
-
|
140
|
-
Widget(Image& image, int x, int y, ZOrder z, bool noAutoShow = false) {
|
141
|
-
this->image = image;
|
142
|
-
this->x = x;
|
143
|
-
this->y = y;
|
144
|
-
this->z = z;
|
145
|
-
active = visible = true;
|
146
|
-
type = wtWidget;
|
147
|
-
this->noAutoShow = noAutoShow;
|
148
|
-
}
|
149
|
-
|
150
|
-
Widget(std::wstring name, Gosu::Graphics& graphics, int x, int y, ZOrder z, bool noAutoShow = false) {
|
151
|
-
loadImage(name, image, graphics);
|
152
|
-
this->x = x;
|
153
|
-
this->y = y;
|
154
|
-
this->z = z;
|
155
|
-
active = visible = true;
|
156
|
-
type = wtWidget;
|
157
|
-
this->noAutoShow = noAutoShow;
|
158
|
-
}
|
159
|
-
// Gosu related
|
160
|
-
virtual void draw(Gosu::Input& input);
|
161
|
-
virtual void update(Gosu::Input& input);
|
162
|
-
virtual void buttonUp(Gosu::Button& btn, Gosu::Input& input); // Redirect call
|
163
|
-
virtual void buttonDown(Gosu::Button& btn, Gosu::Input& input); // Redirect call
|
164
|
-
virtual void move(int vx, int vy); // bewegt um vx/vy; alle untergeordneten auch.
|
165
|
-
int getX() { return x; }
|
166
|
-
int getY() { return y; }
|
167
|
-
ZOrder getZ() { return z; }
|
168
|
-
virtual Image getImage() { return image; }
|
169
|
-
void setX(int x) { this->x = x; }
|
170
|
-
void setY(int y) { this->y = y; }
|
171
|
-
void setZ(ZOrder z) { this->z = z; }
|
172
|
-
WidgetType getType() { return type; }
|
173
|
-
void addWidget(Widget* widget); // unterwidget hinzuf�gen
|
174
|
-
void remWidget(Widget* widget); // unterwidget l�schen
|
175
|
-
// (De-)aktivieren
|
176
|
-
void activate();
|
177
|
-
void deactivate();
|
178
|
-
bool isActive() { return active; }
|
179
|
-
// verstecken/anzeigen
|
180
|
-
void hide();
|
181
|
-
void show(bool force = false); // force: erzwinge anzeigen. hat nur mit noAutoShow effekt.
|
182
|
-
bool isVisible() { return visible; }
|
183
|
-
virtual ~Widget();
|
184
|
-
};
|
185
|
-
|
186
|
-
/**
|
187
|
-
* Movable. Sie (und alles untergeordnete) verschiebt sich. Lustige Sache.
|
188
|
-
*
|
189
|
-
*/
|
190
|
-
class Moveable : public Widget {
|
191
|
-
int omx, omy, wdt, hgt, twdt, thgt;
|
192
|
-
bool moving;
|
193
|
-
public:
|
194
|
-
static std::vector<Moveable*> moveables;
|
195
|
-
boost::function<void(Moveable*)> onTitleLeftClick, onTitleRightClick;
|
196
|
-
Moveable(Image& image, int x, int y, ZOrder z, int titleWidth, int titleHeight)
|
197
|
-
: Widget(image, x, y, z) {
|
198
|
-
moving = false;
|
199
|
-
omx = omy = 0;
|
200
|
-
wdt = image->width();
|
201
|
-
hgt = image->height();
|
202
|
-
twdt = titleWidth;
|
203
|
-
thgt = titleHeight;
|
204
|
-
type = wtMoveable;
|
205
|
-
Moveable::moveables.push_back(this);
|
206
|
-
}
|
207
|
-
|
208
|
-
Moveable(std::wstring name, Gosu::Graphics& graphics, int x, int y, ZOrder z, int titleWidth, int titleHeight)
|
209
|
-
:Widget(name, graphics, x, y, z) {
|
210
|
-
moving = false;
|
211
|
-
omx = omy = 0;
|
212
|
-
wdt = image->width();
|
213
|
-
hgt = image->height();
|
214
|
-
twdt = titleWidth;
|
215
|
-
thgt = titleHeight;
|
216
|
-
type = wtMoveable;
|
217
|
-
Moveable::moveables.push_back(this);
|
218
|
-
}
|
219
|
-
|
220
|
-
void update(Gosu::Input& input);
|
221
|
-
void buttonDown(Gosu::Button& btn, Gosu::Input& input);
|
222
|
-
void buttonUp(Gosu::Button& btn, Gosu::Input& input);
|
223
|
-
void move(int vx, int vy);
|
224
|
-
};
|
225
|
-
|
226
|
-
/**
|
227
|
-
* Primitiver Button der nur f�r Mausklicks zust�ndig ist.
|
228
|
-
* 2 calls: onLeftClick, onRightClick. Param jeweils Button* btn
|
229
|
-
*/
|
230
|
-
class Button : public Widget {
|
231
|
-
protected:
|
232
|
-
int width, height;
|
233
|
-
bool focus;
|
234
|
-
Button* next;
|
235
|
-
public:
|
236
|
-
static Button* btnFocus;
|
237
|
-
boost::function<void (Button*)> onRightClick, onLeftClick;
|
238
|
-
|
239
|
-
Button(int x = 0, int y = 0, ZOrder z = zBackground, bool noAutoShow = false)
|
240
|
-
: Widget(x, y, z, noAutoShow) {
|
241
|
-
width = height = 0;
|
242
|
-
focus = false;
|
243
|
-
next = NULL;
|
244
|
-
type = wtButton;
|
245
|
-
}
|
246
|
-
|
247
|
-
Button(Image& image, int x, int y, ZOrder z, bool noAutoShow = false)
|
248
|
-
: Widget(image, x, y, z, noAutoShow) {
|
249
|
-
width = image->width();
|
250
|
-
height = image->height();
|
251
|
-
focus = false;
|
252
|
-
next = NULL;
|
253
|
-
type = wtButton;
|
254
|
-
}
|
255
|
-
|
256
|
-
Button(std::wstring name, Gosu::Graphics& graphics, int x, int y, ZOrder z, bool noAutoShow = false)
|
257
|
-
: Widget(name, graphics, x, y, z, noAutoShow) {
|
258
|
-
loadImage(name, image, graphics);
|
259
|
-
width = image->width();
|
260
|
-
height = image->height();
|
261
|
-
focus = false;
|
262
|
-
next = NULL;
|
263
|
-
type = wtButton;
|
264
|
-
}
|
265
|
-
|
266
|
-
virtual void update(Gosu::Input& input);
|
267
|
-
virtual void buttonUp(Gosu::Button& btn, Gosu::Input& input);
|
268
|
-
static void buttonUpAll(Gosu::Button& btn, Gosu::Input& input);
|
269
|
-
virtual void setFocus(bool woot) { focus = woot; }
|
270
|
-
virtual void setNextFocus(Button* toFocus) { next = toFocus; }
|
271
|
-
virtual void onFocus(Button* from, Gosu::Input& input);
|
272
|
-
virtual void onDefocus(Button* from, Gosu::Input& input);
|
273
|
-
};
|
274
|
-
|
275
|
-
/**
|
276
|
-
* Textbutton: Dynamischer erzeugte Buttons
|
277
|
-
*/
|
278
|
-
|
279
|
-
class TextButton : public Button {
|
280
|
-
protected:
|
281
|
-
Gosu::Font* font;
|
282
|
-
std::wstring text;
|
283
|
-
public:
|
284
|
-
TextButton(Image& image, int x, int y, ZOrder z, Gosu::Graphics& graphics, std::wstring fontName, std::wstring text, bool noAutoShow = false)
|
285
|
-
: Button(image, x, y, z, noAutoShow) {
|
286
|
-
font = new Gosu::Font(graphics, fontName, image->height()-5);
|
287
|
-
this->text = text;
|
288
|
-
}
|
289
|
-
|
290
|
-
TextButton(Image& image, int x, int y, ZOrder z, Gosu::Font* font, std::wstring text, bool noAutoShow = false)
|
291
|
-
: Button(image, x, y, z, noAutoShow) {
|
292
|
-
this->font = font;
|
293
|
-
this->text = text;
|
294
|
-
}
|
295
|
-
|
296
|
-
TextButton(std::wstring name, Gosu::Graphics& graphics, int x, int y, ZOrder z, std::wstring fontName, std::wstring text, bool noAutoShow = false)
|
297
|
-
: Button(name, graphics, x, y, z, noAutoShow) {
|
298
|
-
font = new Gosu::Font(graphics, fontName, image->height()-5);
|
299
|
-
this->text = text;
|
300
|
-
}
|
301
|
-
|
302
|
-
TextButton(std::wstring name, Gosu::Graphics& graphics, int x, int y, ZOrder z, Gosu::Font* font, std::wstring text, bool noAutoShow = false)
|
303
|
-
: Button(name, graphics, x, y, z, noAutoShow) {
|
304
|
-
this->font = font;
|
305
|
-
this->text = text;
|
306
|
-
}
|
307
|
-
|
308
|
-
TextButton(int x, int y, ZOrder z, Gosu::Graphics& graphics, std::wstring fontname, std::wstring text, int height, bool noAutoShow = false)
|
309
|
-
: Button(x, y, z, noAutoShow) {
|
310
|
-
font = new Gosu::Font(graphics, fontname, height-5);
|
311
|
-
this->text = text;
|
312
|
-
}
|
313
|
-
|
314
|
-
TextButton(int x, int y, ZOrder z, Gosu::Font* font, std::wstring text, bool noAutoShow = false)
|
315
|
-
: Button(x, y, z, noAutoShow) {
|
316
|
-
this->font = font;
|
317
|
-
this->text = text;
|
318
|
-
}
|
319
|
-
|
320
|
-
std::wstring getText() { return text; }
|
321
|
-
Gosu::Font* getFont() { return font; }
|
322
|
-
void setText(std::wstring newText) { text = newText; }
|
323
|
-
|
324
|
-
void draw(Gosu::Input& input);
|
325
|
-
};
|
326
|
-
|
327
|
-
/**
|
328
|
-
* Input Klasse. Abgeleitet von Button f�r width/height Zeug + FOKUS!
|
329
|
-
*/
|
330
|
-
|
331
|
-
class Input : public Button {
|
332
|
-
protected:
|
333
|
-
Gosu::TextInput textInput;
|
334
|
-
Gosu::Font font;
|
335
|
-
public:
|
336
|
-
Input(Image& image, int x, int y, ZOrder z, Gosu::Graphics& graphics, std::wstring fontName)
|
337
|
-
: Button(image, x, y, z), font(graphics, fontName, image->height()-5) {
|
338
|
-
type = wtInput;
|
339
|
-
}
|
340
|
-
|
341
|
-
Input(std::wstring name, Gosu::Graphics& graphics, int x, int y, ZOrder z, std::wstring fontName)
|
342
|
-
: Button(name, graphics, x, y, z), font(graphics, fontName, image->height()-5) {
|
343
|
-
type = wtInput;
|
344
|
-
}
|
345
|
-
void buttonUp(Gosu::Button& btn, Gosu::Input& input);
|
346
|
-
virtual void draw(Gosu::Input& input);
|
347
|
-
std::string text() { return Gosu::narrow(textInput.text()); }
|
348
|
-
void reset() { textInput.setText(L""); }
|
349
|
-
void onFocus(Button* from, Gosu::Input& input);
|
350
|
-
void onDefocus(Button* from, Gosu::Input& input);
|
351
|
-
protected:
|
352
|
-
void ThereCanBeOnlyOne(Gosu::Input& input);
|
353
|
-
};
|
354
|
-
/**
|
355
|
-
* AdvButtons sind 4-tile-ige Buttons.
|
356
|
-
* die Reihenfolge dabei ist:
|
357
|
-
* - Normal
|
358
|
-
* - onHover
|
359
|
-
* - onClick
|
360
|
-
* - disabled
|
361
|
-
* Sie sind/sollten nicht weiter vererbt werden weil draw() das nicht weitergibt.
|
362
|
-
* wozu auch. mit 2 advbuttons arbeiten ist h�sslich.
|
363
|
-
*/
|
364
|
-
class AdvButton : public Button {
|
365
|
-
Animation* animation;
|
366
|
-
public:
|
367
|
-
AdvButton(Animation* animation, int x, int y, ZOrder z, bool noAutoShow = false)
|
368
|
-
: Button(x, y, z, noAutoShow) {
|
369
|
-
this->animation = animation;
|
370
|
-
width = animation->at(0)->width();
|
371
|
-
height = animation->at(0)->height();
|
372
|
-
assert(animation->size() == 4);
|
373
|
-
type = wtAdvButton;
|
374
|
-
}
|
375
|
-
|
376
|
-
AdvButton(std::wstring name, Gosu::Graphics& graphics, int x, int y, int width, int height, ZOrder z, bool noAutoShow = false)
|
377
|
-
: Button(x, y, z, noAutoShow) {
|
378
|
-
animation = new Animation();
|
379
|
-
loadAnimation(name, *animation, graphics, width, height);
|
380
|
-
assert(animation->size() == 4);
|
381
|
-
this->width = width;
|
382
|
-
this->height = height;
|
383
|
-
type = wtAdvButton;
|
384
|
-
}
|
385
|
-
virtual void draw(Gosu::Input& input);
|
386
|
-
Image getImage() { return animation->at(0); }
|
387
|
-
Animation* getAnimation() { return animation; }
|
388
|
-
};
|
389
|
-
|
390
|
-
/**
|
391
|
-
* AdvButton + TextButton
|
392
|
-
*
|
393
|
-
*/
|
394
|
-
|
395
|
-
class AdvTextButton : public TextButton {
|
396
|
-
protected:
|
397
|
-
Animation* animation;
|
398
|
-
AdvTxtBtnKeep keepState;
|
399
|
-
public:
|
400
|
-
AdvTextButton(std::wstring name, Gosu::Graphics& graphics, int x, int y, ZOrder z, int width, int height, std::wstring fontname, std::wstring text, bool noAutoShow = false)
|
401
|
-
:TextButton(x, y, z, graphics, fontname, text, height, noAutoShow)
|
402
|
-
{
|
403
|
-
animation = new Animation();
|
404
|
-
loadAnimation(name, *animation, graphics, width, height);
|
405
|
-
keepState = tbkNone;
|
406
|
-
this->width = width;
|
407
|
-
this->height = height;
|
408
|
-
}
|
409
|
-
|
410
|
-
AdvTextButton(Animation* animation, int x, int y, ZOrder z, Gosu::Font* font, std::wstring text, bool noAutoShow = false)
|
411
|
-
:TextButton(x, y, z, font, text, noAutoShow) {
|
412
|
-
this->animation = animation;
|
413
|
-
keepState = tbkNone;
|
414
|
-
this->width = animation->at(0)->width();
|
415
|
-
this->height = animation->at(0)->height();
|
416
|
-
}
|
417
|
-
|
418
|
-
Image getImage() { return animation->at(0); }
|
419
|
-
void draw(Gosu::Input& input);
|
420
|
-
Animation* getAnimation() { return animation; }
|
421
|
-
AdvTxtBtnKeep getKeepState() { return keepState; }
|
422
|
-
void setKeepState(AdvTxtBtnKeep keep) { keepState = keep; }
|
423
|
-
};
|
424
|
-
#endif
|
425
|
-
|