… | |
… | |
137 | |
137 | |
138 | sub new { |
138 | sub new { |
139 | my $class = shift; |
139 | my $class = shift; |
140 | |
140 | |
141 | my $self = bless { |
141 | my $self = bless { |
142 | x => 0, |
142 | x => 0, |
143 | y => 0, |
143 | y => 0, |
144 | z => 0, |
144 | z => 0, |
145 | can_events => 1, |
145 | can_events => 1, |
146 | @_ |
146 | @_ |
147 | }, $class; |
147 | }, $class; |
148 | |
148 | |
149 | for (keys %$self) { |
149 | for (keys %$self) { |
… | |
… | |
246 | } |
246 | } |
247 | |
247 | |
248 | # return top left coordinates |
248 | # return top left coordinates |
249 | sub _topleft { |
249 | sub _topleft { |
250 | my ($self, $x, $y) = @_; |
250 | my ($self, $x, $y) = @_; |
|
|
251 | |
|
|
252 | $self->{parent} |
|
|
253 | or Carp::confess "no parent widget in _topleft\n";#d# |
251 | |
254 | |
252 | $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); |
255 | $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); |
253 | } |
256 | } |
254 | |
257 | |
255 | # translate global coordinates to local coordinate system |
258 | # translate global coordinates to local coordinate system |
… | |
… | |
492 | sub new { |
495 | sub new { |
493 | my ($class, %arg) = @_; |
496 | my ($class, %arg) = @_; |
494 | |
497 | |
495 | my $children = delete $arg{children} || []; |
498 | my $children = delete $arg{children} || []; |
496 | |
499 | |
497 | my $self = $class->SUPER::new (children => [], can_events => 0, %arg); |
500 | my $self = $class->SUPER::new ( |
|
|
501 | children => [], |
|
|
502 | can_events => 0, |
|
|
503 | %arg, |
|
|
504 | ); |
498 | $self->add ($_) for @$children; |
505 | $self->add ($_) for @$children; |
499 | |
506 | |
500 | $self |
507 | $self |
501 | } |
508 | } |
502 | |
509 | |
… | |
… | |
748 | my $class = shift; |
755 | my $class = shift; |
749 | |
756 | |
750 | # TODO: user_x, user_y, overwrite moveto? |
757 | # TODO: user_x, user_y, overwrite moveto? |
751 | |
758 | |
752 | my $self = $class->SUPER::new ( |
759 | my $self = $class->SUPER::new ( |
753 | bg => [1, 1, 1, 1], |
760 | bg => [1, 1, 1, 1], |
754 | border_bg => [1, 1, 1, 1], |
761 | border_bg => [1, 1, 1, 1], |
755 | border => 0.8, |
762 | border => 0.8, |
756 | can_events => 1, |
763 | can_events => 1, |
757 | @_ |
764 | @_ |
758 | ); |
765 | ); |
759 | |
766 | |
760 | $self->{title} &&= new CFClient::UI::Label |
767 | $self->{title} &&= new CFClient::UI::Label |
… | |
… | |
1151 | |
1158 | |
1152 | sub new { |
1159 | sub new { |
1153 | my ($class, %arg) = @_; |
1160 | my ($class, %arg) = @_; |
1154 | |
1161 | |
1155 | my $self = $class->SUPER::new ( |
1162 | my $self = $class->SUPER::new ( |
1156 | fg => [1, 1, 1], |
1163 | fg => [1, 1, 1], |
1157 | #font => default_font |
1164 | #font => default_font |
1158 | fontsize => 1, |
1165 | fontsize => 1, |
1159 | text => "", |
1166 | text => "", |
1160 | align => -1, |
1167 | align => -1, |
1161 | valign => -1, |
1168 | valign => -1, |
1162 | padding => 2, |
1169 | padding => 2, |
1163 | layout => new CFClient::Layout, |
1170 | layout => new CFClient::Layout, |
1164 | can_events => 0, |
1171 | can_events => 0, |
1165 | %arg |
1172 | %arg |
1166 | ); |
1173 | ); |
1167 | |
1174 | |
1168 | if (exists $self->{template}) { |
1175 | if (exists $self->{template}) { |
… | |
… | |
1292 | |
1299 | |
1293 | sub new { |
1300 | sub new { |
1294 | my $class = shift; |
1301 | my $class = shift; |
1295 | |
1302 | |
1296 | $class->SUPER::new ( |
1303 | $class->SUPER::new ( |
1297 | fg => [1, 1, 1], |
1304 | fg => [1, 1, 1], |
1298 | bg => [0, 0, 0, 0.2], |
1305 | bg => [0, 0, 0, 0.2], |
1299 | active_bg => [1, 1, 1, 0.5], |
1306 | active_bg => [1, 1, 1, 0.5], |
1300 | active_fg => [0, 0, 0], |
1307 | active_fg => [0, 0, 0], |
1301 | can_hover => 1, |
1308 | can_hover => 1, |
1302 | can_focus => 1, |
1309 | can_focus => 1, |
1303 | valign => 0, |
1310 | valign => 0, |
1304 | can_events => 1, |
1311 | can_events => 1, |
1305 | @_ |
1312 | @_ |
1306 | ) |
1313 | ) |
1307 | } |
1314 | } |
1308 | |
1315 | |
… | |
… | |
1462 | my ($self, $ev) = @_; |
1469 | my ($self, $ev) = @_; |
1463 | |
1470 | |
1464 | my $sym = $ev->{sym}; |
1471 | my $sym = $ev->{sym}; |
1465 | |
1472 | |
1466 | if ($sym == 13) { |
1473 | if ($sym == 13) { |
|
|
1474 | unshift @{$self->{history}}, |
|
|
1475 | my $txt = $self->get_text; |
|
|
1476 | $self->{history_pointer} = -1; |
|
|
1477 | $self->{history_saveback} = ''; |
1467 | $self->emit (activate => $self->get_text); |
1478 | $self->emit (activate => $txt); |
1468 | $self->update; |
1479 | $self->update; |
|
|
1480 | |
|
|
1481 | } elsif ($sym == CFClient::SDLK_UP) { |
|
|
1482 | if ($self->{history_pointer} < 0) { |
|
|
1483 | $self->{history_saveback} = $self->get_text; |
|
|
1484 | } |
|
|
1485 | if (@{$self->{history} || []} > 0) { |
|
|
1486 | $self->{history_pointer}++; |
|
|
1487 | if ($self->{history_pointer} >= @{$self->{history} || []}) { |
|
|
1488 | $self->{history_pointer} = @{$self->{history} || []} - 1; |
|
|
1489 | } |
|
|
1490 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
|
|
1491 | } |
|
|
1492 | |
|
|
1493 | } elsif ($sym == CFClient::SDLK_DOWN) { |
|
|
1494 | $self->{history_pointer}--; |
|
|
1495 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
|
|
1496 | |
|
|
1497 | if ($self->{history_pointer} >= 0) { |
|
|
1498 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
|
|
1499 | } else { |
|
|
1500 | $self->set_text ($self->{history_saveback}); |
|
|
1501 | } |
1469 | |
1502 | |
1470 | } else { |
1503 | } else { |
1471 | $self->SUPER::key_down ($ev); |
1504 | $self->SUPER::key_down ($ev); |
1472 | } |
1505 | } |
1473 | |
1506 | |
… | |
… | |
1487 | |
1520 | |
1488 | sub new { |
1521 | sub new { |
1489 | my $class = shift; |
1522 | my $class = shift; |
1490 | |
1523 | |
1491 | $class->SUPER::new ( |
1524 | $class->SUPER::new ( |
1492 | padding => 4, |
1525 | padding => 4, |
1493 | fg => [1, 1, 1], |
1526 | fg => [1, 1, 1], |
1494 | bg => [1, 1, 1, 0.2], |
1527 | bg => [1, 1, 1, 0.2], |
1495 | active_fg => [0, 0, 1], |
1528 | active_fg => [0, 0, 1], |
1496 | can_hover => 1, |
1529 | can_hover => 1, |
1497 | align => 0, |
1530 | align => 0, |
1498 | valign => 0, |
1531 | valign => 0, |
1499 | can_events => 1, |
1532 | can_events => 1, |
1500 | @_ |
1533 | @_ |
1501 | ) |
1534 | ) |
1502 | } |
1535 | } |
1503 | |
1536 | |
… | |
… | |
1794 | |
1827 | |
1795 | sub new { |
1828 | sub new { |
1796 | my ($class, %arg) = @_; |
1829 | my ($class, %arg) = @_; |
1797 | |
1830 | |
1798 | my $self = $class->SUPER::new ( |
1831 | my $self = $class->SUPER::new ( |
1799 | tooltip => $arg{type}, |
1832 | tooltip => $arg{type}, |
|
|
1833 | can_hover => 1, |
1800 | can_events => 1, |
1834 | can_events => 1, |
1801 | can_hover => 1, |
|
|
1802 | %arg, |
1835 | %arg, |
1803 | ); |
1836 | ); |
1804 | |
1837 | |
1805 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
1838 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
1806 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
1839 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
… | |
… | |
1978 | |
2011 | |
1979 | sub new { |
2012 | sub new { |
1980 | my $class = shift; |
2013 | my $class = shift; |
1981 | |
2014 | |
1982 | my $self = $class->SUPER::new ( |
2015 | my $self = $class->SUPER::new ( |
1983 | fontsize => 1, |
2016 | fontsize => 1, |
|
|
2017 | can_events => 0, |
1984 | #font => default_font |
2018 | #font => default_font |
1985 | @_, |
2019 | @_, |
1986 | |
2020 | |
1987 | layout => (new CFClient::Layout), |
2021 | layout => (new CFClient::Layout), |
1988 | par => [], |
2022 | par => [], |
1989 | height => 0, |
2023 | height => 0, |
1990 | children => [ |
2024 | children => [ |
1991 | (new CFClient::UI::Empty expand => 1), |
2025 | (new CFClient::UI::Empty expand => 1), |
1992 | (new CFClient::UI::Slider vertical => 1), |
2026 | (new CFClient::UI::Slider vertical => 1), |
1993 | ], |
2027 | ], |
1994 | ); |
2028 | ); |
1995 | |
2029 | |
… | |
… | |
2180 | |
2214 | |
2181 | sub new { |
2215 | sub new { |
2182 | my $class = shift; |
2216 | my $class = shift; |
2183 | |
2217 | |
2184 | my $self = $class->SUPER::new ( |
2218 | my $self = $class->SUPER::new ( |
2185 | state => 0, |
2219 | state => 0, |
2186 | connect_activate => \&toggle_flopper, |
2220 | connect_activate => \&toggle_flopper, |
2187 | can_events => 1, |
|
|
2188 | @_ |
2221 | @_ |
2189 | ); |
2222 | ); |
2190 | |
2223 | |
2191 | if ($self->{state}) { |
2224 | if ($self->{state}) { |
2192 | $self->{state} = 0; |
2225 | $self->{state} = 0; |