… | |
… | |
269 | $self->emit ("destroy"); |
269 | $self->emit ("destroy"); |
270 | %$self = (); |
270 | %$self = (); |
271 | } |
271 | } |
272 | |
272 | |
273 | sub TO_JSON { |
273 | sub TO_JSON { |
274 | { __w_ => $_[0]{s_id} } |
274 | { "\fw" => $_[0]{s_id} } |
275 | } |
275 | } |
276 | |
276 | |
277 | sub show { |
277 | sub show { |
278 | my ($self) = @_; |
278 | my ($self) = @_; |
279 | |
279 | |
… | |
… | |
358 | |
358 | |
359 | $self->{force_w} = $w; |
359 | $self->{force_w} = $w; |
360 | $self->{force_h} = $h; |
360 | $self->{force_h} = $h; |
361 | |
361 | |
362 | $self->realloc; |
362 | $self->realloc; |
|
|
363 | } |
|
|
364 | |
|
|
365 | # traverse the widget chain up to find the maximum "physical" size constraints |
|
|
366 | sub get_max_wh { |
|
|
367 | my ($self) = @_; |
|
|
368 | |
|
|
369 | return $self->{parent}->get_max_wh |
|
|
370 | if $self->{parent}; |
|
|
371 | |
|
|
372 | ($::WIDTH, $::HEIGHT) |
363 | } |
373 | } |
364 | |
374 | |
365 | sub size_request { |
375 | sub size_request { |
366 | require Carp; |
376 | require Carp; |
367 | Carp::confess "size_request is abstract"; |
377 | Carp::confess "size_request is abstract"; |
… | |
… | |
817 | |
827 | |
818 | 1 |
828 | 1 |
819 | } |
829 | } |
820 | |
830 | |
821 | ############################################################################# |
831 | ############################################################################# |
822 | |
|
|
823 | # back-buffered drawing area |
832 | # back-buffered drawing area |
824 | |
833 | |
825 | package CFPlus::UI::Window; |
834 | package CFPlus::UI::Window; |
826 | |
835 | |
827 | our @ISA = CFPlus::UI::Bin::; |
836 | our @ISA = CFPlus::UI::Bin::; |
… | |
… | |
1376 | $self->CFPlus::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; |
1385 | $self->CFPlus::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; |
1377 | } |
1386 | } |
1378 | |
1387 | |
1379 | sub border { |
1388 | sub border { |
1380 | int $_[0]{border} * $::FONTSIZE |
1389 | int $_[0]{border} * $::FONTSIZE |
|
|
1390 | } |
|
|
1391 | |
|
|
1392 | sub get_max_wh { |
|
|
1393 | my ($self) = @_; |
|
|
1394 | |
|
|
1395 | return ($self->{w}, $self->{h}) |
|
|
1396 | if $self->{visible} && $self->{w}; |
|
|
1397 | |
|
|
1398 | $self->SUPER::get_max_wh |
1381 | } |
1399 | } |
1382 | |
1400 | |
1383 | sub size_request { |
1401 | sub size_request { |
1384 | my ($self) = @_; |
1402 | my ($self) = @_; |
1385 | |
1403 | |
… | |
… | |
1942 | |
1960 | |
1943 | sub size_request { |
1961 | sub size_request { |
1944 | my ($self) = @_; |
1962 | my ($self) = @_; |
1945 | |
1963 | |
1946 | $self->{size_req} ||= do { |
1964 | $self->{size_req} ||= do { |
|
|
1965 | my ($max_w, $max_h) = $self->get_max_wh; |
|
|
1966 | |
1947 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1967 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1948 | $self->{layout}->set_width ($self->{max_w} || -1); |
1968 | $self->{layout}->set_width ($self->{max_w} || $max_w || -1); |
1949 | $self->{layout}->set_ellipsise ($self->{ellipsise}); |
1969 | $self->{layout}->set_ellipsise ($self->{ellipsise}); |
1950 | $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); |
1970 | $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); |
1951 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1971 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1952 | |
1972 | |
1953 | my ($w, $h) = $self->{layout}->size; |
1973 | my ($w, $h) = $self->{layout}->size; |
… | |
… | |
2233 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); |
2253 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); |
2234 | } |
2254 | } |
2235 | |
2255 | |
2236 | glColor_premultiply @{$self->{active_fg}}; |
2256 | glColor_premultiply @{$self->{active_fg}}; |
2237 | glBegin GL_LINES; |
2257 | glBegin GL_LINES; |
2238 | glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; |
2258 | glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy}; |
2239 | glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; |
2259 | glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy} + $self->{cur_h}; |
2240 | glEnd; |
2260 | glEnd; |
2241 | |
2261 | |
2242 | glLineWidth 3; |
2262 | glLineWidth 3; |
2243 | glColor @{$self->{active_outline}}; |
2263 | glColor @{$self->{active_outline}}; |
2244 | glRect_lineloop 0, 0, $self->{w} - 1, $self->{h} - 1; |
2264 | glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; |
2245 | glLineWidth 1; |
2265 | glLineWidth 1; |
2246 | |
2266 | |
2247 | } else { |
2267 | } else { |
2248 | glColor @{$self->{outline}}; |
2268 | glColor @{$self->{outline}}; |
2249 | glTranslate .375, .375; |
|
|
2250 | glBegin GL_LINE_STRIP; |
2269 | glBegin GL_LINE_STRIP; |
2251 | glVertex 0, $self->{h} * .5; |
2270 | glVertex .5, $self->{h} * .5; |
2252 | glVertex 0, $self->{h} - 3; |
2271 | glVertex .5, $self->{h} - 2.5; |
2253 | glVertex $self->{w} - 1, $self->{h} - 3; |
2272 | glVertex $self->{w} - .5, $self->{h} - 2.5; |
2254 | glVertex $self->{w} - 1, $self->{h} * .5; |
2273 | glVertex $self->{w} - .5, $self->{h} * .5; |
2255 | glEnd; |
2274 | glEnd; |
2256 | } |
2275 | } |
2257 | } |
2276 | } |
2258 | |
2277 | |
2259 | ############################################################################# |
2278 | ############################################################################# |
… | |
… | |
2508 | sub _draw { |
2527 | sub _draw { |
2509 | my ($self) = @_; |
2528 | my ($self) = @_; |
2510 | |
2529 | |
2511 | $self->SUPER::_draw; |
2530 | $self->SUPER::_draw; |
2512 | |
2531 | |
2513 | glTranslate $self->{padding_x} + 0.375, $self->{padding_y} + 0.375, 0; |
2532 | glTranslate $self->{padding_x}, $self->{padding_y}, 0; |
2514 | |
2533 | |
2515 | my ($w, $h) = @$self{qw(w h)}; |
2534 | my ($w, $h) = @$self{qw(w h)}; |
2516 | |
2535 | |
2517 | my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2; |
2536 | my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2; |
2518 | |
2537 | |
… | |
… | |
2837 | |
2856 | |
2838 | glEnable GL_BLEND; |
2857 | glEnable GL_BLEND; |
2839 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2858 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2840 | |
2859 | |
2841 | if ($self->{value} >= 0) { |
2860 | if ($self->{value} >= 0) { |
2842 | my $s = 3 + ($self->{w} - 6) * $self->{value}; |
2861 | my $s = int 2 + ($self->{w} - 4) * $self->{value}; |
2843 | |
2862 | |
2844 | glColor_premultiply @{$self->{bar}}; |
2863 | glColor_premultiply @{$self->{bar}}; |
2845 | glRect 2, 2, $s, $self->{h} - 2; |
2864 | glRect 2, 2, $s, $self->{h} - 2; |
2846 | glColor_premultiply @{$self->{bg}}; |
2865 | glColor_premultiply @{$self->{bg}}; |
2847 | glRect $s + 1, 0, $self->{w} - 2, $self->{h} - 2; |
2866 | glRect $s, 2, $self->{w} - 2, $self->{h} - 2; |
2848 | } |
2867 | } |
2849 | |
2868 | |
2850 | glColor_premultiply @{$self->{outline}}; |
2869 | glColor_premultiply @{$self->{outline}}; |
2851 | glRect_lineloop 1, 1, $self->{w} - 2, $self->{h} - 2; |
2870 | glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; |
2852 | |
2871 | |
2853 | glDisable GL_BLEND; |
2872 | glDisable GL_BLEND; |
2854 | |
2873 | |
2855 | { |
2874 | { |
2856 | local $self->{bg}; # do not draw background |
2875 | local $self->{bg}; # do not draw background |
… | |
… | |
2896 | } |
2915 | } |
2897 | |
2916 | |
2898 | sub set_value { |
2917 | sub set_value { |
2899 | my ($self, $lvl, $exp) = @_; |
2918 | my ($self, $lvl, $exp) = @_; |
2900 | |
2919 | |
2901 | <<<<<<< UI.pm |
|
|
2902 | $self->{lvl} = $lvl; |
2920 | $self->{lvl} = $lvl; |
2903 | $self->{exp} = $exp; |
2921 | $self->{exp} = $exp; |
2904 | |
2922 | |
2905 | ======= |
|
|
2906 | $self->{lvl} = $exp; |
|
|
2907 | $self->{exp} = $exp; |
|
|
2908 | |
|
|
2909 | >>>>>>> 1.434 |
|
|
2910 | my $v = -1; |
2923 | my $v = -1; |
2911 | |
2924 | |
2912 | if ($::CONN && (my $table = $::CONN->{exp_table})) { |
2925 | if ($::CONN && (my $table = $::CONN->{exp_table})) { |
2913 | my $l0 = $table->[$lvl - 1]; |
2926 | my $l0 = $table->[$lvl - 1]; |
2914 | my $l1 = $table->[$lvl]; |
2927 | my $l1 = $table->[$lvl]; |
… | |
… | |
3624 | } |
3637 | } |
3625 | |
3638 | |
3626 | sub _draw { |
3639 | sub _draw { |
3627 | my ($self) = @_; |
3640 | my ($self) = @_; |
3628 | |
3641 | |
3629 | glTranslate 0.375, 0.375; |
|
|
3630 | |
|
|
3631 | my ($w, $h) = @$self{qw(w h)}; |
3642 | my ($w, $h) = @$self{qw(w h)}; |
3632 | |
3643 | |
3633 | glColor 1, 0.8, 0.4; |
3644 | glColor 1, 0.8, 0.4; |
3634 | glRect 0, 0, $w, $h; |
3645 | glRect 0, 0, $w, $h; |
3635 | |
3646 | |
3636 | glColor 0, 0, 0; |
3647 | glColor 0, 0, 0; |
3637 | glRect_lineloop 0, 0, $w, $h; |
3648 | glRect_lineloop .5, .5, $w + .5, $h + .5; |
3638 | |
3649 | |
3639 | glTranslate 2 - 0.375, 2 - 0.375; |
3650 | glTranslate 2, 2; |
3640 | |
3651 | |
3641 | $self->SUPER::_draw; |
3652 | $self->SUPER::_draw; |
3642 | } |
3653 | } |
3643 | |
3654 | |
3644 | ############################################################################# |
3655 | ############################################################################# |
… | |
… | |
3971 | my $class = shift; |
3982 | my $class = shift; |
3972 | |
3983 | |
3973 | my $self = $class->SUPER::new ( |
3984 | my $self = $class->SUPER::new ( |
3974 | buttonbar => (new CFPlus::UI::Buttonbar), |
3985 | buttonbar => (new CFPlus::UI::Buttonbar), |
3975 | multiplexer => (new CFPlus::UI::Multiplexer expand => 1), |
3986 | multiplexer => (new CFPlus::UI::Multiplexer expand => 1), |
3976 | active_outline => [1, 1, 0], |
3987 | active_outline => [.7, .7, 0.2], |
3977 | # filter => # will be put between multiplexer and $self |
3988 | # filter => # will be put between multiplexer and $self |
3978 | @_, |
3989 | @_, |
3979 | ); |
3990 | ); |
3980 | |
3991 | |
3981 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
3992 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
… | |
… | |
4062 | |
4073 | |
4063 | $self->SUPER::_draw (); |
4074 | $self->SUPER::_draw (); |
4064 | |
4075 | |
4065 | if (my $cur = $self->{multiplexer}{current}) { |
4076 | if (my $cur = $self->{multiplexer}{current}) { |
4066 | if ($cur = $cur->{c_tab_}) { |
4077 | if ($cur = $cur->{c_tab_}) { |
4067 | glTranslate $cur->{x}, $cur->{y}; |
4078 | glTranslate $self->{buttonbar}{x} + $cur->{x}, |
|
|
4079 | $self->{buttonbar}{y} + $cur->{y}; |
4068 | glLineWidth 3; |
4080 | glLineWidth 3; |
|
|
4081 | #glEnable GL_BLEND; |
|
|
4082 | #glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
4069 | glColor @{$self->{active_outline}}; |
4083 | glColor @{$self->{active_outline}}; |
4070 | glRect_lineloop 1, 1, $cur->{w} - 2, $cur->{h} - 2; |
4084 | glRect_lineloop 1.5, 1.5, $cur->{w} - 1.5, $cur->{h} - 1.5; |
4071 | glLineWidth 1; |
4085 | glLineWidth 1; |
|
|
4086 | #glDisable GL_BLEND; |
4072 | } |
4087 | } |
4073 | } |
4088 | } |
4074 | } |
4089 | } |
4075 | |
4090 | |
4076 | ############################################################################# |
4091 | ############################################################################# |