ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.439 by root, Sun Sep 16 13:04:36 2007 UTC vs.
Revision 1.461 by elmex, Mon Jan 28 12:05:08 2008 UTC

1package CFPlus::UI; 1package DC::UI;
2 2
3use utf8; 3use utf8;
4use strict; 4use strict;
5 5
6use List::Util (); 6use List::Util ();
7use Event;
8 7
9use CFPlus; 8use DC;
10use CFPlus::Pod; 9use DC::Pod;
11use CFPlus::Texture; 10use DC::Texture;
12 11
13our ($FOCUS, $HOVER, $GRAB); # various widgets 12our ($FOCUS, $HOVER, $GRAB); # various widgets
14 13
15our $LAYOUT; 14our $LAYOUT;
16our $ROOT; 15our $ROOT;
17our $TOOLTIP; 16our $TOOLTIP;
18our $BUTTON_STATE; 17our $BUTTON_STATE;
19 18
20our %WIDGET; # all widgets, weak-referenced 19our %WIDGET; # all widgets, weak-referenced
21 20
22our $TOOLTIP_WATCHER = Event->idle (min => 1/60, cb => sub { 21our $TOOLTIP_WATCHER = EV::timer_ns 0, 0.03, sub {
22 $_[0]->stop;
23
23 if (!$GRAB) { 24 if (!$GRAB) {
24 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { 25 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
25 if (length $widget->{tooltip}) { 26 if (length $widget->{tooltip}) {
26 if ($TOOLTIP->{owner} != $widget) { 27 if ($TOOLTIP->{owner} != $widget) {
27 $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner}; 28 $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner};
42 } 43 }
43 44
44 $TOOLTIP->hide; 45 $TOOLTIP->hide;
45 $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner}; 46 $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner};
46 delete $TOOLTIP->{owner}; 47 delete $TOOLTIP->{owner};
47}); 48};
48 49
49sub get_layout { 50sub get_layout {
50 my $layout; 51 my $layout;
51 52
52 for (grep { $_->{name} } values %WIDGET) { 53 for (grep { $_->{name} } values %WIDGET) {
87 my $hover = $HOVER; $HOVER = $widget; 88 my $hover = $HOVER; $HOVER = $widget;
88 89
89 $hover->update if $hover && $hover->{can_hover}; 90 $hover->update if $hover && $hover->{can_hover};
90 $HOVER->update if $HOVER && $HOVER->{can_hover}; 91 $HOVER->update if $HOVER && $HOVER->{can_hover};
91 92
92 $TOOLTIP_WATCHER->start; 93 $TOOLTIP_WATCHER->again;
93 } 94 }
94} 95}
95 96
96sub feed_sdl_button_down_event { 97sub feed_sdl_button_down_event {
97 my ($ev) = @_; 98 my ($ev) = @_;
103 my $widget = $ROOT->find_widget ($x, $y); 104 my $widget = $ROOT->find_widget ($x, $y);
104 105
105 $GRAB = $widget; 106 $GRAB = $widget;
106 $GRAB->update if $GRAB; 107 $GRAB->update if $GRAB;
107 108
108 $TOOLTIP_WATCHER->cb->(); 109 $TOOLTIP_WATCHER->invoke;
109 } 110 }
110 111
111 if ($GRAB) { 112 if ($GRAB) {
112 if ($ev->{button} == 4 || $ev->{button} == 5) { 113 if ($ev->{button} == 4 || $ev->{button} == 5) {
113 # mousewheel 114 # mousewheel
114 my $delta = $ev->{button} * 2 - 9; 115 my $delta = $ev->{button} * 2 - 9;
115 my $shift = $ev->{mod} & CFPlus::KMOD_SHIFT; 116 my $shift = $ev->{mod} & DC::KMOD_SHIFT;
116 117
117 $ev->{dx} = $shift ? $delta : 0; 118 $ev->{dx} = $shift ? $delta : 0;
118 $ev->{dy} = $shift ? 0 : $delta; 119 $ev->{dy} = $shift ? 0 : $delta;
119 120
120 $GRAB->emit (mouse_wheel => $ev); 121 $GRAB->emit (mouse_wheel => $ev);
138 my $grab = $GRAB; undef $GRAB; 139 my $grab = $GRAB; undef $GRAB;
139 $grab->update if $grab; 140 $grab->update if $grab;
140 $GRAB->update if $GRAB; 141 $GRAB->update if $GRAB;
141 142
142 check_hover $widget; 143 check_hover $widget;
143 $TOOLTIP_WATCHER->cb->(); 144 $TOOLTIP_WATCHER->invoke;
144 } 145 }
145} 146}
146 147
147sub feed_sdl_motion_event { 148sub feed_sdl_motion_event {
148 my ($ev) = @_; 149 my ($ev) = @_;
210 reconfigure_widgets; 211 reconfigure_widgets;
211} 212}
212 213
213############################################################################# 214#############################################################################
214 215
215package CFPlus::UI::Event; 216package DC::UI::Event;
216 217
217sub xy { 218sub xy {
218 $_[1]->coord2local ($_[0]{x}, $_[0]{y}) 219 $_[1]->coord2local ($_[0]{x}, $_[0]{y})
219} 220}
220 221
221############################################################################# 222#############################################################################
222 223
223package CFPlus::UI::Base; 224package DC::UI::Base;
224 225
225use strict; 226use strict;
226 227
227use CFPlus::OpenGL; 228use DC::OpenGL;
228 229
229sub new { 230sub new {
230 my $class = shift; 231 my $class = shift;
231 232
232 my $self = bless { 233 my $self = bless {
237 h => undef, 238 h => undef,
238 can_events => 1, 239 can_events => 1,
239 @_ 240 @_
240 }, $class; 241 }, $class;
241 242
242 CFPlus::weaken ($CFPlus::UI::WIDGET{$self+0} = $self); 243 DC::weaken ($DC::UI::WIDGET{$self+0} = $self);
243 244
244 for (keys %$self) { 245 for (keys %$self) {
245 if (/^on_(.*)$/) { 246 if (/^on_(.*)$/) {
246 $self->connect ($1 => delete $self->{$_}); 247 $self->connect ($1 => delete $self->{$_});
247 } 248 }
248 } 249 }
249 250
250 if (my $layout = $CFPlus::UI::LAYOUT->{$self->{name}}) { 251 if (my $layout = $DC::UI::LAYOUT->{$self->{name}}) {
251 $self->{x} = $layout->{x} * $CFPlus::UI::ROOT->{alloc_w} if exists $layout->{x}; 252 $self->{x} = $layout->{x} * $DC::UI::ROOT->{alloc_w} if exists $layout->{x};
252 $self->{y} = $layout->{y} * $CFPlus::UI::ROOT->{alloc_h} if exists $layout->{y}; 253 $self->{y} = $layout->{y} * $DC::UI::ROOT->{alloc_h} if exists $layout->{y};
253 $self->{force_w} = $layout->{w} * $CFPlus::UI::ROOT->{alloc_w} if exists $layout->{w}; 254 $self->{force_w} = $layout->{w} * $DC::UI::ROOT->{alloc_w} if exists $layout->{w};
254 $self->{force_h} = $layout->{h} * $CFPlus::UI::ROOT->{alloc_h} if exists $layout->{h}; 255 $self->{force_h} = $layout->{h} * $DC::UI::ROOT->{alloc_h} if exists $layout->{h};
255 256
256 $self->{x} -= $self->{force_w} * 0.5 if exists $layout->{x}; 257 $self->{x} -= $self->{force_w} * 0.5 if exists $layout->{x};
257 $self->{y} -= $self->{force_h} * 0.5 if exists $layout->{y}; 258 $self->{y} -= $self->{force_h} * 0.5 if exists $layout->{y};
258 259
259 $self->show if $layout->{show}; 260 $self->show if $layout->{show};
277sub show { 278sub show {
278 my ($self) = @_; 279 my ($self) = @_;
279 280
280 return if $self->{parent}; 281 return if $self->{parent};
281 282
282 $CFPlus::UI::ROOT->add ($self); 283 $DC::UI::ROOT->add ($self);
283} 284}
284 285
285sub set_visible { 286sub set_visible {
286 my ($self) = @_; 287 my ($self) = @_;
287 288
308 delete $self->{root}; 309 delete $self->{root};
309 310
310 undef $GRAB if $GRAB == $self; 311 undef $GRAB if $GRAB == $self;
311 undef $HOVER if $HOVER == $self; 312 undef $HOVER if $HOVER == $self;
312 313
313 $CFPlus::UI::TOOLTIP_WATCHER->cb->() 314 $DC::UI::TOOLTIP_WATCHER->invoke
314 if $TOOLTIP->{owner} == $self; 315 if $TOOLTIP->{owner} == $self;
315 316
316 $self->emit ("focus_out"); 317 $self->emit ("focus_out");
317 $self->emit (visibility_change => 0); 318 $self->emit (visibility_change => 0);
318} 319}
337sub hide { 338sub hide {
338 my ($self) = @_; 339 my ($self) = @_;
339 340
340 $self->set_invisible; 341 $self->set_invisible;
341 342
343 # extra $parent copy for 5.8.8+ bug workaround
344 # (otherwise $_[0] in remove gets freed
345 if (my $parent = $self->{parent}) {
342 $self->{parent}->remove ($self) 346 $parent->remove ($self);
343 if $self->{parent}; 347 }
344} 348}
345 349
346sub move_abs { 350sub move_abs {
347 my ($self, $x, $y, $z) = @_; 351 my ($self, $x, $y, $z) = @_;
348 352
360 $self->{force_h} = $h; 364 $self->{force_h} = $h;
361 365
362 $self->realloc; 366 $self->realloc;
363} 367}
364 368
365# travsle the widget chain up to find the maximum "physical" size constraints 369# traverse the widget chain up to find the maximum "physical" size constraints
366sub get_max_wh { 370sub get_max_wh {
367 my ($self) = @_; 371 my ($self) = @_;
368 372
369 return ($self->{alloc_w}, $self->{alloc_h}) 373 my ($w, $h) = @$self{qw(max_w max_h)};
370 if $self->{alloc_w} && !$self->{root}{realloc}{$self+0};
371 374
375 if ($w <= 0 || $h <= 0) {
376 my ($mw, $mh) = $self->{parent}
372 return $self->{parent}->get_max_wh 377 ? $self->{parent}->get_max_wh
373 if $self->{parent};
374
375 ($::WIDTH, $::HEIGHT) 378 : ($::WIDTH, $::HEIGHT);
379
380 $w = $mw if $w <= 0;
381 $h = $mh if $h <= 0;
382 }
383
384 ($w, $h)
376} 385}
377 386
378sub size_request { 387sub size_request {
379 require Carp; 388 require Carp;
380 Carp::confess "size_request is abstract"; 389 Carp::confess "size_request is abstract";
388 my ($self, $x, $y, $w, $h) = @_; 397 my ($self, $x, $y, $w, $h) = @_;
389 398
390 if ($self->{aspect}) { 399 if ($self->{aspect}) {
391 my ($ow, $oh) = ($w, $h); 400 my ($ow, $oh) = ($w, $h);
392 401
393 $w = List::Util::min $w, CFPlus::ceil $h * $self->{aspect}; 402 $w = List::Util::min $w, DC::ceil $h * $self->{aspect};
394 $h = List::Util::min $h, CFPlus::ceil $w / $self->{aspect}; 403 $h = List::Util::min $h, DC::ceil $w / $self->{aspect};
395 404
396 # use alignment to adjust x, y 405 # use alignment to adjust x, y
397 406
398 $x += int 0.5 * ($ow - $w); 407 $x += int 0.5 * ($ow - $w);
399 $y += int 0.5 * ($oh - $h); 408 $y += int 0.5 * ($oh - $h);
440 449
441 return if $self->{tooltip} eq $tooltip; 450 return if $self->{tooltip} eq $tooltip;
442 451
443 $self->{tooltip} = $tooltip; 452 $self->{tooltip} = $tooltip;
444 453
445 if ($CFPlus::UI::TOOLTIP->{owner} == $self) { 454 if ($DC::UI::TOOLTIP->{owner} == $self) {
446 delete $CFPlus::UI::TOOLTIP->{owner}; 455 delete $DC::UI::TOOLTIP->{owner};
447 $CFPlus::UI::TOOLTIP_WATCHER->cb->(); 456 $DC::UI::TOOLTIP_WATCHER->invoke;
448 } 457 }
449} 458}
450 459
451# translate global coordinates to local coordinate system 460# translate global coordinates to local coordinate system
452sub coord2local { 461sub coord2local {
453 my ($self, $x, $y) = @_; 462 my ($self, $x, $y) = @_;
454 463
455 Carp::confess unless $self->{parent};#d# 464 return (undef, undef) unless $self->{parent};
456 465
457 $self->{parent}->coord2local ($x - $self->{x}, $y - $self->{y}) 466 $self->{parent}->coord2local ($x - $self->{x}, $y - $self->{y})
458} 467}
459 468
460# translate local coordinates to global coordinate system 469# translate local coordinates to global coordinate system
461sub coord2global { 470sub coord2global {
462 my ($self, $x, $y) = @_; 471 my ($self, $x, $y) = @_;
463 472
464 Carp::confess unless $self->{parent};#d# 473 return (undef, undef) unless $self->{parent};
465 474
466 $self->{parent}->coord2global ($x + $self->{x}, $y + $self->{y}) 475 $self->{parent}->coord2global ($x + $self->{x}, $y + $self->{y})
467} 476}
468 477
469sub invoke_focus_in { 478sub invoke_focus_in {
518sub connect { 527sub connect {
519 my ($self, $signal, $cb) = @_; 528 my ($self, $signal, $cb) = @_;
520 529
521 push @{ $self->{signal_cb}{$signal} }, $cb; 530 push @{ $self->{signal_cb}{$signal} }, $cb;
522 531
523 defined wantarray and CFPlus::guard { 532 defined wantarray and DC::guard {
524 @{ $self->{signal_cb}{$signal} } = grep $_ != $cb, 533 @{ $self->{signal_cb}{$signal} } = grep $_ != $cb,
525 @{ $self->{signal_cb}{$signal} }; 534 @{ $self->{signal_cb}{$signal} };
526 } 535 }
527} 536}
528 537
566# in .xs 575# in .xs
567 576
568sub set_parent { 577sub set_parent {
569 my ($self, $parent) = @_; 578 my ($self, $parent) = @_;
570 579
571 CFPlus::weaken ($self->{parent} = $parent); 580 DC::weaken ($self->{parent} = $parent);
572 $self->set_visible if $parent->{visible}; 581 $self->set_visible if $parent->{visible};
573} 582}
574 583
575sub realloc { 584sub realloc {
576 my ($self) = @_; 585 my ($self) = @_;
614} 623}
615 624
616sub DESTROY { 625sub DESTROY {
617 my ($self) = @_; 626 my ($self) = @_;
618 627
619 return if CFPlus::in_destruct; 628 return if DC::in_destruct;
620 629
621 local $@; 630 local $@;
622 eval { $self->destroy }; 631 eval { $self->destroy };
623 warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; 632 warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/;
624 633
625 delete $WIDGET{$self+0}; 634 delete $WIDGET{$self+0};
626} 635}
627 636
628############################################################################# 637#############################################################################
629 638
630package CFPlus::UI::DrawBG; 639package DC::UI::DrawBG;
631 640
632our @ISA = CFPlus::UI::Base::; 641our @ISA = DC::UI::Base::;
633 642
634use strict; 643use strict;
635use CFPlus::OpenGL; 644use DC::OpenGL;
636 645
637sub new { 646sub new {
638 my $class = shift; 647 my $class = shift;
639 648
640 $class->SUPER::new ( 649 $class->SUPER::new (
662 } 671 }
663} 672}
664 673
665############################################################################# 674#############################################################################
666 675
667package CFPlus::UI::Empty; 676package DC::UI::Empty;
668 677
669our @ISA = CFPlus::UI::Base::; 678our @ISA = DC::UI::Base::;
670 679
671sub new { 680sub new {
672 my ($class, %arg) = @_; 681 my ($class, %arg) = @_;
673 $class->SUPER::new (can_events => 0, %arg); 682 $class->SUPER::new (can_events => 0, %arg);
674} 683}
681 690
682sub draw { } 691sub draw { }
683 692
684############################################################################# 693#############################################################################
685 694
686package CFPlus::UI::Container; 695package DC::UI::Container;
687 696
688our @ISA = CFPlus::UI::Base::; 697our @ISA = DC::UI::Base::;
689 698
690sub new { 699sub new {
691 my ($class, %arg) = @_; 700 my ($class, %arg) = @_;
692 701
693 my $children = delete $arg{children}; 702 my $children = delete $arg{children};
787 $_->draw for $self->visible_children; 796 $_->draw for $self->visible_children;
788} 797}
789 798
790############################################################################# 799#############################################################################
791 800
792package CFPlus::UI::Bin; 801package DC::UI::Bin;
793 802
794our @ISA = CFPlus::UI::Container::; 803our @ISA = DC::UI::Container::;
795 804
796sub new { 805sub new {
797 my ($class, %arg) = @_; 806 my ($class, %arg) = @_;
798 807
799 my $child = (delete $arg{child}) || new CFPlus::UI::Empty::; 808 my $child = (delete $arg{child}) || new DC::UI::Empty::;
800 809
801 $class->SUPER::new (children => [$child], %arg) 810 $class->SUPER::new (children => [$child], %arg)
802} 811}
803 812
804sub add { 813sub add {
811sub remove { 820sub remove {
812 my ($self, $widget) = @_; 821 my ($self, $widget) = @_;
813 822
814 $self->SUPER::remove ($widget); 823 $self->SUPER::remove ($widget);
815 824
816 $self->{children} = [new CFPlus::UI::Empty] 825 $self->{children} = [new DC::UI::Empty]
817 unless @{$self->{children}}; 826 unless @{$self->{children}};
818} 827}
819 828
820sub child { $_[0]->{children}[0] } 829sub child { $_[0]->{children}[0] }
821 830
832} 841}
833 842
834############################################################################# 843#############################################################################
835# back-buffered drawing area 844# back-buffered drawing area
836 845
837package CFPlus::UI::Window; 846package DC::UI::Window;
838 847
839our @ISA = CFPlus::UI::Bin::; 848our @ISA = DC::UI::Bin::;
840 849
841use CFPlus::OpenGL; 850use DC::OpenGL;
842 851
843sub new { 852sub new {
844 my ($class, %arg) = @_; 853 my ($class, %arg) = @_;
845 854
846 my $self = $class->SUPER::new (%arg); 855 my $self = $class->SUPER::new (%arg);
868} 877}
869 878
870sub render_child { 879sub render_child {
871 my ($self) = @_; 880 my ($self) = @_;
872 881
873 $self->{texture} = new_from_opengl CFPlus::Texture $self->{w}, $self->{h}, sub { 882 $self->{texture} = new_from_opengl DC::Texture $self->{w}, $self->{h}, sub {
874 glClearColor 0, 0, 0, 0; 883 glClearColor 0, 0, 0, 0;
875 glClear GL_COLOR_BUFFER_BIT; 884 glClear GL_COLOR_BUFFER_BIT;
876 885
877 { 886 {
878 package CFPlus::UI::Base; 887 package DC::UI::Base;
879 888
880 local ($draw_x, $draw_y, $draw_w, $draw_h) = 889 local ($draw_x, $draw_y, $draw_w, $draw_h) =
881 (0, 0, $self->{w}, $self->{h}); 890 (0, 0, $self->{w}, $self->{h});
882 891
883 $self->_render; 892 $self->_render;
900 glDisable GL_TEXTURE_2D; 909 glDisable GL_TEXTURE_2D;
901} 910}
902 911
903############################################################################# 912#############################################################################
904 913
905package CFPlus::UI::ViewPort; 914package DC::UI::ViewPort;
906 915
907use List::Util qw(min max); 916use List::Util qw(min max);
908 917
909our @ISA = CFPlus::UI::Window::; 918our @ISA = DC::UI::Window::;
910 919
911sub new { 920sub new {
912 my $class = shift; 921 my $class = shift;
913 922
914 $class->SUPER::new ( 923 $class->SUPER::new (
998 if ( $x >= $self->{x} && $x < $self->{x} + $self->{w} 1007 if ( $x >= $self->{x} && $x < $self->{x} + $self->{w}
999 && $y >= $self->{y} && $y < $self->{y} + $self->{h} 1008 && $y >= $self->{y} && $y < $self->{y} + $self->{h}
1000 ) { 1009 ) {
1001 $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y}) 1010 $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y})
1002 } else { 1011 } else {
1003 $self->CFPlus::UI::Base::find_widget ($x, $y) 1012 $self->DC::UI::Base::find_widget ($x, $y)
1004 } 1013 }
1005} 1014}
1006 1015
1007sub _render { 1016sub _render {
1008 my ($self) = @_; 1017 my ($self) = @_;
1009 1018
1010 local $CFPlus::UI::Base::draw_x = $CFPlus::UI::Base::draw_x - $self->{view_x}; 1019 local $DC::UI::Base::draw_x = $DC::UI::Base::draw_x - $self->{view_x};
1011 local $CFPlus::UI::Base::draw_y = $CFPlus::UI::Base::draw_y - $self->{view_y}; 1020 local $DC::UI::Base::draw_y = $DC::UI::Base::draw_y - $self->{view_y};
1012 1021
1013 CFPlus::OpenGL::glTranslate -$self->{view_x}, -$self->{view_y}; 1022 DC::OpenGL::glTranslate -$self->{view_x}, -$self->{view_y};
1014 1023
1015 $self->SUPER::_render; 1024 $self->SUPER::_render;
1016} 1025}
1017 1026
1018############################################################################# 1027#############################################################################
1019 1028
1020package CFPlus::UI::ScrolledWindow; 1029package DC::UI::ScrolledWindow;
1021 1030
1022our @ISA = CFPlus::UI::Table::; 1031our @ISA = DC::UI::Table::;
1023 1032
1024sub new { 1033sub new {
1025 my ($class, %arg) = @_; 1034 my ($class, %arg) = @_;
1026 1035
1027 my $child = delete $arg{child}; 1036 my $child = delete $arg{child};
1028 1037
1029 my $self; 1038 my $self;
1030 1039
1031 my $hslider = new CFPlus::UI::Slider 1040 my $hslider = new DC::UI::Slider
1032 c_col => 0, 1041 c_col => 0,
1033 c_row => 1, 1042 c_row => 1,
1034 vertical => 0, 1043 vertical => 0,
1035 range => [0, 0, 1, 0.01], # HACK fix 1044 range => [0, 0, 1, 0.01], # HACK fix
1036 on_changed => sub { 1045 on_changed => sub {
1037 $self->{hpos} = $_[1]; 1046 $self->{hpos} = $_[1];
1038 $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); 1047 $self->{vp}->set_offset ($self->{hpos}, $self->{vpos});
1039 }, 1048 },
1040 ; 1049 ;
1041 1050
1042 my $vslider = new CFPlus::UI::Slider 1051 my $vslider = new DC::UI::Slider
1043 c_col => 1, 1052 c_col => 1,
1044 c_row => 0, 1053 c_row => 0,
1045 vertical => 1, 1054 vertical => 1,
1046 range => [0, 0, 1, 0.01], # HACK fix 1055 range => [0, 0, 1, 0.01], # HACK fix
1047 on_changed => sub { 1056 on_changed => sub {
1059 col_expand => [1, 0], 1068 col_expand => [1, 0],
1060 row_expand => [1, 0], 1069 row_expand => [1, 0],
1061 %arg, 1070 %arg,
1062 ); 1071 );
1063 1072
1064 $self->{vp} = new CFPlus::UI::ViewPort 1073 $self->{vp} = new DC::UI::ViewPort
1065 c_col => 0, 1074 c_col => 0,
1066 c_row => 0, 1075 c_row => 0,
1067 expand => 1, 1076 expand => 1,
1068 scroll_x => $self->{scroll_x}, 1077 scroll_x => $self->{scroll_x},
1069 scroll_y => $self->{scroll_y}, 1078 scroll_y => $self->{scroll_y},
1195 $self->SUPER::invoke_size_allocate ($w, $h) 1204 $self->SUPER::invoke_size_allocate ($w, $h)
1196} 1205}
1197 1206
1198############################################################################# 1207#############################################################################
1199 1208
1200package CFPlus::UI::Frame; 1209package DC::UI::Frame;
1201 1210
1202our @ISA = CFPlus::UI::Bin::; 1211our @ISA = DC::UI::Bin::;
1203 1212
1204use CFPlus::OpenGL; 1213use DC::OpenGL;
1205 1214
1206sub new { 1215sub new {
1207 my $class = shift; 1216 my $class = shift;
1208 1217
1209 $class->SUPER::new ( 1218 $class->SUPER::new (
1228 $self->SUPER::_draw; 1237 $self->SUPER::_draw;
1229} 1238}
1230 1239
1231############################################################################# 1240#############################################################################
1232 1241
1233package CFPlus::UI::FancyFrame; 1242package DC::UI::FancyFrame;
1234 1243
1235our @ISA = CFPlus::UI::Bin::; 1244our @ISA = DC::UI::Bin::;
1236 1245
1237use CFPlus::OpenGL; 1246use DC::OpenGL;
1238 1247
1239sub new { 1248sub new {
1240 my ($class, %arg) = @_; 1249 my ($class, %arg) = @_;
1241 1250
1242 if ((exists $arg{label}) && !ref $arg{label}) { 1251 if ((exists $arg{label}) && !ref $arg{label}) {
1243 $arg{label} = new CFPlus::UI::Label 1252 $arg{label} = new DC::UI::Label
1244 align => 1, 1253 align => 1,
1245 valign => 0, 1254 valign => 0.5,
1246 text => $arg{label}, 1255 text => $arg{label},
1247 fontsize => ($arg{border} || 0.8) * 0.75; 1256 fontsize => ($arg{border} || 0.8) * 0.75;
1248 } 1257 }
1249 1258
1250 my $self = $class->SUPER::new ( 1259 my $self = $class->SUPER::new (
1260 1269
1261sub add { 1270sub add {
1262 my ($self, @widgets) = @_; 1271 my ($self, @widgets) = @_;
1263 1272
1264 $self->SUPER::add (@widgets); 1273 $self->SUPER::add (@widgets);
1265 $self->CFPlus::UI::Container::add ($self->{label}) if $self->{label}; 1274 $self->DC::UI::Container::add ($self->{label}) if $self->{label};
1266} 1275}
1267 1276
1268sub border { 1277sub border {
1269 int $_[0]{border} * $::FONTSIZE 1278 int $_[0]{border} * $::FONTSIZE
1270} 1279}
1328 } 1337 }
1329} 1338}
1330 1339
1331############################################################################# 1340#############################################################################
1332 1341
1333package CFPlus::UI::Toplevel; 1342package DC::UI::Toplevel;
1334 1343
1335our @ISA = CFPlus::UI::Bin::; 1344our @ISA = DC::UI::Bin::;
1336 1345
1337use CFPlus::OpenGL; 1346use DC::OpenGL;
1338 1347
1339my $bg = 1348my $bg =
1340 new_from_file CFPlus::Texture CFPlus::find_rcfile "d1_bg.png", 1349 new_from_file DC::Texture DC::find_rcfile "d1_bg.png",
1341 mipmap => 1, wrap => 1; 1350 mipmap => 1, wrap => 1;
1342 1351
1343my @border = 1352my @border =
1344 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 1353 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
1345 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); 1354 qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
1346 1355
1347my @icon = 1356my @icon =
1348 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 1357 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
1349 qw(x1_move.png x1_resize.png); 1358 qw(x1_move.png x1_resize.png);
1350 1359
1351sub new { 1360sub new {
1352 my ($class, %arg) = @_; 1361 my ($class, %arg) = @_;
1353 1362
1359 min_w => 64, 1368 min_w => 64,
1360 min_h => 32, 1369 min_h => 32,
1361 %arg, 1370 %arg,
1362 ); 1371 );
1363 1372
1364 $self->{title_widget} = new CFPlus::UI::Label 1373 $self->{title_widget} = new DC::UI::Label
1365 align => 0, 1374 align => 0.5,
1366 valign => 1, 1375 valign => 1,
1367 text => $self->{title}, 1376 text => $self->{title},
1368 fontsize => $self->{border}, 1377 fontsize => $self->{border},
1369 if exists $self->{title}; 1378 if exists $self->{title};
1370 1379
1371 if ($self->{has_close_button}) { 1380 if ($self->{has_close_button}) {
1372 $self->{close_button} = 1381 $self->{close_button} =
1373 new CFPlus::UI::ImageButton 1382 new DC::UI::ImageButton
1374 path => 'x1_close.png', 1383 path => 'x1_close.png',
1375 on_activate => sub { $self->emit ("delete") }; 1384 on_activate => sub { $self->emit ("delete") };
1376 1385
1377 $self->CFPlus::UI::Container::add ($self->{close_button}); 1386 $self->DC::UI::Container::add ($self->{close_button});
1378 } 1387 }
1379 1388
1380 $self 1389 $self
1381} 1390}
1382 1391
1383sub add { 1392sub add {
1384 my ($self, @widgets) = @_; 1393 my ($self, @widgets) = @_;
1385 1394
1386 $self->SUPER::add (@widgets); 1395 $self->SUPER::add (@widgets);
1387 $self->CFPlus::UI::Container::add ($self->{close_button}) if $self->{close_button}; 1396 $self->DC::UI::Container::add ($self->{close_button}) if $self->{close_button};
1388 $self->CFPlus::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; 1397 $self->DC::UI::Container::add ($self->{title_widget}) if $self->{title_widget};
1389} 1398}
1390 1399
1391sub border { 1400sub border {
1392 int $_[0]{border} * $::FONTSIZE 1401 int $_[0]{border} * $::FONTSIZE
1402}
1403
1404sub get_max_wh {
1405 my ($self) = @_;
1406
1407 return ($self->{w}, $self->{h})
1408 if $self->{visible} && $self->{w};
1409
1410 $self->SUPER::get_max_wh
1393} 1411}
1394 1412
1395sub size_request { 1413sub size_request {
1396 my ($self) = @_; 1414 my ($self) = @_;
1397 1415
1569 if $self->{close_button}; 1587 if $self->{close_button};
1570} 1588}
1571 1589
1572############################################################################# 1590#############################################################################
1573 1591
1574package CFPlus::UI::Table; 1592package DC::UI::Table;
1575 1593
1576our @ISA = CFPlus::UI::Container::; 1594our @ISA = DC::UI::Container::;
1577 1595
1578use List::Util qw(max sum); 1596use List::Util qw(max sum);
1579 1597
1580use CFPlus::OpenGL; 1598use DC::OpenGL;
1581 1599
1582sub new { 1600sub new {
1583 my $class = shift; 1601 my $class = shift;
1584 1602
1585 $class->SUPER::new ( 1603 $class->SUPER::new (
1629 my ($c, $w, $cs) = @$widget{qw(c_col req_w c_colspan)}; 1647 my ($c, $w, $cs) = @$widget{qw(c_col req_w c_colspan)};
1630 1648
1631 my $sw = sum @w[$c .. $c + $cs - 1]; 1649 my $sw = sum @w[$c .. $c + $cs - 1];
1632 1650
1633 if ($w > $sw) { 1651 if ($w > $sw) {
1634 $_ += ($w - $sw) / ($sw ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1]; 1652 $_ += ($w - $sw) / ($_ ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1];
1635 } 1653 }
1636 } 1654 }
1637 1655
1638 # second pass, rows 1656 # second pass, rows
1639 for my $widget (sort { $a->{c_rowspan} <=> $b->{c_rowspan} } @children) { 1657 for my $widget (sort { $a->{c_rowspan} <=> $b->{c_rowspan} } @children) {
1640 my ($r, $h, $rs) = @$widget{qw(c_row req_h c_rowspan)}; 1658 my ($r, $h, $rs) = @$widget{qw(c_row req_h c_rowspan)};
1641 1659
1642 my $sh = sum @h[$r .. $r + $rs - 1]; 1660 my $sh = sum @h[$r .. $r + $rs - 1];
1643 1661
1644 if ($h > $sh) { 1662 if ($h > $sh) {
1645 $_ += ($h - $sh) / ($sh ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1]; 1663 $_ += ($h - $sh) / ($_ ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1];
1646 } 1664 }
1647 } 1665 }
1648 1666
1649 (\@w, \@h) 1667 (\@w, \@h)
1650} 1668}
1673 @col_expand = (1) x @$ws unless @col_expand; 1691 @col_expand = (1) x @$ws unless @col_expand;
1674 my $col_expand = (sum @col_expand) || 1; 1692 my $col_expand = (sum @col_expand) || 1;
1675 1693
1676 $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; 1694 $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws;
1677 1695
1678 CFPlus::UI::harmonize $ws; 1696 DC::UI::harmonize $ws;
1679 1697
1680 my @row_expand = @{$self->{row_expand}}; 1698 my @row_expand = @{$self->{row_expand}};
1681 @row_expand = (1) x @$ws unless @row_expand; 1699 @row_expand = (1) x @$ws unless @row_expand;
1682 my $row_expand = (sum @row_expand) || 1; 1700 my $row_expand = (sum @row_expand) || 1;
1683 1701
1684 $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; 1702 $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs;
1685 1703
1686 CFPlus::UI::harmonize $hs; 1704 DC::UI::harmonize $hs;
1687 1705
1688 my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] } 1706 my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] }
1689 my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] } 1707 my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] }
1690 1708
1691 for my $widget ($self->children) { 1709 for my $widget ($self->children) {
1700 1 1718 1
1701} 1719}
1702 1720
1703############################################################################# 1721#############################################################################
1704 1722
1705package CFPlus::UI::Fixed; 1723package DC::UI::Fixed;
1706 1724
1707use List::Util qw(min max); 1725use List::Util qw(min max);
1708 1726
1709our @ISA = CFPlus::UI::Container::; 1727our @ISA = DC::UI::Container::;
1710 1728
1711sub _scale($$$) { 1729sub _scale($$$) {
1712 my ($rel, $val, $max) = @_; 1730 my ($rel, $val, $max) = @_;
1713 1731
1714 $rel ? $val * $max : $val 1732 $rel ? $val * $max : $val
1766 1 1784 1
1767} 1785}
1768 1786
1769############################################################################# 1787#############################################################################
1770 1788
1771package CFPlus::UI::Box; 1789package DC::UI::Box;
1772 1790
1773our @ISA = CFPlus::UI::Container::; 1791our @ISA = DC::UI::Container::;
1774 1792
1775sub size_request { 1793sub size_request {
1776 my ($self) = @_; 1794 my ($self) = @_;
1777 1795
1778 my @children = $self->visible_children; 1796 my @children = $self->visible_children;
1813 $req[$_] += $space * $children[$_]{expand} 1831 $req[$_] += $space * $children[$_]{expand}
1814 for 0 .. $#children; 1832 for 0 .. $#children;
1815 } 1833 }
1816 } 1834 }
1817 1835
1818 CFPlus::UI::harmonize \@req; 1836 DC::UI::harmonize \@req;
1819 1837
1820 my $pos = 0; 1838 my $pos = 0;
1821 for (0 .. $#children) { 1839 for (0 .. $#children) {
1822 my $alloc = $req[$_]; 1840 my $alloc = $req[$_];
1823 $children[$_]->configure ($self->{vertical} ? (0, $pos, $w, $alloc) : ($pos, 0, $alloc, $h)); 1841 $children[$_]->configure ($self->{vertical} ? (0, $pos, $w, $alloc) : ($pos, 0, $alloc, $h));
1828 1 1846 1
1829} 1847}
1830 1848
1831############################################################################# 1849#############################################################################
1832 1850
1833package CFPlus::UI::HBox; 1851package DC::UI::HBox;
1834 1852
1835our @ISA = CFPlus::UI::Box::; 1853our @ISA = DC::UI::Box::;
1836 1854
1837sub new { 1855sub new {
1838 my $class = shift; 1856 my $class = shift;
1839 1857
1840 $class->SUPER::new ( 1858 $class->SUPER::new (
1843 ) 1861 )
1844} 1862}
1845 1863
1846############################################################################# 1864#############################################################################
1847 1865
1848package CFPlus::UI::VBox; 1866package DC::UI::VBox;
1849 1867
1850our @ISA = CFPlus::UI::Box::; 1868our @ISA = DC::UI::Box::;
1851 1869
1852sub new { 1870sub new {
1853 my $class = shift; 1871 my $class = shift;
1854 1872
1855 $class->SUPER::new ( 1873 $class->SUPER::new (
1858 ) 1876 )
1859} 1877}
1860 1878
1861############################################################################# 1879#############################################################################
1862 1880
1863package CFPlus::UI::Label; 1881package DC::UI::Label;
1864 1882
1865our @ISA = CFPlus::UI::DrawBG::; 1883our @ISA = DC::UI::DrawBG::;
1866 1884
1867use CFPlus::OpenGL; 1885use DC::OpenGL;
1868 1886
1869sub new { 1887sub new {
1870 my ($class, %arg) = @_; 1888 my ($class, %arg) = @_;
1871 1889
1872 my $self = $class->SUPER::new ( 1890 my $self = $class->SUPER::new (
1877 #text => initial text 1895 #text => initial text
1878 #markup => initial narkup 1896 #markup => initial narkup
1879 #max_w => maximum pixel width 1897 #max_w => maximum pixel width
1880 #style => 0, # render flags 1898 #style => 0, # render flags
1881 ellipsise => 3, # end 1899 ellipsise => 3, # end
1882 layout => (new CFPlus::Layout), 1900 layout => (new DC::Layout),
1883 fontsize => 1, 1901 fontsize => 1,
1884 align => -1, 1902 align => 0.5,
1885 valign => -1, 1903 valign => 0.5,
1886 padding_x => 2, 1904 padding_x => 4,
1887 padding_y => 2, 1905 padding_y => 2,
1888 can_events => 0, 1906 can_events => 0,
1889 %arg 1907 %arg
1890 ); 1908 );
1891 1909
1892 if (exists $self->{template}) { 1910 if (exists $self->{template}) {
1893 my $layout = new CFPlus::Layout; 1911 my $layout = new DC::Layout;
1894 $layout->set_text (delete $self->{template}); 1912 $layout->set_text (delete $self->{template});
1895 $self->{template} = $layout; 1913 $self->{template} = $layout;
1896 } 1914 }
1897 1915
1898 if (exists $self->{markup}) { 1916 if (exists $self->{markup}) {
1957 1975
1958 $self->{size_req} ||= do { 1976 $self->{size_req} ||= do {
1959 my ($max_w, $max_h) = $self->get_max_wh; 1977 my ($max_w, $max_h) = $self->get_max_wh;
1960 1978
1961 $self->{layout}->set_font ($self->{font}) if $self->{font}; 1979 $self->{layout}->set_font ($self->{font}) if $self->{font};
1962 $self->{layout}->set_width ($self->{max_w} || $max_w || -1); 1980 $self->{layout}->set_width ($max_w);
1963 $self->{layout}->set_ellipsise ($self->{ellipsise}); 1981 $self->{layout}->set_ellipsise ($self->{ellipsise});
1964 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); 1982 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise});
1965 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 1983 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1966 1984
1967 my ($w, $h) = $self->{layout}->size; 1985 my ($w, $h) = $self->{layout}->size;
1968 1986
1969 if (exists $self->{template}) { 1987 if (exists $self->{template}) {
1970 $self->{template}->set_font ($self->{font}) if $self->{font}; 1988 $self->{template}->set_font ($self->{font}) if $self->{font};
1971 $self->{template}->set_width ($self->{max_w} || -1); 1989 $self->{template}->set_width ($max_w);
1972 $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); 1990 $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE);
1973 1991
1974 my ($w2, $h2) = $self->{template}->size; 1992 my ($w2, $h2) = $self->{template}->size;
1975 1993
1976 $w = List::Util::max $w, $w2; 1994 $w = List::Util::max $w, $w2;
2032 2050
2033 [$self->{layout}->size] 2051 [$self->{layout}->size]
2034 }; 2052 };
2035 2053
2036 unless (exists $self->{ox}) { 2054 unless (exists $self->{ox}) {
2037 $self->{ox} = int ($self->{align} < 0 ? $self->{padding_x} 2055 $self->{ox} = $self->{padding_x} + int $self->{align} * ($self->{w} - $size->[0] - $self->{padding_x} * 2);
2038 : $self->{align} > 0 ? $self->{w} - $size->[0] - $self->{padding_x} 2056 $self->{oy} = $self->{padding_y} + int $self->{valign} * ($self->{h} - $size->[1] - $self->{padding_y} * 2);
2039 : ($self->{w} - $size->[0]) * 0.5);
2040
2041 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding_y}
2042 : $self->{valign} > 0 ? $self->{h} - $size->[1] - $self->{padding_y}
2043 : ($self->{h} - $size->[1]) * 0.5);
2044 2057
2045 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); 2058 $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
2046 }; 2059 };
2047 2060
2048# unless ($self->{list}) { 2061# unless ($self->{list}) {
2049# $self->{list} = CFPlus::OpenGL::glGenList; 2062# $self->{list} = DC::OpenGL::glGenList;
2050# CFPlus::OpenGL::glNewList $self->{list}; 2063# DC::OpenGL::glNewList $self->{list};
2051# $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); 2064# $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style});
2052# CFPlus::OpenGL::glEndList; 2065# DC::OpenGL::glEndList;
2053# } 2066# }
2054# 2067#
2055# CFPlus::OpenGL::glCallList $self->{list}; 2068# DC::OpenGL::glCallList $self->{list};
2056 2069
2057 $self->{layout}->draw; 2070 $self->{layout}->draw;
2058} 2071}
2059 2072
2060#sub destroy { 2073#sub destroy {
2061# my ($self) = @_; 2074# my ($self) = @_;
2062# 2075#
2063# CFPlus::OpenGL::glDeleteList delete $self->{list} if $self->{list}; 2076# DC::OpenGL::glDeleteList delete $self->{list} if $self->{list};
2064# 2077#
2065# $self->SUPER::destroy; 2078# $self->SUPER::destroy;
2066#} 2079#}
2067 2080
2068############################################################################# 2081#############################################################################
2069 2082
2070package CFPlus::UI::EntryBase; 2083package DC::UI::EntryBase;
2071 2084
2072our @ISA = CFPlus::UI::Label::; 2085our @ISA = DC::UI::Label::;
2073 2086
2074use CFPlus::OpenGL; 2087use DC::OpenGL;
2075 2088
2076sub new { 2089sub new {
2077 my $class = shift; 2090 my $class = shift;
2078 2091
2079 $class->SUPER::new ( 2092 $class->SUPER::new (
2083 active_bg => [0, 0, 1, .2], 2096 active_bg => [0, 0, 1, .2],
2084 active_fg => [1, 1, 1], 2097 active_fg => [1, 1, 1],
2085 active_outline => [1, 1, 0], 2098 active_outline => [1, 1, 0],
2086 can_hover => 1, 2099 can_hover => 1,
2087 can_focus => 1, 2100 can_focus => 1,
2101 align => 0,
2088 valign => 0, 2102 valign => 0.5,
2089 can_events => 1, 2103 can_events => 1,
2090 ellipsise => 0, 2104 ellipsise => 0,
2105 padding_x => 4,
2106 padding_y => 2,
2091 #text => ... 2107 #text => ...
2092 #hidden => "*", 2108 #hidden => "*",
2093 @_ 2109 @_
2094 ) 2110 )
2095} 2111}
2146 2162
2147 if ($uni == 8) { 2163 if ($uni == 8) {
2148 substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; 2164 substr $text, --$self->{cursor}, 1, "" if $self->{cursor};
2149 } elsif ($uni == 127) { 2165 } elsif ($uni == 127) {
2150 substr $text, $self->{cursor}, 1, ""; 2166 substr $text, $self->{cursor}, 1, "";
2151 } elsif ($sym == CFPlus::SDLK_LEFT) { 2167 } elsif ($sym == DC::SDLK_LEFT) {
2152 --$self->{cursor} if $self->{cursor}; 2168 --$self->{cursor} if $self->{cursor};
2153 } elsif ($sym == CFPlus::SDLK_RIGHT) { 2169 } elsif ($sym == DC::SDLK_RIGHT) {
2154 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 2170 ++$self->{cursor} if $self->{cursor} < length $self->{text};
2155 } elsif ($sym == CFPlus::SDLK_HOME) { 2171 } elsif ($sym == DC::SDLK_HOME) {
2156 # what a hack 2172 # what a hack
2157 $self->{cursor} = 2173 $self->{cursor} =
2158 (substr $self->{text}, 0, $self->{cursor}) =~ /^(.*\012)/ 2174 (substr $self->{text}, 0, $self->{cursor}) =~ /^(.*\012)/
2159 ? length $1 2175 ? length $1
2160 : 0; 2176 : 0;
2161 } elsif ($sym == CFPlus::SDLK_END) { 2177 } elsif ($sym == DC::SDLK_END) {
2162 # uh, again 2178 # uh, again
2163 $self->{cursor} = 2179 $self->{cursor} =
2164 (substr $self->{text}, $self->{cursor}) =~ /^([^\012]*)\012/ 2180 (substr $self->{text}, $self->{cursor}) =~ /^([^\012]*)\012/
2165 ? $self->{cursor} + length $1 2181 ? $self->{cursor} + length $1
2166 : length $self->{text}; 2182 : length $self->{text};
2269 } 2285 }
2270} 2286}
2271 2287
2272############################################################################# 2288#############################################################################
2273 2289
2274package CFPlus::UI::Entry; 2290package DC::UI::Entry;
2275 2291
2276our @ISA = CFPlus::UI::EntryBase::; 2292our @ISA = DC::UI::EntryBase::;
2277 2293
2278use CFPlus::OpenGL; 2294use DC::OpenGL;
2295
2296sub new {
2297 my $class = shift;
2298
2299 $class->SUPER::new (
2300 history_pointer => -1,
2301 @_
2302 )
2303}
2304
2279 2305
2280sub invoke_key_down { 2306sub invoke_key_down {
2281 my ($self, $ev) = @_; 2307 my ($self, $ev) = @_;
2282 2308
2283 my $sym = $ev->{sym}; 2309 my $sym = $ev->{sym};
2289 $self->{history_pointer} = -1; 2315 $self->{history_pointer} = -1;
2290 $self->{history_saveback} = ''; 2316 $self->{history_saveback} = '';
2291 $self->emit (activate => $txt); 2317 $self->emit (activate => $txt);
2292 $self->update; 2318 $self->update;
2293 2319
2294 } elsif ($sym == CFPlus::SDLK_UP) { 2320 } elsif ($sym == DC::SDLK_UP) {
2295 if ($self->{history_pointer} < 0) { 2321 if ($self->{history_pointer} < 0) {
2296 $self->{history_saveback} = $self->get_text; 2322 $self->{history_saveback} = $self->get_text;
2297 } 2323 }
2298 if (@{$self->{history} || []} > 0) { 2324 if (@{$self->{history} || []} > 0) {
2299 $self->{history_pointer}++; 2325 $self->{history_pointer}++;
2301 $self->{history_pointer} = @{$self->{history} || []} - 1; 2327 $self->{history_pointer} = @{$self->{history} || []} - 1;
2302 } 2328 }
2303 $self->set_text ($self->{history}->[$self->{history_pointer}]); 2329 $self->set_text ($self->{history}->[$self->{history_pointer}]);
2304 } 2330 }
2305 2331
2306 } elsif ($sym == CFPlus::SDLK_DOWN) { 2332 } elsif ($sym == DC::SDLK_DOWN) {
2307 $self->{history_pointer}--; 2333 $self->{history_pointer}--;
2308 $self->{history_pointer} = -1 if $self->{history_pointer} < 0; 2334 $self->{history_pointer} = -1 if $self->{history_pointer} < 0;
2309 2335
2310 if ($self->{history_pointer} >= 0) { 2336 if ($self->{history_pointer} >= 0) {
2311 $self->set_text ($self->{history}->[$self->{history_pointer}]); 2337 $self->set_text ($self->{history}->[$self->{history_pointer}]);
2312 } else { 2338 } else {
2339 if (defined $self->{history_saveback}) {
2313 $self->set_text ($self->{history_saveback}); 2340 $self->set_text ($self->{history_saveback});
2341 $self->{history_saveback} = undef;
2342 }
2314 } 2343 }
2315 2344
2316 } else { 2345 } else {
2317 return $self->SUPER::invoke_key_down ($ev) 2346 return $self->SUPER::invoke_key_down ($ev)
2318 } 2347 }
2320 1 2349 1
2321} 2350}
2322 2351
2323############################################################################# 2352#############################################################################
2324 2353
2325package CFPlus::UI::TextEdit; 2354package DC::UI::TextEdit;
2326 2355
2327our @ISA = CFPlus::UI::EntryBase::; 2356our @ISA = DC::UI::EntryBase::;
2328 2357
2329use CFPlus::OpenGL; 2358use DC::OpenGL;
2359
2360sub new {
2361 my $class = shift;
2362
2363 $class->SUPER::new (
2364 padding_y => 4,
2365
2366 @_
2367 )
2368}
2330 2369
2331sub move_cursor_ver { 2370sub move_cursor_ver {
2332 my ($self, $dy) = @_; 2371 my ($self, $dy) = @_;
2333 2372
2334 my ($y, $x) = $self->{layout}->index_to_line_x ($self->{cursor}); 2373 my ($line, $x) = $self->{layout}->index_to_line_x ($self->{cursor});
2335 2374
2336 $y += $dy; 2375 $line += $dy;
2337 2376
2338 if (defined (my $index = $self->{layout}->line_x_to_index ($y, $x))) { 2377 if (defined (my $index = $self->{layout}->line_x_to_index ($line, $x))) {
2339 $self->{cursor} = $index; 2378 $self->{cursor} = $index;
2340 delete $self->{cur_h}; 2379 delete $self->{cur_h};
2341 $self->update; 2380 $self->update;
2342 return; 2381 return;
2343 } 2382 }
2346sub invoke_key_down { 2385sub invoke_key_down {
2347 my ($self, $ev) = @_; 2386 my ($self, $ev) = @_;
2348 2387
2349 my $sym = $ev->{sym}; 2388 my $sym = $ev->{sym};
2350 2389
2351 if ($sym == CFPlus::SDLK_UP) { 2390 if ($sym == DC::SDLK_UP) {
2352 $self->move_cursor_ver (-1); 2391 $self->move_cursor_ver (-1);
2353 } elsif ($sym == CFPlus::SDLK_DOWN) { 2392 } elsif ($sym == DC::SDLK_DOWN) {
2354 $self->move_cursor_ver (+1); 2393 $self->move_cursor_ver (+1);
2355 } else { 2394 } else {
2356 return $self->SUPER::invoke_key_down ($ev) 2395 return $self->SUPER::invoke_key_down ($ev)
2357 } 2396 }
2358 2397
2359 1 2398 1
2360} 2399}
2361 2400
2362############################################################################# 2401#############################################################################
2363 2402
2364package CFPlus::UI::ButtonBin; 2403package DC::UI::ButtonBin;
2365 2404
2366our @ISA = CFPlus::UI::Bin::; 2405our @ISA = DC::UI::Bin::;
2367 2406
2368use CFPlus::OpenGL; 2407use DC::OpenGL;
2369 2408
2370my @tex = 2409my @tex =
2371 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2410 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
2372 qw(b1_button_inactive.png b1_button_active.png); 2411 qw(b1_button_inactive.png b1_button_active.png);
2373 2412
2374sub new { 2413sub new {
2375 my $class = shift; 2414 my $class = shift;
2376 2415
2377 $class->SUPER::new ( 2416 $class->SUPER::new (
2378 can_hover => 1, 2417 can_hover => 1,
2379 align => 0, 2418 align => 0.5,
2380 valign => 0, 2419 valign => 0.5,
2381 can_events => 1, 2420 can_events => 1,
2382 @_ 2421 @_
2383 ) 2422 )
2384} 2423}
2385 2424
2408 $self->SUPER::_draw; 2447 $self->SUPER::_draw;
2409} 2448}
2410 2449
2411############################################################################# 2450#############################################################################
2412 2451
2413package CFPlus::UI::Button; 2452package DC::UI::Button;
2414 2453
2415our @ISA = CFPlus::UI::Label::; 2454our @ISA = DC::UI::Label::;
2416 2455
2417use CFPlus::OpenGL; 2456use DC::OpenGL;
2418 2457
2419my @tex = 2458my @tex =
2420 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2459 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
2421 qw(b1_button_inactive.png b1_button_active.png); 2460 qw(b1_button_inactive.png b1_button_active.png);
2422 2461
2423sub new { 2462sub new {
2424 my $class = shift; 2463 my $class = shift;
2425 2464
2426 $class->SUPER::new ( 2465 $class->SUPER::new (
2427 padding_x => 4, 2466 padding_x => 8,
2428 padding_y => 4, 2467 padding_y => 4,
2429 fg => [1.0, 1.0, 1.0], 2468 fg => [1.0, 1.0, 1.0],
2430 active_fg => [0.8, 0.8, 0.8], 2469 active_fg => [0.8, 0.8, 0.8],
2431 can_hover => 1, 2470 can_hover => 1,
2432 align => 0, 2471 align => 0.5,
2433 valign => 0, 2472 valign => 0.5,
2434 can_events => 1, 2473 can_events => 1,
2435 @_ 2474 @_
2436 ) 2475 )
2437} 2476}
2438 2477
2463 $self->SUPER::_draw; 2502 $self->SUPER::_draw;
2464} 2503}
2465 2504
2466############################################################################# 2505#############################################################################
2467 2506
2468package CFPlus::UI::CheckBox; 2507package DC::UI::CheckBox;
2469 2508
2470our @ISA = CFPlus::UI::DrawBG::; 2509our @ISA = DC::UI::DrawBG::;
2471 2510
2472my @tex = 2511my @tex =
2473 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2512 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
2474 qw(c1_checkbox_bg.png c1_checkbox_active.png); 2513 qw(c1_checkbox_bg.png c1_checkbox_active.png);
2475 2514
2476use CFPlus::OpenGL; 2515use DC::OpenGL;
2477 2516
2478sub new { 2517sub new {
2479 my $class = shift; 2518 my $class = shift;
2480 2519
2481 $class->SUPER::new ( 2520 $class->SUPER::new (
2538 glDisable GL_TEXTURE_2D; 2577 glDisable GL_TEXTURE_2D;
2539} 2578}
2540 2579
2541############################################################################# 2580#############################################################################
2542 2581
2543package CFPlus::UI::Image; 2582package DC::UI::Image;
2544 2583
2545our @ISA = CFPlus::UI::Base::; 2584our @ISA = DC::UI::Base::;
2546 2585
2547use CFPlus::OpenGL; 2586use DC::OpenGL;
2548 2587
2549our %texture_cache; 2588our %texture_cache;
2550 2589
2551sub new { 2590sub new {
2552 my $class = shift; 2591 my $class = shift;
2559 2598
2560 $self->{path} || $self->{tex} 2599 $self->{path} || $self->{tex}
2561 or Carp::croak "'path' or 'tex' attributes required"; 2600 or Carp::croak "'path' or 'tex' attributes required";
2562 2601
2563 $self->{tex} ||= $texture_cache{$self->{path}} ||= 2602 $self->{tex} ||= $texture_cache{$self->{path}} ||=
2564 new_from_file CFPlus::Texture CFPlus::find_rcfile $self->{path}, mipmap => 1; 2603 new_from_file DC::Texture DC::find_rcfile $self->{path}, mipmap => 1;
2565 2604
2566 CFPlus::weaken $texture_cache{$self->{path}}; 2605 DC::weaken $texture_cache{$self->{path}};
2567 2606
2568 $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; 2607 $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h};
2569 2608
2570 $self 2609 $self
2571} 2610}
2572 2611
2573sub STORABLE_freeze { 2612sub STORABLE_freeze {
2574 my ($self, $cloning) = @_; 2613 my ($self, $cloning) = @_;
2575 2614
2576 $self->{path} 2615 $self->{path}
2577 or die "cannot serialise CFPlus::UI::Image on non-loadable images\n"; 2616 or die "cannot serialise DC::UI::Image on non-loadable images\n";
2578 2617
2579 $self->{path} 2618 $self->{path}
2580} 2619}
2581 2620
2582sub STORABLE_attach { 2621sub STORABLE_attach {
2613 glDisable GL_TEXTURE_2D; 2652 glDisable GL_TEXTURE_2D;
2614} 2653}
2615 2654
2616############################################################################# 2655#############################################################################
2617 2656
2618package CFPlus::UI::ImageButton; 2657package DC::UI::ImageButton;
2619 2658
2620our @ISA = CFPlus::UI::Image::; 2659our @ISA = DC::UI::Image::;
2621 2660
2622use CFPlus::OpenGL; 2661use DC::OpenGL;
2623 2662
2624my %textures; 2663my %textures;
2625 2664
2626sub new { 2665sub new {
2627 my $class = shift; 2666 my $class = shift;
2630 padding_x => 4, 2669 padding_x => 4,
2631 padding_y => 4, 2670 padding_y => 4,
2632 fg => [1, 1, 1], 2671 fg => [1, 1, 1],
2633 active_fg => [0, 0, 1], 2672 active_fg => [0, 0, 1],
2634 can_hover => 1, 2673 can_hover => 1,
2635 align => 0, 2674 align => 0.5,
2636 valign => 0, 2675 valign => 0.5,
2637 can_events => 1, 2676 can_events => 1,
2638 @_ 2677 @_
2639 ); 2678 );
2640} 2679}
2641 2680
2655 1 2694 1
2656} 2695}
2657 2696
2658############################################################################# 2697#############################################################################
2659 2698
2660package CFPlus::UI::VGauge; 2699package DC::UI::VGauge;
2661 2700
2662our @ISA = CFPlus::UI::Base::; 2701our @ISA = DC::UI::Base::;
2663 2702
2664use List::Util qw(min max); 2703use List::Util qw(min max);
2665 2704
2666use CFPlus::OpenGL; 2705use DC::OpenGL;
2667 2706
2668my %tex = ( 2707my %tex = (
2669 food => [ 2708 food => [
2670 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2709 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
2671 qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ 2710 qw/g1_food_gauge_empty.png g1_food_gauge_full.png/
2672 ], 2711 ],
2673 grace => [ 2712 grace => [
2674 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2713 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
2675 qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/ 2714 qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/
2676 ], 2715 ],
2677 hp => [ 2716 hp => [
2678 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2717 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
2679 qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ 2718 qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/
2680 ], 2719 ],
2681 mana => [ 2720 mana => [
2682 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } 2721 map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 }
2683 qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/ 2722 qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/
2684 ], 2723 ],
2685); 2724);
2686 2725
2687# eg. VGauge->new (gauge => 'food'), default gauge: food 2726# eg. VGauge->new (gauge => 'food'), default gauge: food
2790 glDisable GL_TEXTURE_2D; 2829 glDisable GL_TEXTURE_2D;
2791} 2830}
2792 2831
2793############################################################################# 2832#############################################################################
2794 2833
2795package CFPlus::UI::Progress; 2834package DC::UI::Progress;
2796 2835
2797our @ISA = CFPlus::UI::Label::; 2836our @ISA = DC::UI::Label::;
2798 2837
2799use CFPlus::OpenGL; 2838use DC::OpenGL;
2800 2839
2801sub new { 2840sub new {
2802 my ($class, %arg) = @_; 2841 my ($class, %arg) = @_;
2803 2842
2804 my $self = $class->SUPER::new ( 2843 my $self = $class->SUPER::new (
2805 fg => [1, 1, 1], 2844 fg => [1, 1, 1],
2806 bg => [0, 0, 1, 0.2], 2845 bg => [0, 0, 1, 0.2],
2807 bar => [0.7, 0.5, 0.1, 0.8], 2846 bar => [0.7, 0.5, 0.1, 0.8],
2808 outline => [0.4, 0.3, 0], 2847 outline => [0.4, 0.3, 0],
2809 fontsize => 0.9, 2848 fontsize => 0.9,
2810 valign => 0, 2849 valign => 0.5,
2811 align => 0, 2850 align => 0.5,
2812 can_events => 1, 2851 can_events => 1,
2813 ellipsise => 1, 2852 ellipsise => 1,
2814 label => "%d%%", 2853 label => "%d%%",
2815 %arg, 2854 %arg,
2816 ); 2855 );
2824 my ($self, $label) = @_; 2863 my ($self, $label) = @_;
2825 2864
2826 return if $self->{label} eq $label; 2865 return if $self->{label} eq $label;
2827 $self->{label} = $label; 2866 $self->{label} = $label;
2828 2867
2829 $self->CFPlus::UI::Progress::set_value (0 + delete $self->{value}); 2868 $self->DC::UI::Progress::set_value (0 + delete $self->{value});
2830} 2869}
2831 2870
2832sub set_value { 2871sub set_value {
2833 my ($self, $value) = @_; 2872 my ($self, $value) = @_;
2834 2873
2871 } 2910 }
2872} 2911}
2873 2912
2874############################################################################# 2913#############################################################################
2875 2914
2876package CFPlus::UI::ExperienceProgress; 2915package DC::UI::ExperienceProgress;
2877 2916
2878our @ISA = CFPlus::UI::Progress::; 2917our @ISA = DC::UI::Progress::;
2879 2918
2880sub new { 2919sub new {
2881 my ($class, %arg) = @_; 2920 my ($class, %arg) = @_;
2882 2921
2883 my $self = $class->SUPER::new ( 2922 my $self = $class->SUPER::new (
2928 $self->SUPER::set_value ($v); 2967 $self->SUPER::set_value ($v);
2929} 2968}
2930 2969
2931############################################################################# 2970#############################################################################
2932 2971
2933package CFPlus::UI::Gauge; 2972package DC::UI::Gauge;
2934 2973
2935our @ISA = CFPlus::UI::VBox::; 2974our @ISA = DC::UI::VBox::;
2936 2975
2937sub new { 2976sub new {
2938 my ($class, %arg) = @_; 2977 my ($class, %arg) = @_;
2939 2978
2940 my $self = $class->SUPER::new ( 2979 my $self = $class->SUPER::new (
2942 can_hover => 1, 2981 can_hover => 1,
2943 can_events => 1, 2982 can_events => 1,
2944 %arg, 2983 %arg,
2945 ); 2984 );
2946 2985
2947 $self->add ($self->{value} = new CFPlus::UI::Label valign => +1, align => 0, template => "999"); 2986 $self->add ($self->{value} = new DC::UI::Label valign => 1, align => 0.5, template => "999");
2948 $self->add ($self->{gauge} = new CFPlus::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); 2987 $self->add ($self->{gauge} = new DC::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1);
2949 $self->add ($self->{max} = new CFPlus::UI::Label valign => -1, align => 0, template => "999"); 2988 $self->add ($self->{max} = new DC::UI::Label valign => 0, align => 0.5, template => "999");
2950 2989
2951 $self 2990 $self
2952} 2991}
2953 2992
2954sub set_fontsize { 2993sub set_fontsize {
2975 $self->{value}->set_text ($val); 3014 $self->{value}->set_text ($val);
2976} 3015}
2977 3016
2978############################################################################# 3017#############################################################################
2979 3018
2980package CFPlus::UI::Slider; 3019package DC::UI::Slider;
2981 3020
2982use strict; 3021use strict;
2983 3022
2984use CFPlus::OpenGL; 3023use DC::OpenGL;
2985 3024
2986our @ISA = CFPlus::UI::DrawBG::; 3025our @ISA = DC::UI::DrawBG::;
2987 3026
2988my @tex = 3027my @tex =
2989 map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_ } 3028 map { new_from_file DC::Texture DC::find_rcfile $_ }
2990 qw(s1_slider.png s1_slider_bg.png); 3029 qw(s1_slider.png s1_slider_bg.png);
2991 3030
2992sub new { 3031sub new {
2993 my $class = shift; 3032 my $class = shift;
2994 3033
3090sub invoke_mouse_wheel { 3129sub invoke_mouse_wheel {
3091 my ($self, $ev) = @_; 3130 my ($self, $ev) = @_;
3092 3131
3093 my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx}; 3132 my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx};
3094 3133
3095 my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; 3134 my $pagepart = $ev->{mod} & DC::KMOD_SHIFT ? 1 : 0.2;
3096 3135
3097 $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); 3136 $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart);
3098 3137
3099 1 3138 1
3100} 3139}
3153 glDisable GL_TEXTURE_2D; 3192 glDisable GL_TEXTURE_2D;
3154} 3193}
3155 3194
3156############################################################################# 3195#############################################################################
3157 3196
3158package CFPlus::UI::ValSlider; 3197package DC::UI::ValSlider;
3159 3198
3160our @ISA = CFPlus::UI::HBox::; 3199our @ISA = DC::UI::HBox::;
3161 3200
3162sub new { 3201sub new {
3163 my ($class, %arg) = @_; 3202 my ($class, %arg) = @_;
3164 3203
3165 my $range = delete $arg{range}; 3204 my $range = delete $arg{range};
3166 3205
3167 my $self = $class->SUPER::new ( 3206 my $self = $class->SUPER::new (
3168 slider => (new CFPlus::UI::Slider expand => 1, range => $range), 3207 slider => (new DC::UI::Slider expand => 1, range => $range),
3169 entry => (new CFPlus::UI::Label text => "", template => delete $arg{template}), 3208 entry => (new DC::UI::Label text => "", template => delete $arg{template}),
3170 to_value => sub { shift }, 3209 to_value => sub { shift },
3171 from_value => sub { shift }, 3210 from_value => sub { shift },
3172 %arg, 3211 %arg,
3173 ); 3212 );
3174 3213
3194sub set_range { shift->{slider}->set_range (@_) } 3233sub set_range { shift->{slider}->set_range (@_) }
3195sub set_value { shift->{slider}->set_value (@_) } 3234sub set_value { shift->{slider}->set_value (@_) }
3196 3235
3197############################################################################# 3236#############################################################################
3198 3237
3199package CFPlus::UI::TextScroller; 3238package DC::UI::TextScroller;
3200 3239
3201our @ISA = CFPlus::UI::HBox::; 3240our @ISA = DC::UI::HBox::;
3202 3241
3203use CFPlus::OpenGL; 3242use DC::OpenGL;
3204 3243
3205sub new { 3244sub new {
3206 my $class = shift; 3245 my $class = shift;
3207 3246
3208 my $self = $class->SUPER::new ( 3247 my $self = $class->SUPER::new (
3210 can_events => 1, 3249 can_events => 1,
3211 indent => 0, 3250 indent => 0,
3212 #font => default_font 3251 #font => default_font
3213 @_, 3252 @_,
3214 3253
3215 layout => (new CFPlus::Layout), 3254 layout => (new DC::Layout),
3216 par => [], 3255 par => [],
3217 max_par => 0, 3256 max_par => 0,
3218 height => 0, 3257 height => 0,
3219 children => [ 3258 children => [
3220 (new CFPlus::UI::Empty expand => 1), 3259 (new DC::UI::Empty expand => 1),
3221 (new CFPlus::UI::Slider vertical => 1), 3260 (new DC::UI::Slider vertical => 1),
3222 ], 3261 ],
3223 ); 3262 );
3224 3263
3225 $self->{children}[1]->connect (changed => sub { $self->update }); 3264 $self->{children}[1]->connect (changed => sub { $self->update });
3226 3265
3282 $layout->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent}); 3321 $layout->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent});
3283 $layout->set_markup ($para->{markup}); 3322 $layout->set_markup ($para->{markup});
3284 3323
3285 $layout->set_shapes ( 3324 $layout->set_shapes (
3286 map 3325 map
3287 +(0, $_->baseline_shift +$_->{padding_y} - $_->{h}, $_->{w}, $_->{h}), 3326 +(0, $_->baseline_shift + $_->{padding_y} - $_->{h}, $_->{w}, $_->{h}),
3288 @{$para->{widget}} 3327 @{$para->{widget}}
3289 ); 3328 );
3290 3329
3291 $layout 3330 $layout
3292} 3331}
3409 $ROOT->on_post_alloc ($self => sub { 3448 $ROOT->on_post_alloc ($self => sub {
3410 $self->force_uptodate; 3449 $self->force_uptodate;
3411 3450
3412 my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; 3451 my ($W, $H) = @{$self->{children}[0]}{qw(w h)};
3413 3452
3414 $self->{texture} ||= new_from_opengl CFPlus::Texture $W, $H, sub { 3453 $self->{texture} ||= new_from_opengl DC::Texture $W, $H, sub {
3415 glClearColor 0, 0, 0, 0; 3454 glClearColor 0, 0, 0, 0;
3416 glClear GL_COLOR_BUFFER_BIT; 3455 glClear GL_COLOR_BUFFER_BIT;
3417 3456
3418 package CFPlus::UI::Base; 3457 package DC::UI::Base;
3419 local ($draw_x, $draw_y, $draw_w, $draw_h) = 3458 local ($draw_x, $draw_y, $draw_w, $draw_h) =
3420 (0, 0, $self->{w}, $self->{h}); 3459 (0, 0, $self->{w}, $self->{h});
3421 3460
3422 my $top = int $self->{children}[1]{range}[0]; 3461 my $top = int $self->{children}[1]{range}[0];
3423 3462
3482 $self->{children}[1]->draw; 3521 $self->{children}[1]->draw;
3483} 3522}
3484 3523
3485############################################################################# 3524#############################################################################
3486 3525
3487package CFPlus::UI::Animator; 3526package DC::UI::Animator;
3488 3527
3489use CFPlus::OpenGL; 3528use DC::OpenGL;
3490 3529
3491our @ISA = CFPlus::UI::Bin::; 3530our @ISA = DC::UI::Bin::;
3492 3531
3493sub moveto { 3532sub moveto {
3494 my ($self, $x, $y) = @_; 3533 my ($self, $x, $y) = @_;
3495 3534
3496 $self->{moveto} = [$self->{x}, $self->{y}, $x, $y]; 3535 $self->{moveto} = [$self->{x}, $self->{y}, $x, $y];
3524 glPopMatrix; 3563 glPopMatrix;
3525} 3564}
3526 3565
3527############################################################################# 3566#############################################################################
3528 3567
3529package CFPlus::UI::Flopper; 3568package DC::UI::Flopper;
3530 3569
3531our @ISA = CFPlus::UI::Button::; 3570our @ISA = DC::UI::Button::;
3532 3571
3533sub new { 3572sub new {
3534 my $class = shift; 3573 my $class = shift;
3535 3574
3536 my $self = $class->SUPER::new ( 3575 my $self = $class->SUPER::new (
3548 $self->{other}->toggle_visibility; 3587 $self->{other}->toggle_visibility;
3549} 3588}
3550 3589
3551############################################################################# 3590#############################################################################
3552 3591
3553package CFPlus::UI::Tooltip; 3592package DC::UI::Tooltip;
3554 3593
3555our @ISA = CFPlus::UI::Bin::; 3594our @ISA = DC::UI::Bin::;
3556 3595
3557use CFPlus::OpenGL; 3596use DC::OpenGL;
3558 3597
3559sub new { 3598sub new {
3560 my $class = shift; 3599 my $class = shift;
3561 3600
3562 $class->SUPER::new ( 3601 $class->SUPER::new (
3569 my ($self, $widget) = @_; 3608 my ($self, $widget) = @_;
3570 3609
3571 my $tip = $widget->{tooltip}; 3610 my $tip = $widget->{tooltip};
3572 $tip = $tip->($widget) if "CODE" eq ref $tip; 3611 $tip = $tip->($widget) if "CODE" eq ref $tip;
3573 3612
3574 $tip = CFPlus::Pod::section_label tooltip => $1 3613 $tip = DC::Pod::section_label tooltip => $1
3575 if $tip =~ /^#(.*)$/; 3614 if $tip =~ /^#(.*)$/;
3576 3615
3577 if ($ENV{CFPLUS_DEBUG} & 2) { 3616 if ($ENV{CFPLUS_DEBUG} & 2) {
3578 $tip .= "\n\n" . (ref $widget) . "\n" 3617 $tip .= "\n\n" . (ref $widget) . "\n"
3579 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" 3618 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n"
3582 } 3621 }
3583 3622
3584 $tip =~ s/^\n+//; 3623 $tip =~ s/^\n+//;
3585 $tip =~ s/\n+$//; 3624 $tip =~ s/\n+$//;
3586 3625
3587 $self->add (new CFPlus::UI::Label 3626 $self->add (new DC::UI::Label
3588 markup => $tip, 3627 markup => $tip,
3589 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 3628 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
3629 align => 0,
3590 fontsize => 0.8, 3630 fontsize => 0.8,
3591 style => 1, # FLAG_INVERSE 3631 style => 1, # FLAG_INVERSE
3592 ellipsise => 0, 3632 ellipsise => 0,
3593 font => ($widget->{tooltip_font} || $::FONT_PROP), 3633 font => ($widget->{tooltip_font} || $::FONT_PROP),
3594 ); 3634 );
3646 $self->SUPER::_draw; 3686 $self->SUPER::_draw;
3647} 3687}
3648 3688
3649############################################################################# 3689#############################################################################
3650 3690
3651package CFPlus::UI::Face; 3691package DC::UI::Face;
3652 3692
3653our @ISA = CFPlus::UI::DrawBG::; 3693our @ISA = DC::UI::DrawBG::;
3654 3694
3655use CFPlus::OpenGL; 3695use DC::OpenGL;
3656 3696
3657sub new { 3697sub new {
3658 my $class = shift; 3698 my $class = shift;
3659 3699
3660 my $self = $class->SUPER::new ( 3700 my $self = $class->SUPER::new (
3664 can_events => 0, 3704 can_events => 0,
3665 @_, 3705 @_,
3666 ); 3706 );
3667 3707
3668 if ($self->{anim} && $self->{animspeed}) { 3708 if ($self->{anim} && $self->{animspeed}) {
3669 CFPlus::weaken (my $widget = $self); 3709 DC::weaken (my $widget = $self);
3670 3710
3671 $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; 3711 $self->{animspeed} = List::Util::max 0.05, $self->{animspeed};
3672 $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed}; 3712 $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub {
3673 $self->{timer} = Event->timer (
3674 parked => 1,
3675 cb => sub {
3676 return unless $::CONN; 3713 return unless $::CONN;
3677 3714
3678 my $w = $widget 3715 my $w = $widget
3679 or return; 3716 or return;
3680 3717
3681 ++$w->{frame}; 3718 ++$w->{frame};
3682 $w->update_face; 3719 $w->update_face;
3683 3720
3684 # somehow, $widget can go away 3721 # somehow, $widget can go away
3685 $w->update; 3722 $w->update;
3686 $w->update_timer; 3723 $w->update_timer;
3687 },
3688 ); 3724 };
3689 3725
3690 $self->update_face; 3726 $self->update_face;
3691 $self->update_timer; 3727 $self->update_timer;
3692 } 3728 }
3693 3729
3698 my ($self) = @_; 3734 my ($self) = @_;
3699 3735
3700 return unless $self->{timer}; 3736 return unless $self->{timer};
3701 3737
3702 if ($self->{visible}) { 3738 if ($self->{visible}) {
3703 $self->{timer}->at (
3704 $self->{anim_start}
3705 + $self->{animspeed}
3706 * int 1.5 + (Event::time - $self->{anim_start}) / $self->{animspeed}
3707 );
3708 $self->{timer}->start; 3739 $self->{timer}->start;
3709 } else { 3740 } else {
3710 $self->{timer}->stop; 3741 $self->{timer}->stop;
3711 } 3742 }
3712} 3743}
3789 $self->SUPER::destroy; 3820 $self->SUPER::destroy;
3790} 3821}
3791 3822
3792############################################################################# 3823#############################################################################
3793 3824
3794package CFPlus::UI::Buttonbar; 3825package DC::UI::Buttonbar;
3795 3826
3796our @ISA = CFPlus::UI::HBox::; 3827our @ISA = DC::UI::HBox::;
3797 3828
3798# TODO: should actually wrap buttons and other goodies. 3829# TODO: should actually wrap buttons and other goodies.
3799 3830
3800############################################################################# 3831#############################################################################
3801 3832
3802package CFPlus::UI::Menu; 3833package DC::UI::Menu;
3803 3834
3804our @ISA = CFPlus::UI::Toplevel::; 3835our @ISA = DC::UI::Toplevel::;
3805 3836
3806use CFPlus::OpenGL; 3837use DC::OpenGL;
3807 3838
3808sub new { 3839sub new {
3809 my $class = shift; 3840 my $class = shift;
3810 3841
3811 my $self = $class->SUPER::new ( 3842 my $self = $class->SUPER::new (
3812 items => [], 3843 items => [],
3813 z => 100, 3844 z => 100,
3814 @_, 3845 @_,
3815 ); 3846 );
3816 3847
3817 $self->add ($self->{vbox} = new CFPlus::UI::VBox); 3848 $self->add ($self->{vbox} = new DC::UI::VBox);
3818 3849
3819 for my $item (@{ $self->{items} }) { 3850 for my $item (@{ $self->{items} }) {
3820 my ($widget, $cb, $tooltip) = @$item; 3851 my ($widget, $cb, $tooltip) = @$item;
3821 3852
3822 # handle various types of items, only text for now 3853 # handle various types of items, only text for now
3823 if (!ref $widget) { 3854 if (!ref $widget) {
3824 if ($widget =~ /\t/) { 3855 if ($widget =~ /\t/) {
3825 my ($left, $right) = split /\t/, $widget, 2; 3856 my ($left, $right) = split /\t/, $widget, 2;
3826 3857
3827 $widget = new CFPlus::UI::HBox 3858 $widget = new DC::UI::HBox
3828 can_hover => 1, 3859 can_hover => 1,
3829 can_events => 1, 3860 can_events => 1,
3830 tooltip => $tooltip, 3861 tooltip => $tooltip,
3831 children => [ 3862 children => [
3832 (new CFPlus::UI::Label markup => $left, expand => 1), 3863 (new DC::UI::Label markup => $left, expand => 1),
3833 (new CFPlus::UI::Label markup => $right, align => +1), 3864 (new DC::UI::Label markup => $right, align => 1),
3834 ], 3865 ],
3835 ; 3866 ;
3836 3867
3837 } else { 3868 } else {
3838 $widget = new CFPlus::UI::Label 3869 $widget = new DC::UI::Label
3839 can_hover => 1, 3870 can_hover => 1,
3840 can_events => 1, 3871 can_events => 1,
3872 align => 0,
3841 markup => $widget, 3873 markup => $widget,
3842 tooltip => $tooltip; 3874 tooltip => $tooltip;
3843 } 3875 }
3844 } 3876 }
3845 3877
3891 1 3923 1
3892} 3924}
3893 3925
3894############################################################################# 3926#############################################################################
3895 3927
3896package CFPlus::UI::Multiplexer; 3928package DC::UI::Multiplexer;
3897 3929
3898our @ISA = CFPlus::UI::Container::; 3930our @ISA = DC::UI::Container::;
3899 3931
3900sub new { 3932sub new {
3901 my $class = shift; 3933 my $class = shift;
3902 3934
3903 my $self = $class->SUPER::new ( 3935 my $self = $class->SUPER::new (
3964 $self->{current}->draw; 3996 $self->{current}->draw;
3965} 3997}
3966 3998
3967############################################################################# 3999#############################################################################
3968 4000
3969package CFPlus::UI::Notebook; 4001package DC::UI::Notebook;
3970 4002
3971use CFPlus::OpenGL; 4003use DC::OpenGL;
3972 4004
3973our @ISA = CFPlus::UI::VBox::; 4005our @ISA = DC::UI::VBox::;
3974 4006
3975sub new { 4007sub new {
3976 my $class = shift; 4008 my $class = shift;
3977 4009
3978 my $self = $class->SUPER::new ( 4010 my $self = $class->SUPER::new (
3979 buttonbar => (new CFPlus::UI::Buttonbar), 4011 buttonbar => (new DC::UI::Buttonbar),
3980 multiplexer => (new CFPlus::UI::Multiplexer expand => 1), 4012 multiplexer => (new DC::UI::Multiplexer expand => 1),
3981 active_outline => [.7, .7, 0.2], 4013 active_outline => [.7, .7, 0.2],
3982 # filter => # will be put between multiplexer and $self 4014 # filter => # will be put between multiplexer and $self
3983 @_, 4015 @_,
3984 ); 4016 );
3985 4017
3994 4026
3995 for my $child (@$widgets) { 4027 for my $child (@$widgets) {
3996 Scalar::Util::weaken $child; 4028 Scalar::Util::weaken $child;
3997 $child->{c_tab_} ||= do { 4029 $child->{c_tab_} ||= do {
3998 my $tab = 4030 my $tab =
3999 (UNIVERSAL::isa $child->{c_tab}, "CFPlus::UI::Base") 4031 (UNIVERSAL::isa $child->{c_tab}, "DC::UI::Base")
4000 ? $child->{c_tab} 4032 ? $child->{c_tab}
4001 : new CFPlus::UI::Button markup => $child->{c_tab}[0], tooltip => $child->{c_tab}[1]; 4033 : new DC::UI::Button markup => $child->{c_tab}[0], tooltip => $child->{c_tab}[1];
4002 4034
4003 $tab->connect (activate => sub { 4035 $tab->connect (activate => sub {
4004 $wself->set_current_page ($child); 4036 $wself->set_current_page ($child);
4005 }); 4037 });
4006 4038
4036} 4068}
4037 4069
4038sub pages { 4070sub pages {
4039 my ($self) = @_; 4071 my ($self) = @_;
4040 $self->{multiplexer}->children 4072 $self->{multiplexer}->children
4073}
4074
4075sub page_index {
4076 my ($self, $widget) = @_;
4077
4078 my $i = 0;
4079 for ($self->pages) {
4080 if ($_ eq $widget) { return $i };
4081 $i++;
4082 }
4083
4084 undef
4041} 4085}
4042 4086
4043sub add_tab { 4087sub add_tab {
4044 my ($self, $title, $widget, $tooltip) = @_; 4088 my ($self, $title, $widget, $tooltip) = @_;
4045 4089
4082 } 4126 }
4083} 4127}
4084 4128
4085############################################################################# 4129#############################################################################
4086 4130
4087package CFPlus::UI::Selector; 4131package DC::UI::Selector;
4088 4132
4089use utf8; 4133use utf8;
4090 4134
4091our @ISA = CFPlus::UI::Button::; 4135our @ISA = DC::UI::Button::;
4092 4136
4093sub new { 4137sub new {
4094 my $class = shift; 4138 my $class = shift;
4095 4139
4096 my $self = $class->SUPER::new ( 4140 my $self = $class->SUPER::new (
4113 my ($value, $title, $tooltip) = @$_; 4157 my ($value, $title, $tooltip) = @$_;
4114 4158
4115 push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }]; 4159 push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }];
4116 } 4160 }
4117 4161
4118 CFPlus::UI::Menu->new (items => \@menu_items)->popup ($ev); 4162 DC::UI::Menu->new (items => \@menu_items)->popup ($ev);
4119} 4163}
4120 4164
4121sub _set_value { 4165sub _set_value {
4122 my ($self, $value) = @_; 4166 my ($self, $value) = @_;
4123 4167
4124 my ($item) = grep $_->[0] eq $value, @{ $self->{options} } 4168 my ($item) = grep $_->[0] eq $value, @{ $self->{options} };
4169 $item ||= $self->{options}[0]
4125 or return; 4170 or return;
4126 4171
4127 $self->{value} = $item->[0]; 4172 $self->{value} = $item->[0];
4128 $self->set_markup ("$item->[1] ⇓"); 4173 $self->set_markup ("$item->[1] ⇓");
4129 $self->set_tooltip ($item->[2]); 4174# $self->set_tooltip ($item->[2]);
4130} 4175}
4131 4176
4132sub set_value { 4177sub set_value {
4133 my ($self, $value) = @_; 4178 my ($self, $value) = @_;
4134 4179
4136 4181
4137 $self->_set_value ($value); 4182 $self->_set_value ($value);
4138 $self->emit (changed => $value); 4183 $self->emit (changed => $value);
4139} 4184}
4140 4185
4186sub set_options {
4187 my ($self, $options) = @_;
4188
4189 $self->{options} = $options;
4190 $self->_set_value ($self->{value});
4191}
4192
4141############################################################################# 4193#############################################################################
4142 4194
4143package CFPlus::UI::Statusbox; 4195package DC::UI::Statusbox;
4144 4196
4145our @ISA = CFPlus::UI::VBox::; 4197our @ISA = DC::UI::VBox::;
4146 4198
4147sub new { 4199sub new {
4148 my $class = shift; 4200 my $class = shift;
4149 4201
4150 my $self = $class->SUPER::new ( 4202 my $self = $class->SUPER::new (
4151 fontsize => 0.8, 4203 fontsize => 0.8,
4152 @_, 4204 @_,
4153 ); 4205 );
4154 4206
4155 CFPlus::weaken (my $this = $self); 4207 DC::weaken (my $this = $self);
4156 4208
4157 $self->{timer} = Event->timer (after => 1, interval => 1, cb => sub { $this->reorder }); 4209 $self->{timer} = EV::timer 1, 1, sub { $this->reorder };
4158 4210
4159 $self 4211 $self
4160} 4212}
4161 4213
4162sub reorder { 4214sub reorder {
4163 my ($self) = @_; 4215 my ($self) = @_;
4164 my $NOW = Time::HiRes::time; 4216 my $NOW = Time::HiRes::time;
4165 4217
4166 # freeze display when hovering over any label 4218 # freeze display when hovering over any label
4167 return if $CFPlus::UI::TOOLTIP->{owner} 4219 return if $DC::UI::TOOLTIP->{owner}
4168 && grep $CFPlus::UI::TOOLTIP->{owner} == $_->{label}, 4220 && grep $DC::UI::TOOLTIP->{owner} == $_->{label},
4169 values %{ $self->{item} }; 4221 values %{ $self->{item} };
4170 4222
4171 while (my ($k, $v) = each %{ $self->{item} }) { 4223 while (my ($k, $v) = each %{ $self->{item} }) {
4172 delete $self->{item}{$k} if $v->{timeout} < $NOW; 4224 delete $self->{item}{$k} if $v->{timeout} < $NOW;
4173 } 4225 }
4226
4227 $self->{timer}->set (1, 1);
4174 4228
4175 my @widgets; 4229 my @widgets;
4176 4230
4177 my @items = sort { 4231 my @items = sort {
4178 $a->{pri} <=> $b->{pri} 4232 $a->{pri} <=> $b->{pri}
4179 or $b->{id} <=> $a->{id} 4233 or $b->{id} <=> $a->{id}
4180 } values %{ $self->{item} }; 4234 } values %{ $self->{item} };
4181
4182 $self->{timer}->interval (1);
4183 4235
4184 my $count = 10 + 1; 4236 my $count = 10 + 1;
4185 for my $item (@items) { 4237 for my $item (@items) {
4186 last unless --$count; 4238 last unless --$count;
4187 4239
4194 for ($short) { 4246 for ($short) {
4195 s/^\s+//; 4247 s/^\s+//;
4196 s/\s+/ /g; 4248 s/\s+/ /g;
4197 } 4249 }
4198 4250
4199 new CFPlus::UI::Label 4251 new DC::UI::Label
4200 markup => $short, 4252 markup => $short,
4201 tooltip => $item->{tooltip}, 4253 tooltip => $item->{tooltip},
4202 tooltip_font => $::FONT_PROP, 4254 tooltip_font => $::FONT_PROP,
4203 tooltip_width => 0.67, 4255 tooltip_width => 0.67,
4204 fontsize => $item->{fontsize} || $self->{fontsize}, 4256 fontsize => $item->{fontsize} || $self->{fontsize},
4205 max_w => $::WIDTH * 0.44, 4257 max_w => $::WIDTH * 0.44,
4258 align => 0,
4206 fg => [@{ $item->{fg} }], 4259 fg => [@{ $item->{fg} }],
4207 can_events => 1, 4260 can_events => 1,
4208 can_hover => 1 4261 can_hover => 1
4209 }; 4262 };
4210 4263
4211 if ((my $diff = $item->{timeout} - $NOW) < 2) { 4264 if ((my $diff = $item->{timeout} - $NOW) < 2) {
4212 $label->{fg}[3] = ($item->{fg}[3] || 1) * $diff / 2; 4265 $label->{fg}[3] = ($item->{fg}[3] || 1) * $diff / 2;
4213 $label->update; 4266 $label->update;
4214 $label->set_max_size (undef, $label->{req_h} * $diff) 4267 $label->set_max_size (undef, $label->{req_h} * $diff)
4215 if $diff < 1; 4268 if $diff < 1;
4216 $self->{timer}->interval (1/30); 4269 $self->{timer}->set (1/30, 1/30);
4217 } else { 4270 } else {
4218 $label->{fg}[3] = $item->{fg}[3] || 1; 4271 $label->{fg}[3] = $item->{fg}[3] || 1;
4219 } 4272 }
4220 4273
4221 push @widgets, $label; 4274 push @widgets, $label;
4283 $self->SUPER::destroy; 4336 $self->SUPER::destroy;
4284} 4337}
4285 4338
4286############################################################################# 4339#############################################################################
4287 4340
4288package CFPlus::UI::Root; 4341package DC::UI::Root;
4289 4342
4290our @ISA = CFPlus::UI::Container::; 4343our @ISA = DC::UI::Container::;
4291 4344
4292use List::Util qw(min max); 4345use List::Util qw(min max);
4293 4346
4294use CFPlus::OpenGL; 4347use DC::OpenGL;
4295 4348
4296sub new { 4349sub new {
4297 my $class = shift; 4350 my $class = shift;
4298 4351
4299 my $self = $class->SUPER::new ( 4352 my $self = $class->SUPER::new (
4300 visible => 1, 4353 visible => 1,
4301 @_, 4354 @_,
4302 ); 4355 );
4303 4356
4304 CFPlus::weaken ($self->{root} = $self); 4357 DC::weaken ($self->{root} = $self);
4305 4358
4306 $self 4359 $self
4307} 4360}
4308 4361
4309sub size_request { 4362sub size_request {
4357} 4410}
4358 4411
4359sub update { 4412sub update {
4360 my ($self) = @_; 4413 my ($self) = @_;
4361 4414
4362 $::WANT_REFRESH->start; 4415 $::WANT_REFRESH = 1;
4363} 4416}
4364 4417
4365sub add { 4418sub add {
4366 my ($self, @children) = @_; 4419 my ($self, @children) = @_;
4367 4420
4434 4487
4435 delete $queue{$widget+0}; 4488 delete $queue{$widget+0};
4436 4489
4437 my ($w, $h) = $widget->size_request; 4490 my ($w, $h) = $widget->size_request;
4438 4491
4439 $w = max $widget->{min_w}, $w + $widget->{padding_x} * 2; 4492 $w += $widget->{padding_x} * 2;
4440 $h = max $widget->{min_h}, $h + $widget->{padding_y} * 2; 4493 $h += $widget->{padding_y} * 2;
4494
4495 $w = max $widget->{min_w}, $w;
4496 $h = max $widget->{min_h}, $h;
4441 4497
4442 $w = min $widget->{max_w}, $w if exists $widget->{max_w}; 4498 $w = min $widget->{max_w}, $w if exists $widget->{max_w};
4443 $h = min $widget->{max_h}, $h if exists $widget->{max_h}; 4499 $h = min $widget->{max_h}, $h if exists $widget->{max_h};
4444 4500
4445 $w = $widget->{force_w} if exists $widget->{force_w}; 4501 $w = $widget->{force_w} if exists $widget->{force_w};
4512 glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000; 4568 glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000;
4513 glMatrixMode GL_MODELVIEW; 4569 glMatrixMode GL_MODELVIEW;
4514 glLoadIdentity; 4570 glLoadIdentity;
4515 4571
4516 { 4572 {
4517 package CFPlus::UI::Base; 4573 package DC::UI::Base;
4518 4574
4519 local ($draw_x, $draw_y, $draw_w, $draw_h) = 4575 local ($draw_x, $draw_y, $draw_w, $draw_h) =
4520 (0, 0, $self->{w}, $self->{h}); 4576 (0, 0, $self->{w}, $self->{h});
4521 4577
4522 $self->_draw; 4578 $self->_draw;
4523 } 4579 }
4524} 4580}
4525 4581
4526############################################################################# 4582#############################################################################
4527 4583
4528package CFPlus::UI; 4584package DC::UI;
4529 4585
4530$ROOT = new CFPlus::UI::Root; 4586$ROOT = new DC::UI::Root;
4531$TOOLTIP = new CFPlus::UI::Tooltip z => 900; 4587$TOOLTIP = new DC::UI::Tooltip z => 900;
4532 4588
45331 45891
4534 4590

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines