mirror of
https://github.com/elementary/gala.git
synced 2024-12-19 07:11:56 +03:00
WindowClone: scale factor stuff
This commit is contained in:
parent
097cda8b6b
commit
82ca34cbed
@ -111,7 +111,10 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
add_action (drag_action);
|
||||
}
|
||||
|
||||
var scale_factor = InternalUtils.get_ui_scaling_factor ();
|
||||
var window_frame_rect = window.get_frame_rect ();
|
||||
|
||||
unowned var display = wm.get_display ();
|
||||
var scale_factor = display.get_monitor_scale (display.get_monitor_index_for_rect (window_frame_rect));
|
||||
|
||||
var close_button_action = new Clutter.ClickAction ();
|
||||
close_button_action.clicked.connect (() => {
|
||||
@ -123,11 +126,10 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
close_button.button_release_event.connect (() => { return Clutter.EVENT_STOP; });
|
||||
close_button.add_action (close_button_action);
|
||||
|
||||
var window_frame_rect = window.get_frame_rect ();
|
||||
window_icon = new WindowIcon (window, WINDOW_ICON_SIZE, scale_factor);
|
||||
window_icon = new WindowIcon (window, WINDOW_ICON_SIZE, (int)Math.round (scale_factor));
|
||||
window_icon.opacity = 0;
|
||||
window_icon.set_pivot_point (0.5f, 0.5f);
|
||||
set_window_icon_position (window_frame_rect.width, window_frame_rect.height);
|
||||
set_window_icon_position (window_frame_rect.width, window_frame_rect.height, scale_factor);
|
||||
|
||||
window_title = new Tooltip ();
|
||||
window_title.opacity = 0;
|
||||
@ -249,7 +251,9 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
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 ());
|
||||
unowned var display = window.get_display ();
|
||||
var monitor_geom = display.get_monitor_geometry (window.get_monitor ());
|
||||
var scale = display.get_monitor_scale (window.get_monitor ());
|
||||
var offset_x = monitor_geom.x;
|
||||
var offset_y = monitor_geom.y;
|
||||
|
||||
@ -263,7 +267,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
|
||||
active = false;
|
||||
in_slot_animation = true;
|
||||
place_widgets (outer_rect.width, outer_rect.height);
|
||||
place_widgets (outer_rect.width, outer_rect.height, scale);
|
||||
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureTracker.animation_value (initial_x, target_x, percentage);
|
||||
@ -276,7 +280,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
set_position (x, y);
|
||||
|
||||
window_icon.opacity = (uint) opacity;
|
||||
set_window_icon_position (width, height, false);
|
||||
set_window_icon_position (width, height, scale, false);
|
||||
|
||||
shadow_opacity = (uint8) opacity;
|
||||
};
|
||||
@ -309,18 +313,18 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
window_icon.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
|
||||
window_icon.set_easing_duration (duration);
|
||||
window_icon.opacity = 0;
|
||||
set_window_icon_position (outer_rect.width, outer_rect.height);
|
||||
set_window_icon_position (outer_rect.width, outer_rect.height, scale);
|
||||
window_icon.restore_easing_state ();
|
||||
|
||||
var transition = window_icon.get_transition ("opacity");
|
||||
if (transition != null) {
|
||||
transition.completed.connect (() => {
|
||||
in_slot_animation = false;
|
||||
place_widgets (outer_rect.width, outer_rect.height);
|
||||
place_widgets (outer_rect.width, outer_rect.height, scale);
|
||||
});
|
||||
} else {
|
||||
in_slot_animation = false;
|
||||
place_widgets (outer_rect.width, outer_rect.height);
|
||||
place_widgets (outer_rect.width, outer_rect.height, scale);
|
||||
}
|
||||
};
|
||||
|
||||
@ -342,8 +346,11 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
var initial_height = height;
|
||||
|
||||
active = false;
|
||||
unowned var display = wm.get_display ();
|
||||
var scale = display.get_monitor_scale (display.get_monitor_index_for_rect (rect));
|
||||
|
||||
in_slot_animation = true;
|
||||
place_widgets (rect.width, rect.height);
|
||||
place_widgets (rect.width, rect.height, scale);
|
||||
|
||||
GestureTracker.OnUpdate on_animation_update = (percentage) => {
|
||||
var x = GestureTracker.animation_value (initial_x, rect.x, percentage);
|
||||
@ -356,7 +363,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
set_position (x, y);
|
||||
|
||||
window_icon.opacity = (uint) opacity;
|
||||
set_window_icon_position (width, height, false);
|
||||
set_window_icon_position (width, height, scale, false);
|
||||
|
||||
shadow_opacity = (uint8) opacity;
|
||||
};
|
||||
@ -381,7 +388,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
window_icon.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
|
||||
window_icon.set_easing_duration (duration);
|
||||
window_icon.opacity = 255;
|
||||
set_window_icon_position (rect.width, rect.height);
|
||||
set_window_icon_position (rect.width, rect.height, scale);
|
||||
window_icon.restore_easing_state ();
|
||||
|
||||
toggle_shadow (true);
|
||||
@ -390,11 +397,11 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
if (transition != null) {
|
||||
transition.completed.connect (() => {
|
||||
in_slot_animation = false;
|
||||
place_widgets (rect.width, rect.height);
|
||||
place_widgets (rect.width, rect.height, scale);
|
||||
});
|
||||
} else {
|
||||
in_slot_animation = false;
|
||||
place_widgets (rect.width, rect.height);
|
||||
place_widgets (rect.width, rect.height, scale);
|
||||
}
|
||||
};
|
||||
|
||||
@ -482,10 +489,8 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
* Place the widgets, that is the close button and the WindowIcon of the window,
|
||||
* at their positions inside the actor for a given width and height.
|
||||
*/
|
||||
public void place_widgets (int dest_width, int dest_height) {
|
||||
var scale_factor = InternalUtils.get_ui_scaling_factor ();
|
||||
|
||||
var close_button_size = CLOSE_WINDOW_ICON_SIZE * scale_factor;
|
||||
public void place_widgets (int dest_width, int dest_height, float scale_factor) {
|
||||
var close_button_size = InternalUtils.scale_to_int (CLOSE_WINDOW_ICON_SIZE, scale_factor);
|
||||
close_button.set_size (close_button_size, close_button_size);
|
||||
|
||||
close_button.y = -close_button.height * 0.33f;
|
||||
@ -498,8 +503,8 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
window_title.opacity = close_button.opacity;
|
||||
|
||||
window_title.set_text (window.get_title () ?? "", false);
|
||||
window_title.set_max_width (dest_width - (TITLE_MAX_WIDTH_MARGIN * scale_factor));
|
||||
set_window_title_position (dest_width, dest_height);
|
||||
window_title.set_max_width (dest_width - InternalUtils.scale_to_int (TITLE_MAX_WIDTH_MARGIN, scale_factor));
|
||||
set_window_title_position (dest_width, dest_height, scale_factor);
|
||||
}
|
||||
|
||||
private void toggle_shadow (bool show) {
|
||||
@ -773,13 +778,15 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
window_icon.save_easing_state ();
|
||||
window_icon.set_easing_duration (duration);
|
||||
window_icon.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
|
||||
set_window_icon_position (slot.width, slot.height);
|
||||
|
||||
unowned var display = wm.get_display ();
|
||||
var scale = display.get_monitor_scale (display.get_monitor_index_for_rect (slot));
|
||||
set_window_icon_position (slot.width, slot.height, scale);
|
||||
window_icon.restore_easing_state ();
|
||||
}
|
||||
|
||||
private void set_window_icon_position (float window_width, float window_height, bool aligned = true) {
|
||||
var scale_factor = InternalUtils.get_ui_scaling_factor ();
|
||||
var size = WINDOW_ICON_SIZE * scale_factor;
|
||||
private void set_window_icon_position (float window_width, float window_height, float scale_factor, bool aligned = true) {
|
||||
var size = InternalUtils.scale_to_int (WINDOW_ICON_SIZE, scale_factor);
|
||||
var x = (window_width - size) / 2;
|
||||
var y = window_height - (size * 0.75f);
|
||||
|
||||
@ -792,8 +799,7 @@ public class Gala.WindowClone : Clutter.Actor {
|
||||
window_icon.set_position (x, y);
|
||||
}
|
||||
|
||||
private void set_window_title_position (float window_width, float window_height) {
|
||||
var scale_factor = InternalUtils.get_ui_scaling_factor ();
|
||||
private void set_window_title_position (float window_width, float window_height, float scale_factor) {
|
||||
var x = (int)Math.round ((window_width - window_title.width) / 2);
|
||||
var y = (int)Math.round (window_height - (WINDOW_ICON_SIZE * scale_factor) * 0.75f - (window_title.height / 2) - (18 * scale_factor));
|
||||
window_title.set_position (x, y);
|
||||
|
Loading…
Reference in New Issue
Block a user