Skip to content

Commit

Permalink
refactor: rewrite pano scrolview (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
oae committed Aug 25, 2022
1 parent 8ecad76 commit 69ab40e
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 215 deletions.
10 changes: 9 additions & 1 deletion src/components/colorPanoItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActorAlign } from '@gi-types/clutter10';
import { ActorAlign, AlignAxis, AlignConstraint } from '@gi-types/clutter10';
import { BoxLayout, Label } from '@gi-types/st1';
import { PanoItem } from '@pano/components/panoItem';
import { ClipboardContent, clipboardManager, ContentType } from '@pano/utils/clipboardManager';
Expand Down Expand Up @@ -31,6 +31,14 @@ export class ColorPanoItem extends PanoItem {
}),
);

colorContainer.add_constraint(
new AlignConstraint({
source: this,
align_axis: AlignAxis.Y_AXIS,
factor: 0.005,
}),
);

this.body.add_child(colorContainer);
this.connect('activated', this.setClipboardContent.bind(this));
}
Expand Down
1 change: 1 addition & 0 deletions src/components/filePanoItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class FilePanoItem extends PanoItem {
new Icon({
icon_name: this.operation === FileOperation.CUT ? 'edit-cut-symbolic' : 'edit-copy-symbolic',
x_align: ActorAlign.START,
icon_size: 13,
style_class: 'file-icon',
}),
);
Expand Down
7 changes: 7 additions & 0 deletions src/components/panoItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class PanoItem extends BoxLayout {
Global.get().display.set_cursor(Cursor.DEFAULT);
});

this.connect('activated', () => this.get_parent()?.get_parent()?.get_parent()?.hide());

this.header = new PanoItemHeader(PanoItemTypes[dbItem.itemType], dbItem.copyDate);
this.header.connect('on-remove', () => {
this.emit('on-remove', JSON.stringify(this.dbItem));
Expand Down Expand Up @@ -106,4 +108,9 @@ export class PanoItem extends BoxLayout {

return EVENT_PROPAGATE;
}

override destroy(): void {
this.header.destroy();
super.destroy();
}
}
4 changes: 2 additions & 2 deletions src/components/panoItemHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export class PanoItemHeader extends BoxLayout {
this.add_child(actionContainer);
}

override vfunc_destroy(): void {
override destroy(): void {
clearInterval(this.dateUpdateIntervalId);
super.vfunc_destroy();
super.destroy();
}
}
Loading

0 comments on commit 69ab40e

Please sign in to comment.