feat: use better layout notifications

This commit is contained in:
Mikhail Zolotukhin 2021-10-23 01:20:17 +03:00
parent 2862e56194
commit 8c013ac7bc
4 changed files with 19 additions and 8 deletions

View File

@ -164,6 +164,12 @@ export interface Engine {
* @param text the text of the notification * @param text the text of the notification
*/ */
showNotification(text: string): void; showNotification(text: string): void;
/**
* Show the notification with the info
* about the current layout.
*/
showLayoutNotification(): void;
} }
export class EngineImpl implements Engine { export class EngineImpl implements Engine {
@ -566,7 +572,7 @@ export class EngineImpl implements Engine {
step step
); );
if (layout) { if (layout) {
this.controller.showNotification(layout.description); this.showLayoutNotification();
// Minimize inactive windows if Monocle and config.monocleMinimizeRest // Minimize inactive windows if Monocle and config.monocleMinimizeRest
if ( if (
@ -584,7 +590,7 @@ export class EngineImpl implements Engine {
layoutClassID layoutClassID
); );
if (layout) { if (layout) {
this.controller.showNotification(layout.description); this.showLayoutNotification();
// Minimize inactive windows if Monocle and config.monocleMinimizeRest // Minimize inactive windows if Monocle and config.monocleMinimizeRest
if ( if (
@ -695,6 +701,11 @@ export class EngineImpl implements Engine {
this.controller.showNotification(text); this.controller.showNotification(text);
} }
public showLayoutNotification(): void {
const currentLayout = this.currentLayoutOnCurrentSurface();
this.controller.showNotification(`Layout: ${currentLayout.description}`);
}
/** /**
* Returns the tiling area for the given working area and the windows layout. * Returns the tiling area for the given working area and the windows layout.
* *

View File

@ -58,7 +58,7 @@ export default class CascadeLayout implements WindowsLayout {
public readonly classID = CascadeLayout.id; public readonly classID = CascadeLayout.id;
public get description(): string { public get description(): string {
return "Cascade [" + CascadeDirection[this.dir] + "]"; return `Cascade [${CascadeDirection[this.dir]}]`;
} }
constructor(private dir: CascadeDirection = CascadeDirection.SouthEast) { constructor(private dir: CascadeDirection = CascadeDirection.SouthEast) {
@ -105,10 +105,10 @@ export default class CascadeLayout implements WindowsLayout {
public executeAction(engine: Engine, action: Action): void { public executeAction(engine: Engine, action: Action): void {
if (action instanceof IncreaseMasterAreaWindowCount) { if (action instanceof IncreaseMasterAreaWindowCount) {
this.dir = (this.dir + 1 + 8) % 8; this.dir = (this.dir + 1 + 8) % 8;
engine.showNotification(this.description); engine.showLayoutNotification();
} else if (action instanceof DecreaseMasterAreaWindowCount) { } else if (action instanceof DecreaseMasterAreaWindowCount) {
this.dir = (this.dir - 1 + 8) % 8; this.dir = (this.dir - 1 + 8) % 8;
engine.showNotification(this.description); engine.showLayoutNotification();
} else { } else {
action.executeWithoutLayoutOverride(); action.executeWithoutLayoutOverride();
} }

View File

@ -239,6 +239,6 @@ export default class ThreeColumnLayout implements WindowsLayout {
private resizeMaster(engine: Engine, step: -1 | 1): void { private resizeMaster(engine: Engine, step: -1 | 1): void {
this.masterSize = clip(this.masterSize + step, 1, 10); this.masterSize = clip(this.masterSize + step, 1, 10);
engine.showNotification(this.description); engine.showLayoutNotification();
} }
} }

View File

@ -124,12 +124,12 @@ export default class TileLayout implements WindowsLayout {
if (this.numMaster < 10) { if (this.numMaster < 10) {
this.numMaster += 1; this.numMaster += 1;
} }
engine.showNotification(this.description); engine.showLayoutNotification();
} else if (action instanceof DecreaseMasterAreaWindowCount) { } else if (action instanceof DecreaseMasterAreaWindowCount) {
if (this.numMaster > 0) { if (this.numMaster > 0) {
this.numMaster -= 1; this.numMaster -= 1;
} }
engine.showNotification(this.description); engine.showLayoutNotification();
} else if (action instanceof Rotate) { } else if (action instanceof Rotate) {
this.parts.rotate(90); this.parts.rotate(90);
} else if (action instanceof RotatePart) { } else if (action instanceof RotatePart) {