Changeset 33
- Timestamp:
- 12/04/06 02:17:31 (2 years ago)
- Files:
-
- trunk/luigi/adapter.d (modified) (1 diff)
- trunk/luigi/adapters/gld.d (modified) (2 diffs)
- trunk/luigi/adapters/glfw.d (modified) (3 diffs)
- trunk/luigi/adapters/sdl.d (added)
- trunk/luigi/all.d (added)
- trunk/luigi/doc.brf (added)
- trunk/luigi/event.d (modified) (3 diffs)
- trunk/luigi/example1_gld.brf (modified) (1 diff)
- trunk/luigi/example1_sdl.brf (added)
- trunk/luigi/example1_sdl.d (added)
- trunk/luigi/gldraw.d (modified) (4 diffs)
- trunk/luigi/gui.d (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/luigi/adapter.d
r32 r33 135 135 void addWindowSizeCallback(WindowSizeEventDg cb) {_lsig.windowSize.connect(cb);} 136 136 void addWindowCloseCallback(WindowCloseEventDg cb) {_lsig.windowClose.connect(cb);} 137 138 137 } 139 138 trunk/luigi/adapters/gld.d
r29 r33 87 87 case GLD_KEY_HOME: return Key.Home; 88 88 case GLD_KEY_END: return Key.End; 89 case GLD_KEY_KP_0: return Key.KP _0;90 case GLD_KEY_KP_1: return Key.KP _1;91 case GLD_KEY_KP_2: return Key.KP _2;92 case GLD_KEY_KP_3: return Key.KP _3;93 case GLD_KEY_KP_4: return Key.KP _4;94 case GLD_KEY_KP_5: return Key.KP _5;95 case GLD_KEY_KP_6: return Key.KP _6;96 case GLD_KEY_KP_7: return Key.KP _7;97 case GLD_KEY_KP_8: return Key.KP _8;98 case GLD_KEY_KP_9: return Key.KP _9;89 case GLD_KEY_KP_0: return Key.KP0; 90 case GLD_KEY_KP_1: return Key.KP1; 91 case GLD_KEY_KP_2: return Key.KP2; 92 case GLD_KEY_KP_3: return Key.KP3; 93 case GLD_KEY_KP_4: return Key.KP4; 94 case GLD_KEY_KP_5: return Key.KP5; 95 case GLD_KEY_KP_6: return Key.KP6; 96 case GLD_KEY_KP_7: return Key.KP7; 97 case GLD_KEY_KP_8: return Key.KP8; 98 case GLD_KEY_KP_9: return Key.KP9; 99 99 case GLD_KEY_KP_DIVIDE: return Key.KP_Divide; 100 100 case GLD_KEY_KP_MULTIPLY: return Key.KP_Multiply; … … 102 102 case GLD_KEY_KP_ADD: return Key.KP_Add; 103 103 case GLD_KEY_KP_DECIMAL: return Key.KP_Decimal; 104 case GLD_KEY_KP_EQUAL: return Key.KP_Equal ;104 case GLD_KEY_KP_EQUAL: return Key.KP_Equals; 105 105 case GLD_KEY_KP_ENTER: return Key.KP_Enter; 106 106 default: trunk/luigi/adapters/glfw.d
r29 r33 32 32 import luigi.adapter; 33 33 import derelict.glfw.glfw; 34 //import sslot.signal;35 34 import luigi.signalobj; 36 35 … … 87 86 case GLFW_KEY_HOME: return Key.Home; 88 87 case GLFW_KEY_END: return Key.End; 89 case GLFW_KEY_KP_0: return Key.KP _0;90 case GLFW_KEY_KP_1: return Key.KP _1;91 case GLFW_KEY_KP_2: return Key.KP _2;92 case GLFW_KEY_KP_3: return Key.KP _3;93 case GLFW_KEY_KP_4: return Key.KP _4;94 case GLFW_KEY_KP_5: return Key.KP _5;95 case GLFW_KEY_KP_6: return Key.KP _6;96 case GLFW_KEY_KP_7: return Key.KP _7;97 case GLFW_KEY_KP_8: return Key.KP _8;98 case GLFW_KEY_KP_9: return Key.KP _9;88 case GLFW_KEY_KP_0: return Key.KP0; 89 case GLFW_KEY_KP_1: return Key.KP1; 90 case GLFW_KEY_KP_2: return Key.KP2; 91 case GLFW_KEY_KP_3: return Key.KP3; 92 case GLFW_KEY_KP_4: return Key.KP4; 93 case GLFW_KEY_KP_5: return Key.KP5; 94 case GLFW_KEY_KP_6: return Key.KP6; 95 case GLFW_KEY_KP_7: return Key.KP7; 96 case GLFW_KEY_KP_8: return Key.KP8; 97 case GLFW_KEY_KP_9: return Key.KP9; 99 98 case GLFW_KEY_KP_DIVIDE: return Key.KP_Divide; 100 99 case GLFW_KEY_KP_MULTIPLY: return Key.KP_Multiply; … … 102 101 case GLFW_KEY_KP_ADD: return Key.KP_Add; 103 102 case GLFW_KEY_KP_DECIMAL: return Key.KP_Decimal; 104 case GLFW_KEY_KP_EQUAL: return Key.KP_Equal ;103 case GLFW_KEY_KP_EQUAL: return Key.KP_Equals; 105 104 case GLFW_KEY_KP_ENTER: return Key.KP_Enter; 106 105 default: trunk/luigi/event.d
r17 r33 123 123 LAlt, Alt = LAlt, 124 124 RAlt, 125 LMeta, 126 RMeta, 127 LSuper, 128 RSuper, 129 Mode, 130 Compose, 125 131 Tab, 126 132 Enter, … … 132 138 Home, 133 139 End, 134 KP _0,135 KP _1,136 KP _2,137 KP _3,138 KP _4,139 KP _5,140 KP _6,141 KP _7,142 KP _8,143 KP _9,140 KP0, 141 KP1, 142 KP2, 143 KP3, 144 KP4, 145 KP5, 146 KP6, 147 KP7, 148 KP8, 149 KP9, 144 150 KP_Divide, 145 151 KP_Multiply, … … 147 153 KP_Add, 148 154 KP_Decimal, 149 KP_Equal ,155 KP_Equals, 150 156 KP_Enter, 157 158 NumLock, 159 CapsLock, 160 ScrollLock, 161 162 Help, 163 Print, 164 SysReq, 165 Break, 166 Menu, 167 Power, 168 Euro, 169 Undo, 151 170 } 152 171 trunk/luigi/example1_gld.brf
r18 r33 3 3 -I$(DMDDIR)\baxissimo 4 4 -I$(DMDDIR)\ext 5 6 5 -version=useDerelict 7 6 -full trunk/luigi/gldraw.d
r15 r33 365 365 } 366 366 367 void checkGLErrors(char[] file = null, int line = 0) 368 { 369 GLenum err; 370 while ( (err=glGetError()) != GL_NO_ERROR) 371 { 372 char[] errstr; 373 if (file) errstr = std.string.format("OpenGL error: %s(%s): ", file, line); 374 switch(err) { 375 case GL_INVALID_ENUM: 376 // An unacceptable value is specified for an enumerated 377 // argument. The offending command is ignored, having no 378 // side effect other than to set the error flag. 379 errstr ~= "Invalid enum"; 380 break; 381 case GL_INVALID_VALUE: 382 //A numeric argument is out of range. The offending command is 383 //ignored, having no side effect other than to set the error 384 //flag. 385 errstr ~= "Invalid value"; 386 break; 387 case GL_INVALID_OPERATION: 388 //The specified operation is not allowed in the current 389 //state. The offending command is ignored, having no side 390 //effect other than to set the error flag. 391 errstr ~= "Invalid operation"; 392 break; 393 394 case GL_STACK_OVERFLOW: 395 // This command would cause a stack overflow. The 396 // offending command is ignored, having no side effect 397 // other than to set the error flag. 398 errstr ~= "Stack overflow"; 399 break; 400 401 case GL_STACK_UNDERFLOW: 402 // This command would cause a stack underflow. The 403 // offending command is ignored, having no side effect 404 // other than to set the error flag. 405 errstr ~= "Stack underflow"; 406 break; 407 408 case GL_OUT_OF_MEMORY: 409 // There is not enough memory left to execute the 410 // command. The state of the GL is undefined, except for 411 // the state of the error flags, after this error is 412 // recorded. 413 errstr ~= "Out of memory"; 414 break; 415 default: 416 errstr ~= std.string.format("Unknown error code: %s", err); 417 } 418 writefln(errstr); 419 } 420 } 421 422 367 423 //---------------------------------------------------------------------------- 368 424 void push_graphics_state(Rect viewport) { … … 374 430 ); 375 431 glDisable(GL_DEPTH_TEST); 432 glDisable(GL_LIGHTING); 433 glDisable(GL_CULL_FACE); 434 glDisable(GL_TEXTURE_2D); 376 435 glEnable(GL_BLEND); 436 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 437 377 438 glViewport(0,0,lrint(viewport.w),lrint(viewport.h)); 378 439 glMatrixMode(GL_PROJECTION); 440 glPushMatrix(); 379 441 glLoadIdentity(); 380 442 // Note! We put the origin at top left to match window sys conventions … … 383 445 -1,1); 384 446 glMatrixMode(GL_MODELVIEW); 447 glPushMatrix(); 385 448 glLoadIdentity(); 386 449 } … … 393 456 glPopMatrix(); 394 457 // TODO restore viewport? 395 } 458 version(Debug) { 459 checkGLErrors(__FILE__,__LINE__); 460 } 461 } trunk/luigi/gui.d
r32 r33 443 443 } 444 444 445 /** Sets the keyboard focus of this widget's hierarchy to newfocus. 446 * If newfocus is null any current focus item in this widget tree 447 * will be unfocused. 448 */ 449 bool set_focus(Widget newfocus) 450 in { get_root()._focus_sanity_check(); } body 451 { 452 if (newfocus) { 453 if (!newfocus.focusable) return false; 454 if (newfocus.m_focused) return true; 455 } 456 457 // unfocus the current guy first 458 Widget oldFocus = get_focus(); 459 if (oldFocus && !oldFocus._can_lose_focus()) { 460 return false; 461 } 462 else if (oldFocus) { 463 oldFocus._unfocus_rup(); 464 } 465 466 // Stop here if there's no new focus item 467 if (!newfocus) return true; 468 469 // now give focus to the new guy. 470 // Set his m_focused flag and percolate m_childFocused flags up the chain. 471 _FocusEvent ev; 472 ev.previous = oldFocus; 473 newfocus.on_focus(&ev); 474 if (!ev.alive) { 475 newfocus.m_focused = true; 476 if (newfocus.parent) newfocus.parent._set_child_focused_rup(); 477 } 478 return newfocus.m_focused; 479 } 480 481 445 482 /** Set the keyboard focus to this item. 446 483 Returns true if successful, false otherwise. … … 449 486 in { get_root()._focus_sanity_check(); } body 450 487 { 451 if (!focusable) return false; 452 if (m_focused) return true; 453 454 // unfocus the current guy first 455 Widget oldFocus = get_focus(); 456 if (oldFocus && !oldFocus._can_lose_focus()) { 457 return false; 458 } 459 else if (oldFocus) { 460 oldFocus._unfocus_rup(); 461 } 462 463 // now focus this guy. 464 // Set his m_focused flag and percolate m_childFocused flags up the chain. 465 _FocusEvent ev; 466 ev.previous = oldFocus; 467 this.on_focus(&ev); 468 if (!ev.alive) { 469 m_focused = true; 470 if (parent) parent._set_child_focused_rup(); 471 } 472 return m_focused; 488 return set_focus(this); 473 489 } 474 490 … … 1049 1065 1050 1066 /** Constructor. Not every toolkit supports multiple windows (e.g. GLFW,SDL). 1051 If yours doesn't then you won't need the parameter.1067 If yours doesn't then you may not need the parameter. 1052 1068 */ 1053 1069 this(WindowHandle win = null) { … … 1055 1071 hostwin = win; 1056 1072 Size sz = Luigi().get_window_size(win); 1073 writefln("Window size = ", sz); 1057 1074 set_rect(Rect(0,0,sz.w,sz.h)); 1058 1075 Luigi().add_overlay(this); … … 1067 1084 } 1068 1085 1086 /** Return the input adapter in current use. Equivalent to Luigi().adapter. */ 1087 InputAdapter adapter() { 1088 return Luigi().adapter; 1089 } 1090 1069 1091 protected: 1070 1092 override bool _set_mouse_grabber(Widget w) … … 1096 1118 if (focus) { 1097 1119 Luigi().theme.on_key(focus,ev); 1120 } else { 1121 ev.alive = true; 1098 1122 } 1099 1123 if ((!focus || ev.alive) && ev.is_press) … … 1102 1126 // (and also sys hotkeys? Ctrl-X etc) 1103 1127 1104 if (ev.key==Key.Tab) { 1128 if (ev.key==Key.Escape && focus && ev.alive) { 1129 // Lose gui focus 1130 set_focus(null); 1131 ev.alive = false; 1132 } 1133 else if (ev.key==Key.Tab) 1134 { 1105 1135 if (ev.mods == KeyMods.None) { 1106 1136 focus_next(); 1137 ev.alive = false; 1107 1138 } 1108 1139 else if (ev.mods == KeyMods.Shift) { 1109 1140 focus_prev(); 1141 ev.alive = false; 1110 1142 } 1111 1143 } 1144 } 1145 else if (!focus) { 1146 ev.alive = true; 1112 1147 } 1113 1148 } … … 1126 1161 _xform_event_to_widget(target, ev); 1127 1162 Luigi().theme.on_mouse_button(target, ev); 1163 } 1164 else { 1165 ev.alive = true; 1128 1166 } 1129 1167 } … … 1179 1217 } 1180 1218 1181 1219 1182 1220 1183 1221 private: … … 1321 1359 } 1322 1360 } 1361 1362 /// An alternate spelling for Checkbox, because I can never remember which it is. 1363 alias Checkbox CheckBox; 1323 1364 1324 1365 class TextField : Widget … … 1532 1573 } 1533 1574 1575 /// An alternate spelling for TextField, because I can never remember which it is. 1576 alias TextField Textfield; 1577 1534 1578 /** 1535 1579 * Slider represents a floating point value. Since it uses a double for
