Mercurial > otakunoraifu
comparison window/event.cc @ 65:4416cfac86ae
Convert EUC-JP files to UTF8
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Fri, 26 Nov 2010 10:53:15 +0100 |
parents | 15a18fbe6f21 |
children |
comparison
equal
deleted
inserted
replaced
64:045ca45f9610 | 65:4416cfac86ae |
---|---|
33 #include <iostream> | 33 #include <iostream> |
34 #include <sys/stat.h> | 34 #include <sys/stat.h> |
35 | 35 |
36 using namespace std; | 36 using namespace std; |
37 | 37 |
38 bool save_req = false, load_req = false, grpdump_req = false; // scn2k/scn2k_impl.cc: キーボードからセーブ・ロードできるように | 38 bool save_req = false, load_req = false, grpdump_req = false; // scn2k/scn2k_impl.cc: 若若祉若祉若с |
39 bool pressAreq=false,pressFreq=false,pressDreq=false; | 39 bool pressAreq=false,pressFreq=false,pressDreq=false; |
40 namespace Event { | 40 namespace Event { |
41 /* Impl: struct Event::Video */ | 41 /* Impl: struct Event::Video */ |
42 | 42 |
43 Video::Video(Container& container) : region(0, 0, 0, 0), z(0), parent(container) { | 43 Video::Video(Container& container) : region(0, 0, 0, 0), z(0), parent(container) { |
71 if (!activated) return -1; | 71 if (!activated) return -1; |
72 if (region.point_in(x,y)) return z; | 72 if (region.point_in(x,y)) return z; |
73 else return -1; | 73 else return -1; |
74 } | 74 } |
75 | 75 |
76 /* カーソルの動く順序:上、左の順に準位付け */ | 76 /* 若純綺鐚筝綏羣篏篁 */ |
77 bool operator <(const Video& pos1, const Video& pos2) { | 77 bool operator <(const Video& pos1, const Video& pos2) { |
78 if (pos1.region.ty < pos2.region.ty) return true; | 78 if (pos1.region.ty < pos2.region.ty) return true; |
79 if (pos1.region.ty == pos2.region.ty) return pos1.region.lx < pos2.region.lx; | 79 if (pos1.region.ty == pos2.region.ty) return pos1.region.lx < pos2.region.lx; |
80 if (pos1.region.by >= pos2.region.by) return pos1.region.lx <= pos2.region.lx; | 80 if (pos1.region.by >= pos2.region.by) return pos1.region.lx <= pos2.region.lx; |
81 return false; | 81 return false; |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 bool ContainerImplTime::Exec(unsigned int current_time) { | 143 bool ContainerImplTime::Exec(unsigned int current_time) { |
144 if (current_time == Time::NEVER_WAKE) return true; | 144 if (current_time == Time::NEVER_WAKE) return true; |
145 // 呼び出しまでに作製されたitemを追加 | 145 // 若喝冴障с篏茖純item菴遵 |
146 insert(end(), new_item.begin(), new_item.end()); | 146 insert(end(), new_item.begin(), new_item.end()); |
147 new_item.clear(); | 147 new_item.clear(); |
148 if (empty()) return true; | 148 if (empty()) return true; |
149 if (current_time == Time::FRAME_UPDATE) { // ビデオフレームの更新時 | 149 if (current_time == Time::FRAME_UPDATE) { // 若贋井 |
150 for (iterator it = begin(); it != end(); it++) { | 150 for (iterator it = begin(); it != end(); it++) { |
151 if (! it->valid) continue; | 151 if (! it->valid) continue; |
152 | 152 |
153 unsigned tm = it->instance->Wakeup(); | 153 unsigned tm = it->instance->Wakeup(); |
154 if (tm == Time::FRAME_UPDATE) { | 154 if (tm == Time::FRAME_UPDATE) { |
155 it->instance->Elapsed(prev_execed_time); | 155 it->instance->Elapsed(prev_execed_time); |
156 } | 156 } |
157 } | 157 } |
158 } else { // 時間変化時 | 158 } else { // 紊 |
159 if (current_time < prev_execed_time) prev_execed_time = 0; /* 時間が一回りして0に戻ったとき */ | 159 if (current_time < prev_execed_time) prev_execed_time = 0; /* 筝鐚祉c */ |
160 for (iterator it = begin(); it != end(); it++) { | 160 for (iterator it = begin(); it != end(); it++) { |
161 if (! it->valid) continue; | 161 if (! it->valid) continue; |
162 unsigned tm = it->instance->Wakeup(); | 162 unsigned tm = it->instance->Wakeup(); |
163 if (tm >= prev_execed_time && tm < current_time) { | 163 if (tm >= prev_execed_time && tm < current_time) { |
164 it->instance->Elapsed(current_time); | 164 it->instance->Elapsed(current_time); |
165 } | 165 } |
166 } | 166 } |
167 prev_execed_time = current_time; | 167 prev_execed_time = current_time; |
168 } | 168 } |
169 // 処理中に削除された item を実際に削除 | 169 // 筝ゃ item 絎 |
170 erase(remove_if(begin(), end(), is_invalid), end()); | 170 erase(remove_if(begin(), end(), is_invalid), end()); |
171 return true; | 171 return true; |
172 } | 172 } |
173 | 173 |
174 | 174 |
207 void Sort(void); | 207 void Sort(void); |
208 void Motion(int x, int y); // mouse motion | 208 void Motion(int x, int y); // mouse motion |
209 void Press(void); | 209 void Press(void); |
210 void TakeScreenshot(void); | 210 void TakeScreenshot(void); |
211 iterator cur_pos; | 211 iterator cur_pos; |
212 Video* cur_item; // 現在のフォーカス位置 | 212 Video* cur_item; // 憜若剛臀 |
213 int cur_pressed_x, cur_pressed_y; | 213 int cur_pressed_x, cur_pressed_y; |
214 }; | 214 }; |
215 | 215 |
216 void ContainerImplVideo::SetChanged(void) { | 216 void ContainerImplVideo::SetChanged(void) { |
217 if (is_sorted) { | 217 if (is_sorted) { |
317 if (!(*mit->func)(x, y, mit->pointer)) motion_vec.erase(mit); | 317 if (!(*mit->func)(x, y, mit->pointer)) motion_vec.erase(mit); |
318 mit = mit_next; | 318 mit = mit_next; |
319 | 319 |
320 } | 320 } |
321 | 321 |
322 /* @@@ ドラッグ処理とマウスを押す処理のバッティングで「二回ボタンを押さないと云々」関連のバグの可能性あり */ | 322 /* @@@ 医鴻若c潟違с篋帥潟若篋∫c違醇с */ |
323 if (button_pressed & (1<<MOUSE_LEFT)) { | 323 if (button_pressed & (1<<MOUSE_LEFT)) { |
324 if (cur_item) cur_item->Drag(cur_pressed_x, cur_pressed_y, x, y); | 324 if (cur_item) cur_item->Drag(cur_pressed_x, cur_pressed_y, x, y); |
325 return; | 325 return; |
326 } | 326 } |
327 if (cur_item != NULL) cur_item->Motion(x,y); | 327 if (cur_item != NULL) cur_item->Motion(x,y); |
384 int motion_x = 0, motion_y = 0; | 384 int motion_x = 0, motion_y = 0; |
385 SDL_Event event; | 385 SDL_Event event; |
386 SDL_PumpEvents(); | 386 SDL_PumpEvents(); |
387 while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_ALLEVENTS) == 1) { | 387 while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_ALLEVENTS) == 1) { |
388 switch(event.type) { | 388 switch(event.type) { |
389 case SDL_QUIT: return false; // @@@ なにかやらないと | 389 case SDL_QUIT: return false; // @@@ |
390 case SDL_ACTIVEEVENT: // なにもしない | 390 case SDL_ACTIVEEVENT: // |
391 // cout<<"active : gain "<<int(event.active.gain)<<", state "<<int(event.active.state)<<endl; | 391 // cout<<"active : gain "<<int(event.active.gain)<<", state "<<int(event.active.state)<<endl; |
392 break; | 392 break; |
393 case SDL_KEYDOWN: | 393 case SDL_KEYDOWN: |
394 if (!is_sorted) Sort(); | 394 if (!is_sorted) Sort(); |
395 switch(event.key.keysym.sym) { | 395 switch(event.key.keysym.sym) { |
493 case 5: button_pressed |= (1<<MOUSE_DOWN); break; | 493 case 5: button_pressed |= (1<<MOUSE_DOWN); break; |
494 } | 494 } |
495 // cout << "mouse which "<<int(event.button.which)<<"button "<<int(event.button.button)<< | 495 // cout << "mouse which "<<int(event.button.which)<<"button "<<int(event.button.button)<< |
496 // "state "<<int(event.button.state)<<"x "<<event.button.x << "y "<<event.button.y<<endl; | 496 // "state "<<int(event.button.state)<<"x "<<event.button.x << "y "<<event.button.y<<endl; |
497 break; | 497 break; |
498 case SDL_VIDEOEXPOSE: // redraw の必要がある? | 498 case SDL_VIDEOEXPOSE: // redraw 綽荀鐚 |
499 // cout<<"expose."<<endl; | 499 // cout<<"expose."<<endl; |
500 break; | 500 break; |
501 } | 501 } |
502 } | 502 } |
503 // Motion 呼び出しは一回だけ | 503 // Motion 若喝冴筝 |
504 if (is_mouse_motion) | 504 if (is_mouse_motion) |
505 Motion(motion_x, motion_y); | 505 Motion(motion_x, motion_y); |
506 return true; | 506 return true; |
507 } | 507 } |
508 | 508 |
593 return count; | 593 return count; |
594 } | 594 } |
595 | 595 |
596 } /* end of namespace Container */ | 596 } /* end of namespace Container */ |
597 | 597 |
598 // 問題: | 598 // 馹鐚 |
599 // z 軸と xy 軸の相互干渉;高速化 | 599 // z 荵吾 xy 荵吾娯綛我鐚蕭 |
600 // 移動するウィジット描画の高速化 | 600 // 腱糸c吾祉蕭 |
601 // キャッシュ | 601 // c激 |
602 // 文字列の一部のみ更新の高速化 | 602 // 絖筝炊贋違蕭 |
603 // 「階層 z で x なる領域無効化、y なる領域生成」で良い?>Expose | 603 // 絮 z x ≦劫y ц鐚鐚Expose |