Skip to content

Commit

Permalink
Minimized Windows+ Feature and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Apr 26, 2021
1 parent 4d9b0b9 commit 811b080
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### 0.8.4
* Enhancement: Minimize+ Setting "Right Click" on a minimized window gives them border color
* Enhancement: Minimize+ Setting Mouse over minimized windows gives them shadow color
* Compatibility: Search Anywhere "hand" now hidden in Organized Minimize mode when minimized
* Bugfix: Organized Minimize returns windows to their original position when restored/maximized
* Bugfix: Organized Minimize removed unwanted movement when moving windows along the axis
* Bugfix: Sub controls menu adjusted to avoid unwanted shaking animation


### 0.8.3
* Compatibility: Monks Scene Navigation thanks to a contribution from ironmonk88
* Bugfix: Disabled scene preview animation for better compatibility and less strange behaviour
Expand Down
5 changes: 4 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@
"MinimalUI.DynamicUIHint": "Auto hides UI elements after 60 seconds of chat inactivity when controlling tokens or changing scenes.",

"MinimalUI.OrganizedMinimizeName": "MINIMAL UI Organized Minimize",
"MinimalUI.OrganizedMinimizeHint": "This option may help you organize those minimized windows by placing them either on a bottom line or top bar.",
"MinimalUI.OrganizedMinimizeHint": "Organize minimized windows by placing them either on a bottom line or top bar.",
"MinimalUI.OrganizedMinimizeBottom": "Bottom",
"MinimalUI.OrganizedMinimizeBottomBar": "Bottom with Bar",
"MinimalUI.OrganizedMinimizeTop": "Top",
"MinimalUI.OrganizedMinimizeTopBar": "Top with Bar",

"MinimalUI.EnrichedMinimizeName": "MINIMAL UI Organized Minimize+",
"MinimalUI.EnrichedMinimizeHint": "Pin minimized windows with Right Click and highlight on mouse over",

"MinimalUI.PinSidebar": "Pin Controls"

}
5 changes: 4 additions & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@
"MinimalUI.DynamicUIHint": "Oculta automáticamente los elementos de la UI tras 60 segundos de inactividad cuando se está controlando algún icono o navegando entre escenas",

"MinimalUI.OrganizedMinimizeName": "Modo organizado MINIMAL",
"MinimalUI.OrganizedMinimizeHint": "Esta opción le ayudará a organizar las ventanas que minimice, al colocarlas o bien en una franja en la parte inferior o superior",
"MinimalUI.OrganizedMinimizeHint": "Organiza las ventanas que minimice, al colocarlas o bien en una franja en la parte inferior o superior",
"MinimalUI.OrganizedMinimizeBottom": "Abajo",
"MinimalUI.OrganizedMinimizeBottomBar": "Abajo con barra",
"MinimalUI.OrganizedMinimizeTop": "Arriba",
"MinimalUI.OrganizedMinimizeTopBar": "Arriba con barra",

"MinimalUI.EnrichedMinimizeName": "Modo organizado MINIMAL+",
"MinimalUI.EnrichedMinimizeHint": "Fijar ventanas minimizadas con click derecho y resaltar al pasar por encima",

