aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/quarrel/ui.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/awesome/quarrel/ui.lua')
-rw-r--r--.config/awesome/quarrel/ui.lua145
1 files changed, 0 insertions, 145 deletions
diff --git a/.config/awesome/quarrel/ui.lua b/.config/awesome/quarrel/ui.lua
deleted file mode 100644
index 1db4a70..0000000
--- a/.config/awesome/quarrel/ui.lua
+++ /dev/null
@@ -1,145 +0,0 @@
-local awful = require "awful"
-local gtable = require "gears.table"
-local qbind = require "quarrel.bind"
-local qvars = require "quarrel.vars"
-local rtimed = require "lib.rubato.timed"
-local wibox = require "wibox"
-
----@class QuarrelUi
-local qui = {}
-
---- Return qvars.text_font with size scaled by factor
----@param factor number
----@return string
----@see QuarrelVars.text_font
-function qui.font(factor)
- return qvars.text_font .. " " .. qvars.font_size * (factor or 1)
-end
-
---- Inject background widget styling into target
----@param target table
----@return table
-function qui.styled(target)
- return gtable.crush({
- bg = qvars.colors.bg,
- border_color = qvars.colors.bright.black,
- border_width = qvars.border_width,
- shape = qvars.shape,
- }, target)
-end
-
---- Generate a styled popup
----@param target table
----@return table
-function qui.popup(target)
- target.widget = {
- widget = wibox.container.margin,
- margins = qvars.big_padding,
- target.widget,
- }
-
- return awful.popup(qui.styled(target))
-end
-
---- Generate svg recolor string
----@param color string
----@return string
-function qui.recolor(color)
- return "svg{fill:" .. color .. "}"
-end
-
---- Generate icon widget
----@param args table
----@return table
-function qui.icon(args)
- return gtable.crush({
- widget = wibox.widget.imagebox,
- image = args.icon,
- forced_width = qvars.char_height,
- forced_height = qvars.char_height,
- stylesheet = qui.recolor(args.color or qvars.colors.fg),
- }, args.widget or {})
-end
-
---- Generate button widget
----@param args table
----@return table
-function qui.button(args)
- args.press = args.press or function(_) end
- local widget = wibox.widget(gtable.crush({
- widget = wibox.widget.imagebox,
- image = args.image,
- forced_height = qvars.char_height,
- forced_width = qvars.char_height,
- stylesheet = qui.recolor(qvars.colors.fg),
- press = args.press,
- }, args.widget or {}))
-
- widget.buttons = {
- qbind:new {
- triggers = qvars.btns.left,
- press = function()
- widget:press()
- end,
- hidden = true,
- },
- }
-
- return widget
-end
-
---- Generate toggle widget
----@param args table
----@return table
-function qui.toggle(args)
- args.press = args.press or function(_) end
- local widget = qui.button {
- widget = gtable.crush({
- toggled = false,
- silent_press = function(self, state)
- if state then
- self.toggled = state
- else
- self.toggled = not self.toggled
- end
-
- if self.toggled then
- self.image = args.on
- else
- self.image = args.off
- end
- end,
- }, args.widget or {}),
- image = args.off,
- press = function(self)
- if not args.manual then
- self:silent_press()
- end
- args.press(self)
- end,
- }
-
- return widget
-end
-
----@param widget wibox.widget.base
----@param cursor string
-function qui.hoverable(widget, cursor)
- local hovering = false
-
- widget:connect_signal("mouse::enter", function()
- local w = mouse.current_wibox
- if w then
- w.cursor = cursor
- end
- end)
-
- widget:connect_signal("mouse::leave", function()
- local w = mouse.current_wibox
- if w then
- w.cursor = "left_ptr"
- end
- end)
-end
-
-return qui