… | |
… | |
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 | |
… | |
… | |
2233 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); |
2233 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); |
2234 | } |
2234 | } |
2235 | |
2235 | |
2236 | glColor_premultiply @{$self->{active_fg}}; |
2236 | glColor_premultiply @{$self->{active_fg}}; |
2237 | glBegin GL_LINES; |
2237 | glBegin GL_LINES; |
2238 | glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; |
2238 | 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}; |
2239 | glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy} + $self->{cur_h}; |
2240 | glEnd; |
2240 | glEnd; |
2241 | |
2241 | |
2242 | glLineWidth 3; |
2242 | glLineWidth 3; |
2243 | glColor @{$self->{active_outline}}; |
2243 | glColor @{$self->{active_outline}}; |
2244 | glRect_lineloop 0, 0, $self->{w} - 1, $self->{h} - 1; |
2244 | glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; |
2245 | glLineWidth 1; |
2245 | glLineWidth 1; |
2246 | |
2246 | |
2247 | } else { |
2247 | } else { |
2248 | glColor @{$self->{outline}}; |
2248 | glColor @{$self->{outline}}; |
2249 | glTranslate .375, .375; |
|
|
2250 | glBegin GL_LINE_STRIP; |
2249 | glBegin GL_LINE_STRIP; |
2251 | glVertex 0, $self->{h} * .5; |
2250 | glVertex .5, $self->{h} * .5; |
2252 | glVertex 0, $self->{h} - 3; |
2251 | glVertex .5, $self->{h} - 2.5; |
2253 | glVertex $self->{w} - 1, $self->{h} - 3; |
2252 | glVertex $self->{w} - .5, $self->{h} - 2.5; |
2254 | glVertex $self->{w} - 1, $self->{h} * .5; |
2253 | glVertex $self->{w} - .5, $self->{h} * .5; |
2255 | glEnd; |
2254 | glEnd; |
2256 | } |
2255 | } |
2257 | } |
2256 | } |
2258 | |
2257 | |
2259 | ############################################################################# |
2258 | ############################################################################# |
… | |
… | |
2508 | sub _draw { |
2507 | sub _draw { |
2509 | my ($self) = @_; |
2508 | my ($self) = @_; |
2510 | |
2509 | |
2511 | $self->SUPER::_draw; |
2510 | $self->SUPER::_draw; |
2512 | |
2511 | |
2513 | glTranslate $self->{padding_x} + 0.375, $self->{padding_y} + 0.375, 0; |
2512 | glTranslate $self->{padding_x}, $self->{padding_y}, 0; |
2514 | |
2513 | |
2515 | my ($w, $h) = @$self{qw(w h)}; |
2514 | my ($w, $h) = @$self{qw(w h)}; |
2516 | |
2515 | |
2517 | my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2; |
2516 | my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2; |
2518 | |
2517 | |
… | |
… | |
2837 | |
2836 | |
2838 | glEnable GL_BLEND; |
2837 | glEnable GL_BLEND; |
2839 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2838 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2840 | |
2839 | |
2841 | if ($self->{value} >= 0) { |
2840 | if ($self->{value} >= 0) { |
2842 | my $s = 3 + ($self->{w} - 6) * $self->{value}; |
2841 | my $s = int 2 + ($self->{w} - 4) * $self->{value}; |
2843 | |
2842 | |
2844 | glColor_premultiply @{$self->{bar}}; |
2843 | glColor_premultiply @{$self->{bar}}; |
2845 | glRect 2, 2, $s, $self->{h} - 2; |
2844 | glRect 2, 2, $s, $self->{h} - 2; |
2846 | glColor_premultiply @{$self->{bg}}; |
2845 | glColor_premultiply @{$self->{bg}}; |
2847 | glRect $s + 1, 0, $self->{w} - 2, $self->{h} - 2; |
2846 | glRect $s, 2, $self->{w} - 2, $self->{h} - 2; |
2848 | } |
2847 | } |
2849 | |
2848 | |
2850 | glColor_premultiply @{$self->{outline}}; |
2849 | glColor_premultiply @{$self->{outline}}; |
2851 | glRect_lineloop 1, 1, $self->{w} - 2, $self->{h} - 2; |
2850 | glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; |
2852 | |
2851 | |
2853 | glDisable GL_BLEND; |
2852 | glDisable GL_BLEND; |
2854 | |
2853 | |
2855 | { |
2854 | { |
2856 | local $self->{bg}; # do not draw background |
2855 | local $self->{bg}; # do not draw background |
… | |
… | |
3618 | } |
3617 | } |
3619 | |
3618 | |
3620 | sub _draw { |
3619 | sub _draw { |
3621 | my ($self) = @_; |
3620 | my ($self) = @_; |
3622 | |
3621 | |
3623 | glTranslate 0.375, 0.375; |
|
|
3624 | |
|
|
3625 | my ($w, $h) = @$self{qw(w h)}; |
3622 | my ($w, $h) = @$self{qw(w h)}; |
3626 | |
3623 | |
3627 | glColor 1, 0.8, 0.4; |
3624 | glColor 1, 0.8, 0.4; |
3628 | glRect 0, 0, $w, $h; |
3625 | glRect 0, 0, $w, $h; |
3629 | |
3626 | |
3630 | glColor 0, 0, 0; |
3627 | glColor 0, 0, 0; |
3631 | glRect_lineloop 0, 0, $w, $h; |
3628 | glRect_lineloop .5, .5, $w + .5, $h + .5; |
3632 | |
3629 | |
3633 | glTranslate 2 - 0.375, 2 - 0.375; |
3630 | glTranslate 2, 2; |
3634 | |
3631 | |
3635 | $self->SUPER::_draw; |
3632 | $self->SUPER::_draw; |
3636 | } |
3633 | } |
3637 | |
3634 | |
3638 | ############################################################################# |
3635 | ############################################################################# |
… | |
… | |
3965 | my $class = shift; |
3962 | my $class = shift; |
3966 | |
3963 | |
3967 | my $self = $class->SUPER::new ( |
3964 | my $self = $class->SUPER::new ( |
3968 | buttonbar => (new CFPlus::UI::Buttonbar), |
3965 | buttonbar => (new CFPlus::UI::Buttonbar), |
3969 | multiplexer => (new CFPlus::UI::Multiplexer expand => 1), |
3966 | multiplexer => (new CFPlus::UI::Multiplexer expand => 1), |
3970 | active_outline => [1, 1, 0], |
3967 | active_outline => [.7, .7, 0.2], |
3971 | # filter => # will be put between multiplexer and $self |
3968 | # filter => # will be put between multiplexer and $self |
3972 | @_, |
3969 | @_, |
3973 | ); |
3970 | ); |
3974 | |
3971 | |
3975 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
3972 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
… | |
… | |
4056 | |
4053 | |
4057 | $self->SUPER::_draw (); |
4054 | $self->SUPER::_draw (); |
4058 | |
4055 | |
4059 | if (my $cur = $self->{multiplexer}{current}) { |
4056 | if (my $cur = $self->{multiplexer}{current}) { |
4060 | if ($cur = $cur->{c_tab_}) { |
4057 | if ($cur = $cur->{c_tab_}) { |
4061 | glTranslate $cur->{x}, $cur->{y}; |
4058 | glTranslate $self->{buttonbar}{x} + $cur->{x}, |
|
|
4059 | $self->{buttonbar}{y} + $cur->{y}; |
4062 | glLineWidth 3; |
4060 | glLineWidth 3; |
|
|
4061 | #glEnable GL_BLEND; |
|
|
4062 | #glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
4063 | glColor @{$self->{active_outline}}; |
4063 | glColor @{$self->{active_outline}}; |
4064 | glRect_lineloop 1, 1, $cur->{w} - 2, $cur->{h} - 2; |
4064 | glRect_lineloop 1.5, 1.5, $cur->{w} - 1.5, $cur->{h} - 1.5; |
4065 | glLineWidth 1; |
4065 | glLineWidth 1; |
|
|
4066 | #glDisable GL_BLEND; |
4066 | } |
4067 | } |
4067 | } |
4068 | } |
4068 | } |
4069 | } |
4069 | |
4070 | |
4070 | ############################################################################# |
4071 | ############################################################################# |