annotate window/widget.cc @ 66:d112357a0ec1

Fix a bug with savegames introduced with changeset c7bcc0ec2267. Warning: savegames created since c7bcc0ec2267 are probably corrupted, you may have to start the game over. If you chose not to do so, you should replace all occurrences of 'TextWindow' by 'TextImplWindow', and 'Text Window' by 'TextImpl Window' in your save files.
author Thibaut Girka <thib@sitedethib.com>
date Sat, 11 Dec 2010 18:36:20 +0100
parents 4416cfac86ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
223b71206888 Initial import
thib
parents:
diff changeset
3 * All rights reserved.
223b71206888 Initial import
thib
parents:
diff changeset
4 *
223b71206888 Initial import
thib
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without
223b71206888 Initial import
thib
parents:
diff changeset
6 * modification, are permitted provided that the following conditions
223b71206888 Initial import
thib
parents:
diff changeset
7 * are met:
223b71206888 Initial import
thib
parents:
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
9 * notice, this list of conditions and the following disclaimer.
223b71206888 Initial import
thib
parents:
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
223b71206888 Initial import
thib
parents:
diff changeset
12 * documentation and/or other materials provided with the distribution.
223b71206888 Initial import
thib
parents:
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
223b71206888 Initial import
thib
parents:
diff changeset
14 * derived from this software without specific prior written permission.
223b71206888 Initial import
thib
parents:
diff changeset
15 *
223b71206888 Initial import
thib
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
223b71206888 Initial import
thib
parents:
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223b71206888 Initial import
thib
parents:
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
223b71206888 Initial import
thib
parents:
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
223b71206888 Initial import
thib
parents:
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
223b71206888 Initial import
thib
parents:
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
223b71206888 Initial import
thib
parents:
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
223b71206888 Initial import
thib
parents:
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
223b71206888 Initial import
thib
parents:
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
223b71206888 Initial import
thib
parents:
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
223b71206888 Initial import
thib
parents:
diff changeset
26 */
223b71206888 Initial import
thib
parents:
diff changeset
27
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
28 #include "widget.h"
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
29 #include <algorithm>
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
30 #include <map>
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
31 #include <string>
0
223b71206888 Initial import
thib
parents:
diff changeset
32
223b71206888 Initial import
thib
parents:
diff changeset
33 Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect,
223b71206888 Initial import
thib
parents:
diff changeset
34 Surface* dst, const Rect& dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
35 void DSurfaceFill(Surface* src, const Rect& rect, int r, int g, int b, int a = 0xff);
223b71206888 Initial import
thib
parents:
diff changeset
36 void DSurfaceMove(Surface* src, const Rect& srcrect, Surface* dst_o, const Rect& dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
37
223b71206888 Initial import
thib
parents:
diff changeset
38 //static char* wdefault_font_orig = "msgothic.ttc;times.ttf;";
223b71206888 Initial import
thib
parents:
diff changeset
39 static std::map<int, XKFont::HorizLayout*> size_to_layout;
47
5f548e5957a8 * get rid of the "deprecated conversion from string constant to ‘char*’" warnings
thib
parents: 14
diff changeset
40 static const char* wdefault_font_orig = "times.ttf;msgothic.ttc";
0
223b71206888 Initial import
thib
parents:
diff changeset
41 static std::string wdefault_font = wdefault_font_orig;
223b71206888 Initial import
thib
parents:
diff changeset
42
223b71206888 Initial import
thib
parents:
diff changeset
43 void SetFont(const char* font) {
223b71206888 Initial import
thib
parents:
diff changeset
44 if (font == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
45 std::map<int,XKFont::HorizLayout*>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
46 for (it=size_to_layout.begin(); it != size_to_layout.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
47 delete it->second;
223b71206888 Initial import
thib
parents:
diff changeset
48 }
223b71206888 Initial import
thib
parents:
diff changeset
49 size_to_layout.clear();
223b71206888 Initial import
thib
parents:
diff changeset
50 wdefault_font = font;
223b71206888 Initial import
thib
parents:
diff changeset
51 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
52
0
223b71206888 Initial import
thib
parents:
diff changeset
53 // namespace Widget {
223b71206888 Initial import
thib
parents:
diff changeset
54 #define TimeCursor WidTimeCursor
223b71206888 Initial import
thib
parents:
diff changeset
55 #define MouseCursor WidMouseCursor
223b71206888 Initial import
thib
parents:
diff changeset
56 #define Button WidButton
223b71206888 Initial import
thib
parents:
diff changeset
57 #define Scale WidScale
223b71206888 Initial import
thib
parents:
diff changeset
58 #define TextButton WidTextButton
223b71206888 Initial import
thib
parents:
diff changeset
59 #define Text WidText
223b71206888 Initial import
thib
parents:
diff changeset
60 #define AnmTime WidAnmTime
223b71206888 Initial import
thib
parents:
diff changeset
61 #define AnmMove WidAnmMove
223b71206888 Initial import
thib
parents:
diff changeset
62 #define AnmAlpha WidAnmAlpha
223b71206888 Initial import
thib
parents:
diff changeset
63 #define AnmPtnSolid WidAnmPtnSolid
223b71206888 Initial import
thib
parents:
diff changeset
64 #define AnmPtnAlpha WidAnmPtnAlpha
223b71206888 Initial import
thib
parents:
diff changeset
65
223b71206888 Initial import
thib
parents:
diff changeset
66 XKFont::HorizLayout* DefaultLayout(int text_size) {
14
8da1d92ac8f8 Don't create fonts faces for size <= 0, and update objects when their font size is set
thib
parents: 0
diff changeset
67 if(text_size <= 0) abort();//FIXME: Find why the hell text_size can be <= 0
0
223b71206888 Initial import
thib
parents:
diff changeset
68 if (size_to_layout.find(text_size) == size_to_layout.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
69 size_to_layout[text_size] = new XKFont::HorizLayout(wdefault_font.c_str(), text_size);
223b71206888 Initial import
thib
parents:
diff changeset
70 }
223b71206888 Initial import
thib
parents:
diff changeset
71 return size_to_layout[text_size];
223b71206888 Initial import
thib
parents:
diff changeset
72 }
223b71206888 Initial import
thib
parents:
diff changeset
73
223b71206888 Initial import
thib
parents:
diff changeset
74 void PicWidget::activate(void) {
223b71206888 Initial import
thib
parents:
diff changeset
75 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
76
0
223b71206888 Initial import
thib
parents:
diff changeset
77 void PicWidget::deactivate(void) {
223b71206888 Initial import
thib
parents:
diff changeset
78 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
79
0
223b71206888 Initial import
thib
parents:
diff changeset
80 void PicWidget::SetRegion(const Rect& apos) {
223b71206888 Initial import
thib
parents:
diff changeset
81 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
82
0
223b71206888 Initial import
thib
parents:
diff changeset
83 void PicWidget::show(void) {
223b71206888 Initial import
thib
parents:
diff changeset
84 Pic()->show();
223b71206888 Initial import
thib
parents:
diff changeset
85 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
86
0
223b71206888 Initial import
thib
parents:
diff changeset
87 void PicWidget::hide(void) {
223b71206888 Initial import
thib
parents:
diff changeset
88 Pic()->hide();
223b71206888 Initial import
thib
parents:
diff changeset
89 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
90
0
223b71206888 Initial import
thib
parents:
diff changeset
91 void PicWidget::show_all(void) {
223b71206888 Initial import
thib
parents:
diff changeset
92 Pic()->show_all();
223b71206888 Initial import
thib
parents:
diff changeset
93 }
223b71206888 Initial import
thib
parents:
diff changeset
94
223b71206888 Initial import
thib
parents:
diff changeset
95 TimeCursor::TimeCursor(Event::Container& container, int _interval, PicContainer* parent, const char* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r) :
223b71206888 Initial import
thib
parents:
diff changeset
96 Time(container) {
223b71206888 Initial import
thib
parents:
diff changeset
97 interval = _interval;
223b71206888 Initial import
thib
parents:
diff changeset
98 if (interval < 0) interval = 100;
223b71206888 Initial import
thib
parents:
diff changeset
99 nptn = _nptn;
223b71206888 Initial import
thib
parents:
diff changeset
100 if (nptn < 0) nptn = 1;
223b71206888 Initial import
thib
parents:
diff changeset
101 count = 0; old_time = 0;
223b71206888 Initial import
thib
parents:
diff changeset
102
223b71206888 Initial import
thib
parents:
diff changeset
103 x = _sx; y = _sy; dx = _sdx; dy = _sdy;
223b71206888 Initial import
thib
parents:
diff changeset
104 SetPic(parent->create_leaf(r, PicBase::CACHE_BACK));
223b71206888 Initial import
thib
parents:
diff changeset
105 Pic()->SetSurface(s, _sx, _sy);
223b71206888 Initial import
thib
parents:
diff changeset
106 };
223b71206888 Initial import
thib
parents:
diff changeset
107 void TimeCursor::Elapsed(unsigned int current_time) {
223b71206888 Initial import
thib
parents:
diff changeset
108 int move = (current_time-old_time)/interval;
223b71206888 Initial import
thib
parents:
diff changeset
109 if (move) {
223b71206888 Initial import
thib
parents:
diff changeset
110 old_time += move*interval;
223b71206888 Initial import
thib
parents:
diff changeset
111 count += move;
223b71206888 Initial import
thib
parents:
diff changeset
112 count %= nptn;
223b71206888 Initial import
thib
parents:
diff changeset
113 Pic()->SetSurfacePos(x + count*dx, y + count*dy);
223b71206888 Initial import
thib
parents:
diff changeset
114 }
223b71206888 Initial import
thib
parents:
diff changeset
115 if (current_time > old_time+interval) SetWakeup(current_time);
223b71206888 Initial import
thib
parents:
diff changeset
116 else SetWakeup(old_time+interval);
223b71206888 Initial import
thib
parents:
diff changeset
117 }
223b71206888 Initial import
thib
parents:
diff changeset
118
223b71206888 Initial import
thib
parents:
diff changeset
119 MouseCursor::MouseCursor(Event::Container& _container, PicContainer* parent, const char* s, int x, int y, int w, int h) :
223b71206888 Initial import
thib
parents:
diff changeset
120 Event::Video(_container), container(_container) {
223b71206888 Initial import
thib
parents:
diff changeset
121 int sx, sy;
223b71206888 Initial import
thib
parents:
diff changeset
122 _container.MousePos(sx, sy);
223b71206888 Initial import
thib
parents:
diff changeset
123 SetPic(parent->create_leaf(Rect(sx, sy, sx+w, sy+h), 0));
223b71206888 Initial import
thib
parents:
diff changeset
124 Pic()->SetSurface(s, x, y);
223b71206888 Initial import
thib
parents:
diff changeset
125 x = 0; y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
126 container.RegisterGlobalMotionFunc(&Motionfunc, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
127 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
128
0
223b71206888 Initial import
thib
parents:
diff changeset
129 MouseCursor::MouseCursor(Event::Container& _container, PicContainer* parent, Surface* s, int x, int y, int w, int h) :
223b71206888 Initial import
thib
parents:
diff changeset
130 Event::Video(_container), container(_container) {
223b71206888 Initial import
thib
parents:
diff changeset
131 int sx, sy;
223b71206888 Initial import
thib
parents:
diff changeset
132 _container.MousePos(sx, sy);
223b71206888 Initial import
thib
parents:
diff changeset
133 SetPic(parent->create_leaf(Rect(sx, sy, sx+w, sy+h), 0));
223b71206888 Initial import
thib
parents:
diff changeset
134 Pic()->SetSurface(s, x, y);
223b71206888 Initial import
thib
parents:
diff changeset
135 x = 0; y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
136 container.RegisterGlobalMotionFunc(&Motionfunc, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
137 }
223b71206888 Initial import
thib
parents:
diff changeset
138
223b71206888 Initial import
thib
parents:
diff changeset
139 MouseCursor::~MouseCursor() {
223b71206888 Initial import
thib
parents:
diff changeset
140 container.DeleteGlobalMotionFunc(&Motionfunc, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
141 }
223b71206888 Initial import
thib
parents:
diff changeset
142
223b71206888 Initial import
thib
parents:
diff changeset
143 bool MouseCursor::Motionfunc(int x, int y, void* pointer) {
223b71206888 Initial import
thib
parents:
diff changeset
144 MouseCursor* _this = (MouseCursor*)pointer;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
145 // 左上がカーソルポイントの場合
0
223b71206888 Initial import
thib
parents:
diff changeset
146 // _this->Pic()->Move(x,y);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
147 // 左下がカーソルポイントの場合
0
223b71206888 Initial import
thib
parents:
diff changeset
148 _this->Pic()->Move(x,y-_this->Pic()->Height());
223b71206888 Initial import
thib
parents:
diff changeset
149 return true;
223b71206888 Initial import
thib
parents:
diff changeset
150 }
223b71206888 Initial import
thib
parents:
diff changeset
151
223b71206888 Initial import
thib
parents:
diff changeset
152 Button::Button(Event::Container& container, PicContainer* parent, const char* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r, int _z) : sx(_sx), sy(_sy), sdx(_sdx), sdy(_sdy), nptn(_nptn) ,Event::Video(container,r, _z) {
223b71206888 Initial import
thib
parents:
diff changeset
153 SetPic(parent->create_leaf(r, 0));
223b71206888 Initial import
thib
parents:
diff changeset
154 Pic()->SetSurface(s, _sx, _sy);
223b71206888 Initial import
thib
parents:
diff changeset
155 show();
223b71206888 Initial import
thib
parents:
diff changeset
156 is_in = false;
223b71206888 Initial import
thib
parents:
diff changeset
157 is_toggled = false;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
158 press_func = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
159 press_pointer = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
160 drag_func = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
161 drag_pointer = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
162 is_toggle_switch = false;
223b71206888 Initial import
thib
parents:
diff changeset
163 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
164
0
223b71206888 Initial import
thib
parents:
diff changeset
165 Button::Button(Event::Container& container, PicContainer* parent, Surface* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r, int _z) : sx(_sx), sy(_sy), sdx(_sdx), sdy(_sdy), nptn(_nptn) ,Event::Video(container,r, _z) {
223b71206888 Initial import
thib
parents:
diff changeset
166 SetPic(parent->create_leaf(r, 0));
223b71206888 Initial import
thib
parents:
diff changeset
167 Pic()->SetSurface(s, _sx, _sy);
223b71206888 Initial import
thib
parents:
diff changeset
168 show();
223b71206888 Initial import
thib
parents:
diff changeset
169 is_in = false;
223b71206888 Initial import
thib
parents:
diff changeset
170 is_toggled = false;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
171 press_func = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
172 press_pointer = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
173 drag_func = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
174 drag_pointer = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
175 is_toggle_switch = false;
223b71206888 Initial import
thib
parents:
diff changeset
176 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
177
0
223b71206888 Initial import
thib
parents:
diff changeset
178 Button::~Button() {
223b71206888 Initial import
thib
parents:
diff changeset
179 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
180
0
223b71206888 Initial import
thib
parents:
diff changeset
181 void Button::In(void) {
223b71206888 Initial import
thib
parents:
diff changeset
182 is_in = true;
223b71206888 Initial import
thib
parents:
diff changeset
183 if (nptn > 1)
223b71206888 Initial import
thib
parents:
diff changeset
184 if (! is_toggled)
223b71206888 Initial import
thib
parents:
diff changeset
185 Pic()->SetSurfacePos(sx+sdx, sy+sdy);
223b71206888 Initial import
thib
parents:
diff changeset
186 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
187
0
223b71206888 Initial import
thib
parents:
diff changeset
188 void Button::Out(void) {
223b71206888 Initial import
thib
parents:
diff changeset
189 is_in = false;
223b71206888 Initial import
thib
parents:
diff changeset
190 if (!is_toggled)
223b71206888 Initial import
thib
parents:
diff changeset
191 Pic()->SetSurfacePos(sx, sy);
223b71206888 Initial import
thib
parents:
diff changeset
192 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
193
0
223b71206888 Initial import
thib
parents:
diff changeset
194 void Button::Toggle(bool new_toggle) {
223b71206888 Initial import
thib
parents:
diff changeset
195 if (is_toggled == new_toggle) {
223b71206888 Initial import
thib
parents:
diff changeset
196 return;
223b71206888 Initial import
thib
parents:
diff changeset
197 }
223b71206888 Initial import
thib
parents:
diff changeset
198 is_toggled = new_toggle;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
199 // if (is_in) return; // is_in に関わらずウィジットの表示を変更することにする
0
223b71206888 Initial import
thib
parents:
diff changeset
200 if (is_toggled) {
223b71206888 Initial import
thib
parents:
diff changeset
201 if (nptn > 2)
223b71206888 Initial import
thib
parents:
diff changeset
202 Pic()->SetSurfacePos(sx+sdx*2, sy+sdy*2);
223b71206888 Initial import
thib
parents:
diff changeset
203 else if (nptn > 1)
223b71206888 Initial import
thib
parents:
diff changeset
204 Pic()->SetSurfacePos(sx+sdx, sy+sdy);
223b71206888 Initial import
thib
parents:
diff changeset
205 else
223b71206888 Initial import
thib
parents:
diff changeset
206 Pic()->SetSurfacePos(sx, sy);
223b71206888 Initial import
thib
parents:
diff changeset
207 } else {
223b71206888 Initial import
thib
parents:
diff changeset
208 Pic()->SetSurfacePos(sx, sy);
223b71206888 Initial import
thib
parents:
diff changeset
209 }
223b71206888 Initial import
thib
parents:
diff changeset
210 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
211
0
223b71206888 Initial import
thib
parents:
diff changeset
212 void Button::Press(void) {
223b71206888 Initial import
thib
parents:
diff changeset
213 is_in = true;
223b71206888 Initial import
thib
parents:
diff changeset
214 if (is_toggled) ;
223b71206888 Initial import
thib
parents:
diff changeset
215 else if (nptn > 2)
223b71206888 Initial import
thib
parents:
diff changeset
216 Pic()->SetSurfacePos(sx+sdx*2, sy+sdy*2);
223b71206888 Initial import
thib
parents:
diff changeset
217 else if (nptn > 1)
223b71206888 Initial import
thib
parents:
diff changeset
218 Pic()->SetSurfacePos(sx+sdx, sy+sdy);
223b71206888 Initial import
thib
parents:
diff changeset
219 if (press_func) press_func(press_pointer, this);
223b71206888 Initial import
thib
parents:
diff changeset
220 if (is_toggle_switch) Toggle(!is_toggled);
223b71206888 Initial import
thib
parents:
diff changeset
221 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
222
0
223b71206888 Initial import
thib
parents:
diff changeset
223 void Button::Release(void) {
223b71206888 Initial import
thib
parents:
diff changeset
224 if (is_toggled) ;
223b71206888 Initial import
thib
parents:
diff changeset
225 else if (nptn > 1 && is_in)
223b71206888 Initial import
thib
parents:
diff changeset
226 Pic()->SetSurfacePos(sx+sdx, sy+sdy);
223b71206888 Initial import
thib
parents:
diff changeset
227 else if (nptn > 1)
223b71206888 Initial import
thib
parents:
diff changeset
228 Pic()->SetSurfacePos(sx, sy);
223b71206888 Initial import
thib
parents:
diff changeset
229 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
230
0
223b71206888 Initial import
thib
parents:
diff changeset
231 void Button::Drag(int x_from, int y_from, int x_to, int y_to) {
223b71206888 Initial import
thib
parents:
diff changeset
232 if (drag_func) drag_func(x_from,y_from,x_to, y_to,drag_pointer, this);
223b71206888 Initial import
thib
parents:
diff changeset
233 }
223b71206888 Initial import
thib
parents:
diff changeset
234
223b71206888 Initial import
thib
parents:
diff changeset
235 Scale::Scale(Event::Container& _container, PicContainer* _parent, const Rect& r_orig, const Color& _color, bool _is_vertical) :
223b71206888 Initial import
thib
parents:
diff changeset
236 Event::Video(_container,Rect(0,0), 1),
223b71206888 Initial import
thib
parents:
diff changeset
237 container(_container), parent(_parent), cursor_color(_color),
223b71206888 Initial import
thib
parents:
diff changeset
238 mouse_x(0), mouse_y(0), max(0), min(0),
223b71206888 Initial import
thib
parents:
diff changeset
239 value(0), value_add(0), value_dragstart(0), is_vertical(_is_vertical),
223b71206888 Initial import
thib
parents:
diff changeset
240 change_func(0), change_pointer(0) {
223b71206888 Initial import
thib
parents:
diff changeset
241
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
242 arrow_down = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
243 arrow_up = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
244 cursor = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
245 panel = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
246
223b71206888 Initial import
thib
parents:
diff changeset
247 Init(r_orig);
223b71206888 Initial import
thib
parents:
diff changeset
248 }
223b71206888 Initial import
thib
parents:
diff changeset
249
223b71206888 Initial import
thib
parents:
diff changeset
250 extern char* create_button(int number, int& width, int& height, int r, int g, int b);
223b71206888 Initial import
thib
parents:
diff changeset
251 extern char* create_box(int& width, int& height, int r, int g, int b);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
252
0
223b71206888 Initial import
thib
parents:
diff changeset
253 void Scale::Init(Rect r_orig) {
223b71206888 Initial import
thib
parents:
diff changeset
254 int r=cursor_color.r, g=cursor_color.g, b=cursor_color.b;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
255 // 矢印
0
223b71206888 Initial import
thib
parents:
diff changeset
256 int arrow_width = -1;
223b71206888 Initial import
thib
parents:
diff changeset
257 cursor_width = -1;
223b71206888 Initial import
thib
parents:
diff changeset
258 char* button1;
223b71206888 Initial import
thib
parents:
diff changeset
259 char* button2;
223b71206888 Initial import
thib
parents:
diff changeset
260 if (is_vertical) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
261 // 矢印に必要な領域確保
0
223b71206888 Initial import
thib
parents:
diff changeset
262 int arrow_height = r_orig.width();
223b71206888 Initial import
thib
parents:
diff changeset
263 button1 = create_button(2, arrow_height, arrow_width, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
264 button2 = create_button(3, arrow_height, arrow_width, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
265 if (r_orig.height() < arrow_width*4) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
266 if (r_orig.height() < 8) r_orig.by = r_orig.ty + 8; // 小さすぎる場合は強制変更
0
223b71206888 Initial import
thib
parents:
diff changeset
267 free( (void*)button1);
223b71206888 Initial import
thib
parents:
diff changeset
268 free( (void*)button2);
223b71206888 Initial import
thib
parents:
diff changeset
269 arrow_width = r_orig.height()/4;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
270 // 再割り当て
0
223b71206888 Initial import
thib
parents:
diff changeset
271 button1 = create_button(2, arrow_height, arrow_width, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
272 button2 = create_button(3, arrow_height, arrow_width, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
273 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
274 // 矢印ボタンの作成
0
223b71206888 Initial import
thib
parents:
diff changeset
275 Surface* a1s = parent->Root().NewSurfaceFromRGBAData(arrow_height, arrow_width*3, button1, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
276 int x = r_orig.lx; int y = r_orig.ty;
223b71206888 Initial import
thib
parents:
diff changeset
277 arrow_up = new Button(container, parent, a1s, 0, 0, 0, arrow_width, 3, Rect(x,y,x+arrow_height,y+arrow_width),1);
223b71206888 Initial import
thib
parents:
diff changeset
278 arrow_up->Pic()->SetSurfaceFreeFlag();
223b71206888 Initial import
thib
parents:
diff changeset
279 Surface* a2s = parent->Root().NewSurfaceFromRGBAData(arrow_height, arrow_width*3, button2, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
280 x = r_orig.rx - arrow_height; y = r_orig.by - arrow_width;
223b71206888 Initial import
thib
parents:
diff changeset
281 arrow_down = new Button(container, parent, a2s, 0, 0, 0, arrow_width, 3, Rect(x,y,x+arrow_height,y+arrow_width),1);
223b71206888 Initial import
thib
parents:
diff changeset
282 arrow_down->Pic()->SetSurfaceFreeFlag();
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
283 // picture作成(ボタンの動く領域)
0
223b71206888 Initial import
thib
parents:
diff changeset
284 Rect r = r_orig;
223b71206888 Initial import
thib
parents:
diff changeset
285 r.ty += arrow_width;
223b71206888 Initial import
thib
parents:
diff changeset
286 r.by -= arrow_width;
223b71206888 Initial import
thib
parents:
diff changeset
287 panel = parent->create_node(r, 0);
223b71206888 Initial import
thib
parents:
diff changeset
288 SetPic(panel);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
289 // ボタンの中心線を描画、設定
0
223b71206888 Initial import
thib
parents:
diff changeset
290 Surface* s = parent->Root().NewSurface(r.width()/2, r.height(), ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
291 DSurfaceFill(s, Rect(0,0,r.width()/2,r.height()), 0, 0, 0, 0xff);
223b71206888 Initial import
thib
parents:
diff changeset
292 Pic()->SetSurface(s, -r.width()/4, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
293 Pic()->SetSurfaceFreeFlag();
223b71206888 Initial import
thib
parents:
diff changeset
294 } else {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
295 // 矢印に必要な領域確保
0
223b71206888 Initial import
thib
parents:
diff changeset
296 int arrow_height = r_orig.height();
223b71206888 Initial import
thib
parents:
diff changeset
297 button1 = create_button(0, arrow_width, arrow_height, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
298 button2 = create_button(1, arrow_width, arrow_height, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
299 if (r_orig.width() < arrow_width*4) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
300 if (r_orig.width() < 8) r_orig.rx = r_orig.lx + 8; // 小さすぎる場合は強制変更
0
223b71206888 Initial import
thib
parents:
diff changeset
301 free( (void*)button1);
223b71206888 Initial import
thib
parents:
diff changeset
302 free( (void*)button2);
223b71206888 Initial import
thib
parents:
diff changeset
303 arrow_width = r_orig.width()/4;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
304 // 再割り当て
0
223b71206888 Initial import
thib
parents:
diff changeset
305 button1 = create_button(2, arrow_width, arrow_height, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
306 button2 = create_button(3, arrow_width, arrow_height, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
307 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
308 // 矢印ボタンの作成
0
223b71206888 Initial import
thib
parents:
diff changeset
309 Surface* a1s = parent->Root().NewSurfaceFromRGBAData(arrow_width, arrow_height*3, button1, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
310 int x = r_orig.lx; int y = r_orig.ty;
223b71206888 Initial import
thib
parents:
diff changeset
311 arrow_up = new Button(container, parent, a1s, 0, 0, 0, arrow_height, 3, Rect(x,y,x+arrow_width,y+arrow_height),1);
223b71206888 Initial import
thib
parents:
diff changeset
312 arrow_up->Pic()->SetSurfaceFreeFlag();
223b71206888 Initial import
thib
parents:
diff changeset
313 Surface* a2s = parent->Root().NewSurfaceFromRGBAData(arrow_width, arrow_height*3, button2, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
314 x = r_orig.rx - arrow_width; y = r_orig.by - arrow_height;
223b71206888 Initial import
thib
parents:
diff changeset
315 arrow_down = new Button(container, parent, a2s, 0, 0, 0, arrow_height, 3, Rect(x,y,x+arrow_width,y+arrow_height),1);
223b71206888 Initial import
thib
parents:
diff changeset
316 arrow_down->Pic()->SetSurfaceFreeFlag();
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
317 // picture作成(ボタンの動く領域)
0
223b71206888 Initial import
thib
parents:
diff changeset
318 Rect r = r_orig;
223b71206888 Initial import
thib
parents:
diff changeset
319 r.lx += arrow_width;
223b71206888 Initial import
thib
parents:
diff changeset
320 r.rx -= arrow_width;
223b71206888 Initial import
thib
parents:
diff changeset
321 panel = parent->create_node(r, 0);
223b71206888 Initial import
thib
parents:
diff changeset
322 SetPic(panel);
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
323 // ボタンの中心線を描画、設定
0
223b71206888 Initial import
thib
parents:
diff changeset
324 Surface* s = parent->Root().NewSurface(r.width(), r.height()/2, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
325 DSurfaceFill(s, Rect(0,0,r.width(),r.height()/2), 0, 0, 0, 0xff);
223b71206888 Initial import
thib
parents:
diff changeset
326 Pic()->SetSurface(s, 0, -r.height()/4, 0);
223b71206888 Initial import
thib
parents:
diff changeset
327 Pic()->SetSurfaceFreeFlag();
223b71206888 Initial import
thib
parents:
diff changeset
328 }
223b71206888 Initial import
thib
parents:
diff changeset
329 arrow_up->press_func = &Scale::PressArrowUp;
223b71206888 Initial import
thib
parents:
diff changeset
330 arrow_up->press_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
331 arrow_down->press_func = &Scale::PressArrowDown;
223b71206888 Initial import
thib
parents:
diff changeset
332 arrow_down->press_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
333 arrow_up->show();
223b71206888 Initial import
thib
parents:
diff changeset
334 arrow_down->show();
223b71206888 Initial import
thib
parents:
diff changeset
335 panel->show();
223b71206888 Initial import
thib
parents:
diff changeset
336 InitCursor(0);
223b71206888 Initial import
thib
parents:
diff changeset
337 }
223b71206888 Initial import
thib
parents:
diff changeset
338
223b71206888 Initial import
thib
parents:
diff changeset
339 void Scale::InitCursor(int width_ratio) {
223b71206888 Initial import
thib
parents:
diff changeset
340 int r=cursor_color.r, g=cursor_color.g, b=cursor_color.b;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
341 if (cursor != NULL) delete cursor;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
342 cursor = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
343 Rect region(0,0);
223b71206888 Initial import
thib
parents:
diff changeset
344 if (width_ratio < 0) width_ratio = 0;
223b71206888 Initial import
thib
parents:
diff changeset
345 else if (width_ratio > 1024) width_ratio = 1024;
223b71206888 Initial import
thib
parents:
diff changeset
346 if (is_vertical) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
347 if (width_ratio == 0) cursor_width = Pic()->Width() * 3 / 2; // 幅の1.5倍
0
223b71206888 Initial import
thib
parents:
diff changeset
348 else cursor_width = Pic()->Height()*width_ratio/1024;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
349 if (cursor_width <= 0) return; // カーソルなし(いいのか?)
0
223b71206888 Initial import
thib
parents:
diff changeset
350 region = Rect(0, 0, Pic()->Width(), cursor_width);
223b71206888 Initial import
thib
parents:
diff changeset
351 } else { // horizontal
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
352 if (width_ratio == 0) cursor_width = Pic()->Height() * 3 / 2; // 高さの1.5倍
0
223b71206888 Initial import
thib
parents:
diff changeset
353 else cursor_width = Pic()->Width()*width_ratio/1024;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
354 if (cursor_width <= 0) return; // カーソルなし(いいのか?)
0
223b71206888 Initial import
thib
parents:
diff changeset
355 region = Rect(0, 0, cursor_width, Pic()->Height());
223b71206888 Initial import
thib
parents:
diff changeset
356 }
223b71206888 Initial import
thib
parents:
diff changeset
357
223b71206888 Initial import
thib
parents:
diff changeset
358 int height = region.height();
223b71206888 Initial import
thib
parents:
diff changeset
359 int width = region.width();
223b71206888 Initial import
thib
parents:
diff changeset
360 char* box = create_box(width, height, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
361 Surface* boxs = parent->Root().NewSurfaceFromRGBAData(width, height*3, box, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
362 cursor = new Button(container, panel, boxs, 0, 0, 0, height, 3, region, 2);
223b71206888 Initial import
thib
parents:
diff changeset
363 cursor->Pic()->SetSurfaceFreeFlag();
223b71206888 Initial import
thib
parents:
diff changeset
364
223b71206888 Initial import
thib
parents:
diff changeset
365 cursor->press_func = &Scale::PressCursor;
223b71206888 Initial import
thib
parents:
diff changeset
366 cursor->press_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
367 cursor->drag_func = &Scale::DragCursor;
223b71206888 Initial import
thib
parents:
diff changeset
368 cursor->drag_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
369 cursor->show();
223b71206888 Initial import
thib
parents:
diff changeset
370
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
371 // 矢印等をクリックしたときの移動量計算
0
223b71206888 Initial import
thib
parents:
diff changeset
372 int bar_width;
223b71206888 Initial import
thib
parents:
diff changeset
373 if (is_vertical) bar_width = Pic()->Height();
223b71206888 Initial import
thib
parents:
diff changeset
374 else bar_width = Pic()->Width();
223b71206888 Initial import
thib
parents:
diff changeset
375 if (bar_width <= 0) value_add = max-min;
223b71206888 Initial import
thib
parents:
diff changeset
376 else if (cursor_width == 0) value_add = 2;
223b71206888 Initial import
thib
parents:
diff changeset
377 else value_add = scale_max*cursor_width/bar_width;
223b71206888 Initial import
thib
parents:
diff changeset
378 }
223b71206888 Initial import
thib
parents:
diff changeset
379
223b71206888 Initial import
thib
parents:
diff changeset
380 void Scale::PressArrowDown(void* pointer, Button* from) {
223b71206888 Initial import
thib
parents:
diff changeset
381 Scale* self = (Scale*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
382 self->SetScaleValue(self->value + self->value_add);
223b71206888 Initial import
thib
parents:
diff changeset
383 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
384
0
223b71206888 Initial import
thib
parents:
diff changeset
385 void Scale::PressArrowUp(void* pointer, Button* from){
223b71206888 Initial import
thib
parents:
diff changeset
386 Scale* self = (Scale*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
387 self->SetScaleValue(self->value - self->value_add);
223b71206888 Initial import
thib
parents:
diff changeset
388 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
389
0
223b71206888 Initial import
thib
parents:
diff changeset
390 void Scale::PressCursor(void* pointer, Button* from){
223b71206888 Initial import
thib
parents:
diff changeset
391 Scale* self = (Scale*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
392 self->value_dragstart = self->value;
223b71206888 Initial import
thib
parents:
diff changeset
393 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
394
0
223b71206888 Initial import
thib
parents:
diff changeset
395 void Scale::DragCursor(int x_from, int y_from,int x, int y, void* pointer, Button* from){
223b71206888 Initial import
thib
parents:
diff changeset
396 Scale* self = (Scale*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
397 int dx, w;
223b71206888 Initial import
thib
parents:
diff changeset
398 if (self->is_vertical) {
223b71206888 Initial import
thib
parents:
diff changeset
399 dx = y-y_from;
223b71206888 Initial import
thib
parents:
diff changeset
400 w = self->Event::Video::Region().height();
223b71206888 Initial import
thib
parents:
diff changeset
401 } else {
223b71206888 Initial import
thib
parents:
diff changeset
402 dx = x-x_from;
223b71206888 Initial import
thib
parents:
diff changeset
403 w = self->Event::Video::Region().width();
223b71206888 Initial import
thib
parents:
diff changeset
404 }
223b71206888 Initial import
thib
parents:
diff changeset
405 if (w == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
406 self->SetScaleValue(self->value_dragstart + dx*scale_max/w);
223b71206888 Initial import
thib
parents:
diff changeset
407 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
408
0
223b71206888 Initial import
thib
parents:
diff changeset
409 int Scale::CalcValue(void) {
223b71206888 Initial import
thib
parents:
diff changeset
410 Rect own_region = Event::Video::Region();
223b71206888 Initial import
thib
parents:
diff changeset
411 int x, w;
223b71206888 Initial import
thib
parents:
diff changeset
412 if (is_vertical) {
223b71206888 Initial import
thib
parents:
diff changeset
413 w = own_region.height();
223b71206888 Initial import
thib
parents:
diff changeset
414 x = mouse_y - own_region.ty;
223b71206888 Initial import
thib
parents:
diff changeset
415 } else {
223b71206888 Initial import
thib
parents:
diff changeset
416 w = own_region.width();
223b71206888 Initial import
thib
parents:
diff changeset
417 x = mouse_x - own_region.lx;
223b71206888 Initial import
thib
parents:
diff changeset
418 }
223b71206888 Initial import
thib
parents:
diff changeset
419 if (w == 0) return 0;
223b71206888 Initial import
thib
parents:
diff changeset
420 if (x < 0) x = 0;
223b71206888 Initial import
thib
parents:
diff changeset
421 else if (x > w) x = w;
223b71206888 Initial import
thib
parents:
diff changeset
422 return x*scale_max/w;
223b71206888 Initial import
thib
parents:
diff changeset
423 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
424
0
223b71206888 Initial import
thib
parents:
diff changeset
425 void Scale::Press(void){
223b71206888 Initial import
thib
parents:
diff changeset
426 int v = CalcValue();
223b71206888 Initial import
thib
parents:
diff changeset
427 if (v < value) SetScaleValue(value-value_add);
223b71206888 Initial import
thib
parents:
diff changeset
428 else SetScaleValue(value+value_add);
223b71206888 Initial import
thib
parents:
diff changeset
429 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
430
0
223b71206888 Initial import
thib
parents:
diff changeset
431 void Scale::Motion(int x, int y){
223b71206888 Initial import
thib
parents:
diff changeset
432 mouse_x = x;
223b71206888 Initial import
thib
parents:
diff changeset
433 mouse_y = y;
223b71206888 Initial import
thib
parents:
diff changeset
434 }
223b71206888 Initial import
thib
parents:
diff changeset
435
223b71206888 Initial import
thib
parents:
diff changeset
436 void Scale::SetRange(int new_min, int new_max) {
223b71206888 Initial import
thib
parents:
diff changeset
437 min = new_min;
223b71206888 Initial import
thib
parents:
diff changeset
438 max = new_max;
223b71206888 Initial import
thib
parents:
diff changeset
439 SetValue(value);
223b71206888 Initial import
thib
parents:
diff changeset
440 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
441
0
223b71206888 Initial import
thib
parents:
diff changeset
442 void Scale::SetValue(int new_value) {
223b71206888 Initial import
thib
parents:
diff changeset
443 if (min == max) {
223b71206888 Initial import
thib
parents:
diff changeset
444 value = min;
223b71206888 Initial import
thib
parents:
diff changeset
445 SetScaleValue(0);
223b71206888 Initial import
thib
parents:
diff changeset
446 return;
223b71206888 Initial import
thib
parents:
diff changeset
447 }
223b71206888 Initial import
thib
parents:
diff changeset
448 int scale_value = (new_value-min) * scale_max / (max-min);
223b71206888 Initial import
thib
parents:
diff changeset
449 SetScaleValue(scale_value);
223b71206888 Initial import
thib
parents:
diff changeset
450 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
451
0
223b71206888 Initial import
thib
parents:
diff changeset
452 int Scale::GetValue(void) const{
223b71206888 Initial import
thib
parents:
diff changeset
453 return min + value * (max-min) / scale_max;
223b71206888 Initial import
thib
parents:
diff changeset
454 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
455
0
223b71206888 Initial import
thib
parents:
diff changeset
456 void Scale::SetScaleValue(int new_value) {
223b71206888 Initial import
thib
parents:
diff changeset
457 if (new_value < 0) value = 0;
223b71206888 Initial import
thib
parents:
diff changeset
458 else if (new_value > scale_max) value = scale_max;
223b71206888 Initial import
thib
parents:
diff changeset
459 else value = new_value;
223b71206888 Initial import
thib
parents:
diff changeset
460 if (is_vertical) {
223b71206888 Initial import
thib
parents:
diff changeset
461 int h = Pic()->Height();
223b71206888 Initial import
thib
parents:
diff changeset
462 int y = (h-cursor_width) * value / scale_max;
223b71206888 Initial import
thib
parents:
diff changeset
463 if (y < 0) y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
464 cursor->Pic()->Move(0, y);
223b71206888 Initial import
thib
parents:
diff changeset
465 } else { // horizontal
223b71206888 Initial import
thib
parents:
diff changeset
466 int w = Pic()->Width();
223b71206888 Initial import
thib
parents:
diff changeset
467 int x = (w-cursor_width) * value / scale_max;
223b71206888 Initial import
thib
parents:
diff changeset
468 if (x < 0) x = 0;
223b71206888 Initial import
thib
parents:
diff changeset
469 cursor->Pic()->Move(x, 0);
223b71206888 Initial import
thib
parents:
diff changeset
470 }
223b71206888 Initial import
thib
parents:
diff changeset
471 if (change_func) {
223b71206888 Initial import
thib
parents:
diff changeset
472 (*change_func)(change_pointer, this);
223b71206888 Initial import
thib
parents:
diff changeset
473 }
223b71206888 Initial import
thib
parents:
diff changeset
474 }
223b71206888 Initial import
thib
parents:
diff changeset
475
223b71206888 Initial import
thib
parents:
diff changeset
476 TextButton::TextButton(Event::Container& container, PicContainer* parent, const char* text, int _text_size, Attribute attr, const Rect& r_orig, int _z, const Color& _fore, const Color& _pressed, const Color& _back) :
223b71206888 Initial import
thib
parents:
diff changeset
477 Button(container, parent, (Surface*)0, 0, 0, 0, 0, 0, r_orig, _z),
223b71206888 Initial import
thib
parents:
diff changeset
478 root(parent->Root()), surface(0), attribute(attr), text_size(_text_size),
223b71206888 Initial import
thib
parents:
diff changeset
479 fore(_fore), pressed(_pressed), back(_back)
223b71206888 Initial import
thib
parents:
diff changeset
480 {
223b71206888 Initial import
thib
parents:
diff changeset
481 bool rect_changed = false;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
482 // まず、テキスト領域の広さを得る
0
223b71206888 Initial import
thib
parents:
diff changeset
483 Rect r(r_orig);
223b71206888 Initial import
thib
parents:
diff changeset
484
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
485 if (text == NULL) text = "";
0
223b71206888 Initial import
thib
parents:
diff changeset
486 int width = r.width(); int height = r.height();
223b71206888 Initial import
thib
parents:
diff changeset
487 if (width == 0) width = parent->Width() - r.lx;
223b71206888 Initial import
thib
parents:
diff changeset
488
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
489 TextStream ts = TextStream::ParseMoji(text, _fore.r , _fore.g, _fore.b, text_size);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
490 TextGlyphStream gs = DefaultLayout(text_size)->Layout(ts, width);
0
223b71206888 Initial import
thib
parents:
diff changeset
491
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
492 if (r.width() == 0) { // 文字に合わせてウィジット作成
0
223b71206888 Initial import
thib
parents:
diff changeset
493 rect_changed = true;
223b71206888 Initial import
thib
parents:
diff changeset
494 width = gs.width() + text_size;
223b71206888 Initial import
thib
parents:
diff changeset
495 r.rx = r.lx + gs.width();
223b71206888 Initial import
thib
parents:
diff changeset
496 attribute = Attribute(attribute | CENTER);
223b71206888 Initial import
thib
parents:
diff changeset
497 }
223b71206888 Initial import
thib
parents:
diff changeset
498 if (r.height() == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
499 rect_changed = true;
223b71206888 Initial import
thib
parents:
diff changeset
500 if (attribute & NOPADDING) r.by = r.ty + gs.height();
223b71206888 Initial import
thib
parents:
diff changeset
501 else r.by = r.ty + gs.height() + text_size/2;
223b71206888 Initial import
thib
parents:
diff changeset
502 }
223b71206888 Initial import
thib
parents:
diff changeset
503
223b71206888 Initial import
thib
parents:
diff changeset
504 if (rect_changed) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
505 // 大きさ変更
0
223b71206888 Initial import
thib
parents:
diff changeset
506 Pic()->SetSurfaceRect(r);
223b71206888 Initial import
thib
parents:
diff changeset
507 }
223b71206888 Initial import
thib
parents:
diff changeset
508
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
509 sx = 0; sy = 0; sdx = 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
510 sdy = r.height();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
511 nptn = 3;
0
223b71206888 Initial import
thib
parents:
diff changeset
512 int x = 0, y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
513 if (attribute & CENTER)
223b71206888 Initial import
thib
parents:
diff changeset
514 x = (Pic()->Width() - gs.width()) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
515 y = (Pic()->Height() - gs.height()) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
516
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
517 //FIXME: (back.a == NULL ?)
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
518 if (back.a == 0) { // 背景なし、もしくはボタン押の状態のみ背景あり
0
223b71206888 Initial import
thib
parents:
diff changeset
519 surface = root.NewSurface(r.width(), r.height()*2, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
520 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
521 if (attribute & REVERSE) {
223b71206888 Initial import
thib
parents:
diff changeset
522 DSurfaceFill(surface, Rect(0,r.height(),r.width(),r.height()*2), pressed.r, pressed.g, pressed.b, 0xff);
223b71206888 Initial import
thib
parents:
diff changeset
523 }
223b71206888 Initial import
thib
parents:
diff changeset
524 gs.SetColor(fore.r, fore.g, fore.b);
223b71206888 Initial import
thib
parents:
diff changeset
525 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
526 gs.SetColor(pressed.r, pressed.g, pressed.b);
223b71206888 Initial import
thib
parents:
diff changeset
527 if (attribute & REVERSE) {
223b71206888 Initial import
thib
parents:
diff changeset
528 gs.SetReverse(true);
223b71206888 Initial import
thib
parents:
diff changeset
529 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y+r.height()));
223b71206888 Initial import
thib
parents:
diff changeset
530 gs.SetReverse(false);
223b71206888 Initial import
thib
parents:
diff changeset
531 } else {
223b71206888 Initial import
thib
parents:
diff changeset
532 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y+r.height()));
223b71206888 Initial import
thib
parents:
diff changeset
533 }
223b71206888 Initial import
thib
parents:
diff changeset
534 nptn = 2;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
535 } else { // ボタン型の背景あり
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
536 /* ラベル用の Surface を作る */
0
223b71206888 Initial import
thib
parents:
diff changeset
537 width = r.width(); height = r.height();
223b71206888 Initial import
thib
parents:
diff changeset
538 char* box = create_box(width, height, back.r, back.g, back.b);
223b71206888 Initial import
thib
parents:
diff changeset
539 surface = root.NewSurfaceFromRGBAData(r.width(), r.height()*3, box, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
540
223b71206888 Initial import
thib
parents:
diff changeset
541 Surface* text_surface = root.NewSurface(r.width(), r.height(), ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
542 DSurfaceFill(text_surface, Rect(*text_surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
543
223b71206888 Initial import
thib
parents:
diff changeset
544 gs.SetColor(fore.r, fore.g, fore.b);
223b71206888 Initial import
thib
parents:
diff changeset
545 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), text_surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
546 root.BlitSurface(text_surface, Rect(0,0,width,height), surface, Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
547 gs.SetColor(pressed.r, pressed.g, pressed.b);
223b71206888 Initial import
thib
parents:
diff changeset
548 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), text_surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
549 root.BlitSurface(text_surface, Rect(0,0,width,height), surface, Rect(0,height));
223b71206888 Initial import
thib
parents:
diff changeset
550 root.BlitSurface(text_surface, Rect(0,0,width,height), surface, Rect(0,height*2));
223b71206888 Initial import
thib
parents:
diff changeset
551 root.DeleteSurface(text_surface);
223b71206888 Initial import
thib
parents:
diff changeset
552 }
223b71206888 Initial import
thib
parents:
diff changeset
553
223b71206888 Initial import
thib
parents:
diff changeset
554 Pic()->SetSurface(surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
555 show();
223b71206888 Initial import
thib
parents:
diff changeset
556 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
557
0
223b71206888 Initial import
thib
parents:
diff changeset
558 void TextButton::SetText(const char* text, const Color& _fore, const Color& _pressed, const Color& _back)
223b71206888 Initial import
thib
parents:
diff changeset
559 {
223b71206888 Initial import
thib
parents:
diff changeset
560 int width = Pic()->Width(); int height = Pic()->Height();
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
561 // まず、テキスト領域の広さを得る
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
562 if (text == NULL) text = "";
0
223b71206888 Initial import
thib
parents:
diff changeset
563
223b71206888 Initial import
thib
parents:
diff changeset
564 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width);
223b71206888 Initial import
thib
parents:
diff changeset
565
223b71206888 Initial import
thib
parents:
diff changeset
566 int x = 0, y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
567 if (attribute & CENTER) {
223b71206888 Initial import
thib
parents:
diff changeset
568 x = (width - gs.width()) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
569 y = (height - gs.height()) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
570 }
223b71206888 Initial import
thib
parents:
diff changeset
571 int surf_x = Pic()->SurfacePosX();
223b71206888 Initial import
thib
parents:
diff changeset
572 int surf_y = Pic()->SurfacePosY();
223b71206888 Initial import
thib
parents:
diff changeset
573 Pic()->SetSurface( (Surface*)0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
574 root.DeleteSurface(surface);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
575 surface = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
576
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
577 //FIXME: (back.a == NULL) ?
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
578 if (back.a == 0) { // 背景なし
0
223b71206888 Initial import
thib
parents:
diff changeset
579 surface = root.NewSurface(width, height*2, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
580 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
581 if (attribute & REVERSE) {
223b71206888 Initial import
thib
parents:
diff changeset
582 DSurfaceFill(surface, Rect(0,height,width,height*2), pressed.r, pressed.g, pressed.b, 0xff);
223b71206888 Initial import
thib
parents:
diff changeset
583 }
223b71206888 Initial import
thib
parents:
diff changeset
584 gs.SetColor(_fore.r, _fore.g, _fore.b);
223b71206888 Initial import
thib
parents:
diff changeset
585 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
586 gs.SetColor(_pressed.r, _pressed.g, _pressed.b);
223b71206888 Initial import
thib
parents:
diff changeset
587 gs.SetReverse(true);
223b71206888 Initial import
thib
parents:
diff changeset
588 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), surface, Rect(x,y+height));
223b71206888 Initial import
thib
parents:
diff changeset
589 gs.SetReverse(false);
223b71206888 Initial import
thib
parents:
diff changeset
590 nptn = 2;
223b71206888 Initial import
thib
parents:
diff changeset
591 } else {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
592 /* ラベル用の Surface を作る */
0
223b71206888 Initial import
thib
parents:
diff changeset
593 char* box = create_box(width, height, _back.r, _back.g, _back.b);
223b71206888 Initial import
thib
parents:
diff changeset
594 surface = root.NewSurfaceFromRGBAData(width, height*3, box, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
595
223b71206888 Initial import
thib
parents:
diff changeset
596 Surface* text_surface = root.NewSurface(width, height, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
597 DSurfaceFill(text_surface, Rect(*text_surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
598
223b71206888 Initial import
thib
parents:
diff changeset
599 gs.SetColor(_fore.r, _fore.g, _fore.b);
223b71206888 Initial import
thib
parents:
diff changeset
600 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), text_surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
601 root.BlitSurface(text_surface, Rect(0,0,width,height), surface, Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
602 gs.SetColor(_pressed.r, _pressed.g, _pressed.b);
223b71206888 Initial import
thib
parents:
diff changeset
603 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0,0,gs.width(),gs.height()), text_surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
604 root.BlitSurface(text_surface, Rect(0,0,width,height), surface, Rect(0,height));
223b71206888 Initial import
thib
parents:
diff changeset
605 root.BlitSurface(text_surface, Rect(0,0,width,height), surface, Rect(0,height*2));
223b71206888 Initial import
thib
parents:
diff changeset
606 root.DeleteSurface(text_surface);
223b71206888 Initial import
thib
parents:
diff changeset
607 }
223b71206888 Initial import
thib
parents:
diff changeset
608
223b71206888 Initial import
thib
parents:
diff changeset
609 Pic()->SetSurface(surface, surf_x, surf_y);
223b71206888 Initial import
thib
parents:
diff changeset
610 show();
223b71206888 Initial import
thib
parents:
diff changeset
611 }
223b71206888 Initial import
thib
parents:
diff changeset
612
223b71206888 Initial import
thib
parents:
diff changeset
613 TextButton::~TextButton() {
223b71206888 Initial import
thib
parents:
diff changeset
614 if (surface) root.DeleteSurface(surface);
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
615 surface = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
616 }
223b71206888 Initial import
thib
parents:
diff changeset
617
223b71206888 Initial import
thib
parents:
diff changeset
618 Text::Text(Event::Container& container, PicContainer* parent, const Rect& r, const Rect& text_r, int _fontsize) :
223b71206888 Initial import
thib
parents:
diff changeset
619 Event::Video(container),
223b71206888 Initial import
thib
parents:
diff changeset
620 Event::Time(container),
223b71206888 Initial import
thib
parents:
diff changeset
621 event(container),
223b71206888 Initial import
thib
parents:
diff changeset
622 srcrect(0,0,0,0),
223b71206888 Initial import
thib
parents:
diff changeset
623 layout(wdefault_font.c_str(), _fontsize), fontsize(_fontsize) {
223b71206888 Initial import
thib
parents:
diff changeset
624
223b71206888 Initial import
thib
parents:
diff changeset
625 SetPic(parent->create_node(r, 0));
223b71206888 Initial import
thib
parents:
diff changeset
626 surface = parent->Root().NewSurface(text_r.width(), text_r.height(), ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
627 pictext = PicNode()->create_leaf(text_r, PicBase::CACHE_BACK);
223b71206888 Initial import
thib
parents:
diff changeset
628 pictext->SetSurface(surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
629 pictext->show();
223b71206888 Initial import
thib
parents:
diff changeset
630 cursor = 0;
223b71206888 Initial import
thib
parents:
diff changeset
631 cursor_activated = false;
223b71206888 Initial import
thib
parents:
diff changeset
632 window_activated = false;
223b71206888 Initial import
thib
parents:
diff changeset
633
223b71206888 Initial import
thib
parents:
diff changeset
634 event.RegisterGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
635
223b71206888 Initial import
thib
parents:
diff changeset
636 speed = 10;
223b71206888 Initial import
thib
parents:
diff changeset
637 wait_delay = -1;
223b71206888 Initial import
thib
parents:
diff changeset
638 status = PREPARE;
223b71206888 Initial import
thib
parents:
diff changeset
639 old_time = wait_starttime = 0;
223b71206888 Initial import
thib
parents:
diff changeset
640 }
223b71206888 Initial import
thib
parents:
diff changeset
641
223b71206888 Initial import
thib
parents:
diff changeset
642 Text::~Text() {
223b71206888 Initial import
thib
parents:
diff changeset
643 event.DeleteGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
644 PicNode()->Root().DeleteSurface(surface);
223b71206888 Initial import
thib
parents:
diff changeset
645 }
223b71206888 Initial import
thib
parents:
diff changeset
646
223b71206888 Initial import
thib
parents:
diff changeset
647 void Text::SetSpeed(int new_speed) {
223b71206888 Initial import
thib
parents:
diff changeset
648 speed = new_speed;
223b71206888 Initial import
thib
parents:
diff changeset
649 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
650
0
223b71206888 Initial import
thib
parents:
diff changeset
651 void Text::SetWait(int new_wait) {
223b71206888 Initial import
thib
parents:
diff changeset
652 if (new_wait < 0) new_wait = 100000000;
223b71206888 Initial import
thib
parents:
diff changeset
653 wait_delay = new_wait;
223b71206888 Initial import
thib
parents:
diff changeset
654 }
223b71206888 Initial import
thib
parents:
diff changeset
655
223b71206888 Initial import
thib
parents:
diff changeset
656 int Text::CalcScrollHeight(void) {
223b71206888 Initial import
thib
parents:
diff changeset
657 int i;
223b71206888 Initial import
thib
parents:
diff changeset
658 int len = bottom_pos.size();
223b71206888 Initial import
thib
parents:
diff changeset
659 int y0 = bottom_pos[line_number];
223b71206888 Initial import
thib
parents:
diff changeset
660 int height = Rect(*surface).height();
223b71206888 Initial import
thib
parents:
diff changeset
661 for (i=line_number; i<len; i++)
223b71206888 Initial import
thib
parents:
diff changeset
662 if (bottom_pos[i] - y0 > height) break;
223b71206888 Initial import
thib
parents:
diff changeset
663 if (i == line_number) i = line_number + 1;
223b71206888 Initial import
thib
parents:
diff changeset
664 return i - line_number - 1;
223b71206888 Initial import
thib
parents:
diff changeset
665 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
666
0
223b71206888 Initial import
thib
parents:
diff changeset
667 void Text::Elapsed(unsigned int current_time) {
223b71206888 Initial import
thib
parents:
diff changeset
668 SetWakeup(current_time + 50);
223b71206888 Initial import
thib
parents:
diff changeset
669 if (status == PREPARE) {
223b71206888 Initial import
thib
parents:
diff changeset
670 old_time = current_time;
223b71206888 Initial import
thib
parents:
diff changeset
671 return;
223b71206888 Initial import
thib
parents:
diff changeset
672 }
223b71206888 Initial import
thib
parents:
diff changeset
673 int nChar = speed * (current_time - old_time) / 1000;
223b71206888 Initial import
thib
parents:
diff changeset
674 if (speed == -1 || press_count) nChar = -1;
223b71206888 Initial import
thib
parents:
diff changeset
675 if (nChar == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
676 if (speed == -1) old_time = current_time;
223b71206888 Initial import
thib
parents:
diff changeset
677 else old_time += nChar * 1000 / speed;
223b71206888 Initial import
thib
parents:
diff changeset
678
223b71206888 Initial import
thib
parents:
diff changeset
679 switch(status) {
223b71206888 Initial import
thib
parents:
diff changeset
680 case WAIT: goto label_wait;
223b71206888 Initial import
thib
parents:
diff changeset
681 case SCROLL: goto label_scroll;
223b71206888 Initial import
thib
parents:
diff changeset
682 case DRAW2: goto label_draw2;
223b71206888 Initial import
thib
parents:
diff changeset
683 case WAIT2: goto label_wait2;
223b71206888 Initial import
thib
parents:
diff changeset
684 }
223b71206888 Initial import
thib
parents:
diff changeset
685
223b71206888 Initial import
thib
parents:
diff changeset
686 status = DRAW;
223b71206888 Initial import
thib
parents:
diff changeset
687 if (press_count) {
223b71206888 Initial import
thib
parents:
diff changeset
688 nChar = -1;
223b71206888 Initial import
thib
parents:
diff changeset
689 press_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
690 }
223b71206888 Initial import
thib
parents:
diff changeset
691 DrawText(nChar);
223b71206888 Initial import
thib
parents:
diff changeset
692 if (nChar == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
693 status = WAIT;
223b71206888 Initial import
thib
parents:
diff changeset
694 cursor_activated = true;
223b71206888 Initial import
thib
parents:
diff changeset
695 if (cursor_activated && window_activated && cursor) cursor->show();
223b71206888 Initial import
thib
parents:
diff changeset
696 wait_starttime = current_time;
223b71206888 Initial import
thib
parents:
diff changeset
697 label_wait:
223b71206888 Initial import
thib
parents:
diff changeset
698 if (current_time < wait_starttime + wait_delay && press_count == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
699 press_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
700 nChar = 0;
223b71206888 Initial import
thib
parents:
diff changeset
701 cursor_activated = false;
223b71206888 Initial import
thib
parents:
diff changeset
702 if (cursor) cursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
703 while(cur_pos != gstream.end()) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
704 // スクロールしては次行描画、を繰り返す
0
223b71206888 Initial import
thib
parents:
diff changeset
705 for (scroll_height = CalcScrollHeight(); scroll_height > 0; scroll_height--) {
223b71206888 Initial import
thib
parents:
diff changeset
706 status = SCROLL;
223b71206888 Initial import
thib
parents:
diff changeset
707 label_scroll:
223b71206888 Initial import
thib
parents:
diff changeset
708 if (press_count) break;
223b71206888 Initial import
thib
parents:
diff changeset
709 Scrollup(nChar);
223b71206888 Initial import
thib
parents:
diff changeset
710 if (nChar == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
711 status = DRAW2;
223b71206888 Initial import
thib
parents:
diff changeset
712 label_draw2:
223b71206888 Initial import
thib
parents:
diff changeset
713 if (press_count) break;
223b71206888 Initial import
thib
parents:
diff changeset
714 DrawText(nChar);
223b71206888 Initial import
thib
parents:
diff changeset
715 if (nChar == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
716 }
223b71206888 Initial import
thib
parents:
diff changeset
717 if (nChar != 0 && scroll_height) {
223b71206888 Initial import
thib
parents:
diff changeset
718 nChar = 100000;
223b71206888 Initial import
thib
parents:
diff changeset
719 if (status == SCROLL) Scrollup(nChar);
223b71206888 Initial import
thib
parents:
diff changeset
720 DrawText(nChar);
223b71206888 Initial import
thib
parents:
diff changeset
721 scroll_height--;
223b71206888 Initial import
thib
parents:
diff changeset
722 for (; scroll_height > 0; scroll_height--) {
223b71206888 Initial import
thib
parents:
diff changeset
723 Scrollup(nChar);
223b71206888 Initial import
thib
parents:
diff changeset
724 DrawText(nChar);
223b71206888 Initial import
thib
parents:
diff changeset
725 }
223b71206888 Initial import
thib
parents:
diff changeset
726 }
223b71206888 Initial import
thib
parents:
diff changeset
727 press_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
728 status = WAIT2;
223b71206888 Initial import
thib
parents:
diff changeset
729 cursor_activated = true;
223b71206888 Initial import
thib
parents:
diff changeset
730 if (cursor_activated && window_activated && cursor) cursor->show();
223b71206888 Initial import
thib
parents:
diff changeset
731 wait_starttime = current_time;
223b71206888 Initial import
thib
parents:
diff changeset
732 label_wait2:
223b71206888 Initial import
thib
parents:
diff changeset
733 if (current_time < wait_starttime + wait_delay && press_count == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
734 press_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
735 nChar = 0;
223b71206888 Initial import
thib
parents:
diff changeset
736 cursor_activated = false;
223b71206888 Initial import
thib
parents:
diff changeset
737 if (cursor) cursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
738 }
223b71206888 Initial import
thib
parents:
diff changeset
739 status = PREPARE;
223b71206888 Initial import
thib
parents:
diff changeset
740 }
223b71206888 Initial import
thib
parents:
diff changeset
741
223b71206888 Initial import
thib
parents:
diff changeset
742 bool Text::Pressed(int x, int y, void* pointer) {
223b71206888 Initial import
thib
parents:
diff changeset
743 Text* wid = (Text*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
744 if (wid->Pic()->IsHidden()) return true;
223b71206888 Initial import
thib
parents:
diff changeset
745 wid->press_count++;
223b71206888 Initial import
thib
parents:
diff changeset
746 return true;
223b71206888 Initial import
thib
parents:
diff changeset
747 }
223b71206888 Initial import
thib
parents:
diff changeset
748
223b71206888 Initial import
thib
parents:
diff changeset
749 void Text::Clear(void) {
223b71206888 Initial import
thib
parents:
diff changeset
750 stream.container.clear();
223b71206888 Initial import
thib
parents:
diff changeset
751 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
752 pictext->ReBlit();
223b71206888 Initial import
thib
parents:
diff changeset
753 status = PREPARE;
223b71206888 Initial import
thib
parents:
diff changeset
754 }
223b71206888 Initial import
thib
parents:
diff changeset
755
223b71206888 Initial import
thib
parents:
diff changeset
756 void Text::Flush(void) {
223b71206888 Initial import
thib
parents:
diff changeset
757 int nChar = -1;
223b71206888 Initial import
thib
parents:
diff changeset
758 DrawText(nChar);
223b71206888 Initial import
thib
parents:
diff changeset
759 }
223b71206888 Initial import
thib
parents:
diff changeset
760
223b71206888 Initial import
thib
parents:
diff changeset
761 void Text::Start(void) {
223b71206888 Initial import
thib
parents:
diff changeset
762 gstream.clear();
223b71206888 Initial import
thib
parents:
diff changeset
763 bottom_pos.clear();
223b71206888 Initial import
thib
parents:
diff changeset
764 layout.Layout(stream, gstream, bottom_pos, pictext->Width()-fontsize/2);
223b71206888 Initial import
thib
parents:
diff changeset
765
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
766 // height の積算値として bottom_pos を計算
0
223b71206888 Initial import
thib
parents:
diff changeset
767 std::vector<int>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
768 int pos = 0;
223b71206888 Initial import
thib
parents:
diff changeset
769 for (it = bottom_pos.begin(); it != bottom_pos.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
770 pos += *it;
223b71206888 Initial import
thib
parents:
diff changeset
771 *it = pos;
223b71206888 Initial import
thib
parents:
diff changeset
772 }
223b71206888 Initial import
thib
parents:
diff changeset
773
223b71206888 Initial import
thib
parents:
diff changeset
774 cur_pos = gstream.begin();
223b71206888 Initial import
thib
parents:
diff changeset
775 line_number = 0;
223b71206888 Initial import
thib
parents:
diff changeset
776 scrolled_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
777 srcrect = Rect(0, 0, pictext->Width(), pictext->Height());
223b71206888 Initial import
thib
parents:
diff changeset
778 press_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
779
223b71206888 Initial import
thib
parents:
diff changeset
780 status = DRAW;
223b71206888 Initial import
thib
parents:
diff changeset
781 cursor_activated = false;
223b71206888 Initial import
thib
parents:
diff changeset
782 if (cursor) cursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
783 }
223b71206888 Initial import
thib
parents:
diff changeset
784
223b71206888 Initial import
thib
parents:
diff changeset
785 void Text::DrawText(int& nChar) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
786 // 描画範囲を得る
0
223b71206888 Initial import
thib
parents:
diff changeset
787 iterator end = gstream.end();
223b71206888 Initial import
thib
parents:
diff changeset
788 iterator it = cur_pos;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
789 while(nChar && it != end) { // nChar < 0 なら出来るだけの文字を描画
0
223b71206888 Initial import
thib
parents:
diff changeset
790 if (! (it->flag & TextGlyph::Group)) nChar--;
223b71206888 Initial import
thib
parents:
diff changeset
791 if (it->flag & TextGlyph::LineEnd) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
792 if (bottom_pos[line_number+1] > srcrect.by) { //改行すると画面から出てしまう
0
223b71206888 Initial import
thib
parents:
diff changeset
793 it++;
223b71206888 Initial import
thib
parents:
diff changeset
794 if (nChar == 0) nChar = 1;
223b71206888 Initial import
thib
parents:
diff changeset
795 break;
223b71206888 Initial import
thib
parents:
diff changeset
796 }
223b71206888 Initial import
thib
parents:
diff changeset
797 line_number++;
223b71206888 Initial import
thib
parents:
diff changeset
798 }
223b71206888 Initial import
thib
parents:
diff changeset
799 it++;
223b71206888 Initial import
thib
parents:
diff changeset
800 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
801 // 描画する
0
223b71206888 Initial import
thib
parents:
diff changeset
802 Rect r = DSurfaceRenderText(cur_pos, it, srcrect, surface, Rect(0,0,0,0));
223b71206888 Initial import
thib
parents:
diff changeset
803 pictext->ReBlit(r);
223b71206888 Initial import
thib
parents:
diff changeset
804 cur_pos = it;
223b71206888 Initial import
thib
parents:
diff changeset
805 }
223b71206888 Initial import
thib
parents:
diff changeset
806
223b71206888 Initial import
thib
parents:
diff changeset
807 void Text::Scrollup(int& nChar) {
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
808 if (nChar < 0) { // 一画面分スクロールする
0
223b71206888 Initial import
thib
parents:
diff changeset
809 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
810 pictext->ReBlit();
223b71206888 Initial import
thib
parents:
diff changeset
811 srcrect = Rect(*surface);
223b71206888 Initial import
thib
parents:
diff changeset
812 srcrect.rmove(0, bottom_pos[line_number]);
223b71206888 Initial import
thib
parents:
diff changeset
813 line_number++;
223b71206888 Initial import
thib
parents:
diff changeset
814 scrolled_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
815 return;
223b71206888 Initial import
thib
parents:
diff changeset
816 }
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
817 // スクロール幅を求める
0
223b71206888 Initial import
thib
parents:
diff changeset
818 const int max_scroll_count = 8;
223b71206888 Initial import
thib
parents:
diff changeset
819 int dy = bottom_pos[line_number+1] - bottom_pos[line_number];
223b71206888 Initial import
thib
parents:
diff changeset
820 int cur_dy;
223b71206888 Initial import
thib
parents:
diff changeset
821 if (scrolled_count+nChar >= max_scroll_count) {
223b71206888 Initial import
thib
parents:
diff changeset
822 cur_dy = dy - (scrolled_count*dy/max_scroll_count);
223b71206888 Initial import
thib
parents:
diff changeset
823 nChar -= max_scroll_count-scrolled_count;
223b71206888 Initial import
thib
parents:
diff changeset
824 nChar++;
223b71206888 Initial import
thib
parents:
diff changeset
825 scrolled_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
826 line_number++;
223b71206888 Initial import
thib
parents:
diff changeset
827 srcrect.rmove(0, dy);
223b71206888 Initial import
thib
parents:
diff changeset
828 } else {
223b71206888 Initial import
thib
parents:
diff changeset
829 cur_dy = (scrolled_count+nChar)*dy/max_scroll_count;
223b71206888 Initial import
thib
parents:
diff changeset
830 cur_dy -=(scrolled_count*dy/max_scroll_count);
223b71206888 Initial import
thib
parents:
diff changeset
831 scrolled_count += nChar;
223b71206888 Initial import
thib
parents:
diff changeset
832 nChar = 0;
223b71206888 Initial import
thib
parents:
diff changeset
833 }
223b71206888 Initial import
thib
parents:
diff changeset
834 Rect r(*surface);
223b71206888 Initial import
thib
parents:
diff changeset
835 DSurfaceMove(surface, r, surface, Rect(0, -cur_dy, 0, 0));
223b71206888 Initial import
thib
parents:
diff changeset
836 r.ty = r.by-cur_dy;
223b71206888 Initial import
thib
parents:
diff changeset
837 DSurfaceFill(surface, r, 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
838 pictext->ReBlit();
223b71206888 Initial import
thib
parents:
diff changeset
839 }
223b71206888 Initial import
thib
parents:
diff changeset
840
223b71206888 Initial import
thib
parents:
diff changeset
841 void Text::activate(void) {
223b71206888 Initial import
thib
parents:
diff changeset
842 event.RegisterGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
843 Event::Video::activate();
223b71206888 Initial import
thib
parents:
diff changeset
844 window_activated = true;
223b71206888 Initial import
thib
parents:
diff changeset
845 if (cursor_activated && window_activated && cursor) cursor->show();
223b71206888 Initial import
thib
parents:
diff changeset
846 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
847
0
223b71206888 Initial import
thib
parents:
diff changeset
848 void Text::deactivate(void) {
223b71206888 Initial import
thib
parents:
diff changeset
849 event.DeleteGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
850 Event::Video::deactivate();
223b71206888 Initial import
thib
parents:
diff changeset
851 window_activated = false;
223b71206888 Initial import
thib
parents:
diff changeset
852 if (cursor) cursor->hide();
223b71206888 Initial import
thib
parents:
diff changeset
853 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
854
0
223b71206888 Initial import
thib
parents:
diff changeset
855 void Text::SetCursor(TimeCursor* c) {
223b71206888 Initial import
thib
parents:
diff changeset
856 cursor = c;
223b71206888 Initial import
thib
parents:
diff changeset
857 if (c) {
223b71206888 Initial import
thib
parents:
diff changeset
858 if (cursor_activated && window_activated) c->show();
223b71206888 Initial import
thib
parents:
diff changeset
859 else c->hide();
223b71206888 Initial import
thib
parents:
diff changeset
860 }
223b71206888 Initial import
thib
parents:
diff changeset
861 }
223b71206888 Initial import
thib
parents:
diff changeset
862
223b71206888 Initial import
thib
parents:
diff changeset
863 Label::Label(PicContainer* parent, const Rect& r_orig, bool _is_center, const char* text, int _text_size) :
223b71206888 Initial import
thib
parents:
diff changeset
864 is_center(_is_center),
223b71206888 Initial import
thib
parents:
diff changeset
865 root(parent->Root()),
223b71206888 Initial import
thib
parents:
diff changeset
866 text_size(_text_size) {
223b71206888 Initial import
thib
parents:
diff changeset
867 Rect r(r_orig);
223b71206888 Initial import
thib
parents:
diff changeset
868
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
869 if (text == NULL) text = "";
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
870 int width = r.width();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
871 int height = r.height();
0
223b71206888 Initial import
thib
parents:
diff changeset
872 if (width == 0) width = parent->Width() - r.lx;
223b71206888 Initial import
thib
parents:
diff changeset
873
223b71206888 Initial import
thib
parents:
diff changeset
874 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width);
223b71206888 Initial import
thib
parents:
diff changeset
875
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
876 if (r.width() == 0) { // 文字に合わせてウィジット作成
0
223b71206888 Initial import
thib
parents:
diff changeset
877 width = gs.width();
223b71206888 Initial import
thib
parents:
diff changeset
878 r.rx = r.lx + gs.width();
223b71206888 Initial import
thib
parents:
diff changeset
879 }
223b71206888 Initial import
thib
parents:
diff changeset
880 if (r.height() == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
881 r.by = r.ty + gs.height();
223b71206888 Initial import
thib
parents:
diff changeset
882 }
223b71206888 Initial import
thib
parents:
diff changeset
883
223b71206888 Initial import
thib
parents:
diff changeset
884 SetPic(parent->create_leaf(r, 0));
223b71206888 Initial import
thib
parents:
diff changeset
885
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
886 /* ラベル用の Surface を作る */
0
223b71206888 Initial import
thib
parents:
diff changeset
887 surface = parent->Root().NewSurface(r.width(), r.height(), ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
888
223b71206888 Initial import
thib
parents:
diff changeset
889 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
890 int x = 0, y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
891 if (is_center) {
223b71206888 Initial import
thib
parents:
diff changeset
892 x = (Pic()->Width() - gs.width()) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
893 y = (Pic()->Height() - gs.height()) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
894 }
223b71206888 Initial import
thib
parents:
diff changeset
895
223b71206888 Initial import
thib
parents:
diff changeset
896 DSurfaceRenderText(gs.begin(), gs.end(), Rect(*surface), surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
897
223b71206888 Initial import
thib
parents:
diff changeset
898 Pic()->SetSurface(surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
899 show();
223b71206888 Initial import
thib
parents:
diff changeset
900 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
901
0
223b71206888 Initial import
thib
parents:
diff changeset
902 Label::~Label() {
223b71206888 Initial import
thib
parents:
diff changeset
903 root.DeleteSurface(surface);
223b71206888 Initial import
thib
parents:
diff changeset
904 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
905
0
223b71206888 Initial import
thib
parents:
diff changeset
906 void Label::SetText(const char* text) {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
907 if (text == NULL) text = "";
0
223b71206888 Initial import
thib
parents:
diff changeset
908 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, Pic()->Width());
223b71206888 Initial import
thib
parents:
diff changeset
909 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
910 int x = 0, y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
911 if (is_center) {
223b71206888 Initial import
thib
parents:
diff changeset
912 x = (Pic()->Width() - gs.width()) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
913 y = (Pic()->Height() - gs.height()) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
914 }
223b71206888 Initial import
thib
parents:
diff changeset
915
223b71206888 Initial import
thib
parents:
diff changeset
916 DSurfaceRenderText(gs.begin(), gs.end(), Rect(*surface), surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
917 Pic()->ReBlit();
223b71206888 Initial import
thib
parents:
diff changeset
918 }
223b71206888 Initial import
thib
parents:
diff changeset
919
223b71206888 Initial import
thib
parents:
diff changeset
920 Dialog::Dialog(Event::Container& container, PicContainer* parent, const char* text, bool with_cancel) :
223b71206888 Initial import
thib
parents:
diff changeset
921 Event::Video(container) {
223b71206888 Initial import
thib
parents:
diff changeset
922
223b71206888 Initial import
thib
parents:
diff changeset
923 int x,y;
223b71206888 Initial import
thib
parents:
diff changeset
924 status = WAIT;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
925 set_func = NULL;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
926 set_pointer = NULL;
0
223b71206888 Initial import
thib
parents:
diff changeset
927
223b71206888 Initial import
thib
parents:
diff changeset
928 XKFont::HorizLayout& layout = *DefaultLayout(26);
223b71206888 Initial import
thib
parents:
diff changeset
929 int dialog_width = parent->Width() / 2;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
930 TextGlyphStream s_ok = layout.Layout("OK", dialog_width);
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
931 TextGlyphStream s_cancel = layout.Layout("取消", dialog_width);
0
223b71206888 Initial import
thib
parents:
diff changeset
932 TextGlyphStream s_text = layout.Layout(text, dialog_width);
223b71206888 Initial import
thib
parents:
diff changeset
933
223b71206888 Initial import
thib
parents:
diff changeset
934 Rect r_text(0, 0, s_text.width(), s_text.height());
223b71206888 Initial import
thib
parents:
diff changeset
935 Rect r_ok(0, 0, s_ok.width(), s_ok.height());
223b71206888 Initial import
thib
parents:
diff changeset
936 Rect r_cancel(0, 0, s_cancel.width(), s_cancel.height());
223b71206888 Initial import
thib
parents:
diff changeset
937
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
938 /* ダイアログボックスの Surface を作る */
0
223b71206888 Initial import
thib
parents:
diff changeset
939 int dwidth = r_text.width() + (r_text.width()/10)*2 + 6;
223b71206888 Initial import
thib
parents:
diff changeset
940 int dheight = r_text.height() + r_ok.height() + r_cancel.height()*3 + 4;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
941 surface_diag = parent->Root().NewSurface(dwidth, dheight, NO_MASK); // alpha なし
0
223b71206888 Initial import
thib
parents:
diff changeset
942 DSurfaceFill(surface_diag, Rect(*surface_diag), 0xf0, 0xd0, 0xa0);
223b71206888 Initial import
thib
parents:
diff changeset
943 DrawBox(surface_diag, Rect(0,0,dwidth,dheight));
223b71206888 Initial import
thib
parents:
diff changeset
944
223b71206888 Initial import
thib
parents:
diff changeset
945 Surface* surface_text = parent->Root().NewSurface(r_text.width(), r_text.height(), ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
946 s_text.SetColor(0x38, 0x20, 0x18);
223b71206888 Initial import
thib
parents:
diff changeset
947 DSurfaceRenderText(s_text.begin(), s_text.end(), r_text, surface_text, Rect(0, 0, 0, 0));
223b71206888 Initial import
thib
parents:
diff changeset
948 x = r_text.width()/10 + 3;
223b71206888 Initial import
thib
parents:
diff changeset
949 y = r_cancel.height()+2;
223b71206888 Initial import
thib
parents:
diff changeset
950 parent->Root().BlitSurface(surface_text, r_text, surface_diag, Rect(x, y, x+r_text.width(), y+r_text.height()));
223b71206888 Initial import
thib
parents:
diff changeset
951 parent->Root().DeleteSurface(surface_text);
223b71206888 Initial import
thib
parents:
diff changeset
952
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
953 /* panel をつくる */
0
223b71206888 Initial import
thib
parents:
diff changeset
954 x = (parent->Width()-dwidth)/2;
223b71206888 Initial import
thib
parents:
diff changeset
955 y = (parent->Height()-dheight)/2;
223b71206888 Initial import
thib
parents:
diff changeset
956 SetPic(parent->create_node(Rect(x, y, x+dwidth, y+dheight), 0));
223b71206888 Initial import
thib
parents:
diff changeset
957
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
958 /* ボタンを作成する */
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
959 /* f8d8c8 背景(明)*/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
960 /* f0d0a0 背景*/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
961 /* b08040 枠(明)*/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
962 /* 805010 枠*/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
963 /* 382018 黒*/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
964 /* 9890f8 青*/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
965 /* dc6448 赤*/
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
966 /* 各ボタンは左右にボタン幅の 1/4, 上下にボタン幅の 1/4 のマージンを持つ */
0
223b71206888 Initial import
thib
parents:
diff changeset
967 Rect r_btn(r_ok); r_btn.join(r_cancel);
223b71206888 Initial import
thib
parents:
diff changeset
968 int btn_width = r_btn.width() * 3 / 2;
223b71206888 Initial import
thib
parents:
diff changeset
969 int btn_height = r_btn.height() * 3 / 2;
223b71206888 Initial import
thib
parents:
diff changeset
970 surface_btn = parent->Root().NewSurface(btn_width, btn_height*4, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
971 DSurfaceFill(surface_btn, Rect(*surface_btn), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
972 s_ok.SetColor(0x38, 0x20, 0x18);
223b71206888 Initial import
thib
parents:
diff changeset
973 DSurfaceRenderText(s_ok.begin(), s_ok.end(), r_ok, surface_btn, Rect( (btn_width-r_ok.width())/2,(btn_height-r_ok.height())/2));
223b71206888 Initial import
thib
parents:
diff changeset
974 s_ok.SetColor(0x98, 0x90, 0xf8);
223b71206888 Initial import
thib
parents:
diff changeset
975 DSurfaceRenderText(s_ok.begin(), s_ok.end(), r_ok, surface_btn, Rect( (btn_width-r_ok.width())/2,(btn_height-r_ok.height())/2 + btn_height));
223b71206888 Initial import
thib
parents:
diff changeset
976 s_cancel.SetColor(0x38, 0x20, 0x18);
223b71206888 Initial import
thib
parents:
diff changeset
977 DSurfaceRenderText(s_cancel.begin(), s_cancel.end(), r_cancel, surface_btn, Rect( (btn_width-r_cancel.width())/2,(btn_height-r_cancel.height())/2 + btn_height*2));
223b71206888 Initial import
thib
parents:
diff changeset
978 s_cancel.SetColor(0xdc, 0x64, 0x48);
223b71206888 Initial import
thib
parents:
diff changeset
979 DSurfaceRenderText(s_cancel.begin(), s_cancel.end(), r_cancel, surface_btn, Rect( (btn_width-r_cancel.width())/2,(btn_height-r_cancel.height())/2 + btn_height*3));
223b71206888 Initial import
thib
parents:
diff changeset
980
223b71206888 Initial import
thib
parents:
diff changeset
981 x = (dwidth - btn_width*2) / 3;;
223b71206888 Initial import
thib
parents:
diff changeset
982 y = r_cancel.height()*3/2 + r_text.height() + 2;
223b71206888 Initial import
thib
parents:
diff changeset
983 if (!with_cancel) x = (dwidth - btn_width) / 2;
223b71206888 Initial import
thib
parents:
diff changeset
984 Button* b_ok = new Button(container, PicNode(), surface_btn, 0, 0, 0, btn_height, 2, Rect(x, y, x+btn_width, y+btn_height), 1);
223b71206888 Initial import
thib
parents:
diff changeset
985 DrawBox(surface_diag, Rect(x-3,y-2,x+btn_width+3,y+btn_height+2));
223b71206888 Initial import
thib
parents:
diff changeset
986 b_ok->press_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
987 b_ok->press_func = &press_ok;
223b71206888 Initial import
thib
parents:
diff changeset
988 if (with_cancel) {
223b71206888 Initial import
thib
parents:
diff changeset
989 x += x + btn_width;
223b71206888 Initial import
thib
parents:
diff changeset
990 Button* b_cancel = new Button(container, PicNode(), surface_btn, 0, btn_height*2, 0, btn_height, 2, Rect(x, y, x+btn_width, y+btn_height), 1);
223b71206888 Initial import
thib
parents:
diff changeset
991 DrawBox(surface_diag, Rect(x-3,y-2,x+btn_width+3,y+btn_height+2));
223b71206888 Initial import
thib
parents:
diff changeset
992 b_cancel->press_pointer = (void*)this;
223b71206888 Initial import
thib
parents:
diff changeset
993 b_cancel->press_func = &press_cancel;
223b71206888 Initial import
thib
parents:
diff changeset
994 }
223b71206888 Initial import
thib
parents:
diff changeset
995
223b71206888 Initial import
thib
parents:
diff changeset
996 Pic()->SetSurface(surface_diag, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
997 Pic()->ZMove(ZMOVE_TOP);
223b71206888 Initial import
thib
parents:
diff changeset
998
223b71206888 Initial import
thib
parents:
diff changeset
999 show_all();
223b71206888 Initial import
thib
parents:
diff changeset
1000 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1001
0
223b71206888 Initial import
thib
parents:
diff changeset
1002 Dialog::~Dialog() {
223b71206888 Initial import
thib
parents:
diff changeset
1003 PicRoot& root = PicNode()->Root();
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1004 SetPic(NULL);
0
223b71206888 Initial import
thib
parents:
diff changeset
1005 root.DeleteSurface(surface_btn);
223b71206888 Initial import
thib
parents:
diff changeset
1006 root.DeleteSurface(surface_diag);
223b71206888 Initial import
thib
parents:
diff changeset
1007 }
223b71206888 Initial import
thib
parents:
diff changeset
1008
223b71206888 Initial import
thib
parents:
diff changeset
1009 void Dialog::press_ok(void* pointer, Button* btn) {
223b71206888 Initial import
thib
parents:
diff changeset
1010 if (pointer) {
223b71206888 Initial import
thib
parents:
diff changeset
1011 Dialog* wid = (Dialog*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1012 wid->status = OK;
223b71206888 Initial import
thib
parents:
diff changeset
1013 if (wid->set_func) {
223b71206888 Initial import
thib
parents:
diff changeset
1014 (*wid->set_func)(wid->set_pointer, wid);
223b71206888 Initial import
thib
parents:
diff changeset
1015 }
223b71206888 Initial import
thib
parents:
diff changeset
1016 }
223b71206888 Initial import
thib
parents:
diff changeset
1017 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1018
0
223b71206888 Initial import
thib
parents:
diff changeset
1019 void Dialog::press_cancel(void* pointer, Button* btn) {
223b71206888 Initial import
thib
parents:
diff changeset
1020 if (pointer) {
223b71206888 Initial import
thib
parents:
diff changeset
1021 Dialog* wid = (Dialog*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1022 wid->status = CANCEL;
223b71206888 Initial import
thib
parents:
diff changeset
1023 if (wid->set_func) {
223b71206888 Initial import
thib
parents:
diff changeset
1024 (*wid->set_func)(wid->set_pointer, wid);
223b71206888 Initial import
thib
parents:
diff changeset
1025 }
223b71206888 Initial import
thib
parents:
diff changeset
1026 }
223b71206888 Initial import
thib
parents:
diff changeset
1027 }
223b71206888 Initial import
thib
parents:
diff changeset
1028
223b71206888 Initial import
thib
parents:
diff changeset
1029 void Dialog::DrawBox(Surface* s, const Rect& r) {
223b71206888 Initial import
thib
parents:
diff changeset
1030 DSurfaceFill(s, Rect(r.lx, r.ty, r.rx, r.ty+1), 0x80, 0x50, 0x10);
223b71206888 Initial import
thib
parents:
diff changeset
1031 DSurfaceFill(s, Rect(r.lx, r.ty+1, r.rx, r.ty+2), 0x38, 0x20, 0x18);
223b71206888 Initial import
thib
parents:
diff changeset
1032 DSurfaceFill(s, Rect(r.lx, r.by-2, r.rx, r.by-1), 0x80, 0x50, 0x10);
223b71206888 Initial import
thib
parents:
diff changeset
1033 DSurfaceFill(s, Rect(r.lx, r.by-1, r.rx, r.by), 0x38, 0x20, 0x18);
223b71206888 Initial import
thib
parents:
diff changeset
1034
223b71206888 Initial import
thib
parents:
diff changeset
1035 DSurfaceFill(s, Rect(r.lx, r.ty, r.lx+1, r.by), 0xb0, 0x80, 0x40);
223b71206888 Initial import
thib
parents:
diff changeset
1036 DSurfaceFill(s, Rect(r.lx+1, r.ty+1, r.lx+2, r.by-1), 0x80, 0x50, 0x10);
223b71206888 Initial import
thib
parents:
diff changeset
1037 DSurfaceFill(s, Rect(r.lx+1, r.ty+2, r.lx+2, r.by-2), 0x38, 0x20, 0x18);
223b71206888 Initial import
thib
parents:
diff changeset
1038 DSurfaceFill(s, Rect(r.rx-3, r.ty+2, r.rx-2, r.by-2), 0xb0, 0x80, 0x40);
223b71206888 Initial import
thib
parents:
diff changeset
1039 DSurfaceFill(s, Rect(r.rx-2, r.ty+1, r.rx-1, r.by-1), 0x80, 0x50, 0x10);
223b71206888 Initial import
thib
parents:
diff changeset
1040 DSurfaceFill(s, Rect(r.rx-1, r.ty, r.rx, r.by), 0x38, 0x20, 0x18);
223b71206888 Initial import
thib
parents:
diff changeset
1041 }
223b71206888 Initial import
thib
parents:
diff changeset
1042
223b71206888 Initial import
thib
parents:
diff changeset
1043 AnmTime::AnmTime(Event::Container& container, PicBase* _pic, int _total_time, int _all_count) :
223b71206888 Initial import
thib
parents:
diff changeset
1044 Event::Time(container),
223b71206888 Initial import
thib
parents:
diff changeset
1045 PicAnm(_pic), start_time(0), total_time(_total_time), all_count(_all_count) {
223b71206888 Initial import
thib
parents:
diff changeset
1046 status = FINISHED;
223b71206888 Initial import
thib
parents:
diff changeset
1047 if (total_time == 0) total_time = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1048 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1049
0
223b71206888 Initial import
thib
parents:
diff changeset
1050 AnmTime::AnmTime(Event::Container& container, std::vector<PicBase*> _pic, int _total_time, int _all_count) :
223b71206888 Initial import
thib
parents:
diff changeset
1051 Event::Time(container),
223b71206888 Initial import
thib
parents:
diff changeset
1052 PicAnm(_pic), start_time(0), total_time(_total_time), all_count(_all_count) {
223b71206888 Initial import
thib
parents:
diff changeset
1053 status = FINISHED;
223b71206888 Initial import
thib
parents:
diff changeset
1054 if (total_time == 0) total_time = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1055 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1056
0
223b71206888 Initial import
thib
parents:
diff changeset
1057 void AnmTime::Elapsed(unsigned int current_time) {
223b71206888 Initial import
thib
parents:
diff changeset
1058 if (total_time == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1059 if (status == FINISHED || current_time == 0) {SetWakeup(current_time+1); return;}
223b71206888 Initial import
thib
parents:
diff changeset
1060 if (start_time == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1061 start_time = current_time;
223b71206888 Initial import
thib
parents:
diff changeset
1062 Start();
223b71206888 Initial import
thib
parents:
diff changeset
1063 }
223b71206888 Initial import
thib
parents:
diff changeset
1064 unsigned int time_elapsed = current_time - start_time;
223b71206888 Initial import
thib
parents:
diff changeset
1065 if (time_elapsed < total_time) {
223b71206888 Initial import
thib
parents:
diff changeset
1066 int count = time_elapsed * all_count / total_time;
223b71206888 Initial import
thib
parents:
diff changeset
1067 Exec(count);
223b71206888 Initial import
thib
parents:
diff changeset
1068 int next_time = start_time + (count+1) * total_time / all_count;
223b71206888 Initial import
thib
parents:
diff changeset
1069 SetWakeup(next_time);
223b71206888 Initial import
thib
parents:
diff changeset
1070 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1071 Exec(all_count);
223b71206888 Initial import
thib
parents:
diff changeset
1072 Finish();
223b71206888 Initial import
thib
parents:
diff changeset
1073 status = FINISHED;
223b71206888 Initial import
thib
parents:
diff changeset
1074 }
223b71206888 Initial import
thib
parents:
diff changeset
1075 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1076
0
223b71206888 Initial import
thib
parents:
diff changeset
1077 void AnmTime::Abort(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1078 if (status == FINISHED) return;
223b71206888 Initial import
thib
parents:
diff changeset
1079 if (start_time == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1080 Start();
223b71206888 Initial import
thib
parents:
diff changeset
1081 Exec(all_count);
223b71206888 Initial import
thib
parents:
diff changeset
1082 }
223b71206888 Initial import
thib
parents:
diff changeset
1083 if (total_time) {
223b71206888 Initial import
thib
parents:
diff changeset
1084 Finish();
223b71206888 Initial import
thib
parents:
diff changeset
1085 }
223b71206888 Initial import
thib
parents:
diff changeset
1086 status = FINISHED;
223b71206888 Initial import
thib
parents:
diff changeset
1087 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1088
0
223b71206888 Initial import
thib
parents:
diff changeset
1089 bool AnmTime::IsEnd(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1090 return status == FINISHED;
223b71206888 Initial import
thib
parents:
diff changeset
1091 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1092
0
223b71206888 Initial import
thib
parents:
diff changeset
1093 AnmMove::AnmMove(Event::Container& container, PicBase* _pic, const Rect& _to, int total_time) :
223b71206888 Initial import
thib
parents:
diff changeset
1094 AnmTime(container, _pic, total_time),
223b71206888 Initial import
thib
parents:
diff changeset
1095 from(0,0), to(_to) {
223b71206888 Initial import
thib
parents:
diff changeset
1096 from.lx = _pic->PosX();
223b71206888 Initial import
thib
parents:
diff changeset
1097 from.ty = _pic->PosY();
223b71206888 Initial import
thib
parents:
diff changeset
1098 from.rx = from.lx + _pic->Width();
223b71206888 Initial import
thib
parents:
diff changeset
1099 from.by = from.ty + _pic->Height();
223b71206888 Initial import
thib
parents:
diff changeset
1100
223b71206888 Initial import
thib
parents:
diff changeset
1101 int dx = to.lx - from.lx;
223b71206888 Initial import
thib
parents:
diff changeset
1102 int dy = to.ty - from.ty;
223b71206888 Initial import
thib
parents:
diff changeset
1103 if (dx < 0) dx = -dx;
223b71206888 Initial import
thib
parents:
diff changeset
1104 if (dy < 0) dy = -dy;
223b71206888 Initial import
thib
parents:
diff changeset
1105 if (dx < dy) dx = dy;
223b71206888 Initial import
thib
parents:
diff changeset
1106 if (dx == 0) dx = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1107 SetAllCount(dx);
223b71206888 Initial import
thib
parents:
diff changeset
1108 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1109
0
223b71206888 Initial import
thib
parents:
diff changeset
1110 void AnmMove::Exec(int count) {
223b71206888 Initial import
thib
parents:
diff changeset
1111 Rect r(from);
223b71206888 Initial import
thib
parents:
diff changeset
1112 int dx = to.lx - from.lx;
223b71206888 Initial import
thib
parents:
diff changeset
1113 int dy = to.ty - from.ty;
223b71206888 Initial import
thib
parents:
diff changeset
1114 r.rmove(dx*count/all_count, dy*count/all_count);
223b71206888 Initial import
thib
parents:
diff changeset
1115 iterator it;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1116 for (it=pic.begin(); it!=pic.end(); it++)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1117 (*it)->Move(r.lx, r.ty);
0
223b71206888 Initial import
thib
parents:
diff changeset
1118 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1119
0
223b71206888 Initial import
thib
parents:
diff changeset
1120 AnmAlpha::AnmAlpha(Event::Container& container, PicBase* _pic, int alpha_from, int alpha_to, int total_time) :
223b71206888 Initial import
thib
parents:
diff changeset
1121 AnmTime(container, _pic, total_time),
223b71206888 Initial import
thib
parents:
diff changeset
1122 from(alpha_from), to(alpha_to), alpha_r(0,0,1,1) {
223b71206888 Initial import
thib
parents:
diff changeset
1123 if (from < 0) from = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1124 if (from >= ALPHA_MAX) from = ALPHA_MAX;
223b71206888 Initial import
thib
parents:
diff changeset
1125 if (to < 0) to = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1126 if (to >= ALPHA_MAX) to = ALPHA_MAX;
223b71206888 Initial import
thib
parents:
diff changeset
1127 int c = from - to;
223b71206888 Initial import
thib
parents:
diff changeset
1128 if (c < 0) c = -c;
223b71206888 Initial import
thib
parents:
diff changeset
1129 if (c == 0) c = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1130 SetAllCount(c);
223b71206888 Initial import
thib
parents:
diff changeset
1131 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1132
0
223b71206888 Initial import
thib
parents:
diff changeset
1133 AnmAlpha::AnmAlpha(Event::Container& container, std::vector<PicBase*> _pic, int alpha_from, int alpha_to, int total_time) :
223b71206888 Initial import
thib
parents:
diff changeset
1134 AnmTime(container, _pic, total_time),
223b71206888 Initial import
thib
parents:
diff changeset
1135 from(alpha_from), to(alpha_to), alpha_r(0,0,1,1) {
223b71206888 Initial import
thib
parents:
diff changeset
1136 if (from < 0) from = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1137 if (from >= ALPHA_MAX) from = ALPHA_MAX;
223b71206888 Initial import
thib
parents:
diff changeset
1138 if (to < 0) to = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1139 if (to >= ALPHA_MAX) to = ALPHA_MAX;
223b71206888 Initial import
thib
parents:
diff changeset
1140 int c = from - to;
223b71206888 Initial import
thib
parents:
diff changeset
1141 if (c < 0) c = -c;
223b71206888 Initial import
thib
parents:
diff changeset
1142 if (c == 0) c = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1143 SetAllCount(c);
223b71206888 Initial import
thib
parents:
diff changeset
1144 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1145
0
223b71206888 Initial import
thib
parents:
diff changeset
1146 void AnmAlpha::Start(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1147 iterator it;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1148 for (it=pic.begin(); it!=pic.end(); it++)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1149 (*it)->show();
0
223b71206888 Initial import
thib
parents:
diff changeset
1150 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1151
0
223b71206888 Initial import
thib
parents:
diff changeset
1152 void AnmAlpha::Exec(int count) {
223b71206888 Initial import
thib
parents:
diff changeset
1153 alpha = (from * (all_count-count) + (to-from) * count) / all_count;
223b71206888 Initial import
thib
parents:
diff changeset
1154 iterator it;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1155 for (it=pic.begin(); it!=pic.end(); it++)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1156 (*it)->SetSurfaceAlpha(&alpha, alpha_r);
0
223b71206888 Initial import
thib
parents:
diff changeset
1157 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1158
0
223b71206888 Initial import
thib
parents:
diff changeset
1159 void AnmAlpha::Finish(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1160 iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1161 for (it=pic.begin(); it!=pic.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1162 if (to == 0) (*it)->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1163 else if (to != ALPHA_MAX) fprintf(stderr,"Warning in AnmAlpha::Finish: alpha value suddenly changed.\n");
223b71206888 Initial import
thib
parents:
diff changeset
1164 (*it)->SetSurfaceAlpha(0,Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
1165 }
223b71206888 Initial import
thib
parents:
diff changeset
1166 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1167
0
223b71206888 Initial import
thib
parents:
diff changeset
1168 AnmAlphaMove::AnmAlphaMove(Event::Container& container, PicBase* _pic) :
223b71206888 Initial import
thib
parents:
diff changeset
1169 AnmTime(container, _pic, 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1170 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1171
0
223b71206888 Initial import
thib
parents:
diff changeset
1172 void AnmAlphaMove::SetPtn(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1173 int total = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1174 std::vector<Ptn>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1175 for (it=ptns.begin(); it!=ptns.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1176 if (total < it->next_tick) total = it->next_tick;
223b71206888 Initial import
thib
parents:
diff changeset
1177 }
223b71206888 Initial import
thib
parents:
diff changeset
1178 SetAllCount(total);
223b71206888 Initial import
thib
parents:
diff changeset
1179 SetTotalTime(total);
223b71206888 Initial import
thib
parents:
diff changeset
1180 cur_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1181 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1182
0
223b71206888 Initial import
thib
parents:
diff changeset
1183 void AnmAlphaMove::Exec(int count) {
223b71206888 Initial import
thib
parents:
diff changeset
1184 if (ptns.empty()) return;
223b71206888 Initial import
thib
parents:
diff changeset
1185 if (cur_count != 0 && ptns[cur_count].next_tick > count) return;
223b71206888 Initial import
thib
parents:
diff changeset
1186 if (cur_count >= ptns.size()) return;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1187 // 次のパターンを探す
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1188 // count <= it->next_tick なる条件を満たす最後の it を探す
0
223b71206888 Initial import
thib
parents:
diff changeset
1189 std::vector<Ptn>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1190 for (it=ptns.begin()+cur_count; it != ptns.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1191 if (count <= it->next_tick) break;
223b71206888 Initial import
thib
parents:
diff changeset
1192 }
223b71206888 Initial import
thib
parents:
diff changeset
1193 if (it == ptns.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
1194 fprintf(stderr,"end\n");
223b71206888 Initial import
thib
parents:
diff changeset
1195 it = ptns.end() - 1;
223b71206888 Initial import
thib
parents:
diff changeset
1196 }
223b71206888 Initial import
thib
parents:
diff changeset
1197 cur_count = it - ptns.begin();
223b71206888 Initial import
thib
parents:
diff changeset
1198
223b71206888 Initial import
thib
parents:
diff changeset
1199 iterator p;
223b71206888 Initial import
thib
parents:
diff changeset
1200 for (p=pic.begin(); p!=pic.end(); p++) {
223b71206888 Initial import
thib
parents:
diff changeset
1201 // move
223b71206888 Initial import
thib
parents:
diff changeset
1202 (*p)->Move(it->pos.lx, it->pos.ty);
223b71206888 Initial import
thib
parents:
diff changeset
1203 (*p)->SetSurfacePos(it->surface_pos.lx, it->surface_pos.ty);
223b71206888 Initial import
thib
parents:
diff changeset
1204 // alpha set
223b71206888 Initial import
thib
parents:
diff changeset
1205 if (it->alpha == 0) (*p)->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1206 else if (it->alpha == ALPHA_MAX) { (*p)->show(); (*p)->SetSurfaceAlpha(0, Rect(0,0)); }
223b71206888 Initial import
thib
parents:
diff changeset
1207 else { (*p)->show(); (*p)->SetSurfaceAlpha( &(it->alpha), Rect(0,0,1,1)); }
223b71206888 Initial import
thib
parents:
diff changeset
1208 }
223b71206888 Initial import
thib
parents:
diff changeset
1209 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1210
0
223b71206888 Initial import
thib
parents:
diff changeset
1211 void AnmAlphaMove::Finish(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1212 if (ptns.empty()) return;
223b71206888 Initial import
thib
parents:
diff changeset
1213 if (cur_count >= ptns.size() - 1) return;
223b71206888 Initial import
thib
parents:
diff changeset
1214 cur_count = ptns.size() - 1;
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1215 Exec(ptns[cur_count].next_tick); // 最後の pattern の状態にする
0
223b71206888 Initial import
thib
parents:
diff changeset
1216 }
223b71206888 Initial import
thib
parents:
diff changeset
1217
223b71206888 Initial import
thib
parents:
diff changeset
1218 AnmPtnSolid::AnmPtnSolid(Event::Container& container, PicBase* _pic, const unsigned char* _ptn, const Rect& _alpha_r, int total_time) :
223b71206888 Initial import
thib
parents:
diff changeset
1219 AnmTime(container, _pic, total_time),
223b71206888 Initial import
thib
parents:
diff changeset
1220 ptn(_ptn), alpha_r(_alpha_r)
223b71206888 Initial import
thib
parents:
diff changeset
1221 {
223b71206888 Initial import
thib
parents:
diff changeset
1222 ptn_len = alpha_r.width() * alpha_r.height();
223b71206888 Initial import
thib
parents:
diff changeset
1223 alpha = new unsigned char[ptn_len];
223b71206888 Initial import
thib
parents:
diff changeset
1224 int max_a = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1225 for (int i=0; i<ptn_len; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1226 if (ptn[i] > max_a) max_a = ptn[i];
223b71206888 Initial import
thib
parents:
diff changeset
1227 }
223b71206888 Initial import
thib
parents:
diff changeset
1228 if (max_a == 0) max_a = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1229 SetAllCount(max_a);
223b71206888 Initial import
thib
parents:
diff changeset
1230 }
223b71206888 Initial import
thib
parents:
diff changeset
1231
223b71206888 Initial import
thib
parents:
diff changeset
1232 AnmPtnAlpha::AnmPtnAlpha(Event::Container& container, PicBase* _pic, const unsigned char* _ptn, const Rect& _alpha_r, int _band_width, int total_time) :
223b71206888 Initial import
thib
parents:
diff changeset
1233 AnmTime(container, _pic, total_time),
223b71206888 Initial import
thib
parents:
diff changeset
1234 ptn(_ptn), band(_band_width), alpha_r(_alpha_r)
223b71206888 Initial import
thib
parents:
diff changeset
1235 {
223b71206888 Initial import
thib
parents:
diff changeset
1236 ptn_len = alpha_r.width() * alpha_r.height();
223b71206888 Initial import
thib
parents:
diff changeset
1237 alpha = new unsigned char[ptn_len];
223b71206888 Initial import
thib
parents:
diff changeset
1238 if (band <= 0) band = 1;
223b71206888 Initial import
thib
parents:
diff changeset
1239 SetAllCount(ALPHA_MAX+band);
223b71206888 Initial import
thib
parents:
diff changeset
1240 }
223b71206888 Initial import
thib
parents:
diff changeset
1241
223b71206888 Initial import
thib
parents:
diff changeset
1242 void AnmPtnSolid::Exec(int count) {
223b71206888 Initial import
thib
parents:
diff changeset
1243 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1244 for (i=0; i<ptn_len; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1245 if (ptn[i] <= count) alpha[i] = ALPHA_MAX;
223b71206888 Initial import
thib
parents:
diff changeset
1246 else alpha[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1247 }
223b71206888 Initial import
thib
parents:
diff changeset
1248 iterator it;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1249 for (it=pic.begin(); it!=pic.end(); it++)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1250 (*it)->SetSurfaceAlpha(alpha, alpha_r);
0
223b71206888 Initial import
thib
parents:
diff changeset
1251 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1252
0
223b71206888 Initial import
thib
parents:
diff changeset
1253 void AnmPtnAlpha::Exec(int count) {
223b71206888 Initial import
thib
parents:
diff changeset
1254 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1255 int ptn_zero = count;
223b71206888 Initial import
thib
parents:
diff changeset
1256 int ptn_max = count - band;
223b71206888 Initial import
thib
parents:
diff changeset
1257 for (i=0; i<ptn_len; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1258 if (ptn[i] >= ptn_zero) alpha[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1259 else if (ptn[i] < ptn_max) alpha[i] = ALPHA_MAX;
223b71206888 Initial import
thib
parents:
diff changeset
1260 else alpha[i] = (ptn_zero-ptn[i])*ALPHA_MAX/band;
223b71206888 Initial import
thib
parents:
diff changeset
1261 }
223b71206888 Initial import
thib
parents:
diff changeset
1262 iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1263 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(alpha, alpha_r);
223b71206888 Initial import
thib
parents:
diff changeset
1264 }
223b71206888 Initial import
thib
parents:
diff changeset
1265
223b71206888 Initial import
thib
parents:
diff changeset
1266 void AnmPtnSolid::Start(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1267 iterator it;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1268 for (it=pic.begin(); it!=pic.end(); it++)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1269 (*it)->show();
0
223b71206888 Initial import
thib
parents:
diff changeset
1270 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1271
0
223b71206888 Initial import
thib
parents:
diff changeset
1272 void AnmPtnSolid::Finish(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1273 iterator it;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1274 for (it=pic.begin(); it!=pic.end(); it++)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1275 (*it)->SetSurfaceAlpha(0, Rect(0,0));
0
223b71206888 Initial import
thib
parents:
diff changeset
1276 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1277
0
223b71206888 Initial import
thib
parents:
diff changeset
1278 void AnmPtnAlpha::Start(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1279 iterator it;
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1280 for (it=pic.begin(); it!=pic.end(); it++)
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1281 (*it)->show();
0
223b71206888 Initial import
thib
parents:
diff changeset
1282 }
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
1283
0
223b71206888 Initial import
thib
parents:
diff changeset
1284 void AnmPtnAlpha::Finish(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1285 iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1286 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(0, Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
1287 }
223b71206888 Initial import
thib
parents:
diff changeset
1288
223b71206888 Initial import
thib
parents:
diff changeset
1289 /*
223b71206888 Initial import
thib
parents:
diff changeset
1290
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1291 Widget の種類
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1292 Mouse: マウス位置に連動する。Surface と origin が必須
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1293 Panel : なにも存在しないところに張りつけていく
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1294 背景張りつけも可能
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1295 ButtonPanel : 無効化可能。Group の Button がカーソルに入ったら、全Button / Label が「カーソル下」状態になる
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1296 同一変数を扱うボタンは原則、同一ButtonPanel の下に入ること(同期する。高速化可能)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1297 そうでない場合、ボタンの GlobalVariable フラグを立てる必要がある
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1298 背景種類:Window
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1299 内部の透明度と枠形を別々に指定可能。枠形は全枠、部分枠どちらの形でも可能
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1300 (部分枠なら、内部的には上枠、下枠、左右枠と別 Surface で管理する)
0
223b71206888 Initial import
thib
parents:
diff changeset
1301 DragButton
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1302 Panel 全体をドラッグし、場所変更できるボタン。
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1303 Button: 無効化>通常>カーソル下>ボタン押下 のpicture / animation
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1304 Toggle Button にできる(Group化すればRadioButtonにもできる)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1305 Label : 無効化>通常>カーソル下 のanimation
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1306 animation は
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1307 ・上への変化
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1308 ・下への変化
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1309 ・常時変形
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1310 の3つの形式をもつ。
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1311 形式は
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1312 ・x / y increment による(全領域と x,y の大きさを指定すると左上から右上、左下、という方へ勝手に領域を変更していく)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1313 ・色変化(明度変化)。色テーブルを指定する。Surface は alpha のみとする
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1314 どちらも、一つのラベルに使う時間の長さを指定する
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1315 ・callback による。指定した一定時間以上が立つとCallBack が呼び出され、新たなSurface , origin を指定する。
0
223b71206888 Initial import
thib
parents:
diff changeset
1316
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1317 ・Surface は
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1318 普通の画像
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1319 文字列(適当に仮想化)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1320 画像数値列
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1321 のいずれか
0
223b71206888 Initial import
thib
parents:
diff changeset
1322 Cursor
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1323 リターンカーソル。Label の一種。
0
223b71206888 Initial import
thib
parents:
diff changeset
1324 Number
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1325 数字を表示する。フォントの大きさ、もしくは画像数値列
0
223b71206888 Initial import
thib
parents:
diff changeset
1326 Text
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1327 テキストを表示する
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1328 パネルの大きさだけ指定すると適当にやってくれる
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1329 カーソルの位置(文字の次/最終)を指定すること
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1330 機能:文字送り速度設定、読み飛ばし設定(常に最高速で押しっぱなし)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1331 ProgressBar など
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1332 バーの長さ、あるいは位置で変数の大きさを示す。
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1333 Tick, Max を指定、変数の変化には適当に対応できるようにする
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1334 バーの方向として縦/横。Surface は繰り返しで使う(速度上、32pixel くらいあったほうがいいかも?)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1335 バーの代わりにボタンも使える。Surface 指定のメソッドが違うだけ。
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1336 オプション:バーのどこかをクリックされたとき、そこに移動するかそこに向かって移動するか
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1337 オプション?:矢印ボタン(いらないか)
0
223b71206888 Initial import
thib
parents:
diff changeset
1338 ScrollBar
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1339 横/縦。Panel と連動する(専用, ProgressBar の一種として実装)
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1340 (Panel 側で「見えない部分はdelete, 見える部分は自動で作成」機能をつける?:バックログ)
0
223b71206888 Initial import
thib
parents:
diff changeset
1341
223b71206888 Initial import
thib
parents:
diff changeset
1342
223b71206888 Initial import
thib
parents:
diff changeset
1343
65
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1344 メニューの出し方
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1345 右クリック
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1346 ボタンを押す
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1347 上の方、右の方など領域に行くとヌっと出てくる
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1348 メニューモード内
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1349 ボタンを押して終了
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1350 マップを作っておき、各メニューに名前を割り振ると二次元に広がったメニューになる
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1351 名前を割り振ると上に名前リストがでてくる
4416cfac86ae Convert EUC-JP files to UTF8
Thibaut Girka <thib@sitedethib.com>
parents: 53
diff changeset
1352 名前を割り振ると横に名前リストが出てくる
0
223b71206888 Initial import
thib
parents:
diff changeset
1353
223b71206888 Initial import
thib
parents:
diff changeset
1354 */
223b71206888 Initial import
thib
parents:
diff changeset
1355 // }