diff options
Diffstat (limited to '.config/awesome/ui/fresnel/init.lua')
-rw-r--r-- | .config/awesome/ui/fresnel/init.lua | 104 |
1 files changed, 59 insertions, 45 deletions
diff --git a/.config/awesome/ui/fresnel/init.lua b/.config/awesome/ui/fresnel/init.lua index 9905741..5d091b6 100644 --- a/.config/awesome/ui/fresnel/init.lua +++ b/.config/awesome/ui/fresnel/init.lua @@ -1,8 +1,10 @@ local al_prompt = require "lib.bling.widget.app_launcher.prompt" local awful = require "awful" -local beautiful = require "beautiful" local cfg = require "misc.cfg" +local gshape = require "gears.shape" local gtable = require "gears.table" +local qanim = require "quarrel.animation" +local qcolor = require "quarrel.color" local qnative = require "quarrel.native" local qtable = require "quarrel.table" local qui = require "quarrel.ui" @@ -42,8 +44,8 @@ function fresnel:_update(query, scrolled) self._entries_offset = 0 end - local layout = self._widget.widget:get_children_by_id("entry_layout")[1] - local status = self._widget.widget:get_children_by_id("status")[1] + local layout = self._popup.widget:get_children_by_id("entry_layout")[1] + local status = self._popup.widget:get_children_by_id("status")[1] local all_providers = {} local entries_count = 0 @@ -71,18 +73,18 @@ function fresnel:_update(query, scrolled) local entry_widget = wibox.widget { widget = wibox.container.background, - shape = qvars.shape, + shape = qui.shape, { widget = wibox.container.margin, - margins = qvars.padding, + margins = qui.PADDING, { widget = wibox.container.constraint, strategy = "max", - height = qvars.char_height, + height = qui.CHAR_HEIGHT, { { widget = wibox.container.background, - fg = qvars.colors.dim.fg, + fg = qcolor.palette.low, { widget = wibox.widget.textbox, text = entry.provider .. " | ", @@ -92,7 +94,7 @@ function fresnel:_update(query, scrolled) widget = wibox.widget.textbox, text = entry.message, }, - spacing = qvars.padding, + spacing = qui.PADDING, layout = wibox.layout.fixed.horizontal, }, }, @@ -111,21 +113,21 @@ function fresnel:_update(query, scrolled) if self._selected_index + self._entries_offset == i then entry_widget._selected = true - entry_widget.bg = qvars.colors.black + entry_widget.bg = qcolor.palette.bg.high end entry_widget:connect_signal("mouse::enter", function() if entry_widget._selected == true then return end - entry_widget.bg = qvars.colors.black + entry_widget.bg = qcolor.palette.bg.high end) entry_widget:connect_signal("mouse::leave", function() if entry_widget._selected == true then return end - entry_widget.bg = qvars.colors.bg + entry_widget.bg = qcolor.palette.bg() end) layout:add(entry_widget) @@ -143,7 +145,7 @@ fresnel._prompt = al_prompt { prompt = "", reset_on_stop = true, ul_cursor = "low", - bg_cursor = qvars.colors.black, + bg_cursor = qcolor.palette.bg.high, changed_callback = function(text) if fresnel._text == text then return @@ -192,27 +194,31 @@ fresnel._prompt = al_prompt { end, } -fresnel._widget = qui.popup { - visible = false, +local max_height = qui.BIG_PADDING * 2 + (qui.BIG_PADDING * 2 + qui.CHAR_HEIGHT) * 10 +-- + qui.PADDING +-- + qui.PADDING * 9 + +local width = awful.screen.focused().geometry.width / 2 + +fresnel._popup = qui.popup { + -- visible = false, ontop = true, - placement = function(d) - awful.placement.top(d, { - margins = { - top = beautiful.useless_gap * 2, - }, - }) + placement = false, + shape = function(cr, w) + gshape.partially_rounded_rect(cr, w, 0, false, false, true, true, qui.BORDER_RADIUS) end, - minimum_width = awful.screen.focused().geometry.width / 2, - maximum_width = awful.screen.focused().geometry.width / 2, + x = width / 2, + minimum_width = width, + maximum_width = width, + -- maximum_height = max_height, widget = { - { + qui.styled { widget = wibox.container.background, - bg = qvars.colors.black, - fg = qvars.colors.dim.fg, - shape = qvars.shape, + fg = qcolor.palette.fg.low, + bg = qcolor.palette.bg.high, { widget = wibox.container.margin, - margins = qvars.padding, + margins = qui.BIG_PADDING, { { widget = wibox.widget.textbox, @@ -221,16 +227,16 @@ fresnel._widget = qui.popup { { widget = wibox.container.margin, margins = { - left = qvars.padding, - right = qvars.padding, + left = qui.PADDING, + right = qui.PADDING, }, { widget = wibox.container.constraint, strategy = "max", - height = qvars.char_height, + height = qui.CHAR_HEIGHT, { widget = wibox.container.background, - fg = qvars.colors.fg, + fg = qcolor.palette.fg(), fresnel._prompt.textbox, }, }, @@ -247,10 +253,10 @@ fresnel._widget = qui.popup { { widget = wibox.container.margin, margins = { - top = qvars.padding, + top = qui.PADDING, }, { - spacing = qvars.padding, + spacing = qui.PADDING, layout = wibox.layout.fixed.vertical, id = "entry_layout", }, @@ -258,35 +264,43 @@ fresnel._widget = qui.popup { layout = wibox.layout.align.vertical, }, } -fresnel._widget.maximum_height = qvars.big_padding * 2 - + (qvars.padding * 2 + qvars.char_height) * (1 + 10) - + qvars.padding - + qvars.padding * 9 - function fresnel:show() self._toggled = true - self._timed.target = 1 + self._opacity_timed.target = 1 + self._height_timed:set(max_height) self:_update() self._prompt:start() end function fresnel:hide() self._toggled = false - self._timed.target = 0 + self._opacity_timed.target = 0 + self._height_timed:set(0) self._prompt:stop() end -fresnel._timed = rubato.timed { +fresnel._height_timed = qanim:new { + duration = qvars.anim_duration, + pos = 0, + easing = qvars.easing, + subscribed = function(pos) + fresnel._popup.shape = function(cr, w) + gshape.partially_rounded_rect(cr, w, pos, false, false, true, true, qui.BORDER_RADIUS) + end + end, +} + +-- TODO: optimize the search algo to be more efficient and not require making fresnel invisible +fresnel._opacity_timed = rubato.timed { duration = qvars.anim_duration, - intro = qvars.anim_intro, pos = 0, subscribed = function(pos) - fresnel._widget.opacity = pos + fresnel._popup.opacity = pos if pos == 0 then - fresnel._widget.visible = false + fresnel._popup.visible = false else - fresnel._widget.visible = true + fresnel._popup.visible = true end end, } |