mirror of
https://github.com/elementary/gala.git
synced 2024-11-27 15:45:31 +03:00
add delay before expading an inserter preview
This commit is contained in:
parent
bf65d00e39
commit
6f03fc536b
@ -22,9 +22,13 @@ namespace Gala
|
||||
{
|
||||
public class WorkspaceInsertThumb : Actor
|
||||
{
|
||||
const int EXPAND_DELAY = 300;
|
||||
|
||||
public int workspace_index { get; construct set; }
|
||||
public bool expanded { get; private set; default = false; }
|
||||
|
||||
uint expand_timeout = 0;
|
||||
|
||||
public WorkspaceInsertThumb (int workspace_index)
|
||||
{
|
||||
Object (workspace_index: workspace_index);
|
||||
@ -43,23 +47,15 @@ namespace Gala
|
||||
if (!Prefs.get_dynamic_workspaces ())
|
||||
return;
|
||||
|
||||
save_easing_state ();
|
||||
set_easing_mode (AnimationMode.EASE_OUT_QUAD);
|
||||
set_easing_duration (200);
|
||||
|
||||
if (!hovered) {
|
||||
remove_transition ("pulse");
|
||||
opacity = 0;
|
||||
width = IconGroupContainer.SPACING;
|
||||
expanded = false;
|
||||
} else {
|
||||
add_pulse_animation ();
|
||||
opacity = 200;
|
||||
width = IconGroupContainer.GROUP_WIDTH + IconGroupContainer.SPACING * 2;
|
||||
expanded = true;
|
||||
}
|
||||
if (expand_timeout != 0) {
|
||||
Source.remove (expand_timeout);
|
||||
expand_timeout = 0;
|
||||
}
|
||||
|
||||
restore_easing_state ();
|
||||
transform (false);
|
||||
} else
|
||||
expand_timeout = Timeout.add (EXPAND_DELAY, expand);
|
||||
});
|
||||
|
||||
add_action (drop);
|
||||
@ -74,6 +70,36 @@ namespace Gala
|
||||
add_child (icon);
|
||||
}
|
||||
|
||||
bool expand ()
|
||||
{
|
||||
expand_timeout = 0;
|
||||
|
||||
transform (true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void transform (bool expand)
|
||||
{
|
||||
save_easing_state ();
|
||||
set_easing_mode (AnimationMode.EASE_OUT_QUAD);
|
||||
set_easing_duration (200);
|
||||
|
||||
if (!expand) {
|
||||
remove_transition ("pulse");
|
||||
opacity = 0;
|
||||
width = IconGroupContainer.SPACING;
|
||||
expanded = false;
|
||||
} else {
|
||||
add_pulse_animation ();
|
||||
opacity = 200;
|
||||
width = IconGroupContainer.GROUP_WIDTH + IconGroupContainer.SPACING * 2;
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
restore_easing_state ();
|
||||
}
|
||||
|
||||
void add_pulse_animation ()
|
||||
{
|
||||
var transition = new TransitionGroup ();
|
||||
|
Loading…
Reference in New Issue
Block a user