… | |
… | |
82 | } |
82 | } |
83 | |
83 | |
84 | sub feed_sdl_button_down_event { |
84 | sub feed_sdl_button_down_event { |
85 | my ($ev) = @_; |
85 | my ($ev) = @_; |
86 | my ($x, $y) = ($ev->{x}, $ev->{y}); |
86 | my ($x, $y) = ($ev->{x}, $ev->{y}); |
|
|
87 | |
|
|
88 | warn "button down $ev->{button}\n";#d# |
87 | |
89 | |
88 | if (!$BUTTON_STATE) { |
90 | if (!$BUTTON_STATE) { |
89 | my $widget = $ROOT->find_widget ($x, $y); |
91 | my $widget = $ROOT->find_widget ($x, $y); |
90 | |
92 | |
91 | $GRAB = $widget; |
93 | $GRAB = $widget; |
… | |
… | |
452 | |
454 | |
453 | $FOCUS->emit ("focus_out") if $FOCUS; |
455 | $FOCUS->emit ("focus_out") if $FOCUS; |
454 | $self->emit ("focus_in"); |
456 | $self->emit ("focus_in"); |
455 | } |
457 | } |
456 | |
458 | |
457 | sub invoke_mouse_motion { 1 } |
459 | sub invoke_mouse_motion { 0 } |
458 | sub invoke_button_up { 1 } |
460 | sub invoke_button_up { 0 } |
459 | sub invoke_key_down { 1 } |
461 | sub invoke_key_down { 0 } |
460 | sub invoke_key_up { 1 } |
462 | sub invoke_key_up { 0 } |
461 | |
463 | |
462 | sub invoke_button_down { |
464 | sub invoke_button_down { |
463 | my ($self, $ev, $x, $y) = @_; |
465 | my ($self, $ev, $x, $y) = @_; |
464 | |
466 | |
465 | $self->grab_focus; |
467 | $self->grab_focus; |
466 | |
468 | |
|
|
469 | warn "button down $ev->{button} $x $y\n";#d# |
|
|
470 | |
467 | 1 |
471 | 0 |
468 | } |
472 | } |
469 | |
473 | |
470 | sub connect { |
474 | sub connect { |
471 | my ($self, $signal, $cb) = @_; |
475 | my ($self, $signal, $cb) = @_; |
472 | |
476 | |
… | |
… | |
996 | my ($self, $widget) = @_; |
1000 | my ($self, $widget) = @_; |
997 | |
1001 | |
998 | $self->{vp}->add ($self->{child} = $widget); |
1002 | $self->{vp}->add ($self->{child} = $widget); |
999 | } |
1003 | } |
1000 | |
1004 | |
|
|
1005 | sub invoke_button_down { |
|
|
1006 | my ($self, $ev) = @_; |
|
|
1007 | |
|
|
1008 | warn "button down $ev->{button}\n";#d# |
|
|
1009 | |
|
|
1010 | 0 |
|
|
1011 | } |
|
|
1012 | |
1001 | sub update_slider { |
1013 | sub update_slider { |
1002 | my ($self) = @_; |
1014 | my ($self) = @_; |
1003 | |
1015 | |
1004 | $self->{slider}->set_range ([$self->{slider}{range}[0], 0, $self->{vp}->child->{h}, $self->{vp}{h}, 1]); |
1016 | $self->{slider}->set_range ([$self->{slider}{range}[0], 0, $self->{vp}->child->{h}, $self->{vp}{h}, 1]); |
1005 | } |
1017 | } |
… | |
… | |
1082 | my $self = $class->SUPER::new ( |
1094 | my $self = $class->SUPER::new ( |
1083 | bg => [1, 1, 1, 1], |
1095 | bg => [1, 1, 1, 1], |
1084 | border_bg => [1, 1, 1, 1], |
1096 | border_bg => [1, 1, 1, 1], |
1085 | border => 0.6, |
1097 | border => 0.6, |
1086 | can_events => 1, |
1098 | can_events => 1, |
1087 | min_w => 16, |
1099 | min_w => 64, |
1088 | min_h => 16, |
1100 | min_h => 32, |
1089 | %arg, |
1101 | %arg, |
1090 | ); |
1102 | ); |
1091 | |
1103 | |
1092 | $self->{title_widget} = new CFClient::UI::Label |
1104 | $self->{title_widget} = new CFClient::UI::Label |
1093 | align => 0, |
1105 | align => 0, |
… | |
… | |
2118 | my $self = $class->SUPER::new ( |
2130 | my $self = $class->SUPER::new ( |
2119 | can_events => 0, |
2131 | can_events => 0, |
2120 | @_, |
2132 | @_, |
2121 | ); |
2133 | ); |
2122 | |
2134 | |
2123 | $self->{path} |
2135 | $self->{path} || $self->{tex} |
2124 | or Carp::croak "required attribute 'path' not set"; |
2136 | or Carp::croak "'path' or 'tex' attributes required"; |
2125 | |
2137 | |
2126 | $self->{tex} = $texture_cache{$self->{path}} ||= |
2138 | $self->{tex} ||= $texture_cache{$self->{path}} ||= |
2127 | new_from_file CFClient::Texture CFClient::find_rcfile $self->{path}, mipmap => 1; |
2139 | new_from_file CFClient::Texture CFClient::find_rcfile $self->{path}, mipmap => 1; |
2128 | |
2140 | |
2129 | Scalar::Util::weaken $texture_cache{$self->{path}}; |
2141 | Scalar::Util::weaken $texture_cache{$self->{path}}; |
2130 | |
2142 | |
2131 | $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; |
2143 | $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; |
… | |
… | |
3816 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
3828 | my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; |
3817 | |
3829 | |
3818 | $w = 0 if $w < 0; |
3830 | $w = 0 if $w < 0; |
3819 | $h = 0 if $h < 0; |
3831 | $h = 0 if $h < 0; |
3820 | |
3832 | |
|
|
3833 | $w = max $widget->{min_w}, $w; |
|
|
3834 | $h = max $widget->{min_h}, $h; |
|
|
3835 | |
|
|
3836 | $w = min $widget->{max_w}, $w if exists $widget->{max_w}; |
|
|
3837 | $h = min $widget->{max_h}, $h if exists $widget->{max_h}; |
|
|
3838 | |
3821 | $w = int $w + 0.5; |
3839 | $w = int $w + 0.5; |
3822 | $h = int $h + 0.5; |
3840 | $h = int $h + 0.5; |
3823 | |
3841 | |
3824 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
3842 | if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { |
3825 | $widget->{old_w} = $widget->{w}; |
3843 | $widget->{old_w} = $widget->{w}; |