"MinimalUI.PinSidebar": "Controles de chincheta"

}
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Minimal UI",
"author": "JeansenVaars#2857",
"description": "Minimal UI allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.",
"version": "0.8.3",
"version": "0.8.4",
"minimumCoreVersion": "0.7.9",
"compatibleCoreVersion": "0.7.9",
"dependencies": [
Expand All @@ -26,5 +26,5 @@
],
"url": "https://github.com/saif-ellafi/foundryvtt-minimal-ui.git",
"manifest": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/latest/download/module.json",
"download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/latest/download/foundryvtt-minimal-ui_0.8.3.zip"
"download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/latest/download/foundryvtt-minimal-ui_0.8.4.zip"
}
6 changes: 3 additions & 3 deletions modules/component/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export default class MinimalUIControls {
static cssControlsHiddenPositionSmall = '-62px';
static cssControlsHiddenPositionStandard = '-72px';

static cssControlsSubMenuSmall = '55px';
static cssControlsSubMenuStandard = '65px';
static cssControlsSubMenuDndUi = '65px';
static cssControlsSubMenuSmall = '48px';
static cssControlsSubMenuStandard = '58px';
static cssControlsSubMenuDndUi = '58px';

static cssControlsPaddingDefault = '7px';
static cssControlsPaddingSmall = '26px';
Expand Down
72 changes: 60 additions & 12 deletions modules/feature/minimize.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class MinimalUIMinimize {
.minimized {
${rule}: ${measure} !important;
width: ${MinimalUIMinimize.cssMinimizedSize}px !important;
height: 1px !important;
}
`, stylesheet.cssRules.length
);
Expand Down Expand Up @@ -50,13 +51,46 @@ export default class MinimalUIMinimize {
static cleanupMinimizeBar(app, force) {
const minimizedApps = $(".minimized");
const minimizedStash = Object.values(MinimalUIMinimize.minimizedStash);
const matchedStash = minimizedStash.find(a => a.appId === app?.appId);
const matchedStash = minimizedStash.find(a => a.app.appId === app?.appId);
if ((force) || (minimizedApps.length === 0) || (minimizedApps.length === 1 && matchedStash)) {
MinimalUIMinimize.minimizedStash = {};
$("#minimized-bar").hide();
}
}

static enrichStyling(app) {
app.element.find(".close").text('');
app.element.find(".close").append(`<a class="header-button close"><i class="fas fa-times"></i></a>`);
app.element.find(".window-draggable-handle").hide();
if (game.settings.get('minimal-ui', 'enrichedMinimize') === 'enabled') {
const header = app.element.find(".window-header");
header.on('contextmenu', function () {
if (header.hasClass('minimized-pinned'))
header.removeClass('minimized-pinned')
else
header.addClass('minimized-pinned')
});
header.hover(
function () {
header.addClass('minimized-highlight')
},
function () {
header.removeClass('minimized-highlight')
}
)
}
}

static unenrichStyling(app) {
app.element.find(".close").text('');
app.element.find(".close").append(`<i class="fas fa-times"></i>Close`);
app.element.find(".window-draggable-handle").show();
if (game.settings.get('minimal-ui', 'enrichedMinimize') === 'enabled') {
app.element.find(".window-header").removeClass('minimized-pinned');
app.element.find(".window-header").off();
}
}

static initSettings() {
game.settings.register('minimal-ui', 'organizedMinimize', {
name: game.i18n.localize("MinimalUI.OrganizedMinimizeName"),
Expand All @@ -71,7 +105,22 @@ export default class MinimalUIMinimize {
"topBar": game.i18n.localize("MinimalUI.OrganizedMinimizeTopBar"),
"disabled": game.i18n.localize("MinimalUI.Disabled")
},
default: "disabled",
default: "topBar",
onChange: _ => {
window.location.reload()
}
});
game.settings.register('minimal-ui', 'enrichedMinimize', {
name: game.i18n.localize("MinimalUI.EnrichedMinimizeName"),
hint: game.i18n.localize("MinimalUI.EnrichedMinimizeHint"),
scope: 'world',
config: true,
type: String,
choices: {
"enabled": game.i18n.localize("MinimalUI.Enabled"),
"disabled": game.i18n.localize("MinimalUI.Disabled")
},
default: "enabled",
onChange: _ => {
window.location.reload()
}
Expand Down Expand Up @@ -100,24 +149,22 @@ export default class MinimalUIMinimize {
const jumpGap = MinimalUIMinimize.cssMinimizedSize + 10;
const boardSize = parseInt($("#board").css('width'));
const maxGap = boardSize - sidebarGap;
console.log('MinimalUI: Application.prototype.minimize was called');
const targetHtml = $(`[data-appid='${this.appId}']`);
targetHtml.hide();
let targetPos;
for (let i = minGap; i < maxGap + jumpGap; i = i + jumpGap) {
if (MinimalUIMinimize.minimizedStash[i]?.appId === this.appId) {
if (MinimalUIMinimize.minimizedStash[i]?.app.appId === this.appId) {
targetPos = i;
break;
} else if (!targetPos && !MinimalUIMinimize.minimizedStash[i]?.rendered) {
MinimalUIMinimize.minimizedStash[i] = this;
break
} else if (!targetPos && !MinimalUIMinimize.minimizedStash[i]?.app.rendered) {
MinimalUIMinimize.minimizedStash[i] = {app: this, oldLeft: this.position.left};
targetPos = i;
break;
}
}
this.setPosition({left: targetPos ?? this.position.left});
const result = wrapped(...args);
this.element.find(".close").text('');
this.element.find(".close").append(`<a class="header-button close"><i class="fas fa-times"></i></a>`);
MinimalUIMinimize.enrichStyling(this);
await new Promise(waitABit => setTimeout(waitABit, 200));
if (['bottomBar', 'topBar'].includes(minimizedSetting)) {
$("#minimized-bar").show();
Expand All @@ -127,16 +174,17 @@ export default class MinimalUIMinimize {
}, 'WRAPPER');

libWrapper.register('minimal-ui', 'Application.prototype.maximize', async function (wrapped, ...args) {
console.log('MinimalUI: Application.prototype.maximize was called');
let targetHtml = $(`[data-appid='${this.appId}']`);
targetHtml.hide();
let result = wrapped(...args);
await new Promise(waitABit => setTimeout(waitABit, 200));
const minimizedSetting = game.settings.get('minimal-ui', 'organizedMinimize');
const minimizedStash = Object.values(MinimalUIMinimize.minimizedStash);
const matchedStash = minimizedStash.find(a => a.app.appId === this?.appId);
this.setPosition({left: matchedStash.oldLeft});
if (['bottomBar', 'topBar'].includes(minimizedSetting))
MinimalUIMinimize.cleanupMinimizeBar(this);
this.element.find(".close").text('');
this.element.find(".close").append(`<i class="fas fa-times"></i>Close`);
MinimalUIMinimize.unenrichStyling(this);
targetHtml.show();
return result;
}, 'WRAPPER');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foundryvtt-minimal-ui",
"version": "0.8.3",
"version": "0.8.4",
"description": "Minimal UI allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.",
"main": "minimalui.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions styles/feature/minimize.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@
border-radius: 5px;
left: var(--minileft);
opacity: 90%;
}

.minimized-highlight {
background: var(--shadowcolor);
}

.minimized-pinned {
background: var(--bordercolor);
}

0 comments on commit 811b080

Please sign in to comment.