Skip to content

Commit

Permalink
Minimized bar now uses only necessary space
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Apr 26, 2021
1 parent cf16361 commit e59b10d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
### 0.8.6
* Enhancement: New Hotbar setting option: Only GM (Hides Macro Hotbar for players)
* Enhancement: Organized Minimized Bar now takes only necessary amount of space
* Enhancement: Better looking minimized windows with Minimal UI colorset
* Enhancement: Better looking Minimized Bar (when enabled) and more transparent
* Enhancement: New Hotbar setting option: Only GM (Hides Macro Hotbar for players)
* Bugfix: Fixed miscalculation with the minimized bar in some circumstances
* Bugfix: Fixed an error in some circumstances causing minimized windows to disappear



### 0.8.5
* Bugfix: Minimize+ colors darkened
* Bugfix: Minimized a window that was pinned now stays pinned
Expand Down
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.5",
"version": "0.8.6",
"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.5.zip"
"download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/latest/download/foundryvtt-minimal-ui_0.8.6.zip"
}
25 changes: 17 additions & 8 deletions modules/feature/minimize.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export default class MinimalUIMinimize {
static cssMinimizedSize = 150;
static cssTopBarLeftStart = 5;
static cssBottomBarLeftStart = 200;
static cssTopBarWidthDiff = 430;
static cssBottomBarWidthDiff = 525;

static fixMinimizedRule(rule, measure) {
let stylesheet = document.querySelector('link[href*=minimalui]');
Expand All @@ -27,14 +25,22 @@ export default class MinimalUIMinimize {
}

static positionMinimizeBar() {
const availableWidth = parseInt($("#board").css('width'));
switch (game.settings.get('minimal-ui', 'organizedMinimize')) {
const setting = game.settings.get('minimal-ui', 'organizedMinimize');
let maxPosition = Math.max(
...Object.entries(MinimalUIMinimize.minimizedStash)
.filter(([_, app]) => app.app.rendered)
.map(([pos, _]) => Number(pos))
.concat(0)
);
switch (setting) {
case 'topBar': {
rootStyle.setProperty('--minimw', availableWidth - MinimalUIMinimize.cssTopBarWidthDiff + 'px');
maxPosition += maxPosition > 0 ? MinimalUIMinimize.cssMinimizedSize : MinimalUIMinimize.cssTopBarLeftStart;
rootStyle.setProperty('--minimw', maxPosition + 'px');
break;
}
case 'bottomBar': {
rootStyle.setProperty('--minimw', availableWidth - MinimalUIMinimize.cssBottomBarWidthDiff + 'px');
maxPosition += maxPosition > 0 ? MinimalUIMinimize.cssMinimizedSize : MinimalUIMinimize.cssBottomBarLeftStart;
rootStyle.setProperty('--minimw', maxPosition + 'px');
break;
}
}
Expand All @@ -60,6 +66,7 @@ export default class MinimalUIMinimize {
MinimalUIMinimize.minimizedStash = {};
$("#minimized-bar").hide();
}
MinimalUIMinimize.positionMinimizeBar();
}

static enrichStyling(app) {
Expand Down Expand Up @@ -114,7 +121,7 @@ export default class MinimalUIMinimize {
"topBar": game.i18n.localize("MinimalUI.OrganizedMinimizeTopBar"),
"disabled": game.i18n.localize("MinimalUI.Disabled")
},
default: "top",
default: "topBar",
onChange: _ => {
window.location.reload()
}
Expand Down Expand Up @@ -175,8 +182,10 @@ export default class MinimalUIMinimize {
const result = wrapped(...args);
MinimalUIMinimize.enrichStyling(this);
await new Promise(waitABit => setTimeout(waitABit, 200));
if (['bottomBar', 'topBar'].includes(minimizedSetting))
if (['bottomBar', 'topBar'].includes(minimizedSetting)) {
MinimalUIMinimize.positionMinimizeBar();
$("#minimized-bar").show();
}
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.5",
"version": "0.8.6",
"description": "Minimal UI allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.",
"main": "minimalui.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions styles/feature/minimize.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
top: var(--minimtop);
border-radius: 5px;
left: var(--minileft);
opacity: 25%;
opacity: 40%;
transition: 0.2s;
border: 1px solid var(--bordercolor);
box-shadow: 3px 0 var(--shadowstrength) 0 var(--shadowcolor);
}

.window-app.minimized .window-header {
border: 1px solid var(--bordercolor);
box-shadow: 3px 0 var(--shadowstrength) 0 var(--shadowcolor);
box-shadow: 0 0 var(--shadowstrength) 0 var(--shadowcolor);
}

.minimized-highlight {
Expand Down

0 comments on commit e59b10d

Please sign in to comment.