Skip to content

Commit

Permalink
Merge branch 'rabbithole-theme-workspacemenu' into rabbithole-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
LycanDarko666 committed Apr 2, 2023
2 parents e15c72d + 2719238 commit e59953f
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 68 deletions.
30 changes: 29 additions & 1 deletion awesome-workspace-manager/widgets/workspace-menu/controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local naughty = require("naughty")
local viewHelper = require("awesome-workspace-manager.widgets.viewHelper")
local beautiful = require("beautiful")
local modal = require("awesome-workspace-manager.modal")
local cairo = require("lgi").cairo

local _M = {}

Expand All @@ -26,6 +27,33 @@ function WorkspaceMenuController:new(workspaceManagerService)

workspaceManagerService:subscribeController(self)

-- set rounded rectangle shape to root element
local surface = cairo.ImageSurface.create(cairo.Format.ARGB32, 1, 1)
local cr = cairo.Context(surface)
cr:set_source_rgba(1,1,1,1)
cr:rectangle(0,0,200,30)
cr:fill()
surface:flush()
local radius = 5
local rounded_rect_shape = function(cr, width, height)
cr:move_to(radius, 0)
cr:line_to(width - radius, 0)
cr:arc(width - radius, radius, radius, -math.pi/2, 0)
cr:line_to(width, height - radius)
cr:arc(width - radius, height - radius, radius, 0, math.pi/2)
cr:line_to(radius, height)
cr:arc(radius, height - radius, radius, math.pi/2, math.pi)
cr:line_to(0, radius)
cr:arc(radius, radius, radius, math.pi, 3*math.pi/2)
cr:close_path()
end
self.view.bindings.root.shape = rounded_rect_shape
self.view.bindings.root.shape_bounding = surface:get_data()
self.view.bindings.root.resize = true
-- set smaller font size for the textbox
self.view.bindings.textbox.font = "Ubuntu 10"
self.view.bindings.textbox.align = "center"

return self
end

Expand Down Expand Up @@ -140,4 +168,4 @@ function _M.get(workspaceManagerService)
return WorkspaceMenuController:new(workspaceManagerService)
end

return setmetatable({}, { __call = function(_, workspaceManagerService) return _M.get(workspaceManagerService) end })
return setmetatable({}, { __call = function(_, workspaceManagerService) return _M.get(workspaceManagerService) end })
2 changes: 1 addition & 1 deletion bunny_bar/center_bar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ return function(s, widgets)
screen = s,
widget = wibox.container.background,
ontop = false,
bg = color["Yellow100"],
bg = color["Blur"], -- requires picom to be turned on
visible = true,
maximum_width = dpi(500),
placement = function(c) awful.placement.top(c, { margins = dpi(10) }) end,
Expand Down
4 changes: 3 additions & 1 deletion bunny_bar/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- Bunny_bar - Rabbithole's segmented wibar system

-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
Expand Down Expand Up @@ -34,7 +36,7 @@ awful.screen.connect_for_each_screen(function(s)
require("src.modules.volume_osd")(s)
require("src.modules.brightness_osd")(s)
require("src.modules.titlebar")
require("src.modules.volume_controller")(s)
--require("src.modules.volume_controller")(s)

-- Widgets definitions
--s.battery = require("src.widgets.battery")()
Expand Down
2 changes: 1 addition & 1 deletion bunny_bar/left_bar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ return function(s, widgets)
screen = s,
widget = wibox.container.background,
ontop = false,
bg = color["LightBlueA700"],
bg = color["LightBlue200"],
visible = true,
maximum_width = dpi(650),
placement = function(c) awful.placement.top_left(c, { margins = dpi(10) }) end,
Expand Down
129 changes: 65 additions & 64 deletions bunny_bar/right_bar.lua
Original file line number Diff line number Diff line change
@@ -1,76 +1,77 @@
--------------------------------------------------------------------------------------------------------------
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
--------------------------------------------------------------------------------------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("src.theme.colors")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")

return function(s, widgets)

local top_right = awful.popup {
widget = wibox.container.background,
ontop = false,
bg = 'DeepPurpleA700', --color["PinkA100"],
visible = true,
screen = s,
placement = function(c) awful.placement.top_right(c, { margins = dpi(10) }) end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 10)
end
}

top_right:struts {
top = 55
}
-- Custom local libraries
local color = require("src.theme.colors")

