… | |
… | |
293 | |
293 | |
294 | $self->emit (visibility_change => 1); |
294 | $self->emit (visibility_change => 1); |
295 | |
295 | |
296 | $self->realloc if !exists $self->{req_w}; |
296 | $self->realloc if !exists $self->{req_w}; |
297 | |
297 | |
298 | $_->set_visible for $self->children; |
298 | $_->set_visible for $self->visible_children; |
299 | } |
299 | } |
300 | |
300 | |
301 | sub set_invisible { |
301 | sub set_invisible { |
302 | my ($self) = @_; |
302 | my ($self) = @_; |
303 | |
303 | |
… | |
… | |
1256 | fontsize => ($arg{border} || 0.8) * 0.75; |
1256 | fontsize => ($arg{border} || 0.8) * 0.75; |
1257 | } |
1257 | } |
1258 | |
1258 | |
1259 | my $self = $class->SUPER::new ( |
1259 | my $self = $class->SUPER::new ( |
1260 | # label => "", |
1260 | # label => "", |
1261 | fg => [0.6, 0.3, 0.1], |
1261 | fg => undef, |
1262 | border => 0.8, |
1262 | border => 0.8, |
1263 | style => 'single', |
1263 | style => 'single', |
1264 | %arg, |
1264 | %arg, |
1265 | ); |
1265 | ); |
1266 | |
1266 | |
… | |
… | |
1319 | my $border = $self->border; |
1319 | my $border = $self->border; |
1320 | my ($w, $h) = ($self->{w}, $self->{h}); |
1320 | my ($w, $h) = ($self->{w}, $self->{h}); |
1321 | |
1321 | |
1322 | $child->draw; |
1322 | $child->draw; |
1323 | |
1323 | |
1324 | glColor @{$self->{fg}}; |
1324 | glColor @{$self->{fg} || $DC::THEME{fancyframe}}; |
1325 | glBegin GL_LINE_STRIP; |
1325 | glBegin GL_LINE_STRIP; |
1326 | glVertex $border * 1.5 , $border * 0.5 + 0.5; |
1326 | glVertex $border * 1.5 , $border * 0.5 + 0.5; |
1327 | glVertex $border * 0.5 + 0.5, $border * 0.5 + 0.5; |
1327 | glVertex $border * 0.5 + 0.5, $border * 0.5 + 0.5; |
1328 | glVertex $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5; |
1328 | glVertex $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5; |
1329 | glVertex $w - $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5; |
1329 | glVertex $w - $border * 0.5 + 0.5, $h - $border * 0.5 + 0.5; |
… | |
… | |
1361 | my ($class, %arg) = @_; |
1361 | my ($class, %arg) = @_; |
1362 | |
1362 | |
1363 | my $self = $class->SUPER::new ( |
1363 | my $self = $class->SUPER::new ( |
1364 | bg => [1, 1, 1, 1], |
1364 | bg => [1, 1, 1, 1], |
1365 | border_bg => [1, 1, 1, 1], |
1365 | border_bg => [1, 1, 1, 1], |
1366 | border => 1, |
1366 | border => 0.8, |
1367 | can_events => 1, |
1367 | can_events => 1, |
1368 | min_w => 64, |
1368 | min_w => 64, |
1369 | min_h => 32, |
1369 | min_h => 32, |
1370 | %arg, |
1370 | %arg, |
1371 | ); |
1371 | ); |
… | |
… | |
2090 | my $class = shift; |
2090 | my $class = shift; |
2091 | |
2091 | |
2092 | $class->SUPER::new ( |
2092 | $class->SUPER::new ( |
2093 | fg => [1, 1, 1], |
2093 | fg => [1, 1, 1], |
2094 | bg => [0, 0, 0, 0.2], |
2094 | bg => [0, 0, 0, 0.2], |
2095 | outline => [0.6, 0.3, 0.1], |
2095 | outline => undef, |
2096 | active_bg => [0, 0, 1, .2], |
2096 | active_bg => [0, 0, 1, .2], |
2097 | active_fg => [1, 1, 1], |
2097 | active_fg => [1, 1, 1], |
2098 | active_outline => [1, 1, 0], |
2098 | active_outline => [1, 1, 0], |
2099 | can_hover => 1, |
2099 | can_hover => 1, |
2100 | can_focus => 1, |
2100 | can_focus => 1, |
… | |
… | |
2273 | glColor @{$self->{active_outline}}; |
2273 | glColor @{$self->{active_outline}}; |
2274 | glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; |
2274 | glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; |
2275 | glLineWidth 1; |
2275 | glLineWidth 1; |
2276 | |
2276 | |
2277 | } else { |
2277 | } else { |
2278 | glColor @{$self->{outline}}; |
2278 | glColor @{$self->{outline} || $DC::THEME{entry_outline}}; |
2279 | glBegin GL_LINE_STRIP; |
2279 | glBegin GL_LINE_STRIP; |
2280 | glVertex .5, $self->{h} * .5; |
2280 | glVertex .5, $self->{h} * .5; |
2281 | glVertex .5, $self->{h} - 2.5; |
2281 | glVertex .5, $self->{h} - 2.5; |
2282 | glVertex $self->{w} - .5, $self->{h} - 2.5; |
2282 | glVertex $self->{w} - .5, $self->{h} - 2.5; |
2283 | glVertex $self->{w} - .5, $self->{h} * .5; |
2283 | glVertex $self->{w} - .5, $self->{h} * .5; |
… | |
… | |
3620 | |
3620 | |
3621 | $tip =~ s/^\n+//; |
3621 | $tip =~ s/^\n+//; |
3622 | $tip =~ s/\n+$//; |
3622 | $tip =~ s/\n+$//; |
3623 | |
3623 | |
3624 | $self->add (new DC::UI::Label |
3624 | $self->add (new DC::UI::Label |
|
|
3625 | fg => $DC::THEME{tooltip_fg}, |
3625 | markup => $tip, |
3626 | markup => $tip, |
3626 | max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, |
3627 | max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, |
3627 | align => 0, |
3628 | align => 0, |
3628 | fontsize => 0.8, |
3629 | fontsize => 0.8, |
3629 | style => 1, # FLAG_INVERSE |
3630 | style => $DC::THEME{tooltip_style}, # FLAG_INVERSE |
3630 | ellipsise => 0, |
3631 | ellipsise => 0, |
3631 | font => ($widget->{tooltip_font} || $::FONT_PROP), |
3632 | font => ($widget->{tooltip_font} || $::FONT_PROP), |
3632 | ); |
3633 | ); |
3633 | } |
3634 | } |
3634 | |
3635 | |
… | |
… | |
3671 | sub _draw { |
3672 | sub _draw { |
3672 | my ($self) = @_; |
3673 | my ($self) = @_; |
3673 | |
3674 | |
3674 | my ($w, $h) = @$self{qw(w h)}; |
3675 | my ($w, $h) = @$self{qw(w h)}; |
3675 | |
3676 | |
3676 | glColor 1, 0.8, 0.4; |
3677 | glColor @{ $DC::THEME{tooltip_bg} }; |
3677 | glRect 0, 0, $w, $h; |
3678 | glRect 0, 0, $w, $h; |
3678 | |
3679 | |
3679 | glColor 0, 0, 0; |
3680 | glColor @{ $DC::THEME{tooltip_border} }; |
3680 | glRect_lineloop .5, .5, $w + .5, $h + .5; |
3681 | glRect_lineloop .5, .5, $w + .5, $h + .5; |
3681 | |
3682 | |
3682 | glTranslate 2, 2; |
3683 | glTranslate 2, 2; |
3683 | |
3684 | |
3684 | $self->SUPER::_draw; |
3685 | $self->SUPER::_draw; |
… | |
… | |
3932 | |
3933 | |
3933 | my $self = $class->SUPER::new ( |
3934 | my $self = $class->SUPER::new ( |
3934 | @_, |
3935 | @_, |
3935 | ); |
3936 | ); |
3936 | |
3937 | |
3937 | $self->{current} = $self->{children}[0] |
3938 | $self->set_current_page (0); |
3938 | if @{ $self->{children} }; |
|
|
3939 | |
3939 | |
3940 | $self |
3940 | $self |
3941 | } |
3941 | } |
3942 | |
3942 | |
3943 | sub add { |
3943 | sub add { |
3944 | my ($self, @widgets) = @_; |
3944 | my ($self, @widgets) = @_; |
3945 | |
3945 | |
3946 | $self->SUPER::add (@widgets); |
3946 | $self->SUPER::add (@widgets); |
3947 | |
3947 | |
3948 | $self->{current} = $self->{children}[0] |
3948 | $self->set_current_page (0) |
3949 | if @{ $self->{children} }; |
3949 | unless @widgets == @{ $self->{children} }; |
3950 | } |
3950 | } |
3951 | |
3951 | |
3952 | sub get_current_page { |
3952 | sub get_current_page { |
3953 | my ($self) = @_; |
3953 | my ($self) = @_; |
3954 | |
3954 | |
… | |
… | |
3960 | |
3960 | |
3961 | my $widget = ref $page_or_widget |
3961 | my $widget = ref $page_or_widget |
3962 | ? $page_or_widget |
3962 | ? $page_or_widget |
3963 | : $self->{children}[$page_or_widget]; |
3963 | : $self->{children}[$page_or_widget]; |
3964 | |
3964 | |
|
|
3965 | $self->{current}->set_invisible if $self->{current} && $self->{visible}; |
|
|
3966 | |
3965 | $self->{current} = $widget; |
3967 | if (($self->{current} = $widget)) { |
|
|
3968 | $self->{current}->set_visible if $self->{current} && $self->{visible}; |
3966 | $self->{current}->configure (0, 0, $self->{w}, $self->{h}); |
3969 | $self->{current}->configure (0, 0, $self->{w}, $self->{h}); |
3967 | |
3970 | |
3968 | $self->emit (page_changed => $self->{current}); |
3971 | $self->emit (page_changed => $self->{current}); |
|
|
3972 | } |
3969 | |
3973 | |
3970 | $self->realloc; |
3974 | $self->realloc; |
3971 | } |
3975 | } |
3972 | |
3976 | |
3973 | sub visible_children { |
3977 | sub visible_children { |
3974 | $_[0]{current} |
3978 | $_[0]{current} || () |
3975 | } |
3979 | } |
3976 | |
3980 | |
3977 | sub size_request { |
3981 | sub size_request { |
3978 | my ($self) = @_; |
3982 | my ($self) = @_; |
3979 | |
3983 | |
|
|
3984 | $self->{current} |
3980 | $self->{current}->size_request |
3985 | ? $self->{current}->size_request |
|
|
3986 | : (0, 0) |
3981 | } |
3987 | } |
3982 | |
3988 | |
3983 | sub invoke_size_allocate { |
3989 | sub invoke_size_allocate { |
3984 | my ($self, $w, $h) = @_; |
3990 | my ($self, $w, $h) = @_; |
3985 | |
3991 | |
3986 | $self->{current}->configure (0, 0, $w, $h); |
3992 | $self->{current}->configure (0, 0, $w, $h) |
|
|
3993 | if $self->{current}; |
3987 | |
3994 | |
3988 | 1 |
3995 | 1 |
3989 | } |
3996 | } |
3990 | |
3997 | |
3991 | sub _draw { |
3998 | sub _draw { |
3992 | my ($self) = @_; |
3999 | my ($self) = @_; |
3993 | |
4000 | |
3994 | $self->{current}->draw; |
4001 | $self->{current}->draw |
|
|
4002 | if $self->{current}; |
3995 | } |
4003 | } |
3996 | |
4004 | |
3997 | ############################################################################# |
4005 | ############################################################################# |
3998 | |
4006 | |
3999 | package DC::UI::Notebook; |
4007 | package DC::UI::Notebook; |
… | |
… | |
4209 | $self |
4217 | $self |
4210 | } |
4218 | } |
4211 | |
4219 | |
4212 | sub reorder { |
4220 | sub reorder { |
4213 | my ($self) = @_; |
4221 | my ($self) = @_; |
4214 | my $NOW = Time::HiRes::time; |
4222 | my $NOW = EV::time; |
4215 | |
4223 | |
4216 | # freeze display when hovering over any label |
4224 | # freeze display when hovering over any label |
4217 | return if $DC::UI::TOOLTIP->{owner} |
4225 | return if $DC::UI::TOOLTIP->{owner} |
4218 | && grep $DC::UI::TOOLTIP->{owner} == $_->{label}, |
4226 | && grep $DC::UI::TOOLTIP->{owner} == $_->{label}, |
4219 | values %{ $self->{item} }; |
4227 | values %{ $self->{item} }; |
… | |
… | |
4269 | $label->{fg}[3] = $item->{fg}[3] || 1; |
4277 | $label->{fg}[3] = $item->{fg}[3] || 1; |
4270 | } |
4278 | } |
4271 | |
4279 | |
4272 | push @widgets, $label; |
4280 | push @widgets, $label; |
4273 | } |
4281 | } |
|
|
4282 | |
|
|
4283 | my $hash = join ",", @widgets; |
|
|
4284 | return if $hash eq $self->{last_widget_hash}; |
|
|
4285 | $self->{last_widget_hash} = $hash; |
4274 | |
4286 | |
4275 | $self->clear; |
4287 | $self->clear; |
4276 | $self->SUPER::add (reverse @widgets); |
4288 | $self->SUPER::add (reverse @widgets); |
4277 | } |
4289 | } |
4278 | |
4290 | |