Skip to content

Commit

Permalink
Merge pull request #2775 from CommandPost/issue/2774-ui-height-tweaks
Browse files Browse the repository at this point in the history
Restrict UI height to screen height and show scrollbars if bigger
  • Loading branch information
latenitefilms committed Oct 27, 2021
2 parents be5caa9 + c61c6ef commit 74818b2
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/plugins/core/controlsurfaces/manager/css/preferences.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ body {
background-color: #1f1f1f;
font-family: -apple-system;
font-size: 13px;
overflow:hidden;
max-width: 100%;
overflow-x: hidden;
color: #999999;
}

Expand Down
16 changes: 15 additions & 1 deletion src/plugins/core/controlsurfaces/manager/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local hs = _G.hs
local log = require "hs.logger".new "prefsMgr"

local inspect = require "hs.inspect"
local mouse = require "hs.mouse"
local screen = require "hs.screen"
local timer = require "hs.timer"
local toolbar = require "hs.webview.toolbar"
Expand Down Expand Up @@ -525,7 +526,20 @@ function mod.selectPanel(id)
offset = -20
end

mod._webview:size({w = mod.DEFAULT_WIDTH, h = height + offset})
--------------------------------------------------------------------------------
-- Make sure the panel isn't bigger than the screen:
--------------------------------------------------------------------------------
local heightWithOffset = height + offset

local currentScreen = mouse.getCurrentScreen()
local currentFrame = currentScreen and currentScreen:frame()
local currentHeight = currentFrame and currentFrame.h

if heightWithOffset > currentHeight then
heightWithOffset = currentHeight - 10
end

mod._webview:size({w = mod.DEFAULT_WIDTH, h = heightWithOffset})
end

end
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/core/preferences/manager/css/preferences.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ body {
background-color: #1f1f1f;
font-family: -apple-system;
font-size: 13px;
overflow:hidden;
max-width: 100%;
overflow-x: hidden;
color: #999999;
}

Expand Down
16 changes: 15 additions & 1 deletion src/plugins/core/preferences/manager/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local hs = _G.hs
local log = require "hs.logger".new "prefsMgr"

local inspect = require "hs.inspect"
local mouse = require "hs.mouse"
local screen = require "hs.screen"
local timer = require "hs.timer"
local toolbar = require "hs.webview.toolbar"
Expand Down Expand Up @@ -515,7 +516,20 @@ function mod.selectPanel(id)
offset = -20
end

mod._webview:size({w = mod.DEFAULT_WIDTH, h = height + offset})
--------------------------------------------------------------------------------
-- Make sure the panel isn't bigger than the screen:
--------------------------------------------------------------------------------
local heightWithOffset = height + offset

local currentScreen = mouse.getCurrentScreen()
local currentFrame = currentScreen and currentScreen:frame()
local currentHeight = currentFrame and currentFrame.h

if heightWithOffset > currentHeight then
heightWithOffset = currentHeight - 10
end

mod._webview:size({w = mod.DEFAULT_WIDTH, h = heightWithOffset})
end

end
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/core/toolbox/manager/css/preferences.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ body {
background-color: #1f1f1f;
font-family: -apple-system;
font-size: 13px;
overflow:hidden;
max-width: 100%;
overflow-x: hidden;
color: #999999;
}

Expand Down
16 changes: 15 additions & 1 deletion src/plugins/core/toolbox/manager/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local hs = _G.hs
local log = require "hs.logger".new "utils"

local inspect = require "hs.inspect"
local mouse = require "hs.mouse"
local screen = require "hs.screen"
local timer = require "hs.timer"
local toolbar = require "hs.webview.toolbar"
Expand Down Expand Up @@ -515,7 +516,20 @@ function mod.selectPanel(id)
offset = -20
end

mod._webview:size({w = mod.DEFAULT_WIDTH, h = height + offset})
--------------------------------------------------------------------------------
-- Make sure the panel isn't bigger than the screen:
--------------------------------------------------------------------------------
local heightWithOffset = height + offset

local currentScreen = mouse.getCurrentScreen()
local currentFrame = currentScreen and currentScreen:frame()
local currentHeight = currentFrame and currentFrame.h

if heightWithOffset > currentHeight then
heightWithOffset = currentHeight - 10
end

mod._webview:size({w = mod.DEFAULT_WIDTH, h = heightWithOffset})
end

end
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/core/watchfolders/manager/html/panels.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
background-color: #1f1f1f;
font-family: -apple-system;
font-size: 13px;
overflow:hidden;
max-width: 100%;
overflow-x: hidden;
color: #999999;
}
a {
Expand Down
16 changes: 15 additions & 1 deletion src/plugins/core/watchfolders/manager/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local hs = _G.hs
local log = require "hs.logger".new "watchMan"

local inspect = require "hs.inspect"
local mouse = require "hs.mouse"
local screen = require "hs.screen"
local timer = require "hs.timer"
local toolbar = require "hs.webview.toolbar"
Expand Down Expand Up @@ -447,7 +448,20 @@ function mod.selectPanel(id)
-- Resize Panel:
--------------------------------------------------------------------------------
if v.id == id and v.height and type(v.height) == "number" and mod._webview:hswindow() and mod._webview:hswindow():isVisible() then
mod._webview:size({w = mod.DEFAULT_WIDTH, h = v.height })
--------------------------------------------------------------------------------
-- Make sure the panel isn't bigger than the screen:
--------------------------------------------------------------------------------
local heightWithOffset = v.height

local currentScreen = mouse.getCurrentScreen()
local currentFrame = currentScreen and currentScreen:frame()
local currentHeight = currentFrame and currentFrame.h

if heightWithOffset > currentHeight then
heightWithOffset = currentHeight - 10
end

mod._webview:size({w = mod.DEFAULT_WIDTH, h = heightWithOffset})
end

local style = v.id == id and "block" or "none"
Expand Down

0 comments on commit 74818b2

Please sign in to comment.