… | |
… | |
22 | our $TOOLTIP_WATCHER = Event->idle (min => 1/60, cb => sub { |
22 | our $TOOLTIP_WATCHER = Event->idle (min => 1/60, cb => sub { |
23 | if (!$GRAB) { |
23 | if (!$GRAB) { |
24 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
24 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
25 | if (length $widget->{tooltip}) { |
25 | if (length $widget->{tooltip}) { |
26 | if ($TOOLTIP->{owner} != $widget) { |
26 | if ($TOOLTIP->{owner} != $widget) { |
|
|
27 | $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner}; |
27 | $TOOLTIP->hide; |
28 | $TOOLTIP->hide; |
28 | |
29 | |
29 | $TOOLTIP->{owner} = $widget; |
30 | $TOOLTIP->{owner} = $widget; |
|
|
31 | $TOOLTIP->{owner}->emit ("tooltip_show") if $TOOLTIP->{owner}; |
30 | |
32 | |
31 | return if $ENV{CFPLUS_DEBUG} & 8; |
33 | return if $ENV{CFPLUS_DEBUG} & 8; |
32 | |
34 | |
33 | my $tip = $widget->{tooltip}; |
35 | my $tip = $widget->{tooltip}; |
34 | |
36 | |
… | |
… | |
42 | } |
44 | } |
43 | } |
45 | } |
44 | } |
46 | } |
45 | |
47 | |
46 | $TOOLTIP->hide; |
48 | $TOOLTIP->hide; |
|
|
49 | $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner}; |
47 | delete $TOOLTIP->{owner}; |
50 | delete $TOOLTIP->{owner}; |
48 | }); |
51 | }); |
49 | |
52 | |
50 | sub get_layout { |
53 | sub get_layout { |
51 | my $layout; |
54 | my $layout; |
… | |
… | |
263 | my ($self) = @_; |
266 | my ($self) = @_; |
264 | |
267 | |
265 | $self->hide; |
268 | $self->hide; |
266 | $self->emit ("destroy"); |
269 | $self->emit ("destroy"); |
267 | %$self = (); |
270 | %$self = (); |
|
|
271 | } |
|
|
272 | |
|
|
273 | sub TO_JSON { |
|
|
274 | { __widget_ref__ => $_[0]{s_id} } |
268 | } |
275 | } |
269 | |
276 | |
270 | sub show { |
277 | sub show { |
271 | my ($self) = @_; |
278 | my ($self) = @_; |
272 | |
279 | |
… | |
… | |
1966 | my $mod = $ev->{mod}; |
1973 | my $mod = $ev->{mod}; |
1967 | my $sym = $ev->{sym}; |
1974 | my $sym = $ev->{sym}; |
1968 | my $uni = $ev->{unicode}; |
1975 | my $uni = $ev->{unicode}; |
1969 | |
1976 | |
1970 | my $text = $self->get_text; |
1977 | my $text = $self->get_text; |
|
|
1978 | |
|
|
1979 | $self->{cursor} = List::Util::max 0, List::Util::min $self->{cursor}, length $text; |
1971 | |
1980 | |
1972 | if ($uni == 8) { |
1981 | if ($uni == 8) { |
1973 | substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; |
1982 | substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; |
1974 | } elsif ($uni == 127) { |
1983 | } elsif ($uni == 127) { |
1975 | substr $text, $self->{cursor}, 1, ""; |
1984 | substr $text, $self->{cursor}, 1, ""; |
… | |
… | |
2830 | #font => default_font |
2839 | #font => default_font |
2831 | @_, |
2840 | @_, |
2832 | |
2841 | |
2833 | layout => (new CFPlus::Layout), |
2842 | layout => (new CFPlus::Layout), |
2834 | par => [], |
2843 | par => [], |
|
|
2844 | max_par => 0, |
2835 | height => 0, |
2845 | height => 0, |
2836 | children => [ |
2846 | children => [ |
2837 | (new CFPlus::UI::Empty expand => 1), |
2847 | (new CFPlus::UI::Empty expand => 1), |
2838 | (new CFPlus::UI::Slider vertical => 1), |
2848 | (new CFPlus::UI::Slider vertical => 1), |
2839 | ], |
2849 | ], |
… | |
… | |
2962 | wrapped => 1, |
2972 | wrapped => 1, |
2963 | }; |
2973 | }; |
2964 | |
2974 | |
2965 | $self->add (@{ $para->{widget} }) if @{ $para->{widget} }; |
2975 | $self->add (@{ $para->{widget} }) if @{ $para->{widget} }; |
2966 | push @{$self->{par}}, $para; |
2976 | push @{$self->{par}}, $para; |
|
|
2977 | } |
|
|
2978 | |
|
|
2979 | if (my $max = $self->{max_par}) { |
|
|
2980 | shift @{$self->{par}} while @{$self->{par}} > $max; |
2967 | } |
2981 | } |
2968 | |
2982 | |
2969 | $self->{need_reflow}++; |
2983 | $self->{need_reflow}++; |
2970 | $self->update; |
2984 | $self->update; |
2971 | } |
2985 | } |