… | |
… | |
8 | use CFClient; |
8 | use CFClient; |
9 | |
9 | |
10 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
10 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
11 | |
11 | |
12 | our $ROOT; |
12 | our $ROOT; |
|
|
13 | our $TOOLTIP; |
13 | our $BUTTON_STATE; |
14 | our $BUTTON_STATE; |
|
|
15 | |
|
|
16 | sub check_tooltip { |
|
|
17 | if (!$GRAB) { |
|
|
18 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
|
|
19 | if (exists $widget->{tooltip}) { |
|
|
20 | |
|
|
21 | if ($TOOLTIP->{owner} != $widget) { |
|
|
22 | $TOOLTIP->{owner} = $widget; |
|
|
23 | $TOOLTIP->set_text ($widget->{tooltip}); |
|
|
24 | $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); |
|
|
25 | $TOOLTIP->show; |
|
|
26 | } |
|
|
27 | |
|
|
28 | return; |
|
|
29 | } |
|
|
30 | } |
|
|
31 | } |
|
|
32 | |
|
|
33 | $TOOLTIP->hide; |
|
|
34 | delete $TOOLTIP->{owner}; |
|
|
35 | } |
14 | |
36 | |
15 | # class methods for events |
37 | # class methods for events |
16 | sub feed_sdl_key_down_event { |
38 | sub feed_sdl_key_down_event { |
17 | $FOCUS->key_down ($_[0]) if $FOCUS; |
39 | $FOCUS->key_down ($_[0]) if $FOCUS; |
18 | } |
40 | } |
… | |
… | |
28 | if (!$BUTTON_STATE) { |
50 | if (!$BUTTON_STATE) { |
29 | my $widget = $ROOT->find_widget ($x, $y); |
51 | my $widget = $ROOT->find_widget ($x, $y); |
30 | |
52 | |
31 | $GRAB = $widget; |
53 | $GRAB = $widget; |
32 | $GRAB->update if $GRAB; |
54 | $GRAB->update if $GRAB; |
|
|
55 | |
|
|
56 | check_tooltip; |
33 | } |
57 | } |
34 | |
58 | |
35 | $BUTTON_STATE |= 1 << ($ev->{button} - 1); |
59 | $BUTTON_STATE |= 1 << ($ev->{button} - 1); |
36 | |
60 | |
37 | $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; |
61 | $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; |
… | |
… | |
49 | |
73 | |
50 | if (!$BUTTON_STATE) { |
74 | if (!$BUTTON_STATE) { |
51 | my $grab = $GRAB; undef $GRAB; |
75 | my $grab = $GRAB; undef $GRAB; |
52 | $grab->update if $grab; |
76 | $grab->update if $grab; |
53 | $GRAB->update if $GRAB; |
77 | $GRAB->update if $GRAB; |
|
|
78 | |
|
|
79 | check_tooltip; |
54 | } |
80 | } |
55 | } |
81 | } |
56 | |
82 | |
57 | sub feed_sdl_motion_event { |
83 | sub feed_sdl_motion_event { |
58 | my ($ev) = @_; |
84 | my ($ev) = @_; |
… | |
… | |
63 | if ($widget != $HOVER) { |
89 | if ($widget != $HOVER) { |
64 | my $hover = $HOVER; $HOVER = $widget; |
90 | my $hover = $HOVER; $HOVER = $widget; |
65 | |
91 | |
66 | $hover->update if $hover && $hover->{can_hover}; |
92 | $hover->update if $hover && $hover->{can_hover}; |
67 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
93 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
|
|
94 | |
|
|
95 | check_tooltip; |
68 | } |
96 | } |
69 | |
97 | |
70 | $HOVER->mouse_motion ($ev, $HOVER->coord2local ($x, $y)) if $HOVER; |
98 | $HOVER->mouse_motion ($ev, $HOVER->coord2local ($x, $y)) if $HOVER; |
71 | } |
99 | } |
72 | |
100 | |
… | |
… | |
96 | |
124 | |
97 | my $self = bless { |
125 | my $self = bless { |
98 | x => 0, |
126 | x => 0, |
99 | y => 0, |
127 | y => 0, |
100 | z => 0, |
128 | z => 0, |
|
|
129 | can_events => 1, |
101 | @_ |
130 | @_ |
102 | }, $class; |
131 | }, $class; |
103 | |
132 | |
104 | for (keys %$self) { |
133 | for (keys %$self) { |
105 | if (/^connect_(.*)$/) { |
134 | if (/^connect_(.*)$/) { |
… | |
… | |
140 | 0 |
169 | 0 |
141 | } |
170 | } |
142 | |
171 | |
143 | sub size_request { |
172 | sub size_request { |
144 | require Carp; |
173 | require Carp; |
145 | Carp::confess "size_request is abtract"; |
174 | Carp::confess "size_request is abstract"; |
146 | } |
175 | } |
147 | |
176 | |
148 | sub configure { |
177 | sub configure { |
149 | my ($self, $x, $y, $w, $h) = @_; |
178 | my ($self, $x, $y, $w, $h) = @_; |
150 | |
179 | |
151 | $self->{x} = $x; |
|
|
152 | $self->{y} = $y; |
|
|
153 | |
|
|
154 | if ($self->{aspect}) { |
180 | if ($self->{aspect}) { |
155 | $w = List::Util::min $w, int $h * $self->{aspect}; |
181 | my $w2 = List::Util::min $w, int $h * $self->{aspect}; |
156 | $h = List::Util::min $h, int $w / $self->{aspect}; |
182 | my $h2 = List::Util::min $h, int $w / $self->{aspect}; |
157 | } |
|
|
158 | |
183 | |
|
|
184 | # use alignment to adjust x, y |
|
|
185 | |
|
|
186 | $x += int +($w - $w2) * 0.5; |
|
|
187 | $y += int +($h - $h2) * 0.5; |
|
|
188 | |
|
|
189 | ($w, $h) = ($w2, $h2); |
|
|
190 | } |
|
|
191 | |
|
|
192 | if ($self->{x} != $x || $self->{y} != $y) { |
|
|
193 | $self->{x} = $x; |
|
|
194 | $self->{y} = $y; |
|
|
195 | $self->update; |
|
|
196 | } |
|
|
197 | |
159 | return unless $self->{w} != $w || $self->{h} != $h; |
198 | if ($self->{w} != $w || $self->{h} != $h) { |
160 | |
|
|
161 | $self->{w} = $w; |
199 | $self->{w} = $w; |
162 | $self->{h} = $h; |
200 | $self->{h} = $h; |
163 | |
201 | |
164 | $self->size_allocate ($w, $h); |
202 | $self->size_allocate ($w, $h); |
165 | $self->update; |
203 | $self->update; |
|
|
204 | } |
166 | } |
205 | } |
167 | |
206 | |
168 | sub size_allocate { |
207 | sub size_allocate { |
169 | # nothing to be done |
208 | # nothing to be done |
170 | } |
209 | } |
… | |
… | |
268 | } |
307 | } |
269 | |
308 | |
270 | sub find_widget { |
309 | sub find_widget { |
271 | my ($self, $x, $y) = @_; |
310 | my ($self, $x, $y) = @_; |
272 | |
311 | |
|
|
312 | return () unless $self->{can_events}; |
|
|
313 | |
273 | return $self |
314 | return $self |
274 | if $x >= $self->{x} && $x < $self->{x} + $self->{w} |
315 | if $x >= $self->{x} && $x < $self->{x} + $self->{w} |
275 | && $y >= $self->{y} && $y < $self->{y} + $self->{h}; |
316 | && $y >= $self->{y} && $y < $self->{y} + $self->{h}; |
276 | |
317 | |
277 | () |
318 | () |
… | |
… | |
284 | } |
325 | } |
285 | |
326 | |
286 | sub check_size { |
327 | sub check_size { |
287 | my ($self) = @_; |
328 | my ($self) = @_; |
288 | |
329 | |
|
|
330 | return unless $self->{parent}; |
|
|
331 | |
289 | my ($w, $h) = $self->size_request; |
332 | my ($w, $h) = $self->size_request; |
290 | |
333 | |
291 | if ($w != $self->{req_w} || $h != $self->{req_h}) { |
334 | if ($w != $self->{req_w} || $h != $self->{req_h}) { |
292 | $self->{req_w} = $w; |
335 | $self->{req_w} = $w; |
293 | $self->{req_h} = $h; |
336 | $self->{req_h} = $h; |
294 | |
337 | |
295 | $self->{parent}->check_size |
338 | $self->{parent}->check_size; |
296 | if $self->{parent}; |
|
|
297 | } |
339 | } |
298 | } |
340 | } |
299 | |
341 | |
300 | sub update { |
342 | sub update { |
301 | my ($self) = @_; |
343 | my ($self) = @_; |
… | |
… | |
368 | |
410 | |
369 | package CFClient::UI::Empty; |
411 | package CFClient::UI::Empty; |
370 | |
412 | |
371 | our @ISA = CFClient::UI::Base::; |
413 | our @ISA = CFClient::UI::Base::; |
372 | |
414 | |
|
|
415 | sub new { |
|
|
416 | my ($class, %arg) = @_; |
|
|
417 | $class->SUPER::new (can_events => 0, %arg); |
|
|
418 | } |
|
|
419 | |
373 | sub size_request { |
420 | sub size_request { |
374 | (0, 0) |
421 | (0, 0) |
375 | } |
422 | } |
376 | |
423 | |
377 | sub draw { } |
424 | sub draw { } |
… | |
… | |
385 | sub new { |
432 | sub new { |
386 | my ($class, %arg) = @_; |
433 | my ($class, %arg) = @_; |
387 | |
434 | |
388 | my $children = delete $arg{children} || []; |
435 | my $children = delete $arg{children} || []; |
389 | |
436 | |
390 | my $self = $class->SUPER::new (children => [], %arg); |
437 | my $self = $class->SUPER::new (children => [], can_events => 0, %arg); |
391 | $self->add ($_) for @$children; |
438 | $self->add ($_) for @$children; |
392 | |
439 | |
393 | $self |
440 | $self |
394 | } |
441 | } |
395 | |
442 | |
… | |
… | |
414 | delete $child->{parent}; |
461 | delete $child->{parent}; |
415 | |
462 | |
416 | $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; |
463 | $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; |
417 | |
464 | |
418 | $self->check_size; |
465 | $self->check_size; |
|
|
466 | $self->update; |
419 | } |
467 | } |
420 | |
468 | |
421 | sub find_widget { |
469 | sub find_widget { |
422 | my ($self, $x, $y) = @_; |
470 | my ($self, $x, $y) = @_; |
423 | |
471 | |
… | |
… | |
551 | sub new { die } |
599 | sub new { die } |
552 | |
600 | |
553 | sub size_request { |
601 | sub size_request { |
554 | my ($self) = @_; |
602 | my ($self) = @_; |
555 | |
603 | |
556 | @$self{qw(child_w child_h)} = $self->child->size_request; |
604 | @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; |
557 | $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); |
605 | $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); |
558 | |
606 | |
559 | @$self{qw(child_w child_h)} |
607 | @$self{qw(child_w child_h)} |
560 | } |
608 | } |
561 | |
609 | |
… | |
… | |
571 | package CFClient::UI::Frame; |
619 | package CFClient::UI::Frame; |
572 | |
620 | |
573 | our @ISA = CFClient::UI::Bin::; |
621 | our @ISA = CFClient::UI::Bin::; |
574 | |
622 | |
575 | use CFClient::OpenGL; |
623 | use CFClient::OpenGL; |
576 | |
|
|
577 | sub size_request { |
|
|
578 | my ($self) = @_; |
|
|
579 | my $chld = $self->child |
|
|
580 | or return (0, 0); |
|
|
581 | |
|
|
582 | $chld->move (2, 2); |
|
|
583 | |
|
|
584 | map { $_ + 4 } $chld->size_request; |
|
|
585 | } |
|
|
586 | |
|
|
587 | sub size_allocate { |
|
|
588 | my ($self, $x, $y, $w, $h) = @_; |
|
|
589 | |
|
|
590 | $self->child->configure (2, 2, $w - 4, $h - 4); |
|
|
591 | } |
|
|
592 | |
|
|
593 | sub _draw { |
|
|
594 | my ($self) = @_; |
|
|
595 | |
|
|
596 | my $chld = $self->child; |
|
|
597 | |
|
|
598 | my ($w, $h) = $chld->size_request; |
|
|
599 | |
|
|
600 | glBegin GL_QUADS; |
|
|
601 | glColor 0, 0, 0; |
|
|
602 | glVertex 0 , 0; |
|
|
603 | glVertex 0 , $h + 4; |
|
|
604 | glVertex $w + 4 , $h + 4; |
|
|
605 | glVertex $w + 4 , 0; |
|
|
606 | glEnd; |
|
|
607 | |
|
|
608 | $chld->draw; |
|
|
609 | } |
|
|
610 | |
|
|
611 | ############################################################################# |
|
|
612 | |
|
|
613 | package CFClient::UI::FancyFrame; |
|
|
614 | |
|
|
615 | our @ISA = CFClient::UI::Bin::; |
|
|
616 | |
|
|
617 | use CFClient::OpenGL; |
|
|
618 | |
|
|
619 | my @tex = |
|
|
620 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
621 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
|
|
622 | |
624 | |
623 | sub new { |
625 | sub new { |
624 | my $class = shift; |
626 | my $class = shift; |
625 | |
627 | |
626 | # TODO: user_x, user_y, overwrite moveto? |
|
|
627 | |
|
|
628 | $class->SUPER::new ( |
628 | my $self = $class->SUPER::new ( |
629 | bg => [1, 1, 1, 1], |
629 | bg => [1, 1, 1, 1], |
630 | border_bg => [1, 1, 1, 1], |
630 | border_bg => [1, 1, 1, 1], |
631 | border => 0.8, |
631 | border => 0.8, |
632 | @_ |
632 | @_ |
633 | ) |
633 | ); |
|
|
634 | |
|
|
635 | $self |
|
|
636 | } |
|
|
637 | |
|
|
638 | sub set_size { |
|
|
639 | my ($self, $w, $h) = @_; |
|
|
640 | $self->{req_w} = $w; |
|
|
641 | $self->{req_h} = $h; |
|
|
642 | $self->check_size; |
|
|
643 | } |
|
|
644 | |
|
|
645 | sub size_request { |
|
|
646 | my ($self) = @_; |
|
|
647 | ($self->{req_w}, $self->{req_h}) |
|
|
648 | } |
|
|
649 | |
|
|
650 | sub size_allocate { |
|
|
651 | my ($self, $w, $h) = @_; |
|
|
652 | $self->{w} = $w; |
|
|
653 | $self->{h} = $h; |
|
|
654 | $self->child->configure (0, 0, $w, $h); |
|
|
655 | } |
|
|
656 | |
|
|
657 | sub _draw { |
|
|
658 | my ($self) = @_; |
|
|
659 | |
|
|
660 | my ($w, $h) = ($self->{w}, $self->{h}); |
|
|
661 | |
|
|
662 | glEnable GL_BLEND; |
|
|
663 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
664 | glEnable GL_TEXTURE_2D; |
|
|
665 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
666 | |
|
|
667 | # glBegin GL_QUADS; |
|
|
668 | # glColor 0, 0, 0, 0; |
|
|
669 | # glVertex 0 , 0; |
|
|
670 | # glVertex 0 , $h; |
|
|
671 | # glVertex $w, $h; |
|
|
672 | # glVertex $w, 0; |
|
|
673 | # glEnd; |
|
|
674 | |
|
|
675 | |
|
|
676 | $self->child->draw; |
|
|
677 | glDisable GL_BLEND; |
|
|
678 | glDisable GL_TEXTURE_2D; |
|
|
679 | } |
|
|
680 | |
|
|
681 | ############################################################################# |
|
|
682 | |
|
|
683 | package CFClient::UI::FancyFrame; |
|
|
684 | |
|
|
685 | our @ISA = CFClient::UI::Bin::; |
|
|
686 | |
|
|
687 | use CFClient::OpenGL; |
|
|
688 | |
|
|
689 | my @tex = |
|
|
690 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
691 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
|
|
692 | |
|
|
693 | sub new { |
|
|
694 | my $class = shift; |
|
|
695 | |
|
|
696 | # TODO: user_x, user_y, overwrite moveto? |
|
|
697 | |
|
|
698 | my $self = $class->SUPER::new ( |
|
|
699 | bg => [1, 1, 1, 1], |
|
|
700 | border_bg => [1, 1, 1, 1], |
|
|
701 | border => 0.8, |
|
|
702 | can_events => 1, |
|
|
703 | @_ |
|
|
704 | ); |
|
|
705 | |
|
|
706 | $self->{title} &&= new CFClient::UI::Label |
|
|
707 | align => 0, |
|
|
708 | valign => 1, |
|
|
709 | text => $self->{title}, |
|
|
710 | fontsize => 1; |
|
|
711 | |
|
|
712 | $self |
634 | } |
713 | } |
635 | |
714 | |
636 | sub border { |
715 | sub border { |
637 | int $_[0]{border} * $::FONTSIZE |
716 | int $_[0]{border} * $::FONTSIZE |
638 | } |
717 | } |
… | |
… | |
653 | sub size_allocate { |
732 | sub size_allocate { |
654 | my ($self, $w, $h) = @_; |
733 | my ($self, $w, $h) = @_; |
655 | |
734 | |
656 | $h -= List::Util::max 0, $self->border * 2; |
735 | $h -= List::Util::max 0, $self->border * 2; |
657 | $w -= List::Util::max 0, $self->border * 2; |
736 | $w -= List::Util::max 0, $self->border * 2; |
|
|
737 | |
|
|
738 | $self->{title}->configure ($self->border, $self->border - $::FONTSIZE * 2, $w, $::FONTSIZE * 2) |
|
|
739 | if $self->{title}; |
658 | |
740 | |
659 | $self->child->configure ($self->border, $self->border, $w, $h); |
741 | $self->child->configure ($self->border, $self->border, $w, $h); |
660 | } |
742 | } |
661 | |
743 | |
662 | sub button_down { |
744 | sub button_down { |
… | |
… | |
742 | $bg->draw_quad ($border, $border, $cw, $ch); |
824 | $bg->draw_quad ($border, $border, $cw, $ch); |
743 | |
825 | |
744 | glDisable GL_TEXTURE_2D; |
826 | glDisable GL_TEXTURE_2D; |
745 | glDisable GL_BLEND; |
827 | glDisable GL_BLEND; |
746 | |
828 | |
|
|
829 | $self->{title}->draw if $self->{title}; |
747 | $self->child->draw; |
830 | $self->child->draw; |
748 | } |
831 | } |
749 | |
832 | |
750 | ############################################################################# |
833 | ############################################################################# |
751 | |
834 | |
… | |
… | |
793 | or next; |
876 | or next; |
794 | |
877 | |
795 | for my $x (0 .. $#$row) { |
878 | for my $x (0 .. $#$row) { |
796 | my $widget = $row->[$x] |
879 | my $widget = $row->[$x] |
797 | or next; |
880 | or next; |
798 | my ($w, $h) = $widget->size_request; |
881 | my ($w, $h) = @$widget{qw(req_w req_h)}; |
799 | |
882 | |
800 | $w[$x] = max $w[$x], $w; |
883 | $w[$x] = max $w[$x], $w; |
801 | $h[$y] = max $h[$y], $h; |
884 | $h[$y] = max $h[$y], $h; |
802 | } |
885 | } |
803 | } |
886 | } |
… | |
… | |
908 | |
991 | |
909 | ($h, $w) = ($w, $h); |
992 | ($h, $w) = ($w, $h); |
910 | |
993 | |
911 | my $children = $self->{children}; |
994 | my $children = $self->{children}; |
912 | |
995 | |
913 | my @h = map +($_->size_request)[0], @$children; |
996 | my @h = map $_->{req_w}, @$children; |
914 | |
997 | |
915 | my $req_h = List::Util::sum @h; |
998 | my $req_h = List::Util::sum @h; |
916 | |
999 | |
917 | if ($req_h > $h) { |
1000 | if ($req_h > $h) { |
918 | # ah well, not enough space |
1001 | # ah well, not enough space |
… | |
… | |
966 | sub size_allocate { |
1049 | sub size_allocate { |
967 | my ($self, $w, $h) = @_; |
1050 | my ($self, $w, $h) = @_; |
968 | |
1051 | |
969 | my $children = $self->{children}; |
1052 | my $children = $self->{children}; |
970 | |
1053 | |
971 | my @h = map +($_->size_request)[1], @$children; |
1054 | my @h = map $_->{req_h}, @$children; |
972 | |
1055 | |
973 | my $req_h = List::Util::sum @h; |
1056 | my $req_h = List::Util::sum @h; |
974 | |
1057 | |
975 | if ($req_h > $h) { |
1058 | if ($req_h > $h) { |
976 | # ah well, not enough space |
1059 | # ah well, not enough space |
… | |
… | |
1017 | text => "", |
1100 | text => "", |
1018 | align => -1, |
1101 | align => -1, |
1019 | valign => -1, |
1102 | valign => -1, |
1020 | padding => 2, |
1103 | padding => 2, |
1021 | layout => new CFClient::Layout, |
1104 | layout => new CFClient::Layout, |
|
|
1105 | can_events => 0, |
1022 | %arg |
1106 | %arg |
1023 | ); |
1107 | ); |
1024 | |
1108 | |
1025 | $self->{xxx}++ if $self->{text} eq "Client Setup" && $self->{align};#d# |
1109 | if (exists $self->{template}) { |
|
|
1110 | my $layout = new CFClient::Layout; |
|
|
1111 | $layout->set_text (delete $self->{template}); |
|
|
1112 | $self->{template} = $layout; |
|
|
1113 | } |
1026 | |
1114 | |
1027 | $self->set_text (delete $self->{text}) if exists $self->{text}; |
1115 | $self->set_text (delete $self->{text}) if exists $self->{text}; |
1028 | $self->set_markup (delete $self->{markup}) if exists $self->{markup}; |
1116 | $self->set_markup (delete $self->{markup}) if exists $self->{markup}; |
1029 | |
1117 | |
1030 | $self |
1118 | $self |
… | |
… | |
1044 | my ($self, $text) = @_; |
1132 | my ($self, $text) = @_; |
1045 | |
1133 | |
1046 | $self->{layout}->set_text ($text); |
1134 | $self->{layout}->set_text ($text); |
1047 | |
1135 | |
1048 | delete $self->{texture}; |
1136 | delete $self->{texture}; |
|
|
1137 | $self->check_size; |
1049 | $self->update; |
1138 | $self->update; |
1050 | } |
1139 | } |
1051 | |
1140 | |
1052 | sub set_markup { |
1141 | sub set_markup { |
1053 | my ($self, $markup) = @_; |
1142 | my ($self, $markup) = @_; |
1054 | |
1143 | |
1055 | $self->{layout}->set_markup ($markup); |
1144 | $self->{layout}->set_markup ($markup); |
1056 | |
1145 | |
1057 | delete $self->{texture}; |
1146 | delete $self->{texture}; |
|
|
1147 | $self->check_size; |
1058 | $self->update; |
1148 | $self->update; |
1059 | } |
1149 | } |
1060 | |
1150 | |
1061 | sub size_request { |
1151 | sub size_request { |
1062 | my ($self) = @_; |
1152 | my ($self) = @_; |
1063 | |
1153 | |
1064 | $self->{layout}->set_width; |
1154 | $self->{layout}->set_width; |
1065 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1155 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1066 | |
1156 | |
1067 | my ($w, $h) = $self->{layout}->size; |
1157 | my ($w, $h) = $self->{layout}->size; |
|
|
1158 | |
|
|
1159 | if (exists $self->{template}) { |
|
|
1160 | $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); |
|
|
1161 | |
|
|
1162 | my ($w2, $h2) = $self->{template}->size; |
|
|
1163 | |
|
|
1164 | $w = List::Util::max $w, $w2; |
|
|
1165 | $h = List::Util::max $h, $h2; |
|
|
1166 | } |
1068 | |
1167 | |
1069 | ( |
1168 | ( |
1070 | $w + $self->{padding} * 2, |
1169 | $w + $self->{padding} * 2, |
1071 | $h + $self->{padding} * 2, |
1170 | $h + $self->{padding} * 2, |
1072 | ) |
1171 | ) |
… | |
… | |
1074 | |
1173 | |
1075 | sub size_allocate { |
1174 | sub size_allocate { |
1076 | my ($self, $w, $h) = @_; |
1175 | my ($self, $w, $h) = @_; |
1077 | |
1176 | |
1078 | delete $self->{texture}; |
1177 | delete $self->{texture}; |
|
|
1178 | } |
|
|
1179 | |
|
|
1180 | sub set_fontsize { |
|
|
1181 | my ($self, $fontsize) = @_; |
|
|
1182 | |
|
|
1183 | $self->{fontsize} = $fontsize; |
|
|
1184 | delete $self->{texture}; |
|
|
1185 | $self->check_size; |
|
|
1186 | $self->update; |
1079 | } |
1187 | } |
1080 | |
1188 | |
1081 | sub _draw { |
1189 | sub _draw { |
1082 | my ($self) = @_; |
1190 | my ($self) = @_; |
1083 | |
1191 | |
… | |
… | |
1129 | active_bg => [1, 1, 1, 0.5], |
1237 | active_bg => [1, 1, 1, 0.5], |
1130 | active_fg => [0, 0, 0], |
1238 | active_fg => [0, 0, 0], |
1131 | can_hover => 1, |
1239 | can_hover => 1, |
1132 | can_focus => 1, |
1240 | can_focus => 1, |
1133 | valign => 0, |
1241 | valign => 0, |
|
|
1242 | can_events => 1, |
1134 | @_ |
1243 | @_ |
1135 | ) |
1244 | ) |
1136 | } |
1245 | } |
1137 | |
1246 | |
1138 | sub _set_text { |
1247 | sub _set_text { |
… | |
… | |
1166 | } |
1275 | } |
1167 | |
1276 | |
1168 | sub size_allocate { |
1277 | sub size_allocate { |
1169 | my ($self, $w, $h) = @_; |
1278 | my ($self, $w, $h) = @_; |
1170 | |
1279 | |
1171 | $self->_set_text ($self->{text}); |
1280 | $self->_set_text (delete $self->{text});#d# don't check for == inside _set_text |
1172 | } |
1281 | } |
1173 | |
1282 | |
1174 | sub set_text { |
1283 | sub set_text { |
1175 | my ($self, $text) = @_; |
1284 | my ($self, $text) = @_; |
1176 | |
1285 | |
… | |
… | |
1309 | our @ISA = CFClient::UI::Label::; |
1418 | our @ISA = CFClient::UI::Label::; |
1310 | |
1419 | |
1311 | use CFClient::OpenGL; |
1420 | use CFClient::OpenGL; |
1312 | |
1421 | |
1313 | my @tex = |
1422 | my @tex = |
1314 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1423 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1315 | qw(b1_button_active.png); |
1424 | qw(b1_button_active.png); |
1316 | |
1425 | |
1317 | sub new { |
1426 | sub new { |
1318 | my $class = shift; |
1427 | my $class = shift; |
1319 | |
1428 | |
… | |
… | |
1323 | bg => [1, 1, 1, 0.2], |
1432 | bg => [1, 1, 1, 0.2], |
1324 | active_fg => [0, 0, 1], |
1433 | active_fg => [0, 0, 1], |
1325 | can_hover => 1, |
1434 | can_hover => 1, |
1326 | align => 0, |
1435 | align => 0, |
1327 | valign => 0, |
1436 | valign => 0, |
|
|
1437 | can_events => 1, |
1328 | @_ |
1438 | @_ |
1329 | ) |
1439 | ) |
1330 | } |
1440 | } |
1331 | |
1441 | |
1332 | sub button_up { |
1442 | sub button_up { |
… | |
… | |
1366 | package CFClient::UI::CheckBox; |
1476 | package CFClient::UI::CheckBox; |
1367 | |
1477 | |
1368 | our @ISA = CFClient::UI::DrawBG::; |
1478 | our @ISA = CFClient::UI::DrawBG::; |
1369 | |
1479 | |
1370 | my @tex = |
1480 | my @tex = |
1371 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
1481 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1372 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
1482 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
1373 | |
1483 | |
1374 | use CFClient::OpenGL; |
1484 | use CFClient::OpenGL; |
1375 | |
1485 | |
1376 | sub new { |
1486 | sub new { |
… | |
… | |
1425 | glDisable GL_BLEND; |
1535 | glDisable GL_BLEND; |
1426 | } |
1536 | } |
1427 | |
1537 | |
1428 | ############################################################################# |
1538 | ############################################################################# |
1429 | |
1539 | |
1430 | package CFClient::UI::VGauge; |
1540 | package CFClient::UI::Image; |
1431 | |
1541 | |
1432 | our @ISA = CFClient::UI::Base::; |
1542 | our @ISA = CFClient::UI::Base::; |
1433 | |
1543 | |
1434 | use CFClient::OpenGL; |
1544 | use CFClient::OpenGL; |
|
|
1545 | use Carp qw/confess/; |
1435 | |
1546 | |
1436 | my %tex = ( |
1547 | our %loaded_images; |
1437 | food => [ |
|
|
1438 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1439 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
|
|
1440 | ], |
|
|
1441 | grace => [ |
|
|
1442 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1443 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/ |
|
|
1444 | ], |
|
|
1445 | hp => [ |
|
|
1446 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1447 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
|
|
1448 | ], |
|
|
1449 | mana => [ |
|
|
1450 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1451 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/ |
|
|
1452 | ], |
|
|
1453 | ); |
|
|
1454 | |
1548 | |
1455 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
|
|
1456 | sub new { |
1549 | sub new { |
1457 | my $class = shift; |
1550 | my $class = shift; |
1458 | |
1551 | |
1459 | my $self = $class->SUPER::new ( |
1552 | my $self = $class->SUPER::new (can_events => 0, @_); |
1460 | gauge => 'food', |
|
|
1461 | @_ |
|
|
1462 | ); |
|
|
1463 | |
1553 | |
1464 | $self->{aspect} = $tex{$self->{gauge}}[0]{w} / $tex{$self->{gauge}}[0]{h}; |
1554 | $self->{image} or confess "Image has 'image' not set. This is a fatal error!"; |
|
|
1555 | |
|
|
1556 | $loaded_images{$self->{image}} ||= |
|
|
1557 | new_from_file CFClient::Texture CFClient::find_rcfile $self->{image}, mipmap => 1; |
|
|
1558 | |
|
|
1559 | my $tex = $self->{tex} = $loaded_images{$self->{image}}; |
|
|
1560 | |
|
|
1561 | Scalar::Util::weaken $loaded_images{$self->{image}}; |
|
|
1562 | |
|
|
1563 | $self->{aspect} = $tex->{w} / $tex->{h}; |
1465 | |
1564 | |
1466 | $self |
1565 | $self |
1467 | } |
1566 | } |
1468 | |
1567 | |
1469 | sub size_request { |
1568 | sub size_request { |
1470 | my ($self) = @_; |
1569 | my ($self) = @_; |
1471 | |
1570 | |
1472 | my $tex = $tex{$self->{gauge}}[0]; |
1571 | ($self->{tex}->{w}, $self->{tex}->{h}) |
1473 | |
|
|
1474 | @$tex{qw(w h)} |
|
|
1475 | } |
|
|
1476 | |
|
|
1477 | sub set_max { |
|
|
1478 | my ($self, $max) = @_; |
|
|
1479 | |
|
|
1480 | $self->{max_val} = $max; |
|
|
1481 | } |
|
|
1482 | |
|
|
1483 | sub set_value { |
|
|
1484 | my ($self, $val, $max) = @_; |
|
|
1485 | |
|
|
1486 | $self->set_max ($max) |
|
|
1487 | if defined $max; |
|
|
1488 | |
|
|
1489 | $max = $self->{max_val}; |
|
|
1490 | $self->{val} = $val; |
|
|
1491 | |
|
|
1492 | $self->update; |
|
|
1493 | } |
1572 | } |
1494 | |
1573 | |
1495 | sub _draw { |
1574 | sub _draw { |
1496 | my ($self) = @_; |
1575 | my ($self) = @_; |
1497 | |
1576 | |
1498 | my $tex = $tex{$self->{gauge}}; |
1577 | my $tex = $self->{tex}; |
1499 | |
1578 | |
1500 | my ($w, $h) = ($self->{w}, $self->{h}); |
1579 | my ($w, $h) = ($self->{w}, $self->{h}); |
1501 | |
1580 | |
1502 | my $ycut = $self->{val} / ($self->{max_val} || 1); |
1581 | if ($self->{rot90}) { |
1503 | $ycut = 1 if $self->{val} > $self->{max_val}; |
1582 | glRotate 90, 0, 0, 1; |
|
|
1583 | glTranslate 0, -$self->{w}, 0; |
1504 | |
1584 | |
1505 | my $t1 = $tex->[0]; |
1585 | ($w, $h) = ($h, $w); |
1506 | my $t2 = $tex->[1]; |
1586 | } |
1507 | |
1587 | |
1508 | glEnable GL_BLEND; |
1588 | glEnable GL_BLEND; |
1509 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1589 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1510 | glEnable GL_TEXTURE_2D; |
1590 | glEnable GL_TEXTURE_2D; |
1511 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1591 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1512 | |
1592 | |
|
|
1593 | $tex->draw_quad (0, 0, $w, $h); |
|
|
1594 | |
|
|
1595 | glDisable GL_BLEND; |
|
|
1596 | glDisable GL_TEXTURE_2D; |
|
|
1597 | } |
|
|
1598 | |
|
|
1599 | ############################################################################# |
|
|
1600 | |
|
|
1601 | package CFClient::UI::VGauge; |
|
|
1602 | |
|
|
1603 | our @ISA = CFClient::UI::Base::; |
|
|
1604 | |
|
|
1605 | use CFClient::OpenGL; |
|
|
1606 | |
|
|
1607 | my %tex = ( |
|
|
1608 | food => [ |
|
|
1609 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
1610 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
|
|
1611 | ], |
|
|
1612 | grace => [ |
|
|
1613 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
1614 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/ |
|
|
1615 | ], |
|
|
1616 | hp => [ |
|
|
1617 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
1618 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
|
|
1619 | ], |
|
|
1620 | mana => [ |
|
|
1621 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
|
|
1622 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/ |
|
|
1623 | ], |
|
|
1624 | ); |
|
|
1625 | |
|
|
1626 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
|
|
1627 | sub new { |
|
|
1628 | my $class = shift; |
|
|
1629 | |
|
|
1630 | my $self = $class->SUPER::new ( |
|
|
1631 | type => 'food', |
|
|
1632 | @_ |
|
|
1633 | ); |
|
|
1634 | |
|
|
1635 | $self->{aspect} = $tex{$self->{type}}[0]{w} / $tex{$self->{type}}[0]{h}; |
|
|
1636 | |
|
|
1637 | $self |
|
|
1638 | } |
|
|
1639 | |
|
|
1640 | sub size_request { |
|
|
1641 | my ($self) = @_; |
|
|
1642 | |
|
|
1643 | #my $tex = $tex{$self->{type}}[0]; |
|
|
1644 | #@$tex{qw(w h)} |
|
|
1645 | (0, 0) |
|
|
1646 | } |
|
|
1647 | |
|
|
1648 | sub set_max { |
|
|
1649 | my ($self, $max) = @_; |
|
|
1650 | |
|
|
1651 | $self->{max_val} = $max; |
|
|
1652 | } |
|
|
1653 | |
|
|
1654 | sub set_value { |
|
|
1655 | my ($self, $val, $max) = @_; |
|
|
1656 | |
|
|
1657 | $self->set_max ($max) |
|
|
1658 | if defined $max; |
|
|
1659 | |
|
|
1660 | $max = $self->{max_val}; |
|
|
1661 | $self->{val} = $val; |
|
|
1662 | |
|
|
1663 | $self->update; |
|
|
1664 | } |
|
|
1665 | |
|
|
1666 | sub _draw { |
|
|
1667 | my ($self) = @_; |
|
|
1668 | |
|
|
1669 | my $tex = $tex{$self->{type}}; |
|
|
1670 | |
|
|
1671 | my ($w, $h) = ($self->{w}, $self->{h}); |
|
|
1672 | |
|
|
1673 | if ($self->{vertical}) { |
|
|
1674 | glRotate 90, 0, 0, 1; |
|
|
1675 | glTranslate 0, -$self->{w}, 0; |
|
|
1676 | |
|
|
1677 | ($w, $h) = ($h, $w); |
|
|
1678 | } |
|
|
1679 | |
|
|
1680 | my $ycut = $self->{val} / ($self->{max_val} || 1); |
|
|
1681 | $ycut = 1 if $self->{val} > $self->{max_val}; |
|
|
1682 | |
|
|
1683 | my $t1 = $tex->[0]; |
|
|
1684 | my $t2 = $tex->[1]; |
|
|
1685 | |
|
|
1686 | glEnable GL_BLEND; |
|
|
1687 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1688 | glEnable GL_TEXTURE_2D; |
|
|
1689 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1690 | |
1513 | my $h1 = $self->{h} - $ycut * $self->{h}; |
1691 | my $h1 = $self->{h} - $ycut * $self->{h}; |
1514 | my $h2 = $ycut * $self->{h}; |
1692 | my $h2 = $ycut * $self->{h}; |
1515 | |
1693 | |
1516 | my $yp = 0; |
|
|
1517 | |
|
|
1518 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
1694 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
1519 | glBegin GL_QUADS; |
1695 | glBegin GL_QUADS; |
1520 | glTexCoord 0 , 0; glVertex 0 , $yp; |
1696 | glTexCoord 0 , 0; glVertex 0 , 0; |
1521 | glTexCoord 0 , $t1->{t} * (1 - $ycut); glVertex 0 , $yp + $h1; |
1697 | glTexCoord 0 , $t1->{t} * (1 - $ycut); glVertex 0 , $h1; |
1522 | glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut); glVertex 0 + $w, $yp + $h1; |
1698 | glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut); glVertex $w, $h1; |
1523 | glTexCoord $t1->{s}, 0; glVertex 0 + $w, $yp; |
1699 | glTexCoord $t1->{s}, 0; glVertex $w, 0; |
1524 | glEnd; |
1700 | glEnd; |
1525 | |
|
|
1526 | $yp += $h1; |
|
|
1527 | |
1701 | |
1528 | glBindTexture GL_TEXTURE_2D, $t2->{name}; |
1702 | glBindTexture GL_TEXTURE_2D, $t2->{name}; |
1529 | glBegin GL_QUADS; |
1703 | glBegin GL_QUADS; |
1530 | glTexCoord 0 , $t2->{t} * (1 - $ycut); glVertex 0 , $yp; |
1704 | glTexCoord 0 , $t2->{t} * (1 - $ycut); glVertex 0 , $h1; |
1531 | glTexCoord 0 , $t2->{t}; glVertex 0 , $yp + $h2; |
1705 | glTexCoord 0 , $t2->{t}; glVertex 0 , $h1 + $h2; |
1532 | glTexCoord $t2->{s}, $t2->{t}; glVertex 0 + $w, $yp + $h2; |
1706 | glTexCoord $t2->{s}, $t2->{t}; glVertex $w, $h1 + $h2; |
1533 | glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut); glVertex 0 + $w, $yp; |
1707 | glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut); glVertex $w, $h1; |
1534 | glEnd; |
1708 | glEnd; |
1535 | |
1709 | |
1536 | glDisable GL_BLEND; |
1710 | glDisable GL_BLEND; |
1537 | glDisable GL_TEXTURE_2D; |
1711 | glDisable GL_TEXTURE_2D; |
|
|
1712 | } |
|
|
1713 | |
|
|
1714 | ############################################################################# |
|
|
1715 | |
|
|
1716 | package CFClient::UI::Gauge; |
|
|
1717 | |
|
|
1718 | our @ISA = CFClient::UI::VBox::; |
|
|
1719 | |
|
|
1720 | sub new { |
|
|
1721 | my ($class, %arg) = @_; |
|
|
1722 | |
|
|
1723 | my $self = $class->SUPER::new ( |
|
|
1724 | tooltip => $arg{type}, |
|
|
1725 | %arg, |
|
|
1726 | ); |
|
|
1727 | |
|
|
1728 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
|
|
1729 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); |
|
|
1730 | $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999"); |
|
|
1731 | |
|
|
1732 | $self |
|
|
1733 | } |
|
|
1734 | |
|
|
1735 | sub set_fontsize { |
|
|
1736 | my ($self, $fsize) = @_; |
|
|
1737 | |
|
|
1738 | $self->{value}->set_fontsize ($fsize); |
|
|
1739 | $self->{max} ->set_fontsize ($fsize); |
|
|
1740 | } |
|
|
1741 | |
|
|
1742 | sub set_value { |
|
|
1743 | my ($self, $val, $max) = @_; |
|
|
1744 | |
|
|
1745 | $self->set_max ($max) |
|
|
1746 | if defined $max; |
|
|
1747 | |
|
|
1748 | $self->{gauge}->set_value ($val, $max); |
|
|
1749 | $self->{value}->set_text ($val); |
|
|
1750 | } |
|
|
1751 | |
|
|
1752 | sub set_max { |
|
|
1753 | my ($self, $max) = @_; |
|
|
1754 | |
|
|
1755 | $self->{gauge}->set_max ($max); |
|
|
1756 | $self->{max}->set_text ($max); |
1538 | } |
1757 | } |
1539 | |
1758 | |
1540 | ############################################################################# |
1759 | ############################################################################# |
1541 | |
1760 | |
1542 | package CFClient::UI::Slider; |
1761 | package CFClient::UI::Slider; |
… | |
… | |
1882 | my $class = shift; |
2101 | my $class = shift; |
1883 | |
2102 | |
1884 | my $self = $class->SUPER::new ( |
2103 | my $self = $class->SUPER::new ( |
1885 | state => 0, |
2104 | state => 0, |
1886 | connect_activate => \&toggle_flopper, |
2105 | connect_activate => \&toggle_flopper, |
|
|
2106 | can_events => 1, |
1887 | @_ |
2107 | @_ |
1888 | ); |
2108 | ); |
1889 | |
2109 | |
1890 | if ($self->{state}) { |
2110 | if ($self->{state}) { |
1891 | $self->{state} = 0; |
2111 | $self->{state} = 0; |
… | |
… | |
1920 | use CFClient::OpenGL; |
2140 | use CFClient::OpenGL; |
1921 | |
2141 | |
1922 | sub check_size { |
2142 | sub check_size { |
1923 | my ($self) = @_; |
2143 | my ($self) = @_; |
1924 | |
2144 | |
1925 | $self->configure (0, 0, $::WITH, $::HEIGHT); |
2145 | $self->configure (0, 0, $::WIDTH, $::HEIGHT); |
1926 | } |
2146 | } |
1927 | |
2147 | |
1928 | sub size_request { |
2148 | sub size_request { |
1929 | ($::WIDTH, $::HEIGHT) |
2149 | ($::WIDTH, $::HEIGHT) |
1930 | } |
2150 | } |
… | |
… | |
1932 | sub configure { |
2152 | sub configure { |
1933 | my ($self, $x, $y, $w, $h) = @_; |
2153 | my ($self, $x, $y, $w, $h) = @_; |
1934 | |
2154 | |
1935 | $self->SUPER::configure ($x, $y, $w, $h); |
2155 | $self->SUPER::configure ($x, $y, $w, $h); |
1936 | |
2156 | |
1937 | $_->configure ($_->{x}, $_->{y}, $_->size_request) |
|
|
1938 | for @{$self->{children}}; |
2157 | for my $child (@{$self->{children}}) { |
|
|
2158 | my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)}; |
|
|
2159 | |
|
|
2160 | $X = List::Util::max 0, List::Util::min $w - $W, $X; |
|
|
2161 | $Y = List::Util::max 0, List::Util::min $h - $H, $Y; |
|
|
2162 | $child->configure ($X, $Y, $W,$H); |
|
|
2163 | } |
1939 | } |
2164 | } |
1940 | |
2165 | |
1941 | sub _topleft { |
2166 | sub _topleft { |
1942 | my ($self, $x, $y) = @_; |
2167 | my ($self, $x, $y) = @_; |
1943 | |
2168 | |
… | |
… | |
1951 | ::refresh (); |
2176 | ::refresh (); |
1952 | } |
2177 | } |
1953 | |
2178 | |
1954 | sub add { |
2179 | sub add { |
1955 | my ($self, $child) = @_; |
2180 | my ($self, $child) = @_; |
|
|
2181 | |
|
|
2182 | # integerize window positions |
|
|
2183 | $child->{x} = int $child->{x}; |
|
|
2184 | $child->{y} = int $child->{y}; |
1956 | |
2185 | |
1957 | $self->SUPER::add ($child); |
2186 | $self->SUPER::add ($child); |
1958 | } |
2187 | } |
1959 | |
2188 | |
1960 | sub on_refresh { |
2189 | sub on_refresh { |
… | |
… | |
1986 | ############################################################################# |
2215 | ############################################################################# |
1987 | |
2216 | |
1988 | package CFClient::UI; |
2217 | package CFClient::UI; |
1989 | |
2218 | |
1990 | $ROOT = new CFClient::UI::Root; |
2219 | $ROOT = new CFClient::UI::Root; |
|
|
2220 | $TOOLTIP = new CFClient::UI::Label fontsize => 0.8, can_events => 0; |
1991 | |
2221 | |
1992 | 1 |
2222 | 1 |
1993 | |
2223 | |