@@ -49,57 +49,48 @@ public class Maya.View.VAutoHider : Gtk.Bin {
4949
5050 public override void size_allocate (Gtk .Allocation allocation ) {
5151 base . size_allocate (allocation);
52- int global_height = allocation . height;
53- int children_length = (int )main_box. get_children (). length () - 1 ;
52+
53+ int children_length = (int ) main_box. get_children (). length () - 1 ;
5454 if (children_length == 0 ) {
5555 more_label. hide ();
5656 return ;
5757 }
5858
59- int height = 0 ;
6059 int more_label_height;
61- int shown_children = 0 ;
6260 more_label. show ();
6361 more_label. vexpand = false ;
6462 more_label. get_preferred_height (out more_label_height, null );
65- more_label. vexpand = true ;
6663 more_label. hide ();
64+
65+ int shown_children = 0 ;
66+ int shown_children_height = 0 ;
6767 foreach (var child in main_box. get_children ()) {
68- if (child == more_label)
68+ if (child == more_label) {
6969 continue ;
70-
71- bool last = (shown_children == children_length - 1 );
70+ }
7271
7372 int child_height;
7473 child. show ();
7574 child. get_preferred_height (out child_height, null );
76- ((Maya . View . EventButton ) child). hide_without_animate ();
7775
78- bool should_hide;
79- if (global_height - more_label_height < child_height + height) {
80- should_hide = true ;
81- if (last && (global_height >= child_height + height)) {
82- should_hide = false ;
76+ if (shown_children_height + child_height > allocation . height - more_label_height) {
77+ var last = shown_children == children_length - 1 ;
78+ if ( ! last || shown_children_height + child_height > allocation . height) {
79+ (( Maya . View . EventButton ) child) . hide_without_animate ();
80+ continue ;
8381 }
84- } else {
85- should_hide = false ;
86- height + = child_height;
8782 }
8883
89- if (should_hide) {
90- ((Maya . View . EventButton ) child). hide_without_animate ();
91- } else {
92- ((Maya . View . EventButton ) child). show_without_animate ();
93- shown_children++ ;
94- }
84+ ((Maya . View . EventButton ) child). show_without_animate ();
85+ shown_children++ ;
86+ shown_children_height + = child_height;
9587 }
9688
97- int more = children_length - shown_children;
98- if (shown_children != children_length && more > 0 ) {
89+ var hidden_children = children_length - shown_children;
90+ if (hidden_children > 0 ) {
9991 more_label. show ();
100- more_label. set_label (_(" %u more…" ). printf ((uint )more));
101- } else {
102- more_label. hide ();
92+ more_label. label = _(" %i more…" ). printf (hidden_children);
93+ more_label. vexpand = true ;
10394 }
10495 }
10596
0 commit comments