+titlbar tabbed group indicator +tasklist tabbed group indicator (#88)

* +titlbar tabbed group indicator +tasklist tabbed group indicator

* fixup! +titlbar tabbed group indicator +tasklist tabbed group indicator

* fixup! fixup! +titlbar tabbed group indicator +tasklist tabbed group indicator

* fixup! fixup! fixup! +titlbar tabbed group indicator +tasklist tabbed group indicator

* Import bling

* reeeeeeeeeee

* stuff

* fixup! stuff

* fixup! fixup! stuff

* fixup! fixup! fixup! stuff

* fixup! fixup! fixup! fixup! stuff

* fixup! fixup! fixup! fixup! fixup! stuff

* fixup! fixup! fixup! fixup! fixup! fixup! stuff

* fixup! fixup! fixup! fixup! fixup! fixup! fixup! stuff

Co-authored-by: gokul <33443763+JavaCafe01@users.noreply.github.com>
This commit is contained in:
contribuewwt 2021-08-19 00:09:33 +05:30 committed by GitHub
parent 0aa1a92c72
commit bdc025fb63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 286 additions and 3 deletions

View File

@ -5,3 +5,4 @@ The following developers have contributed major code to bling:
* [Grumph](https://github.com/Grumph) * [Grumph](https://github.com/Grumph)
* [Bysmutheye](https://github.com/Bysmutheye) * [Bysmutheye](https://github.com/Bysmutheye)
* [HumblePresent](https://github.com/HumblePresent) * [HumblePresent](https://github.com/HumblePresent)
* [undefinedDarkness](https://github.com/undefinedDarkness)

View File

@ -47,8 +47,16 @@ Modern theme:
*screenshot by [javacafe](https://github.com/JavaCafe01)* *screenshot by [javacafe](https://github.com/JavaCafe01)*
### Signals ### Signals
The tabbed module emits 1 signals for the purpose of integrating with your rice, The tabbed module emits a few signals for the purpose of integration,
```lua ```lua
-- bling::tabbed::update -- triggered whenever a tabbed object is updated -- bling::tabbed::update -- triggered whenever a tabbed object is updated
-- tabobj -- the object that caused the update -- tabobj -- the object that caused the update
-- bling::tabbed::client_added -- triggered whenever a new client is added to a tab group
-- tabobj -- the object that the client was added to
-- client -- the client that added
-- bling::tabbed::client_removed -- triggered whenever a client is removed from a tab group
-- tabobj -- the object that the client was removed from
-- client -- the client that was removed
-- bling::tabbed::changed_focus -- triggered whenever a tab group's focus is changed
-- tabobj -- the modified tab group
``` ```

106
docs/widgets/tabbed_misc.md Normal file
View File

@ -0,0 +1,106 @@
## 🧱 Tabbed Miscellaneous <!-- {docsify-ignore} -->
This comprises a few widgets to better represent tabbed groups (from the tabbed module) in your desktop.
The widgets currently included are:
- Titlebar Indicator
- Tasklist
![Preview Image](https://i.imgur.com/ZeYSrxY.png)
## Titlebar Indicator
### Usage
To use the task list indicator:
**NOTE:** Options can be set as theme vars under the table `theme.bling_tabbed_misc_titlebar_indicator`
```lua
bling.widget.tabbed_misc.titlebar_indicator(client, {
layout_spacing = dpi(5), -- Set spacing in between items
icon_size = dpi(24),
icon_margin = 0,
bg_color_focus = "#282828", -- Color for the focused items
bg_color = "#1d2021", -- Color for normal / unfocused items
icon_shape = gears.shape.circle -- Set icon shape,
})
```
a widget_template option is also available:
```lua
bling.widget.tabbed_misc.titlebar_indicator(client, {
widget_template = {
{
widget = awful.widget.clienticon,
id = 'icon_role'
},
widget = wibox.container.margin,
margins = 2,
id = 'click_role'
}
})
```
### Example Implementation
You normally embed the widget in your titlebar...
```lua
awful.titlebar(c).widget = {
{ -- Left
bling.widget.tabbed_misc.titlebar_indicator(c),
layout = wibox.layout.fixed.horizontal
},
{ -- Middle
{ -- Title
align = "center",
widget = awful.titlebar.widget.titlewidget(c)
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{ -- Right
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.closebutton (c),
layout = wibox.layout.fixed.horizontal
},
layout = wibox.layout.align.horizontal
}
```
## Tasklist
### Usage
Similar to the titlebar indicator, it can be used like so:
**NOTE:** Similar to above, options can also be used under as theme vars under the table
```lua
require('bling.widget.tabbed').custom_tasklist(s, {
icon_margin = dpi(0), -- Item Margin
icon_size = dpi(24), -- Does not apply to tabbed groups
group_row_spacing = dpi(2), -- Spacing between rows in a group indicator
filter = awful.widget.tasklist.filter.currenttags, -- Set awful.widget.titlbar like filter
layout = wibox.layout.fixed.vertical, -- Tasklist layout
-- widget_template = {...} -- Identical to above widget template, used for regular clients, has click & icon roles
})
```
### Implementation
It can be used as follows:
```lua
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
mylauncher,
s.mytaglist,
s.mypromptbox,
},
require('bling.widget.tabbed_misc').custom_tasklist(s),
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
mykeyboardlayout,
wibox.widget.systray(),
mytextclock,
s.mylayoutbox,
},
}
```

View File

@ -41,6 +41,7 @@ tabbed.remove = function(c)
awful.titlebar.hide(c, bar.position) awful.titlebar.hide(c, bar.position)
end end
c.bling_tabbed = nil c.bling_tabbed = nil
awesome.emit_signal("bling::tabbed::client_removed", tabobj, c)
tabbed.switch_to(tabobj, 1) tabbed.switch_to(tabobj, 1)
end end
@ -62,7 +63,7 @@ tabbed.add = function(c, tabobj)
-- but the new client needs to have the tabobj property -- but the new client needs to have the tabobj property
-- before a clean switch can happen -- before a clean switch can happen
tabbed.update(tabobj) tabbed.update(tabobj)
awesome.emit_signal("bling::tabbed::client_added", tabobj) awesome.emit_signal("bling::tabbed::client_added", tabobj, c)
tabbed.switch_to(tabobj, #tabobj.clients) tabbed.switch_to(tabobj, #tabobj.clients)
end end
@ -151,6 +152,7 @@ tabbed.update = function(tabobj)
end end
end end
-- Maybe remove if I'm the only one using it?
awesome.emit_signal("bling::tabbed::update", tabobj) awesome.emit_signal("bling::tabbed::update", tabobj)
if not beautiful.tabbar_disable then if not beautiful.tabbar_disable then
tabbed.update_tabbar(tabobj) tabbed.update_tabbar(tabobj)
@ -173,6 +175,7 @@ tabbed.switch_to = function(tabobj, new_idx)
helpers.client.sync(c, old_focused_c) helpers.client.sync(c, old_focused_c)
end end
end end
awesome.emit_signal("bling::tabbed::changed_focus", tabobj)
tabbed.update(tabobj) tabbed.update(tabobj)
end end

View File

@ -1,4 +1,5 @@
return { return {
tag_preview = require(... .. ".tag_preview"), tag_preview = require(... .. ".tag_preview"),
task_preview = require(... .. ".task_preview") task_preview = require(... .. ".task_preview"),
tabbed_misc = require(... .. ".tabbed_misc")
} }

View File

@ -0,0 +1,53 @@
local wibox = require('wibox')
local awful = require('awful')
local gears = require('gears')
local beautiful = require('beautiful')
local dpi = require("beautiful.xresources").apply_dpi
local function tabobj_support(self, c, index, clients)
-- Self is the background widget in this context
if not c.bling_tabbed then
return
end
local group = c.bling_tabbed
-- Single item tabbed group's dont get special rendering
if #group.clients > 1 then
local wrapper = wibox.widget({
{
-- This is so dumb... but it works so meh
{
id = "row1",
layout = wibox.layout.flex.horizontal,
},
{
id = "row2",
layout = wibox.layout.flex.horizontal,
},
spacing = dpi(2),
layout = wibox.layout.fixed.vertical,
},
id = 'click_role',
widget = wibox.container.margin,
margins = dpi(5)
})
for idx, c in ipairs(group.clients) do
if c and c.icon then
-- TODO: Don't do this in a -1iq way
if idx <= 2 then
wrapper:get_children_by_id("row1")[1]:add(awful.widget.clienticon(c))
else
wrapper:get_children_by_id("row2")[1]:add(awful.widget.clienticon(c))
end
end
end
self.widget = wrapper
end
end
return tabobj_support

View File

@ -0,0 +1,4 @@
return {
titlebar_indicator = require(tostring(...):match(".*bling") .. ".widget.tabbed_misc.titlebar_indicator"),
custom_tasklist = require(tostring(...):match(".*bling") .. ".widget.tabbed_misc.custom_tasklist")
}

View File

@ -0,0 +1,107 @@
local wibox = require('wibox')
local awful = require('awful')
local gears = require('gears')
local beautiful = require('beautiful')
local dpi = require("beautiful.xresources").apply_dpi
local tabbed_module = require(tostring(...):match(".*bling") .. ".module.tabbed")
-- Just check if a table contains a value.
local function tbl_contains(tbl, item)
for _, v in ipairs(tbl) do
if v == item then
return true
end
end
return false
end
-- Needs to be run, every time a new titlbear is created
return function(c, opts)
-- Args & Fallback -- Widget templates are in their original loactions
opts = gears.table.crush({
layout_spacing = dpi(4),
icon_size = dpi(20),
icon_margin = dpi(4),
bg_color_focus = "#ff0000",
bg_color = "#00000000",
icon_shape = function(cr,w,h) gears.shape.rounded_rect(cr,w,h,0) end
}, gears.table.join(opts, beautiful.bling_tabbed_misc_titlebar_indicator))
-- Container to store icons
local tabbed_icons = wibox.widget({
layout = wibox.layout.fixed.horizontal,
spacing = opts.layout_spacing,
})
awesome.connect_signal("bling::tabbed::client_removed", function(_, removed_c)
-- Remove from list
for idx, icon in ipairs(tabbed_icons.children) do
if icon:get_children_by_id("icon_role")[1].client == removed_c then
tabbed_icons:remove(idx)
end
end
-- Empty list
if removed_c == c then
tabbed_icons:reset()
end
end)
local function recreate(group)
if tbl_contains(group.clients, c) then
tabbed_icons:reset()
local focused = group.clients[group.focused_idx]
-- Autohide?
if #group.clients == 1 then
return
end
for idx, client in ipairs(group.clients) do
local widget = wibox.widget(opts.widget_template or {
{
{
{
id = 'icon_role',
forced_width = opts.icon_size,
forced_height = opts.icon_size,
widget = awful.widget.clienticon,
},
margins = opts.icon_margin,
widget = wibox.container.margin,
},
bg = (client == focused) and (opts.bg_color_focus) or (opts.bg_color),
shape = opts.icon_shape,
id = 'click_role',
widget = wibox.container.background,
},
halign = "center",
valign = "center",
widget = wibox.container.place,
})
-- Add icons & etc
for _, w in ipairs(widget:get_children_by_id("icon_role")) do
-- TODO: Allow fallback icon?
w.image = client.icon
w.client = client
end
for _, w in ipairs(widget:get_children_by_id("click_role")) do
w:add_button(awful.button({}, 1, function()
tabbed_module.switch_to(group,idx)
end))
end
tabbed_icons:add(widget)
end
end
end
awesome.connect_signal("bling::tabbed::client_added", recreate)
awesome.connect_signal("bling::tabbed::changed_focus", recreate)
return tabbed_icons
end