local function prepare_widgets(widgets)
local layout = {
forced_height = 40,
layout = wibox.layout.fixed.horizontal
-- This returns a widget for the right bar
return function(s, widgets)
-- create right wibar as a floating popup widget
local top_right = awful.popup {
widget = wibox.container.background,
ontop = false,
bg = color["BlueA400"],
visible = true,
screen = s,
placement = function(c) awful.placement.top_right(c, { margins = dpi(10) }) end,
-- rounded edges
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 10)
end
}
-- this sets the distance between the top of the screen and the clients
top_right:struts {
top = 55
}
for i, widget in pairs(widgets) do
if i == 1 then
table.insert(layout,
{
widget,
left = dpi(6),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
elseif i == #widgets then
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
else
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
end

local function prepare_widgets(widgets)
local layout = {
forced_height = 40,
layout = wibox.layout.fixed.horizontal
}
for i, widget in pairs(widgets) do
if i == 1 then
table.insert(layout,
{
widget,
left = dpi(6),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
elseif i == #widgets then
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
else
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
end
end
return layout
return layout
end

top_right:setup {
nil,
nil,
prepare_widgets(widgets),
layout = wibox.layout.align.horizontal
}
top_right:setup {
nil,
nil,
prepare_widgets(widgets),
layout = wibox.layout.align.horizontal
}
end
135 changes: 135 additions & 0 deletions src/widgets/button_widget.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
-- Awesome libs
local wibox = require("wibox")
local gears = require("gears")

-- Define the button widget function
local function create_button_widget(args)
local args = args or {}
local bg_normal = args.bg_normal or "#333333"
local bg_hover = args.bg_hover or "#444444"
local bg_press = args.bg_press or "#555555"
local fg_normal = args.fg_normal or "#ffffff"
local fg_hover = args.fg_hover or "#ffffff"
local fg_press = args.fg_press or "#ffffff"
local font = args.font or "sans 10"
local shape = args.shape or function(cr, width, height) gears.shape.rectangle(cr, width, height) end
local shadow = args.shadow or false
local text = args.text or ""
local onclick = args.onclick or function() end

local button = wibox.widget {
{
{
{
text = text,
font = font,
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
margins = 5,
widget = wibox.container.margin
},
bg = bg_normal,
shape = shape,
widget = wibox.container.background
},
forced_width = 100,
forced_height = 30,
widget = wibox.container.constraint
}

-- Change button background color and text color on hover and press
button:connect_signal("mouse::enter", function()
button:get_children_by_id("bg")[1].bg = bg_hover
button:get_children_by_id("text")[1].markup = "<b>" .. text .. "</b>"
button:get_children_by_id("text")[1].fg = fg_hover
end)
button:connect_signal("mouse::leave", function()
button:get_children_by_id("bg")[1].bg = bg_normal
button:get_children_by_id("text")[1].markup = text
button:get_children_by_id("text")[1].fg = fg_normal
end)
button:connect_signal("button::press", function()
button:get_children_by_id("bg")[1].bg = bg_press
button:get_children_by_id("text")[1].fg = fg_press
end)
button:connect_signal("button::release", function()
button:get_children_by_id("bg")[1].bg = bg_hover
button:get_children_by_id("text")[1].fg = fg_hover
onclick()
end)

-- Add a shadow to the button if specified
if shadow then
button = wibox.widget {
{
button,
widget = wibox.container.background
},
shape = shape,
widget = wibox.container.background
}
button = wibox.widget {
{
{
button,
widget = wibox.container.background
},
widget = wibox.container.margin
},
widget = wibox.container.background
}
button = wibox.widget {
{
{
button,
widget = wibox.container.background
},
widget = wibox.container.margin
},
widget = wibox.container.background
}
button = wibox.widget {
{
{
button,
widget = wibox.container.background
},
widget = wibox.container.margin
}
button = wibox.widget {
{
{
button,
widget = wibox.container.background
},
widget = wibox.container.margin
},
widget = wibox.container.background
}
button = wibox.widget {
{
{
button,
widget = wibox.container.background
},
widget = wibox.container.margin
},
widget = wibox.container.background
}
button = wibox.widget {
{
{
button,
widget = wibox.container.background
},
widget = wibox.container.margin
},
shape = shape,
widget = wibox.container.background
}
end

return button
end

0 comments on commit e59953f

Please sign in to comment.