Changeset 10
- Timestamp:
- 11/23/06 21:25:48 (2 years ago)
- Files:
-
- trunk/luigi/arranger.d (modified) (1 diff)
- trunk/luigi/bitmaps.d (modified) (1 diff)
- trunk/luigi/example1.brf (modified) (1 diff)
- trunk/luigi/example1.d (modified) (2 diffs)
- trunk/luigi/gldraw.d (modified) (3 diffs)
- trunk/luigi/gui.d (modified) (6 diffs)
- trunk/luigi/theme.d (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/luigi/arranger.d
r7 r10 65 65 Size preferred_size(Size bounds); 66 66 67 /** Return stretch factor in x and y directions. 68 * If component is fixed size, then should be 0. 69 * If nonzero then all nonzero elements share the 70 * available space in proportion with their stretch 71 * factors. So a stretch=2 gets twice as much 72 * space as a stretch=1. 73 */ 74 int stretch_x(); 75 int stretch_y(); 76 67 77 void set_rect(Rect s); 68 void set_position(Point p); 78 void set_position(Point p); 69 79 void set_size(Size sz); 70 80 trunk/luigi/bitmaps.d
r7 r10 197 197 }; 198 198 199 Orion Sky Lawlor, olawlor@acm.org, 2006/05/04 (LGPL) 199 Orion Sky Lawlor, olawlor@acm.org 200 @ This stuff was orignally in C++ and labelled LGPL, but Bill Baxter 201 @ got Lawlor's permission to make it ZLIB via email on Aug 13, 2006 200 202 */ 201 203 trunk/luigi/example1.brf
r5 r10 1 # Damn, envvars like %DMDDIR% don't work2 1 -g 3 2 -debug 4 -I ..\..\baxissimo5 -I ..\..\ext3 -I$(DMDDIR)\baxissimo 4 -I$(DMDDIR)\ext 6 5 -full 7 6 -cleanup trunk/luigi/example1.d
r7 r10 60 60 class CoolTarget(T...) 61 61 { 62 this( void delegate(T ...) dg) { fn = dg; }62 this( void delegate(T) dg) { fn = dg; } 63 63 void slot(T args) { 64 64 fn(args); 65 65 } 66 void delegate(T ...) fn;66 void delegate(T) fn; 67 67 } 68 68 class BDelegate … … 194 194 Button b28 = arranged( g.add_widget(new Button("Tool8"))); 195 195 Button b29 = arranged( g.add_widget(new Button("Tool9"))); 196 Slider s01 = arranged( g.add_widget(new Slider("Thingy"))); 197 auto T = new CoolTarget!(double)((double d){ writefln("Slider now %s",d); } ); 198 s01.value_changed.fconnect!(typeof(&T.slot),1)(&T.slot); 196 199 } 197 200 trunk/luigi/gldraw.d
r7 r10 246 246 { 247 247 r.inset(0.5); 248 float x = r.x; 249 float y = r.y; 250 float x2 = r.x2; 251 float y2 = r.y2; 252 253 translate(0.5,0.5); scope(exit) untranslate(0.5,0.5); 254 glColor4ubv( bkg.ptr ); 255 glBegin( GL_LINE_LOOP ); 256 glVertex2f( x+1, y+1 ); glVertex2f( x2-1, y+1 ); 257 glVertex2f( x2-1, y2-1 ); glVertex2f( x+1, y2-1 ); 258 glEnd(); 259 260 glColor4ubv( light.ptr ); 261 glBegin( GL_LINE_STRIP ); 262 glVertex2f( x, y2 ); glVertex2f( x, y ); glVertex2f( x2, y ); 263 glEnd(); 264 265 glColor4ubv( dark.ptr ); 266 glBegin( GL_LINE_STRIP ); 267 glVertex2f( x2, y ); glVertex2f( x2, y2 ); glVertex2f( x, y2 ); 268 glEnd(); 269 270 glColor4ubv( medium.ptr ); 271 glBegin( GL_LINE_STRIP ); 272 glVertex2f( x2-1, y+1 ); glVertex2f( x2-1, y2-1 ); glVertex2f( x+1, y2-1 ); 273 glEnd(); 248 249 with (r) { 250 translate(0.5,0.5); scope(exit) untranslate(0.5,0.5); 251 glColor4ubv( bkg.ptr ); 252 glBegin( GL_LINE_LOOP ); 253 glVertex2f( x+1, y+1 ); glVertex2f( x2-1, y+1 ); 254 glVertex2f( x2-1, y2-1 ); glVertex2f( x+1, y2-1 ); 255 glEnd(); 256 257 glColor4ubv( light.ptr ); 258 glBegin( GL_LINE_STRIP ); 259 glVertex2f( x, y2 ); glVertex2f( x, y ); glVertex2f( x2, y ); 260 glEnd(); 261 262 glColor4ubv( dark.ptr ); 263 glBegin( GL_LINE_STRIP ); 264 glVertex2f( x2, y ); glVertex2f( x2, y2 ); glVertex2f( x, y2 ); 265 glEnd(); 266 267 glColor4ubv( medium.ptr ); 268 glBegin( GL_LINE_STRIP ); 269 glVertex2f( x2-1, y+1 ); glVertex2f( x2-1, y2-1 ); glVertex2f( x+1, y2-1 ); 270 glEnd(); 271 } 274 272 } 275 273 … … 277 275 { 278 276 r.inset(0.5); 277 278 with(r) { 279 // inner loop 280 glBegin( GL_LINE_STRIP ); 281 glColor4ubv( medium.ptr ); 282 glVertex2f( x +1, y2-1 ); 283 glVertex2f( x +1, y +1 ); 284 glVertex2f( x2-1, y +1 ); 285 286 glColor4ubv( bkg.ptr ); 287 glVertex2f( x2-1, y +1 ); 288 glVertex2f( x2-1, y2-1 ); 289 glVertex2f( x +1, y2-1 ); 290 glEnd(); 291 292 // outer loop 293 glBegin( GL_LINE_STRIP ); 294 glColor4ubv( dark.ptr ); 295 glVertex2f( x , y2 ); 296 glVertex2f( x , y ); 297 glVertex2f( x2, y ); 298 299 glColor4ubv( light.ptr ); 300 glVertex2f( x2, y ); 301 glVertex2f( x2, y2 ); 302 glVertex2f( x , y2 ); 303 glEnd(); 304 } 279 305 // stroke_raised_rect(r, bkg, light, medium, dark); 306 /* 280 307 glColor3ubv(dark.ptr); 281 308 glBegin( GL_LINE_LOOP ); … … 288 315 glVertex2f( r.x2-1, r.y2-1 ); glVertex2f( r.x+1, r.y2-1 ); 289 316 glEnd(); 290 317 */ 291 318 292 319 /* trunk/luigi/gui.d
r7 r10 207 207 S add_widget(S)(S w) 208 208 { 209 static assert(is(S:Widget), "add requires a Widget as argument");209 static assert(is(S:Widget), "add_widget requires a Widget as argument"); 210 210 add(w); 211 211 return w; … … 566 566 } 567 567 568 int stretch_x() { return m_stretchx; } 569 int stretch_y() { return m_stretchy; } 570 void stretch(ubyte both) { m_stretchx = m_stretchy = both; } 571 void stretch(ubyte x, ubyte y) { m_stretchx = x; m_stretchy = y; } 572 568 573 //------------------------------------------------------------------------ 569 574 // Hooks for the theme … … 580 585 bool m_focused = false; 581 586 Arranger m_arranger = null; 587 ubyte m_stretchx = 0; // stretchyness for arrangement 588 ubyte m_stretchy = 0; 582 589 583 590 // for any per-instance data needed by theme … … 1523 1530 override double value() { return m_value; } 1524 1531 override double value(double v) { 1532 if (v<m_min) v=m_min; 1533 if (v>m_max) v=m_max; 1525 1534 if (v==m_value) return m_value; 1526 1535 m_value = v; … … 1533 1542 label = label_; 1534 1543 value_changed = new ValueChangedSignal; 1535 } 1544 m_focusable = true; 1545 } 1546 1547 int on_key(inout KeyEvent ev) { 1548 if (ev.is_press) { 1549 switch(ev.key) 1550 { 1551 case Key.Right: 1552 case Key.Up: 1553 value = value + m_increment; break; 1554 case Key.Left: 1555 case Key.Down: 1556 value = value - m_increment; break; 1557 case Key.PageUp: 1558 value = value + m_page; break; 1559 case Key.PageDown: 1560 value = value - m_page; break; 1561 default: 1562 // pass 1563 } 1564 } 1565 return 0; 1566 } 1567 1568 double value_max() { return m_max; } 1569 double value_min() { return m_min; } 1570 double increment() { return m_increment; } 1571 double page_increment() { return m_page; } 1536 1572 1537 1573 char[] label; … … 1543 1579 private: 1544 1580 double m_value = 0; 1581 double m_saveValue = 0; 1582 double m_max = 100; 1583 double m_min = 0; 1584 double m_increment = 1; 1585 double m_page = 10; 1586 bool m_horizontal = true; 1545 1587 } 1546 1588 trunk/luigi/theme.d
r7 r10 70 70 return null; 71 71 } 72 return null; 72 73 } 73 74 void add(ClassInfo c, FuncT f) { … … 92 93 _addFuncs!(TextField)(&textfield_draw, &textfield_best_size, &textfield_min_size); 93 94 m_drawFuncs.add(Panel.classinfo, &panel_draw); 94 //_addFuncs!(Slider)(&slider_draw, &slider_best_size);95 _addFuncs!(Slider)(&slider_draw, &slider_best_size, &slider_min_size); 95 96 //_addFuncs!(Spinner)(&spinner_draw, &spinner_best_size); 96 97 //_addFuncs!(RadioButton)(&radiobutton_draw, &radiobutton_best_size); … … 555 556 556 557 //----SLIDER---------------------------------------------------------------- 557 /* 558 static const int scroll_thumb_w = 8; 559 static const int scroll_thumb_h = 18; 558 560 Size slider_min_size(Widget widget, Size bounds) { 559 561 auto w = cast(Slider)widget; assert(w); 560 return Size( 0,0);562 return Size(scroll_thumb_w+20, scroll_thumb_h+5); 561 563 } 562 564 Size slider_best_size(Widget widget, Size bounds) { 563 565 auto w = cast(Slider)widget; assert(w); 564 return Size( 0,0);566 return Size(100,scroll_thumb_h+5); 565 567 } 566 568 void slider_draw(Widget widget) { … … 568 570 set_color(get_background_color(widget)); 569 571 fill_rect(w.rect); 570 } 571 */ 572 translate(widget.rect.pos); scope(exit) untranslate(widget.rect.pos); 573 { 574 Rect rect = w.rect; 575 576 float ctr = 0.5*(rect.h); 577 const int tw = 2; 578 Rect rtrack = Rect(tw, ctr-tw, rect.w-tw-tw, tw+tw); 579 stroke_sunken_rect( 580 rtrack, bkg_color,hilite_color[0],hilite_color[1],hilite_color[2]); 581 582 Rect rthumb; rthumb.size = Size(scroll_thumb_w,scroll_thumb_h); 583 float t = w.value/(w.value_max-w.value_min); 584 float vpos = tw + t*(rtrack.w-rthumb.w); 585 rthumb.x = lrint(vpos); 586 rthumb.y = lrint(rect.h-rthumb.h)/2; 587 set_color(bkg_color); 588 589 fill_rect(rthumb); 590 stroke_raised_rect( 591 rthumb, bkg_color,hilite_color[0],hilite_color[1],hilite_color[2]); 592 593 if (w.focused()) { 594 set_color(hilite_color[0]); 595 Rect r; r.x = 0; r.y = 0; r.size = rect.size; 596 r.inset(1); 597 glEnable(GL_LINE_STIPPLE); 598 glLineStipple( 1, 0x5555 ); 599 stroke_rect(r); 600 glDisable(GL_LINE_STIPPLE); 601 } 602 } 603 } 572 604 //----SPINNER---------------------------------------------------------------- 573 605 /*
