Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 19 additions & 28 deletions src/Grid/VAutoHider.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,57 +49,48 @@ public class Maya.View.VAutoHider : Gtk.Bin {

public override void size_allocate (Gtk.Allocation allocation) {
base.size_allocate (allocation);
int global_height = allocation.height;
int children_length = (int)main_box.get_children ().length () - 1;

int children_length = (int) main_box.get_children ().length () - 1;
if (children_length == 0) {
more_label.hide ();
return;
}

int height = 0;
int more_label_height;
int shown_children = 0;
more_label.show ();
more_label.vexpand = false;
more_label.get_preferred_height (out more_label_height, null);
more_label.vexpand = true;
more_label.hide ();

int shown_children = 0;
int shown_children_height = 0;
foreach (var child in main_box.get_children ()) {
if (child == more_label)
if (child == more_label) {
continue;

bool last = (shown_children == children_length - 1);
}

int child_height;
child.show ();
child.get_preferred_height (out child_height, null);
((Maya.View.EventButton) child).hide_without_animate ();

bool should_hide;
if (global_height - more_label_height < child_height + height) {
should_hide = true;
if (last && (global_height >= child_height + height)) {
should_hide = false;
if (shown_children_height + child_height > allocation.height - more_label_height) {
var last = shown_children == children_length - 1;
if (!last || shown_children_height + child_height > allocation.height) {
((Maya.View.EventButton) child).hide_without_animate ();
continue;
}
} else {
should_hide = false;
height += child_height;
}

if (should_hide) {
((Maya.View.EventButton) child).hide_without_animate ();
} else {
((Maya.View.EventButton) child).show_without_animate ();
shown_children++;
}
((Maya.View.EventButton) child).show_without_animate ();
shown_children++;
shown_children_height += child_height;
}

int more = children_length - shown_children;
if (shown_children != children_length && more > 0) {
var hidden_children = children_length - shown_children;
if (hidden_children > 0) {
more_label.show ();
more_label.set_label (_("%u more…").printf ((uint)more));
} else {
more_label.hide ();
more_label.label = _("%i more…").printf (hidden_children);
more_label.vexpand = true;
}
}

Expand Down
Loading