Skip to content

Commit

Permalink
feat: Rename setNextWindowNoDrag to setNextWindowPositionFixed
Browse files Browse the repository at this point in the history
  • Loading branch information
warxander committed Nov 16, 2023
1 parent f839db7 commit 94d98aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,8 @@ export function setDebugEnabled(enabled: boolean) {
Ui.setDebugEnabled(enabled);
}

/** `false` by default */
export function setNextWindowNoDrag(isNoDrag: boolean) {
Ui.setNextWindowNoDrag(isNoDrag);
export function setNextWindowPositionFixed() {
Ui.setNextWindowPositionFixed();
}

/** `false` by default */
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ globalThis.exports('getUi', Exports.getUi);
globalThis.exports('isDebugEnabled', Exports.isDebugEnabled);
globalThis.exports('setDebugEnabled', Exports.setDebugEnabled);

globalThis.exports('setNextWindowNoDrag', Exports.setNextWindowNoDrag);
globalThis.exports('setNextWindowPositionFixed', Exports.setNextWindowPositionFixed);
globalThis.exports('setNextWindowNoBackground', Exports.setNextWindowNoBackground);
globalThis.exports('setNextWindowId', Exports.setNextWindowId);
globalThis.exports('setNextWindowSpacing', Exports.setNextWindowSpacing);
Expand Down
13 changes: 6 additions & 7 deletions src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ItemState {

enum WindowFlags {
None,
NoDrag = 1 << 1,
FixedPosition = 1 << 1,
NoBackground = 1 << 2
}

Expand Down Expand Up @@ -62,9 +62,8 @@ export class Ui {
Ui.isDebugEnabled_ = enabled;
}

static setNextWindowNoDrag(isNoDrag: boolean) {
if (isNoDrag) Ui.nextWindowState.windowFlags |= WindowFlags.NoDrag;
else Ui.nextWindowState.windowFlags &= ~WindowFlags.NoDrag;
static setNextWindowPositionFixed() {
Ui.nextWindowState.windowFlags |= WindowFlags.FixedPosition;
}

static setNextWindowNoBackground(isNoBackground: boolean) {
Expand Down Expand Up @@ -100,8 +99,8 @@ export class Ui {
return Ui.nextWindowState.spacing ?? Ui.style.window.spacing;
}

static isWindowNoDrag(): boolean {
return !!(Ui.nextWindowState.windowFlags & WindowFlags.NoDrag);
static isWindowPositionFixed(): boolean {
return !!(Ui.nextWindowState.windowFlags & WindowFlags.FixedPosition);
}

static isWindowNoBackground(): boolean {
Expand Down Expand Up @@ -229,7 +228,7 @@ export class Ui {
}

private beginWindowDrag() {
if (Ui.isWindowNoDrag() || Ui.isWindowInputDisabled()) return;
if (Ui.isWindowPositionFixed() || Ui.isWindowInputDisabled()) return;

const mousePosition = this.input.getMousePosition();

Expand Down

0 comments on commit 94d98aa

Please sign in to comment.