mirror of
https://github.com/elementary/gala.git
synced 2024-10-26 07:51:41 +03:00
Multitasking view animation use GestureTracker
This commit is contained in:
parent
104f819e76
commit
5bba638ccf
@ -31,13 +31,13 @@ namespace Gala {
|
||||
|
||||
public Meta.Display display { get; construct; }
|
||||
public int monitor { get; construct; }
|
||||
public GestureAnimationDirector gesture_animation_director { get; construct; }
|
||||
public GestureTracker gesture_tracker { get; construct; }
|
||||
|
||||
WindowCloneContainer window_container;
|
||||
BackgroundManager background;
|
||||
|
||||
public MonitorClone (Meta.Display display, int monitor, GestureAnimationDirector gesture_animation_director) {
|
||||
Object (display: display, monitor: monitor, gesture_animation_director: gesture_animation_director);
|
||||
public MonitorClone (Meta.Display display, int monitor, GestureTracker gesture_tracker) {
|
||||
Object (display: display, monitor: monitor, gesture_tracker: gesture_tracker);
|
||||
}
|
||||
|
||||
construct {
|
||||
@ -46,7 +46,7 @@ namespace Gala {
|
||||
background = new BackgroundManager (display, monitor, false);
|
||||
background.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
||||
|
||||
window_container = new WindowCloneContainer (gesture_animation_director);
|
||||
window_container = new WindowCloneContainer (gesture_tracker);
|
||||
window_container.window_selected.connect ((w) => { window_selected (w); });
|
||||
display.restacked.connect (window_container.restack_windows);
|
||||
|
||||
@ -93,16 +93,16 @@ namespace Gala {
|
||||
/**
|
||||
* Animate the windows from their old location to a tiled layout
|
||||
*/
|
||||
public void open () {
|
||||
window_container.open ();
|
||||
public void open (bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
window_container.open (null, with_gesture, is_cancel_animation);
|
||||
// background.opacity = 0; TODO consider this option
|
||||
}
|
||||
|
||||
/**
|
||||
* Animate the windows back to their old location
|
||||
*/
|
||||
public void close () {
|
||||
window_container.close ();
|
||||
public void close (bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
window_container.close (with_gesture, is_cancel_animation);
|
||||
background.opacity = 255;
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,8 @@ namespace Gala {
|
||||
public const int ANIMATION_DURATION = 250;
|
||||
public const AnimationMode ANIMATION_MODE = AnimationMode.EASE_OUT_QUAD;
|
||||
|
||||
private GestureAnimationDirector gesture_animation_director;
|
||||
private GestureTracker gesture_tracker;
|
||||
private GestureTracker multitasking_gesture_tracker;
|
||||
private GestureTracker workspace_gesture_tracker;
|
||||
|
||||
const int SMOOTH_SCROLL_DELAY = 500;
|
||||
|
||||
@ -58,12 +58,14 @@ namespace Gala {
|
||||
opened = false;
|
||||
display = wm.get_display ();
|
||||
|
||||
gesture_animation_director = new GestureAnimationDirector (ANIMATION_DURATION, ANIMATION_DURATION);
|
||||
multitasking_gesture_tracker = new GestureTracker (ANIMATION_DURATION, ANIMATION_DURATION);
|
||||
multitasking_gesture_tracker.enable_touchpad ();
|
||||
multitasking_gesture_tracker.on_gesture_detected.connect (on_multitasking_gesture_detected);
|
||||
|
||||
gesture_tracker = new GestureTracker (AnimationDuration.WORKSPACE_SWITCH_MIN, AnimationDuration.WORKSPACE_SWITCH);
|
||||
gesture_tracker.enable_touchpad ();
|
||||
gesture_tracker.enable_scroll (this, Clutter.Orientation.HORIZONTAL);
|
||||
gesture_tracker.on_gesture_detected.connect (on_gesture_detected);
|
||||
workspace_gesture_tracker = new GestureTracker (AnimationDuration.WORKSPACE_SWITCH_MIN, AnimationDuration.WORKSPACE_SWITCH);
|
||||
workspace_gesture_tracker.enable_touchpad ();
|
||||
workspace_gesture_tracker.enable_scroll (this, Clutter.Orientation.HORIZONTAL);
|
||||
workspace_gesture_tracker.on_gesture_detected.connect (on_workspace_gesture_detected);
|
||||
|
||||
workspaces = new Actor ();
|
||||
workspaces.set_easing_mode (AnimationMode.EASE_OUT_QUAD);
|
||||
@ -143,7 +145,7 @@ namespace Gala {
|
||||
if (monitor == primary)
|
||||
continue;
|
||||
|
||||
var monitor_clone = new MonitorClone (display, monitor, gesture_animation_director);
|
||||
var monitor_clone = new MonitorClone (display, monitor, multitasking_gesture_tracker);
|
||||
monitor_clone.window_selected.connect (window_selected);
|
||||
monitor_clone.visible = opened;
|
||||
|
||||
@ -204,13 +206,33 @@ namespace Gala {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void on_gesture_detected (Gesture gesture) {
|
||||
private void on_multitasking_gesture_detected (Gesture gesture) {
|
||||
var enabled = workspace_gesture_tracker.settings.is_gesture_enabled (GestureSettings.MULTITASKING_ENABLED);
|
||||
var fingers = workspace_gesture_tracker.settings.gesture_fingers (GestureSettings.MULTITASKING_FINGERS);
|
||||
|
||||
bool up = gesture.direction == GestureDirection.UP;
|
||||
bool down = gesture.direction == GestureDirection.DOWN;
|
||||
bool can_handle_swipe = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE
|
||||
&& (up || down)
|
||||
&& gesture.fingers == fingers;
|
||||
bool can_handle_gesture = enabled && can_handle_swipe;
|
||||
|
||||
if (can_handle_gesture) {
|
||||
if (up && !opened) {
|
||||
toggle (true, false);
|
||||
} else if (down && opened) {
|
||||
toggle (true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void on_workspace_gesture_detected (Gesture gesture) {
|
||||
if (!opened) {
|
||||
return;
|
||||
}
|
||||
|
||||
var enabled = gesture_tracker.settings.is_gesture_enabled (GestureSettings.WORKSPACE_ENABLED);
|
||||
var fingers = gesture_tracker.settings.gesture_fingers (GestureSettings.WORKSPACE_FINGERS);
|
||||
var enabled = workspace_gesture_tracker.settings.is_gesture_enabled (GestureSettings.WORKSPACE_ENABLED);
|
||||
var fingers = workspace_gesture_tracker.settings.gesture_fingers (GestureSettings.WORKSPACE_FINGERS);
|
||||
|
||||
bool can_handle_scroll = gesture.type == Gdk.EventType.SCROLL;
|
||||
bool can_handle_swipe = gesture.type == Gdk.EventType.TOUCHPAD_SWIPE
|
||||
@ -219,7 +241,7 @@ namespace Gala {
|
||||
bool can_handle_gesture = enabled && (can_handle_scroll || can_handle_swipe);
|
||||
|
||||
if (can_handle_gesture) {
|
||||
var direction = gesture_tracker.settings.get_natural_scroll_direction (gesture);
|
||||
var direction = workspace_gesture_tracker.settings.get_natural_scroll_direction (gesture);
|
||||
switch_workspace_with_gesture (direction);
|
||||
}
|
||||
}
|
||||
@ -260,20 +282,20 @@ namespace Gala {
|
||||
debug ("Initial X: %f", initial_x);
|
||||
debug ("Target X: %f", target_x);
|
||||
|
||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureTracker.animation_value (initial_x, target_x, percentage, true);
|
||||
workspaces.x = x;
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnEnd on_animation_end = (percentage, cancel_action, calculated_duration) => {
|
||||
gesture_tracker.enabled = false;
|
||||
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action, calculated_duration) => {
|
||||
workspace_gesture_tracker.enabled = false;
|
||||
|
||||
var duration = is_nudge_animation ? (AnimationDuration.NUDGE / 2) : calculated_duration;
|
||||
workspaces.set_easing_duration (duration);
|
||||
workspaces.x = (is_nudge_animation || cancel_action) ? initial_x : target_x;
|
||||
|
||||
workspaces.get_transition ("x").completed.connect (() => {
|
||||
gesture_tracker.enabled = true;
|
||||
workspace_gesture_tracker.enabled = true;
|
||||
|
||||
if (!is_nudge_animation && !cancel_action) {
|
||||
manager.get_workspace_by_index (target_workspace_index).activate (display.get_current_time ());
|
||||
@ -282,7 +304,7 @@ namespace Gala {
|
||||
});
|
||||
};
|
||||
|
||||
gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
|
||||
workspace_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -346,7 +368,7 @@ namespace Gala {
|
||||
|
||||
void add_workspace (int num) {
|
||||
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
|
||||
var workspace = new WorkspaceClone (manager.get_workspace_by_index (num), gesture_animation_director);
|
||||
var workspace = new WorkspaceClone (manager.get_workspace_by_index (num), multitasking_gesture_tracker);
|
||||
workspace.window_selected.connect (window_selected);
|
||||
workspace.selected.connect (activate_workspace);
|
||||
|
||||
@ -497,40 +519,18 @@ namespace Gala {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void open (HashTable<string,Variant>? hints = null) {
|
||||
bool manual_animation = hints != null && hints.get ("manual_animation").get_boolean ();
|
||||
|
||||
if (!opened) {
|
||||
if (manual_animation && !animating) {
|
||||
debug ("Starting MultitaskingView manual open animation");
|
||||
gesture_animation_director.running = true;
|
||||
}
|
||||
|
||||
toggle ();
|
||||
}
|
||||
|
||||
if (opened && manual_animation && gesture_animation_director.running) {
|
||||
gesture_animation_director.update_animation (hints);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void close (HashTable<string,Variant>? hints = null) {
|
||||
bool manual_animation = hints != null && hints.get ("manual_animation").get_boolean ();
|
||||
|
||||
if (opened) {
|
||||
if (manual_animation && !animating) {
|
||||
debug ("Starting MultitaskingView manual close animation");
|
||||
gesture_animation_director.running = true;
|
||||
}
|
||||
|
||||
toggle ();
|
||||
}
|
||||
|
||||
if (!opened && manual_animation && gesture_animation_director.running) {
|
||||
gesture_animation_director.update_animation (hints);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -538,7 +538,7 @@ namespace Gala {
|
||||
* starting the modal mode and hiding the WindowGroup. Finally tells all components
|
||||
* to animate to their positions.
|
||||
*/
|
||||
void toggle () {
|
||||
void toggle (bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
if (animating) {
|
||||
return;
|
||||
}
|
||||
@ -551,9 +551,9 @@ namespace Gala {
|
||||
foreach (var container in window_containers_monitors) {
|
||||
if (opening) {
|
||||
container.visible = true;
|
||||
container.open ();
|
||||
container.open (with_gesture, is_cancel_animation);
|
||||
} else {
|
||||
container.close ();
|
||||
container.close (with_gesture, is_cancel_animation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,26 +592,26 @@ namespace Gala {
|
||||
child.remove_all_transitions ();
|
||||
}
|
||||
|
||||
if (!gesture_animation_director.canceling) {
|
||||
if (!is_cancel_animation) {
|
||||
update_positions (false);
|
||||
}
|
||||
|
||||
foreach (var child in workspaces.get_children ()) {
|
||||
unowned WorkspaceClone workspace = (WorkspaceClone) child;
|
||||
if (opening) {
|
||||
workspace.open ();
|
||||
workspace.open (with_gesture, is_cancel_animation);
|
||||
} else {
|
||||
workspace.close ();
|
||||
workspace.close (with_gesture, is_cancel_animation);
|
||||
}
|
||||
}
|
||||
|
||||
if (opening) {
|
||||
show_docks ();
|
||||
show_docks (with_gesture, is_cancel_animation);
|
||||
} else {
|
||||
hide_docks ();
|
||||
hide_docks (with_gesture, is_cancel_animation);
|
||||
}
|
||||
|
||||
GestureAnimationDirector.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
var animation_duration = cancel_action ? 0 : ANIMATION_DURATION;
|
||||
Timeout.add (animation_duration, () => {
|
||||
if (!opening) {
|
||||
@ -631,26 +631,23 @@ namespace Gala {
|
||||
}
|
||||
|
||||
animating = false;
|
||||
gesture_animation_director.disconnect_all_handlers ();
|
||||
gesture_animation_director.running = false;
|
||||
gesture_animation_director.canceling = cancel_action;
|
||||
|
||||
if (cancel_action) {
|
||||
toggle ();
|
||||
toggle (false, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
if (!gesture_animation_director.running) {
|
||||
on_animation_end (100, false, 0);
|
||||
if (!with_gesture) {
|
||||
on_animation_end (1, false, 0);
|
||||
} else {
|
||||
gesture_animation_director.connect_handlers (null, null, (owned) on_animation_end);
|
||||
multitasking_gesture_tracker.connect_handlers (null, null, (owned) on_animation_end);
|
||||
}
|
||||
}
|
||||
|
||||
void show_docks () {
|
||||
void show_docks (bool with_gesture, bool is_cancel_animation) {
|
||||
float clone_offset_x, clone_offset_y;
|
||||
dock_clones.get_transformed_position (out clone_offset_x, out clone_offset_y);
|
||||
|
||||
@ -688,37 +685,37 @@ namespace Gala {
|
||||
var clone = new SafeWindowClone (window, true);
|
||||
dock_clones.add_child (clone);
|
||||
|
||||
GestureAnimationDirector.OnBegin on_animation_begin = () => {
|
||||
GestureTracker.OnBegin on_animation_begin = () => {
|
||||
clone.set_position (initial_x, initial_y);
|
||||
clone.set_easing_mode (0);
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||
var y = GestureAnimationDirector.animation_value (initial_y, target_y, percentage);
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var y = GestureTracker.animation_value (initial_y, target_y, percentage);
|
||||
clone.y = y;
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
clone.set_easing_mode (ANIMATION_MODE);
|
||||
|
||||
if (cancel_action) {
|
||||
return;
|
||||
}
|
||||
|
||||
clone.set_easing_duration (gesture_animation_director.canceling ? 0 : ANIMATION_DURATION);
|
||||
clone.set_easing_duration (is_cancel_animation ? 0 : ANIMATION_DURATION);
|
||||
clone.y = target_y;
|
||||
};
|
||||
|
||||
if (!gesture_animation_director.running) {
|
||||
if (!with_gesture) {
|
||||
on_animation_begin (0);
|
||||
on_animation_end (100, false, 0);
|
||||
on_animation_end (1, false, 0);
|
||||
} else {
|
||||
gesture_animation_director.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned) on_animation_end);
|
||||
multitasking_gesture_tracker.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned) on_animation_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hide_docks () {
|
||||
void hide_docks (bool with_gesture, bool is_cancel_animation) {
|
||||
float clone_offset_x, clone_offset_y;
|
||||
dock_clones.get_transformed_position (out clone_offset_x, out clone_offset_y);
|
||||
|
||||
@ -727,12 +724,12 @@ namespace Gala {
|
||||
var initial_y = dock.y;
|
||||
var target_y = dock.source.y - clone_offset_y;
|
||||
|
||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||
var y = GestureAnimationDirector.animation_value (initial_y, target_y, percentage);
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var y = GestureTracker.animation_value (initial_y, target_y, percentage);
|
||||
dock.y = y;
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
if (cancel_action) {
|
||||
return;
|
||||
}
|
||||
@ -742,10 +739,10 @@ namespace Gala {
|
||||
dock.y = target_y;
|
||||
};
|
||||
|
||||
if (!gesture_animation_director.running) {
|
||||
on_animation_end (100, false, 0);
|
||||
if (!with_gesture) {
|
||||
on_animation_end (1, false, 0);
|
||||
} else {
|
||||
gesture_animation_director.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
|
||||
multitasking_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ namespace Gala {
|
||||
}
|
||||
|
||||
public bool overview_mode { get; construct; }
|
||||
public GestureAnimationDirector? gesture_animation_director { get; construct; }
|
||||
public GestureTracker? gesture_tracker { get; construct; }
|
||||
|
||||
[CCode (notify = false)]
|
||||
public uint8 shadow_opacity {
|
||||
@ -121,8 +121,8 @@ namespace Gala {
|
||||
Actor active_shape;
|
||||
Actor window_icon;
|
||||
|
||||
public WindowClone (Meta.Window window, GestureAnimationDirector? gesture_animation_director, bool overview_mode = false) {
|
||||
Object (window: window, gesture_animation_director: gesture_animation_director, overview_mode: overview_mode);
|
||||
public WindowClone (Meta.Window window, GestureTracker? gesture_tracker, bool overview_mode = false) {
|
||||
Object (window: window, gesture_tracker: gesture_tracker, overview_mode: overview_mode);
|
||||
}
|
||||
|
||||
construct {
|
||||
@ -280,7 +280,7 @@ namespace Gala {
|
||||
*
|
||||
* @param animate Animate the transformation of the placement
|
||||
*/
|
||||
public void transition_to_original_state (bool animate) {
|
||||
public void transition_to_original_state (bool animate, bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
var outer_rect = window.get_frame_rect ();
|
||||
|
||||
var monitor_geom = window.get_display ().get_monitor_geometry (window.get_monitor ());
|
||||
@ -295,16 +295,16 @@ namespace Gala {
|
||||
var target_x = outer_rect.x - offset_x;
|
||||
var target_y = outer_rect.y - offset_y;
|
||||
|
||||
GestureAnimationDirector.OnBegin on_animation_begin = () => {
|
||||
GestureTracker.OnBegin on_animation_begin = () => {
|
||||
window_icon.set_easing_duration (0);
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureAnimationDirector.animation_value (initial_x, target_x, percentage);
|
||||
var y = GestureAnimationDirector.animation_value (initial_y, target_y, percentage);
|
||||
var width = GestureAnimationDirector.animation_value (initial_width, outer_rect.width, percentage);
|
||||
var height = GestureAnimationDirector.animation_value (initial_height, outer_rect.height, percentage);
|
||||
var opacity = GestureAnimationDirector.animation_value (255f, 0f, percentage);
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureTracker.animation_value (initial_x, target_x, percentage);
|
||||
var y = GestureTracker.animation_value (initial_y, target_y, percentage);
|
||||
var width = GestureTracker.animation_value (initial_width, outer_rect.width, percentage);
|
||||
var height = GestureTracker.animation_value (initial_height, outer_rect.height, percentage);
|
||||
var opacity = GestureTracker.animation_value (255f, 0f, percentage);
|
||||
|
||||
set_size (width, height);
|
||||
set_position (x, y);
|
||||
@ -313,7 +313,7 @@ namespace Gala {
|
||||
height - (WINDOW_ICON_SIZE * scale_factor) * 0.75f);
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
window_icon.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
||||
|
||||
if (cancel_action) {
|
||||
@ -342,35 +342,35 @@ namespace Gala {
|
||||
close_button.opacity = 0;
|
||||
};
|
||||
|
||||
if (!animate || gesture_animation_director == null || !gesture_animation_director.running) {
|
||||
if (!animate || gesture_tracker == null || !with_gesture) {
|
||||
on_animation_begin (0);
|
||||
on_animation_end (100, false, 0);
|
||||
on_animation_end (1, false, 0);
|
||||
} else {
|
||||
gesture_animation_director.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned) on_animation_end);
|
||||
gesture_tracker.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned) on_animation_end);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Animate the window to the given slot
|
||||
*/
|
||||
public void take_slot (Meta.Rectangle rect) {
|
||||
public void take_slot (Meta.Rectangle rect, bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
slot = rect;
|
||||
var initial_x = x;
|
||||
var initial_y = y;
|
||||
var initial_width = width;
|
||||
var initial_height = height;
|
||||
|
||||
GestureAnimationDirector.OnBegin on_animation_begin = () => {
|
||||
GestureTracker.OnBegin on_animation_begin = () => {
|
||||
window_icon.opacity = 0;
|
||||
window_icon.set_easing_duration (0);
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureAnimationDirector.animation_value (initial_x, rect.x, percentage);
|
||||
var y = GestureAnimationDirector.animation_value (initial_y, rect.y, percentage);
|
||||
var width = GestureAnimationDirector.animation_value (initial_width, rect.width, percentage);
|
||||
var height = GestureAnimationDirector.animation_value (initial_height, rect.height, percentage);
|
||||
var opacity = GestureAnimationDirector.animation_value (0f, 255f, percentage);
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureTracker.animation_value (initial_x, rect.x, percentage);
|
||||
var y = GestureTracker.animation_value (initial_y, rect.y, percentage);
|
||||
var width = GestureTracker.animation_value (initial_width, rect.width, percentage);
|
||||
var height = GestureTracker.animation_value (initial_height, rect.height, percentage);
|
||||
var opacity = GestureTracker.animation_value (0f, 255f, percentage);
|
||||
|
||||
set_size (width, height);
|
||||
set_position (x, y);
|
||||
@ -379,7 +379,7 @@ namespace Gala {
|
||||
height - (WINDOW_ICON_SIZE * scale_factor) * 0.75f);
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
window_icon.set_easing_duration (MultitaskingView.ANIMATION_DURATION);
|
||||
|
||||
if (cancel_action) {
|
||||
@ -411,11 +411,11 @@ namespace Gala {
|
||||
}
|
||||
};
|
||||
|
||||
if (gesture_animation_director == null || !gesture_animation_director.running) {
|
||||
if (gesture_tracker == null || !with_gesture) {
|
||||
on_animation_begin (0);
|
||||
on_animation_end (100, false, 0);
|
||||
on_animation_end (1, false, 0);
|
||||
} else {
|
||||
gesture_animation_director.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned) on_animation_end);
|
||||
gesture_tracker.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned) on_animation_end);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace Gala {
|
||||
public int padding_right { get; set; default = 12; }
|
||||
public int padding_bottom { get; set; default = 12; }
|
||||
|
||||
public GestureAnimationDirector? gesture_animation_director { get; construct; }
|
||||
public GestureTracker? gesture_tracker { get; construct; }
|
||||
public bool overview_mode { get; construct; }
|
||||
|
||||
bool opened;
|
||||
@ -41,8 +41,8 @@ namespace Gala {
|
||||
*/
|
||||
WindowClone? current_window;
|
||||
|
||||
public WindowCloneContainer (GestureAnimationDirector? gesture_animation_director, bool overview_mode = false) {
|
||||
Object (gesture_animation_director: gesture_animation_director, overview_mode: overview_mode);
|
||||
public WindowCloneContainer (GestureTracker? gesture_tracker, bool overview_mode = false) {
|
||||
Object (gesture_tracker: gesture_tracker, overview_mode: overview_mode);
|
||||
}
|
||||
|
||||
construct {
|
||||
@ -69,11 +69,11 @@ namespace Gala {
|
||||
|
||||
var windows_ordered = display.sort_windows_by_stacking (windows);
|
||||
|
||||
var new_window = new WindowClone (window, gesture_animation_director, overview_mode);
|
||||
var new_window = new WindowClone (window, gesture_tracker, overview_mode);
|
||||
|
||||
new_window.selected.connect (window_selected_cb);
|
||||
new_window.destroy.connect (window_destroyed);
|
||||
new_window.request_reposition.connect (reflow);
|
||||
new_window.request_reposition.connect (() => reflow ());
|
||||
|
||||
var added = false;
|
||||
unowned Meta.Window? target = null;
|
||||
@ -166,7 +166,7 @@ namespace Gala {
|
||||
* Recalculate the tiling positions of the windows and animate them to
|
||||
* the resulting spots.
|
||||
*/
|
||||
public void reflow () {
|
||||
public void reflow (bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
if (!opened)
|
||||
return;
|
||||
|
||||
@ -199,7 +199,7 @@ namespace Gala {
|
||||
|
||||
foreach (var tilable in window_positions) {
|
||||
unowned WindowClone window = (WindowClone) tilable.id;
|
||||
window.take_slot (tilable.rect);
|
||||
window.take_slot (tilable.rect, with_gesture, is_cancel_animation);
|
||||
window.place_widgets (tilable.rect.width, tilable.rect.height);
|
||||
}
|
||||
}
|
||||
@ -309,7 +309,7 @@ namespace Gala {
|
||||
/**
|
||||
* When opened the WindowClones are animated to a tiled layout
|
||||
*/
|
||||
public void open (Window? selected_window = null) {
|
||||
public void open (Window? selected_window = null, bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
if (opened) {
|
||||
return;
|
||||
}
|
||||
@ -335,20 +335,20 @@ namespace Gala {
|
||||
|
||||
// make sure our windows are where they belong in case they were moved
|
||||
// while were closed.
|
||||
if (gesture_animation_director == null || !gesture_animation_director.canceling) {
|
||||
if (gesture_tracker == null || !is_cancel_animation) {
|
||||
foreach (var window in get_children ()) {
|
||||
((WindowClone) window).transition_to_original_state (false);
|
||||
((WindowClone) window).transition_to_original_state (false, with_gesture, is_cancel_animation);
|
||||
}
|
||||
}
|
||||
|
||||
reflow ();
|
||||
reflow (with_gesture, is_cancel_animation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the transition_to_original_state() function on each child
|
||||
* to make them take their original locations again.
|
||||
*/
|
||||
public void close () {
|
||||
public void close (bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
if (!opened) {
|
||||
return;
|
||||
}
|
||||
@ -356,7 +356,7 @@ namespace Gala {
|
||||
opened = false;
|
||||
|
||||
foreach (var window in get_children ()) {
|
||||
((WindowClone) window).transition_to_original_state (true);
|
||||
((WindowClone) window).transition_to_original_state (true, with_gesture, is_cancel_animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ namespace Gala {
|
||||
public signal void selected (bool close_view);
|
||||
|
||||
public Workspace workspace { get; construct; }
|
||||
public GestureAnimationDirector gesture_animation_director { get; construct; }
|
||||
public GestureTracker gesture_tracker { get; construct; }
|
||||
public IconGroup icon_group { get; private set; }
|
||||
public WindowCloneContainer window_container { get; private set; }
|
||||
|
||||
@ -145,8 +145,8 @@ namespace Gala {
|
||||
|
||||
uint hover_activate_timeout = 0;
|
||||
|
||||
public WorkspaceClone (Workspace workspace, GestureAnimationDirector gesture_animation_director) {
|
||||
Object (workspace: workspace, gesture_animation_director: gesture_animation_director);
|
||||
public WorkspaceClone (Workspace workspace, GestureTracker gesture_tracker) {
|
||||
Object (workspace: workspace, gesture_tracker: gesture_tracker);
|
||||
}
|
||||
|
||||
construct {
|
||||
@ -162,7 +162,7 @@ namespace Gala {
|
||||
return false;
|
||||
});
|
||||
|
||||
window_container = new WindowCloneContainer (gesture_animation_director);
|
||||
window_container = new WindowCloneContainer (gesture_tracker);
|
||||
window_container.window_selected.connect ((w) => { window_selected (w); });
|
||||
window_container.set_size (monitor_geometry.width, monitor_geometry.height);
|
||||
display.restacked.connect (window_container.restack_windows);
|
||||
@ -316,7 +316,7 @@ namespace Gala {
|
||||
* Also sets the current_window of the WindowCloneContainer to the active window
|
||||
* if it belongs to this workspace.
|
||||
*/
|
||||
public void open () {
|
||||
public void open (bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
if (opened) {
|
||||
return;
|
||||
}
|
||||
@ -327,7 +327,7 @@ namespace Gala {
|
||||
var display = workspace.get_display ();
|
||||
|
||||
var monitor = display.get_monitor_geometry (display.get_primary_monitor ());
|
||||
var initial_x = gesture_animation_director.canceling ? x : x + current_x_overlap ();
|
||||
var initial_x = is_cancel_animation ? x : x + current_x_overlap ();
|
||||
var target_x = multitasking_view_x ();
|
||||
|
||||
var scale = (float)(monitor.height - TOP_OFFSET * scale_factor - BOTTOM_OFFSET * scale_factor) / monitor.height;
|
||||
@ -335,20 +335,20 @@ namespace Gala {
|
||||
|
||||
update_size (monitor);
|
||||
|
||||
GestureAnimationDirector.OnBegin on_animation_begin = () => {
|
||||
GestureTracker.OnBegin on_animation_begin = () => {
|
||||
x = initial_x;
|
||||
background.set_pivot_point (0.5f, pivotY);
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureAnimationDirector.animation_value (initial_x, target_x, percentage);
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureTracker.animation_value (initial_x, target_x, percentage);
|
||||
set_x (x);
|
||||
|
||||
double update_scale = (double)GestureAnimationDirector.animation_value (1.0f, (float)scale, percentage);
|
||||
double update_scale = (double) GestureTracker.animation_value (1.0f, (float)scale, percentage);
|
||||
background.set_scale (update_scale, update_scale);
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
if (cancel_action) {
|
||||
return;
|
||||
}
|
||||
@ -366,11 +366,11 @@ namespace Gala {
|
||||
background.restore_easing_state ();
|
||||
};
|
||||
|
||||
if (!gesture_animation_director.running) {
|
||||
if (!with_gesture) {
|
||||
on_animation_begin (0);
|
||||
on_animation_end (100, false, 0);
|
||||
on_animation_end (1, false, 0);
|
||||
} else {
|
||||
gesture_animation_director.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned)on_animation_end);
|
||||
gesture_tracker.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned)on_animation_end);
|
||||
}
|
||||
|
||||
Meta.Rectangle area = {
|
||||
@ -388,36 +388,37 @@ namespace Gala {
|
||||
|
||||
icon_group.redraw ();
|
||||
|
||||
window_container.open (display.get_workspace_manager ().get_active_workspace () == workspace ? display.get_focus_window () : null);
|
||||
Window? selected_window = display.get_workspace_manager ().get_active_workspace () == workspace ? display.get_focus_window () : null;
|
||||
window_container.open (selected_window, with_gesture, is_cancel_animation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the view again by animating the background back to its scale and
|
||||
* the windows back to their old locations.
|
||||
*/
|
||||
public void close () {
|
||||
public void close (bool with_gesture = false, bool is_cancel_animation = false) {
|
||||
if (!opened) {
|
||||
return;
|
||||
}
|
||||
|
||||
opened = false;
|
||||
|
||||
var initial_x = gesture_animation_director.canceling ? x : multitasking_view_x ();
|
||||
var initial_x = is_cancel_animation ? x : multitasking_view_x ();
|
||||
var target_x = multitasking_view_x () + current_x_overlap ();
|
||||
|
||||
double initial_scale_x, initial_scale_y;
|
||||
background.get_scale (out initial_scale_x, out initial_scale_y);
|
||||
|
||||
GestureAnimationDirector.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureAnimationDirector.animation_value (initial_x, target_x, percentage);
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureTracker.animation_value (initial_x, target_x, percentage);
|
||||
set_x (x);
|
||||
|
||||
double scale_x = (double) GestureAnimationDirector.animation_value ((float) initial_scale_x, 1.0f, percentage);
|
||||
double scale_y = (double) GestureAnimationDirector.animation_value ((float) initial_scale_y, 1.0f, percentage);
|
||||
double scale_x = (double) GestureTracker.animation_value ((float) initial_scale_x, 1.0f, percentage);
|
||||
double scale_y = (double) GestureTracker.animation_value ((float) initial_scale_y, 1.0f, percentage);
|
||||
background.set_scale (scale_x, scale_y);
|
||||
};
|
||||
|
||||
GestureAnimationDirector.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
|
||||
if (cancel_action) {
|
||||
return;
|
||||
}
|
||||
@ -435,13 +436,13 @@ namespace Gala {
|
||||
background.restore_easing_state ();
|
||||
};
|
||||
|
||||
if (!gesture_animation_director.running) {
|
||||
on_animation_end (100, false, 0);
|
||||
if (!with_gesture) {
|
||||
on_animation_end (1, false, 0);
|
||||
} else {
|
||||
gesture_animation_director.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
|
||||
gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
|
||||
}
|
||||
|
||||
window_container.close ();
|
||||
window_container.close (with_gesture, is_cancel_animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user