Move upderlay widget to Radical
This commit is contained in:
parent
960028e414
commit
5b635e96e5
33
README.md
33
README.md
|
@ -188,7 +188,7 @@ Multiple items can have multiple sets of options.
|
||||||
| selected | Select this item | boolean |
|
| selected | Select this item | boolean |
|
||||||
| checkable | Is the item dual state (a checkbox) | boolean |
|
| checkable | Is the item dual state (a checkbox) | boolean |
|
||||||
| checked | Is the item checked or not | boolean |
|
| checked | Is the item checked or not | boolean |
|
||||||
| underlay | Text to render at the far-right of the item | string |
|
| underlay | Text to render at the far-right of the item | [array of] string |
|
||||||
| prefix_widget | Widget to append at the begenning of the item| widget |
|
| prefix_widget | Widget to append at the begenning of the item| widget |
|
||||||
| suffix_widget | Widget to append at the end of the item | widget |
|
| suffix_widget | Widget to append at the end of the item | widget |
|
||||||
| tooltip | A tooltip shown on the side or bottom | string |
|
| tooltip | A tooltip shown on the side or bottom | string |
|
||||||
|
@ -219,18 +219,19 @@ here is the list:
|
||||||
|
|
||||||
Radical also use the some of the same theme options as awful.menu, plus some:
|
Radical also use the some of the same theme options as awful.menu, plus some:
|
||||||
|
|
||||||
* menu_height
|
| Name | Description | Type |
|
||||||
* menu_width
|
| ---------------------------- | ------------------------------------- | ---------------------- |
|
||||||
* menu_border_width
|
| menu_height | Menu height | String/Gradient/Pattern |
|
||||||
* menu_border_color
|
| menu_width | Menu default/minimum width | Number |
|
||||||
* border_width
|
| menu_border_width | Border width | Number |
|
||||||
* border_color
|
| menu_border_color | Border color | String/Gradient/Pattern |
|
||||||
* menu_fg_normal
|
| menu_fg_normal | Text/Foreground color | String/Gradient/Pattern |
|
||||||
* menu_bg_focus
|
| menu_bg_focus | Selected item color | String/Gradient/Pattern |
|
||||||
* menu_bg_header
|
| menu_bg_header | Header widget background color | String/Gradient/Pattern |
|
||||||
* menu_bg_alternate
|
| menu_bg_alternate | Scrollbar and other widget color | String/Gradient/Pattern |
|
||||||
* menu_bg_normal
|
| menu_bg_normal | Default background | String/Gradient/Pattern |
|
||||||
* menu_bg_highlight
|
| menu_bg_highlight | Highlighted item background | String/Gradient/Pattern |
|
||||||
* menu_submenu_icon
|
| menu_submenu_icon | Sub menu pixmap (aka >) | Path/Pattern |
|
||||||
* menu_separator_color
|
| menu_separator_color | Menu separator color | String/Gradient/Pattern |
|
||||||
* menu_submenu_icon
|
| draw_underlay | Function returning the underlay pixmap | Function |
|
||||||
|
|
||||||
|
|
6
bar.lua
6
bar.lua
|
@ -106,6 +106,12 @@ local function create_item(item,data,args)
|
||||||
-- Text
|
-- Text
|
||||||
local tb = wibox.widget.textbox()
|
local tb = wibox.widget.textbox()
|
||||||
tb.fit = textbox_fit
|
tb.fit = textbox_fit
|
||||||
|
tb.draw = function(self,w, cr, width, height)
|
||||||
|
if item.underlay then
|
||||||
|
vertical.paint_underlay(data,item,cr,width,height)
|
||||||
|
end
|
||||||
|
wibox.widget.textbox.draw(self,w, cr, width, height)
|
||||||
|
end
|
||||||
item.widget = bg
|
item.widget = bg
|
||||||
tb:set_text(item.text)
|
tb:set_text(item.text)
|
||||||
|
|
||||||
|
|
9
base.lua
9
base.lua
|
@ -2,10 +2,11 @@ local setmetatable = setmetatable
|
||||||
local pairs,ipairs = pairs, ipairs
|
local pairs,ipairs = pairs, ipairs
|
||||||
local type,string = type,string
|
local type,string = type,string
|
||||||
local print,unpack = print, unpack
|
local print,unpack = print, unpack
|
||||||
local beautiful = require( "beautiful" )
|
local beautiful = require( "beautiful" )
|
||||||
local util = require( "awful.util" )
|
local util = require( "awful.util" )
|
||||||
local aw_key = require( "awful.key" )
|
local aw_key = require( "awful.key" )
|
||||||
local object = require( "radical.object" )
|
local object = require( "radical.object" )
|
||||||
|
local vertical = require( "radical.layout.vertical" )
|
||||||
|
|
||||||
local capi = { mouse = mouse, screen = screen , keygrabber = keygrabber, root=root, }
|
local capi = { mouse = mouse, screen = screen , keygrabber = keygrabber, root=root, }
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ local function new(args)
|
||||||
icon = module.icon_transform and module.icon_transform(v.icon or module.default_icon) or v.icon or module.default_icon,
|
icon = module.icon_transform and module.icon_transform(v.icon or module.default_icon) or v.icon or module.default_icon,
|
||||||
suffix_widget = not auto_release and l or nil,
|
suffix_widget = not auto_release and l or nil,
|
||||||
selected = capi.client.focus and capi.client.focus == v,
|
selected = capi.client.focus and capi.client.focus == v,
|
||||||
underlay = v:tags()[1] and draw_underlay(v:tags()[1].name),
|
underlay = v:tags()[1] and v:tags()[1].name,
|
||||||
checkable = not auto_release,
|
checkable = not auto_release,
|
||||||
checked = not auto_release and is_in_tag(t,v) or nil,
|
checked = not auto_release and is_in_tag(t,v) or nil,
|
||||||
button1 = function()
|
button1 = function()
|
||||||
|
|
|
@ -12,8 +12,8 @@ local wibox = require("wibox")
|
||||||
|
|
||||||
local module = {
|
local module = {
|
||||||
margins = {
|
margins = {
|
||||||
TOP = 2,
|
TOP = 0,
|
||||||
BOTTOM = 2,
|
BOTTOM = 0,
|
||||||
RIGHT = 20,
|
RIGHT = 20,
|
||||||
LEFT = 3
|
LEFT = 3
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ local checkbox = require( "radical.widgets.checkbox" )
|
||||||
local scroll = require( "radical.widgets.scroll" )
|
local scroll = require( "radical.widgets.scroll" )
|
||||||
local filter = require( "radical.widgets.filter" )
|
local filter = require( "radical.widgets.filter" )
|
||||||
local fkey = require( "radical.widgets.fkey" )
|
local fkey = require( "radical.widgets.fkey" )
|
||||||
|
local underlay = require( "radical.widgets.underlay" )
|
||||||
local beautiful = require("beautiful" )
|
local beautiful = require("beautiful" )
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local color = require( "gears.color" )
|
local color = require( "gears.color" )
|
||||||
|
@ -65,9 +66,10 @@ local function item_fit(data,item,...)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Like an overlay, but under
|
-- Like an overlay, but under
|
||||||
local function paint_underlay(data,item,cr,width,height)
|
function module.paint_underlay(data,item,cr,width,height)
|
||||||
cr:save()
|
cr:save()
|
||||||
cr:set_source_surface(item.underlay,width-item.underlay:get_width()-3)
|
local udl = underlay.draw(item.underlay)
|
||||||
|
cr:set_source_surface(udl,width-udl:get_width()-3)
|
||||||
cr:paint_with_alpha(data.underlay_alpha)
|
cr:paint_with_alpha(data.underlay_alpha)
|
||||||
cr:restore()
|
cr:restore()
|
||||||
end
|
end
|
||||||
|
@ -148,7 +150,7 @@ function module:setup_text(item,data)
|
||||||
|
|
||||||
text_w.draw = function(self,w, cr, width, height)
|
text_w.draw = function(self,w, cr, width, height)
|
||||||
if item.underlay then
|
if item.underlay then
|
||||||
paint_underlay(data,item,cr,width,height)
|
module.paint_underlay(data,item,cr,width,height)
|
||||||
end
|
end
|
||||||
wibox.widget.textbox.draw(self,w, cr, width, height)
|
wibox.widget.textbox.draw(self,w, cr, width, height)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
local type = type
|
||||||
|
local color = require("gears.color")
|
||||||
|
local gsurface = require("gears.surface")
|
||||||
|
local cairo = require("lgi").cairo
|
||||||
|
local pango = require("lgi").Pango
|
||||||
|
local pangocairo = require("lgi").PangoCairo
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
|
||||||
|
local module = {}
|
||||||
|
|
||||||
|
local pango_l,pango_crx = {},{}
|
||||||
|
|
||||||
|
function module.draw(text,args)
|
||||||
|
local args = args or {}
|
||||||
|
local padding = beautiful.default_height/3
|
||||||
|
local height = args.height or (beautiful.menu_height)
|
||||||
|
if not pango_l[height] then
|
||||||
|
local pango_crx = pangocairo.font_map_get_default():create_context()
|
||||||
|
pango_l[height] = pango.Layout.new(pango_crx)
|
||||||
|
local desc = pango.FontDescription()
|
||||||
|
desc:set_family("Verdana")
|
||||||
|
desc:set_weight(pango.Weight.BOLD)
|
||||||
|
desc:set_size((height-padding*2) * pango.SCALE)
|
||||||
|
pango_l[height]:set_font_description(desc)
|
||||||
|
end
|
||||||
|
pango_l[height].text = text
|
||||||
|
local width = pango_l[height]:get_pixel_extents().width + height + padding
|
||||||
|
local img = cairo.ImageSurface.create(cairo.Format.ARGB32, width+(args.padding_right or 0), height+padding)
|
||||||
|
cr = cairo.Context(img)
|
||||||
|
cr:set_source(color(args.bg or beautiful.bg_alternate))
|
||||||
|
cr:arc((height-padding)/2 + 2, (height-padding)/2 + padding/4 + (args.margins or 0), (height-padding)/2+(args.padding or 0)/2,0,2*math.pi)
|
||||||
|
cr:fill()
|
||||||
|
cr:arc(width - (height-padding)/2 - 2, (height-padding)/2 + padding/4 + (args.margins or 0), (height-padding)/2+(args.padding or 0)/2,0,2*math.pi)
|
||||||
|
cr:rectangle((height-padding)/2+2,padding/4 + (args.margins or 0)-(args.padding or 0)/2,width - (height),(height-padding)+(args.padding or 0))
|
||||||
|
cr:fill()
|
||||||
|
cr:set_source(color(args.fg or beautiful.bg_normal))
|
||||||
|
cr:set_operator(cairo.Operator.CLEAR)
|
||||||
|
cr:move_to(height/2 + 2,padding/4 + (args.margins or 0)-(args.padding or 0)/2)
|
||||||
|
cr:show_layout(pango_l[height])
|
||||||
|
return img
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||||
|
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
Loading…
Reference in New Issue