Skip to content

Commit

Permalink
fix: use correct scaling when calculating the height. fixes #151
Browse files Browse the repository at this point in the history
  • Loading branch information
oae committed Mar 6, 2023
1 parent 42ea7cb commit a71e999
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
23 changes: 16 additions & 7 deletions src/components/panoItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { MetaInfo, TYPE_STRING } from '@gi-types/gobject2';
import { Point } from '@gi-types/graphene1';
import { Cursor } from '@gi-types/meta10';
import { Global } from '@gi-types/shell0';
import { BoxLayout } from '@gi-types/st1';
import { BoxLayout, ThemeContext } from '@gi-types/st1';
import { PanoItemHeader } from '@pano/components/panoItemHeader';
import { DBItem } from '@pano/utils/db';
import { registerGObjectClass } from '@pano/utils/gjs';
Expand Down Expand Up @@ -140,16 +140,25 @@ export class PanoItem extends BoxLayout {
this.add_child(this.header);
this.add_child(this.body);

this.set_height(this.settings.get_int('window-height') - 80);
this.set_width(this.settings.get_int('window-height') - 80);
this.body.set_height(this.settings.get_int('window-height') - 80 - 57);
const themeContext = ThemeContext.get_for_stage(Global.get().get_stage());

themeContext.connect('notify::scale-factor', () => {
this.setWindowHeight();
});

this.setWindowHeight();
this.settings.connect('changed::window-height', () => {
this.set_height(this.settings.get_int('window-height') - 80);
this.set_width(this.settings.get_int('window-height') - 80);
this.body.set_height(this.settings.get_int('window-height') - 80 - 57);
this.setWindowHeight();
});
}

private setWindowHeight() {
const { scaleFactor } = ThemeContext.get_for_stage(Global.get().get_stage());
this.set_height((this.settings.get_int('window-height') - 80) * scaleFactor);
this.set_width((this.settings.get_int('window-height') - 80) * scaleFactor);
this.body.set_height((this.settings.get_int('window-height') - 80 - 57) * scaleFactor);
}

private setSelected(selected: boolean) {
if (selected) {
const activeItemBorderColor = this.settings.get_string('active-item-border-color');
Expand Down
11 changes: 9 additions & 2 deletions src/components/searchBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { icon_new_for_string, IconPrototype } from '@gi-types/gio2';
import { MetaInfo, TYPE_BOOLEAN, TYPE_INT, TYPE_STRING } from '@gi-types/gobject2';
import { Cursor } from '@gi-types/meta10';
import { Global } from '@gi-types/shell0';
import { BoxLayout, Entry, Icon } from '@gi-types/st1';
import { BoxLayout, Entry, Icon, ThemeContext } from '@gi-types/st1';
import { registerGObjectClass } from '@pano/utils/gjs';
import { PanoItemTypes } from '@pano/utils/panoItemType';
import { _, getCurrentExtension } from '@pano/utils/shell';
Expand Down Expand Up @@ -51,15 +51,22 @@ export class SearchBox extends BoxLayout {
vertical: false,
});

const themeContext = ThemeContext.get_for_stage(Global.get().get_stage());

this.search = new Entry({
can_focus: true,
hint_text: _('Type to search, Tab to cycle'),
track_hover: true,
width: 300,
width: 300 * themeContext.scaleFactor,
primary_icon: this.createSearchEntryIcon('edit-find-symbolic', 'search-entry-icon'),
secondary_icon: this.createSearchEntryIcon('starred-symbolic', 'search-entry-fav-icon'),
});

themeContext.connect('notify::scale-factor', () => {
const { scaleFactor } = ThemeContext.get_for_stage(Global.get().get_stage());
this.search.set_width(300 * scaleFactor);
});

this.search.connect('primary-icon-clicked', () => {
this.focus();
this.toggleItemType(false);
Expand Down
13 changes: 10 additions & 3 deletions src/containers/panoWindow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ActorAlign, AnimationMode, EVENT_PROPAGATE, KEY_Escape, KeyEvent } from '@gi-types/clutter10';
import { Settings } from '@gi-types/gio2';
import { BoxLayout } from '@gi-types/st1';
import { Global } from '@gi-types/shell0';
import { BoxLayout, ThemeContext } from '@gi-types/st1';
import { MonitorBox } from '@pano/components/monitorBox';
import { PanoScrollView } from '@pano/components/panoScrollView';
import { SearchBox } from '@pano/components/searchBox';
Expand Down Expand Up @@ -30,9 +31,15 @@ export class PanoWindow extends BoxLayout {
});

this.settings = getCurrentExtensionSettings();
this.set_height(this.settings.get_int('window-height'));
const themeContext = ThemeContext.get_for_stage(Global.get().get_stage());
this.set_height(this.settings.get_int('window-height') * themeContext.scaleFactor);
this.settings.connect('changed::window-height', () => {
this.set_height(this.settings.get_int('window-height'));
this.set_height(this.settings.get_int('window-height') * themeContext.scaleFactor);
});

themeContext.connect('notify::scale-factor', () => {
const { scaleFactor } = ThemeContext.get_for_stage(Global.get().get_stage());
this.set_height(this.settings.get_int('window-height') * scaleFactor);
});

this.settings.connect('changed::window-background-color', () => {
Expand Down

0 comments on commit a71e999

Please sign in to comment.