diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2002-09-03 11:53:17 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2002-09-03 11:53:17 +0000 |
commit | 7c466926ccdf01b01abede0cd5b40e0953de2ddf (patch) | |
tree | 7b7c5f2d411604bcdf947fd8442e238eacbfc732 | |
parent | 31f88563d82cccc918203f040ac1043793690b29 (diff) | |
download | control-center-7c466926ccdf01b01abede0cd5b40e0953de2ddf.tar control-center-7c466926ccdf01b01abede0cd5b40e0953de2ddf.tar.gz control-center-7c466926ccdf01b01abede0cd5b40e0953de2ddf.tar.bz2 control-center-7c466926ccdf01b01abede0cd5b40e0953de2ddf.tar.xz control-center-7c466926ccdf01b01abede0cd5b40e0953de2ddf.zip |
- ugtk :
o create_pix_text:
* remove
* kill uni colored background
* api change:
+ background argument => background list
+ remove bold argument
* render all text (normal, highlighted, selected) on specified
background in one pass
o gtkicons_labels_widget():
* explain/comment
* move all drawing logic in &$draw
* create buffer area, text pics only one time
* add a pixbuf for highlighted item
* render highlighted icon by making it more transparent
* recalculate drawing buffer only on state change
- mcc :
* move all drawing logic in &$draw
* create buffer area, text pics only one time
* render highlighted icon by making it more transparent
* recalculate drawing buffer only on state change
-rwxr-xr-x | control-center | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/control-center b/control-center index 7dc2d4f4..24088deb 100755 --- a/control-center +++ b/control-center @@ -269,12 +269,12 @@ my $left_back_pixbuf_unaltered_h = gtkcreate_png_pixbuf('mcc-left-back2'); my @darea_left_list; my $cursor_hand = new Gtk::Gdk::Cursor 60; my $cursor_normal = new Gtk::Gdk::Cursor 68; -my @back; -($back[0], undef) = gtkcreate_png('mcc-left-back'); -$back[1] = $back[0]; -($back[2], undef) = gtkcreate_png('mcc-left-back2'); my ($index, $left_locked, $pending_app) = (0, 0, 0); my $darea_left_sav; +my $back; +($back->[0], undef) = gtkcreate_png('mcc-left-back'); +$back->[1] = $back->[0]; +($back->[2], undef) = gtkcreate_png('mcc-left-back2'); foreach (@tree) { $index++; my $index = $index; @@ -282,48 +282,50 @@ foreach (@tree) { my $darea_left = gtkset_usize(new Gtk::DrawingArea, 160, 45); $darea_left->{state} = 0; - my $dbl_area_left; + my ($dbl_area_left, $pix, $width, $height); $darea_left->set_events(['exposure_mask', 'enter_notify_mask', 'leave_notify_mask', 'button_press_mask', 'button_release_mask' ]); - $darea_left->signal_connect(size_allocate => sub { $dbl_area_left = undef }); my @left_back_pixbuf; # 0 => unselected, 1 => highlited, 2 => selected $left_back_pixbuf[0] = compose_with_back($_->[1], $left_back_pixbuf_unaltered); $left_back_pixbuf[2] = compose_with_back($_->[1], $left_back_pixbuf_unaltered_h); - $left_back_pixbuf[1] = $left_back_pixbuf[0]; - my ($width, $height) = ($left_back_pixbuf[0]->get_width, $left_back_pixbuf[0]->get_height); - $darea_left->signal_connect(expose_event => sub { + $left_back_pixbuf[1] = compose_with_back($_->[1], $left_back_pixbuf_unaltered, 170); + my ($pixbuf_width, $pixbuf_height) = ($left_back_pixbuf[0]->get_width, $left_back_pixbuf[0]->get_height); + my $draw = sub { my ($dx, $dy) = ($darea_left->allocation->[2], $darea_left->allocation->[3]); my $state = $darea_left->{state}; - if (!defined($dbl_area_left) || $darea_left->{state} != $dbl_area_left->{state}) { - my ($pix, $width, $height) = create_pix_text($darea_left, $text, "#0#0#0", - $darea_left->style->font, - max($dx-40, 0), $dy, 0, 0, $back[$state], 160, 45, 0, 1, $state); + if (!defined($dbl_area_left)) { + print "Creating left text pixmaps\n"; + ($pix, $width, $height) = create_pix_text($darea_left, $text, "#0#0#0", $darea_left->style->font, + max($dx-40, 0), $dy, 0, 0, $back, 160, 45, 0, 1); $dbl_area_left = new Gtk::Gdk::Pixmap($darea_left->window, $dx, $dy); - $dbl_area_left->{state} = $darea_left->{state}; + } + # Redraw if state change (selected <=> not selected) + if (!$dbl_area_left->{state} || $state != $dbl_area_left->{state}) { + print "Update left text pixmaps\n"; + $dbl_area_left->{state} = $state; $darea_left->{dbl} = $dbl_area_left; - fill_tiled($darea_left, $dbl_area_left, $back[$state], 40, $dy, 40, 45); + fill_tiled($darea_left, $dbl_area_left, $back->[$state], 40, $dy, 40, 45); $dbl_area_left->draw_pixmap($darea_left->style->bg_gc('normal'), - $pix, 0, 0, 40, 0, $width, $height); - } + $pix->[$state], 0, 0, 40, 0, $width, $height); + $left_back_pixbuf[$state]->render_to_drawable($dbl_area_left, $darea_left->style->fg_gc('normal'), 0, 0, 8, 10, + $pixbuf_width, $pixbuf_height, 'normal', 0, 0); + } + print "Render left text pixmaps\n"; $darea_left->window->draw_pixmap($darea_left->style->bg_gc('normal'), $dbl_area_left, 0, 0, 0, 0, ($dx, $dy)); - - $left_back_pixbuf[$state]->render_to_drawable($darea_left->window, $darea_left->style->fg_gc('normal'), 0, 0, 8, 10, - $width, $height, 'normal', 0, 0); - }); + }; + $darea_left->signal_connect(expose_event => $draw); $darea_left->signal_connect(realize => sub { $darea_left->window->set_cursor($cursor_hand) }); $darea_left->signal_connect(enter_notify_event => sub { return if ($darea_left->{state} != 0); $darea_left->{state} = 1; - $left_back_pixbuf[$darea_left->{state}]->render_to_drawable($darea_left->window, $darea_left->style->fg_gc('normal'), 0, 0, 8, 10, - $width, $height, 'normal', 0, 0); + &$draw; }); $darea_left->signal_connect(leave_notify_event => sub { return if ($darea_left->{state} != 1); $darea_left->{state} = 0; - $left_back_pixbuf[$darea_left->{state}]->render_to_drawable($darea_left->window, $darea_left->style->fg_gc('normal'), 0, 0, 8, 10, - $width, $height, 'normal', 0, 0); + &$draw; }); $darea_left->signal_connect(button_release_event => sub { $left_locked and return; @@ -339,7 +341,8 @@ foreach (@tree) { } } $darea_left->window->set_cursor($cursor_normal); - $darea_left->{state} = 2, $darea_left->draw(undef); + $darea_left->{state} = 2; + &$draw; if ($still_in_splash_screen) { $still_in_splash_screen = 0; update_exp(); @@ -426,7 +429,7 @@ res_socket(); foreach (@darea_left_list) { $fixed_left->put($_->[1], 0, $_->[0]) } -$fixed_left->signal_connect(realize => sub { $fixed_left->window->set_back_pixmap($back[0], 0) }); +$fixed_left->signal_connect(realize => sub { $fixed_left->window->set_back_pixmap($back->[0], 0) }); my $dbl_area; my ($pixmap_back, undef) = gtkcreate_png('mcc-title-back'); @@ -447,7 +450,6 @@ $darea_title->signal_connect(button_release_event => sub { $_->[1]->draw(undef); } }); -$darea_title->signal_connect(configure_event => sub { $dbl_area = undef }); $darea_title->signal_connect(expose_event => sub { my @dim = @{$_[1]->{area}}; |