Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Re #204: Remove stack for showing tweet actions
Browse files Browse the repository at this point in the history
This mainly loses the cross-fade animation, but makes it feel snappier.

We also have a minor bug where resizing while actions are visible
can't track the grid height, but who activates actions on a tweet and
*then* resizes the window? It all fixes itself after they toggle back
to the tweet.
  • Loading branch information
IBBoard committed Dec 26, 2020
1 parent 9ae71d1 commit fb67941
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
20 changes: 13 additions & 7 deletions src/list/TweetListEntry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public class TweetListEntry : Cb.TwitterItem, Gtk.ListBoxRow {
[GtkChild]
private Gtk.Grid grid;
[GtkChild]
private Gtk.Stack stack;
[GtkChild]
private Gtk.Box action_box;
[GtkChild]
private Gtk.Label reply_label;
Expand Down Expand Up @@ -78,7 +76,7 @@ public class TweetListEntry : Cb.TwitterItem, Gtk.ListBoxRow {
}
public bool shows_actions {
get {
return stack.visible_child == action_box;
return action_box.visible;
}
}
private unowned Account account;
Expand Down Expand Up @@ -555,7 +553,8 @@ public class TweetListEntry : Cb.TwitterItem, Gtk.ListBoxRow {

if (tweet.is_flag_set (Cb.TweetState.DELETED)) {
this.sensitive = false;
stack.visible_child = grid;
grid.show();
action_box.hide();
}

this.values_set = true;
Expand Down Expand Up @@ -625,12 +624,19 @@ public class TweetListEntry : Cb.TwitterItem, Gtk.ListBoxRow {
if (this._read_only)
return;

if (stack.visible_child == action_box) {
stack.visible_child = grid;
if (action_box.visible) {
grid.show();
action_box.hide();
this.activatable = true;
this.grab_focus();
} else {
stack.visible_child = action_box;
// We can't use size groups because they only work when all elements are visible
// So kludge an approximation with set_size_request on the action box (which will always be the shortest widget)
// XXX: Currently doesn't take into account changes in grid height while grid is hidden
var grid_height = grid.get_allocated_height() + grid.get_margin_top() + grid.get_margin_bottom();
action_box.set_size_request(-1, grid_height);
action_box.show();
grid.hide();
this.activatable = false;
retweet_button.grab_focus();
}
Expand Down
8 changes: 4 additions & 4 deletions ui/tweet-list-entry.ui
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
<signal name="focus-out-event" handler="focus_out_cb"/>
<signal name="key-release-event" handler="key_released_cb"/>
<child>
<object class="GtkStack" id="stack">
<object class="GtkBox" id="stack">
<property name="visible">1</property>
<property name="visible-child">grid</property>
<property name="transition-type">crossfade</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="action_box">
<property name="visible">1</property>
<property name="visible">0</property>
<property name="spacing">12</property>
<property name="halign">center</property>
<property name="vexpand">true</property>
<child>
<object class="DoubleTapButton" id="retweet_button">
<property name="visible">true</property>
Expand Down

0 comments on commit fb67941

Please sign in to comment.