Skip to content

Commit

Permalink
Got attached icons to scale properly now.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsheeler committed Feb 10, 2025
1 parent 593ca4a commit 14e48f6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
56 changes: 34 additions & 22 deletions src/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,9 @@ export const Preview = GObject.registerClass({

let constraint = Clutter.BindConstraint.new(this, Clutter.BindCoordinate.ALL, 0);
this._application_icon_box.add_constraint(constraint);
this._application_icon_box.set_child(this._icon);

this._icon.set_pivot_point(0.5, 0.5);
this._icon.set_scale(this.switcher._iconScaleUpDown ? 0 : scale, this.switcher._iconScaleUpDown ? 0 : scale);


this._icon.opacity = 255 * this.switcher._settings.overlay_icon_opacity;

this.bind_property('rotation_angle_y', this._application_icon_box, 'rotation_angle_y',
Expand All @@ -359,11 +358,24 @@ export const Preview = GObject.registerClass({
GObject.BindingFlags.SYNC_CREATE);
this.switcher.previewActor.add_child(this._application_icon_box);

this._application_inner_icon_box = new St.Bin({
style_class: 'window-iconbox',
width: 1,
height: 1,
opacity: 255,
pivot_point: new Graphene.Point({x:0.5, y:0.5}),
scale_x: this.switcher._iconScaleUpDown ? 0 : target_size,
scale_y: this.switcher._iconScaleUpDown ? 0 : target_size,
});

this._application_icon_box.set_child(this._application_inner_icon_box);
this._application_inner_icon_box.set_child(this._icon);

if (this.switcher._iconScaleUpDown) {
this.switcher._manager.platform.tween(this._icon, {
this.switcher._manager.platform.tween(this._application_inner_icon_box, {
transition: 'easeInOutQuint',
scale_x: scale,
scale_y: scale,
scale_x: target_size,
scale_y: target_size,
time: this.switcher._getRandomTime(),
});
}
Expand All @@ -379,15 +391,14 @@ export const Preview = GObject.registerClass({
});
} else {
this._icon.removing = false;

this.switcher._logger.log(`adding icon ${this.metaWin.title}, iconscaleupdown {this.swi}`);
if (this.switcher._iconScaleUpDown) {
let t = this._application_icon_box.get_transition('scale_x');
if (!t || t.get_interval().peek_final_value() !== scale) {

this.switcher._manager.platform.tween(this._icon, {
let t = this._application_inner_icon_box.get_transition('scale_x');
if (!t || t.get_interval().peek_final_value() !== target_size) {
this.switcher._manager.platform.tween(this._application_inner_icon_box, {
transition: 'easeInOutQuint',
scale_x: scale,
scale_y: scale,
scale_x: target_size,
scale_y: target_size,
time: this.switcher._getRandomTime(),
});
}
Expand Down Expand Up @@ -419,10 +430,7 @@ export const Preview = GObject.registerClass({
time: animation_time,
onComplete: () => {
if (this._icon !== null) {
this._icon.destroy()
this._icon = null;
this._application_icon_box.destroy();
this._application_icon_box = null;
this._destroyApplicationIconBox();
}
},
});
Expand All @@ -432,17 +440,14 @@ export const Preview = GObject.registerClass({
if (this._icon !== null) {
let t = this._icon.get_transition('scale-x');
if (!t || t.get_interval().peek_final_value() !== 0) {
this.switcher._manager.platform.tween(this._icon, {
this.switcher._manager.platform.tween(this._application_inner_icon_box, {
transition: 'easeInOutQuint',
scale_x: 0,
scale_y: 0,
time: animation_time,
onComplete: () => {
if (this._icon !== null) {
this._icon.destroy()
this._icon = null;
this._application_icon_box.destroy();
this._application_icon_box = null;
this._destroyApplicationIconBox();
}
},
});
Expand All @@ -452,6 +457,13 @@ export const Preview = GObject.registerClass({
}
}

_destroyApplicationIconBox() {
this._application_icon_box.destroy();
this._application_icon_box = null;
this._application_inner_icon_box = null;
this._icon = null;
}

vfunc_leave_event(_crossingEvent) {
if (this._destroying) return Clutter.EVENT_PROPAGATE;
this.remove_highlight();
Expand Down
8 changes: 4 additions & 4 deletions src/switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,12 +755,13 @@ export class Switcher {
let icon_box = this._windowIconBoxes[this._currentIndex];

if (this._iconScaleUpDown) {
const scale = this._settings.icon_style === "Classic" ? 1 : app_icon_size;
icon_box.set_pivot_point(0.5, 0.5);
let tx = icon_box.get_transition('scale-x');
if (!tx || tx.get_interval().peek_final_value() !== 1) {
this._manager.platform.tween(icon_box, {
scale_x: app_icon_size,
scale_y: app_icon_size,
scale_x: scale,
scale_y: scale,
time: this._settings.animation_time,
transition: 'easeInOutQuint',
});
Expand Down Expand Up @@ -798,8 +799,7 @@ export class Switcher {
let icon_box_low = this._windowIconBoxes[idx_low];
let icon_box_high = this._windowIconBoxes[idx_high];

let scale = app_icon_size;
;
let scale = this._settings.icon_style === "Classic" ? 1 : app_icon_size;
let alpha = 1;
if (this._settings.icon_style === "Attached") {
scale = 0;
Expand Down

0 comments on commit 14e48f6

Please sign in to comment.