… | |
… | |
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) { |
… | |
… | |
492 | sub new { |
492 | sub new { |
493 | my ($class, %arg) = @_; |
493 | my ($class, %arg) = @_; |
494 | |
494 | |
495 | my $children = delete $arg{children} || []; |
495 | my $children = delete $arg{children} || []; |
496 | |
496 | |
497 | my $self = $class->SUPER::new (children => [], can_events => 0, %arg); |
497 | my $self = $class->SUPER::new ( |
|
|
498 | children => [], |
|
|
499 | can_events => 0, |
|
|
500 | %arg, |
|
|
501 | ); |
498 | $self->add ($_) for @$children; |
502 | $self->add ($_) for @$children; |
499 | |
503 | |
500 | $self |
504 | $self |
501 | } |
505 | } |
502 | |
506 | |
… | |
… | |
748 | my $class = shift; |
752 | my $class = shift; |
749 | |
753 | |
750 | # TODO: user_x, user_y, overwrite moveto? |
754 | # TODO: user_x, user_y, overwrite moveto? |
751 | |
755 | |
752 | my $self = $class->SUPER::new ( |
756 | my $self = $class->SUPER::new ( |
753 | bg => [1, 1, 1, 1], |
757 | bg => [1, 1, 1, 1], |
754 | border_bg => [1, 1, 1, 1], |
758 | border_bg => [1, 1, 1, 1], |
755 | border => 0.8, |
759 | border => 0.8, |
756 | can_events => 1, |
760 | can_events => 1, |
757 | @_ |
761 | @_ |
758 | ); |
762 | ); |
759 | |
763 | |
760 | $self->{title} &&= new CFClient::UI::Label |
764 | $self->{title} &&= new CFClient::UI::Label |
… | |
… | |
1151 | |
1155 | |
1152 | sub new { |
1156 | sub new { |
1153 | my ($class, %arg) = @_; |
1157 | my ($class, %arg) = @_; |
1154 | |
1158 | |
1155 | my $self = $class->SUPER::new ( |
1159 | my $self = $class->SUPER::new ( |
1156 | fg => [1, 1, 1], |
1160 | fg => [1, 1, 1], |
1157 | #font => default_font |
1161 | #font => default_font |
1158 | fontsize => 1, |
1162 | fontsize => 1, |
1159 | text => "", |
1163 | text => "", |
1160 | align => -1, |
1164 | align => -1, |
1161 | valign => -1, |
1165 | valign => -1, |
1162 | padding => 2, |
1166 | padding => 2, |
1163 | layout => new CFClient::Layout, |
1167 | layout => new CFClient::Layout, |
1164 | can_events => 0, |
1168 | can_events => 0, |
1165 | %arg |
1169 | %arg |
1166 | ); |
1170 | ); |
1167 | |
1171 | |
1168 | if (exists $self->{template}) { |
1172 | if (exists $self->{template}) { |
… | |
… | |
1292 | |
1296 | |
1293 | sub new { |
1297 | sub new { |
1294 | my $class = shift; |
1298 | my $class = shift; |
1295 | |
1299 | |
1296 | $class->SUPER::new ( |
1300 | $class->SUPER::new ( |
1297 | fg => [1, 1, 1], |
1301 | fg => [1, 1, 1], |
1298 | bg => [0, 0, 0, 0.2], |
1302 | bg => [0, 0, 0, 0.2], |
1299 | active_bg => [1, 1, 1, 0.5], |
1303 | active_bg => [1, 1, 1, 0.5], |
1300 | active_fg => [0, 0, 0], |
1304 | active_fg => [0, 0, 0], |
1301 | can_hover => 1, |
1305 | can_hover => 1, |
1302 | can_focus => 1, |
1306 | can_focus => 1, |
1303 | valign => 0, |
1307 | valign => 0, |
1304 | can_events => 1, |
1308 | can_events => 1, |
1305 | @_ |
1309 | @_ |
1306 | ) |
1310 | ) |
1307 | } |
1311 | } |
1308 | |
1312 | |
… | |
… | |
1462 | my ($self, $ev) = @_; |
1466 | my ($self, $ev) = @_; |
1463 | |
1467 | |
1464 | my $sym = $ev->{sym}; |
1468 | my $sym = $ev->{sym}; |
1465 | |
1469 | |
1466 | if ($sym == 13) { |
1470 | if ($sym == 13) { |
|
|
1471 | unshift @{$self->{history}}, |
|
|
1472 | my $txt = $self->get_text; |
|
|
1473 | $self->{history_pointer} = -1; |
1467 | $self->emit (activate => $self->get_text); |
1474 | $self->emit (activate => $txt); |
1468 | $self->update; |
1475 | $self->update; |
|
|
1476 | |
|
|
1477 | } elsif ($sym == CFClient::SDLK_UP) { |
|
|
1478 | if ($self->{history_pointer} < 0) { |
|
|
1479 | $self->{history_saveback} = $self->get_text; |
|
|
1480 | } |
|
|
1481 | $self->{history_pointer}++; |
|
|
1482 | if ($self->{history_pointer} >= @{$self->{history}}) { |
|
|
1483 | $self->{history_pointer} = @{$self->{history}} - 1; |
|
|
1484 | } |
|
|
1485 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
|
|
1486 | |
|
|
1487 | } elsif ($sym == CFClient::SDLK_DOWN) { |
|
|
1488 | $self->{history_pointer}--; |
|
|
1489 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
|
|
1490 | |
|
|
1491 | if ($self->{history_pointer} >= 0) { |
|
|
1492 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
|
|
1493 | } else { |
|
|
1494 | $self->set_text ($self->{history_saveback}); |
|
|
1495 | } |
1469 | |
1496 | |
1470 | } else { |
1497 | } else { |
1471 | $self->SUPER::key_down ($ev); |
1498 | $self->SUPER::key_down ($ev); |
1472 | } |
1499 | } |
1473 | |
1500 | |
… | |
… | |
1487 | |
1514 | |
1488 | sub new { |
1515 | sub new { |
1489 | my $class = shift; |
1516 | my $class = shift; |
1490 | |
1517 | |
1491 | $class->SUPER::new ( |
1518 | $class->SUPER::new ( |
1492 | padding => 4, |
1519 | padding => 4, |
1493 | fg => [1, 1, 1], |
1520 | fg => [1, 1, 1], |
1494 | bg => [1, 1, 1, 0.2], |
1521 | bg => [1, 1, 1, 0.2], |
1495 | active_fg => [0, 0, 1], |
1522 | active_fg => [0, 0, 1], |
1496 | can_hover => 1, |
1523 | can_hover => 1, |
1497 | align => 0, |
1524 | align => 0, |
1498 | valign => 0, |
1525 | valign => 0, |
1499 | can_events => 1, |
1526 | can_events => 1, |
1500 | @_ |
1527 | @_ |
1501 | ) |
1528 | ) |
1502 | } |
1529 | } |
1503 | |
1530 | |
… | |
… | |
1794 | |
1821 | |
1795 | sub new { |
1822 | sub new { |
1796 | my ($class, %arg) = @_; |
1823 | my ($class, %arg) = @_; |
1797 | |
1824 | |
1798 | my $self = $class->SUPER::new ( |
1825 | my $self = $class->SUPER::new ( |
1799 | tooltip => $arg{type}, |
1826 | tooltip => $arg{type}, |
1800 | can_events => 1, |
|
|
1801 | can_hover => 1, |
1827 | can_hover => 1, |
1802 | %arg, |
1828 | %arg, |
1803 | ); |
1829 | ); |
1804 | |
1830 | |
1805 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
1831 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
… | |
… | |
1978 | |
2004 | |
1979 | sub new { |
2005 | sub new { |
1980 | my $class = shift; |
2006 | my $class = shift; |
1981 | |
2007 | |
1982 | my $self = $class->SUPER::new ( |
2008 | my $self = $class->SUPER::new ( |
1983 | fontsize => 1, |
2009 | fontsize => 1, |
|
|
2010 | can_events => 0, |
1984 | #font => default_font |
2011 | #font => default_font |
1985 | @_, |
2012 | @_, |
1986 | |
2013 | |
1987 | layout => (new CFClient::Layout), |
2014 | layout => (new CFClient::Layout), |
1988 | par => [], |
2015 | par => [], |
1989 | height => 0, |
2016 | height => 0, |
1990 | children => [ |
2017 | children => [ |
1991 | (new CFClient::UI::Empty expand => 1), |
2018 | (new CFClient::UI::Empty expand => 1), |
1992 | (new CFClient::UI::Slider vertical => 1), |
2019 | (new CFClient::UI::Slider vertical => 1), |
1993 | ], |
2020 | ], |
1994 | ); |
2021 | ); |
1995 | |
2022 | |
… | |
… | |
2180 | |
2207 | |
2181 | sub new { |
2208 | sub new { |
2182 | my $class = shift; |
2209 | my $class = shift; |
2183 | |
2210 | |
2184 | my $self = $class->SUPER::new ( |
2211 | my $self = $class->SUPER::new ( |
2185 | state => 0, |
2212 | state => 0, |
2186 | connect_activate => \&toggle_flopper, |
2213 | connect_activate => \&toggle_flopper, |
2187 | can_events => 1, |
|
|
2188 | @_ |
2214 | @_ |
2189 | ); |
2215 | ); |
2190 | |
2216 | |
2191 | if ($self->{state}) { |
2217 | if ($self->{state}) { |
2192 | $self->{state} = 0; |
2218 | $self->{state} = 0; |