From fd7e4b6c05856f72a68380396232d44c5d9108bc Mon Sep 17 00:00:00 2001 From: tomasklaen Date: Mon, 13 Sep 2021 09:24:57 +0200 Subject: [PATCH] Add top_bar option Possible values: - never - no-border: in windowed mode when border is disabled, or fullscreen - always Closes #15 --- README.md | 4 +++- uosc.conf | 4 +++- uosc.lua | 23 ++++++++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c4874ca..4059578 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,9 @@ menu_hjkl_navigation=no menu_opacity=0.8 menu_font_scale=1 -# top bar with window controls and media title shown only in no-border mode +# top bar with window controls and media title +# can be: never, no-border, always +top_bar=no-border top_bar_size=40 top_bar_size_fullscreen=46 top_bar_persistency= diff --git a/uosc.conf b/uosc.conf index bc69b1d..9091de7 100644 --- a/uosc.conf +++ b/uosc.conf @@ -52,7 +52,9 @@ menu_hjkl_navigation=no menu_opacity=0.8 menu_font_scale=1 -# top bar with window controls and media title shown only in no-border mode +# top bar with window controls and media title +# can be: never, no-border, always +top_bar=no-border top_bar_size=40 top_bar_size_fullscreen=46 top_bar_persistency= diff --git a/uosc.lua b/uosc.lua index 70cce87..192a71e 100644 --- a/uosc.lua +++ b/uosc.lua @@ -73,7 +73,9 @@ menu_hjkl_navigation=no menu_opacity=0.8 menu_font_scale=1 -# top bar with window controls and media title shown only in no-border mode +# top bar with window controls and media title +# can be: never, no-border, always +top_bar=no-border top_bar_size=40 top_bar_size_fullscreen=46 top_bar_persistency= @@ -249,6 +251,7 @@ local options = { menu_opacity = 0.8, menu_font_scale = 1, + top_bar = 'no-border', top_bar_size = 40, top_bar_size_fullscreen = 46, top_bar_persistency = '', @@ -2342,6 +2345,16 @@ elements:add('top_bar', Element.new({ if this.forced_proximity then return this.forced_proximity end return (elements.volume_slider and elements.volume_slider.pressed) and 0 or this.proximity end, + decide_enabled = function(this) + if options.top_bar == 'no-border' then + this.enabled = not state.border or state.fullormaxed + elseif options.top_bar == 'always' then + this.enabled = true + else + this.enabled = false + end + this.enabled = this.enabled and (options.top_bar_controls or options.top_bar_title) + end, update_dimensions = function(this) this.size = state.fullormaxed and options.top_bar_size_fullscreen or options.top_bar_size this.icon_size = round(this.size / 8) @@ -2354,8 +2367,12 @@ elements:add('top_bar', Element.new({ this.title_bx = this.bx - (options.top_bar_controls and (this.button_width * 3) or 0) this.ax = options.top_bar_title and elements.window_border.size or this.title_bx end, - on_prop_border = function(this, value) - this.enabled = not value and (options.top_bar_controls or options.top_bar_title) + on_prop_border = function(this) + this:decide_enabled() + this:update_dimensions() + end, + on_prop_fullormaxed = function(this) + this:decide_enabled() this:update_dimensions() end, on_display_change = function(this) this:update_dimensions() end,