Add icon_transformation option (take this from Blind playbook)
It can use Blind common.drawing tools to implement some magic. I may merge this into Radical and kill Blind as everything else is pretty much deprecated at this point. Blind was never more than a hack.
This commit is contained in:
parent
1dea6095b0
commit
7046b40f83
135
README.md
135
README.md
|
@ -142,50 +142,51 @@ Multiple items can have multiple sets of options.
|
|||
|
||||
### Menu options
|
||||
|
||||
| Name | Description | Type |
|
||||
| --------------- | -------------------------------------------------- | ----------------------------- |
|
||||
| bg | Background color | String/gradient/pattern |
|
||||
| fg | Foreground (text) color | String/gradient/pattern |
|
||||
| bg_focus | Background of focussed items | String/gradient/pattern |
|
||||
| fg_focus | Foreground of focussed items | String/gradient/pattern |
|
||||
| bg_hover | Background of hoverred items | String/gradient/pattern |
|
||||
| fg_hover | Foreground of hoverred items | String/gradient/pattern |
|
||||
| bg_alternate | Alternate background color | String/gradient/pattern |
|
||||
| bg_highlight | Highlight background color | String/gradient/pattern |
|
||||
| bg_header | Header (see widgets section) color | String/gradient/pattern |
|
||||
| bg_prefix | Prefix background for item_styles that support it | String/gradient/pattern |
|
||||
| border_color | Border color | String/gradient/pattern |
|
||||
| border_width | Border width | number |
|
||||
| item_height | Default height of items | number |
|
||||
| item_width | Default width of items | number |
|
||||
| width | Original width | number |
|
||||
| default_width | Default menu width | number |
|
||||
| icon_size | Icon size | number |
|
||||
| auto_resize | Resize menu if items are too large | boolean |
|
||||
| parent_geometry | Set the menu parent | geometry array |
|
||||
| arrow_type | Set the arrow type when use arrow style | see "arrow_type" enum |
|
||||
| visible | Show or hide the menu | boolean |
|
||||
| direction | The direction from which the arrow will point | "left","right","top","bottom" |
|
||||
| row | Number of row (in grid layout) | number |
|
||||
| column | Number of columns (in grid layout) | number |
|
||||
| layout | The menu layout (default:vertical) | see "Menu layouts" section |
|
||||
| style | The menu style (default:arrow) | see "Menu style" |
|
||||
| item_style | The item style (default:basic) | see "Item style" |
|
||||
| filter | Filter the menu when the user type | boolean |
|
||||
| show_filter | Show a filter widget at the bottom | boolean |
|
||||
| filter_string | Default filter string | string |
|
||||
| fkeys_prefix | Display F1-F12 indicators for easy navigation | boolean |
|
||||
| underlay_alpha | Underlay (see item options) opacity | 0-1 |
|
||||
| filter_prefix | Text to be shown at begenning of the filter string | string |
|
||||
| max_items | Maximum number of items before showing scrollbar | number |
|
||||
| enable_keyboard | Enable or disable keyboard navigation / hooks | boolean |
|
||||
| disable_markup | Disable pango markup in items text | boolean |
|
||||
| x | X position (absolute) | number |
|
||||
| y | Y position (absolute) | number |
|
||||
| sub_menu_on | Show submenu on selection or when clicking | see "event" enum |
|
||||
| select_on | The event used to trigger item selection | see "event" enum |
|
||||
| overlay | A layer on top of the item | function(data,item,cr,w,h) |
|
||||
| opacity | Make this menu translucent (require a compositor) | number (0 to 1) |
|
||||
| Name | Description | Type |
|
||||
| ------------------- | -------------------------------------------------- | ----------------------------- |
|
||||
| bg | Background color | String/gradient/pattern |
|
||||
| fg | Foreground (text) color | String/gradient/pattern |
|
||||
| bg_focus | Background of focussed items | String/gradient/pattern |
|
||||
| fg_focus | Foreground of focussed items | String/gradient/pattern |
|
||||
| bg_hover | Background of hoverred items | String/gradient/pattern |
|
||||
| fg_hover | Foreground of hoverred items | String/gradient/pattern |
|
||||
| bg_alternate | Alternate background color | String/gradient/pattern |
|
||||
| bg_highlight | Highlight background color | String/gradient/pattern |
|
||||
| bg_header | Header (see widgets section) color | String/gradient/pattern |
|
||||
| bg_prefix | Prefix background for item_styles that support it | String/gradient/pattern |
|
||||
| border_color | Border color | String/gradient/pattern |
|
||||
| border_width | Border width | number |
|
||||
| item_height | Default height of items | number |
|
||||
| item_width | Default width of items | number |
|
||||
| width | Original width | number |
|
||||
| default_width | Default menu width | number |
|
||||
| icon_size | Icon size | number |
|
||||
| auto_resize | Resize menu if items are too large | boolean |
|
||||
| parent_geometry | Set the menu parent | geometry array |
|
||||
| arrow_type | Set the arrow type when use arrow style | see "arrow_type" enum |
|
||||
| visible | Show or hide the menu | boolean |
|
||||
| direction | The direction from which the arrow will point | "left","right","top","bottom" |
|
||||
| row | Number of row (in grid layout) | number |
|
||||
| column | Number of columns (in grid layout) | number |
|
||||
| layout | The menu layout (default:vertical) | see "Menu layouts" section |
|
||||
| style | The menu style (default:arrow) | see "Menu style" |
|
||||
| item_style | The item style (default:basic) | see "Item style" |
|
||||
| filter | Filter the menu when the user type | boolean |
|
||||
| show_filter | Show a filter widget at the bottom | boolean |
|
||||
| filter_string | Default filter string | string |
|
||||
| fkeys_prefix | Display F1-F12 indicators for easy navigation | boolean |
|
||||
| underlay_alpha | Underlay (see item options) opacity | 0-1 |
|
||||
| filter_prefix | Text to be shown at begenning of the filter string | string |
|
||||
| max_items | Maximum number of items before showing scrollbar | number |
|
||||
| enable_keyboard | Enable or disable keyboard navigation / hooks | boolean |
|
||||
| disable_markup | Disable pango markup in items text | boolean |
|
||||
| x | X position (absolute) | number |
|
||||
| y | Y position (absolute) | number |
|
||||
| sub_menu_on | Show submenu on selection or when clicking | see "event" enum |
|
||||
| select_on | The event used to trigger item selection | see "event" enum |
|
||||
| overlay | A layer on top of the item | function(data,item,cr,w,h) |
|
||||
| opacity | Make this menu translucent (require a compositor) | number (0 to 1) |
|
||||
| icon_transformation | Hijack the icon drawing function | function(icon,data,item) |
|
||||
|
||||
###Item options
|
||||
|
||||
|
@ -241,6 +242,14 @@ here is the list:
|
|||
Menu also emit many signals, the syntax is usually `PROPERTY_NAME::changed`.
|
||||
Some others are `item::moved`, `item::swapped`, `item::removed`, `item::appended`
|
||||
|
||||
Here is an example of how to catch an "opacity" change:
|
||||
|
||||
```lua
|
||||
mymenu:connect_signal("opacity::changed",function(value)
|
||||
-- Do something
|
||||
end)
|
||||
```
|
||||
|
||||
Most item_layout also repackage the default widget signals. It usually does the
|
||||
same as using the `buttonX` menu attributes, but is preferrable in some scenarios
|
||||
like when a modifier is applied.
|
||||
|
@ -276,20 +285,26 @@ An example of how to use them:
|
|||
|
||||
Radical also use the some of the same theme options as awful.menu, plus some:
|
||||
|
||||
| Name | Description | Type |
|
||||
| ---------------------------- | ------------------------------------- | ---------------------- |
|
||||
| menu_height | Menu height | String/Gradient/Pattern |
|
||||
| menu_width | Menu default/minimum width | Number |
|
||||
| menu_border_width | Border width | Number |
|
||||
| menu_border_color | Border color | String/Gradient/Pattern |
|
||||
| menu_fg_normal | Text/Foreground color | String/Gradient/Pattern |
|
||||
| menu_bg_focus | Selected item color | String/Gradient/Pattern |
|
||||
| menu_bg_header | Header widget background color | String/Gradient/Pattern |
|
||||
| menu_bg_alternate | Scrollbar and other widget color | String/Gradient/Pattern |
|
||||
| menu_bg_normal | Default background | String/Gradient/Pattern |
|
||||
| menu_bg_highlight | Highlighted item background | String/Gradient/Pattern |
|
||||
| menu_submenu_icon | Sub menu pixmap (aka >) | Path/Pattern |
|
||||
| menu_separator_color | Menu separator color | String/Gradient/Pattern |
|
||||
| menu_opacity | Use your favorite compositor | Number (0=0%, 1=100%) |
|
||||
| draw_underlay | Function returning the underlay pixmap | Function |
|
||||
| Name | Description | Type |
|
||||
| ---------------------------- | ------------------------------------- | ------------------------- |
|
||||
| menu_height | Menu height | String/Gradient/Pattern |
|
||||
| menu_width | Menu default/minimum width | Number |
|
||||
| menu_border_width | Border width | Number |
|
||||
| menu_border_color | Border color | String/Gradient/Pattern |
|
||||
| menu_fg_normal | Text/Foreground color | String/Gradient/Pattern |
|
||||
| menu_bg_focus | Selected item color | String/Gradient/Pattern |
|
||||
| menu_bg_header | Header widget background color | String/Gradient/Pattern |
|
||||
| menu_bg_alternate | Scrollbar and other widget color | String/Gradient/Pattern |
|
||||
| menu_bg_normal | Default background | String/Gradient/Pattern |
|
||||
| menu_bg_highlight | Highlighted item background | String/Gradient/Pattern |
|
||||
| menu_submenu_icon | Sub menu pixmap (aka >) | Path/Pattern |
|
||||
| menu_separator_color | Menu separator color | String/Gradient/Pattern |
|
||||
| menu_opacity | Use your favorite compositor | Number (0=0%, 1=100%) |
|
||||
| menu_draw_underlay | Function returning the underlay pixmap | function(array,width) |
|
||||
| menu_icon_transformation | The function used to draw the icon | function(image,data,item) |
|
||||
|
||||
Styling can also be done using the icon_transformation option. This feature
|
||||
allow masks such as desaturation, tinting, invert or some matrix to be applied
|
||||
on the pixmap before it is being drawn. This function take the path/surface as
|
||||
only parameter and return the transformed surface.
|
||||
|
||||
|
|
1
base.lua
1
base.lua
|
@ -342,6 +342,7 @@ local function new(args)
|
|||
select_on = args.select_on or module.event.HOVER,
|
||||
overlay = args.overlay or nil,
|
||||
opacity = args.opacity or beautiful.menu_opacity or 1,
|
||||
icon_transformation = args.icon_transformation or nil,
|
||||
},
|
||||
get_map = {
|
||||
is_menu = function() return true end,
|
||||
|
|
|
@ -74,7 +74,8 @@ end
|
|||
local function new(args)
|
||||
local t,auto_release = tag.selected(capi.client.focus and capi.client.focus.screen or capi.mouse.screen),args.auto_release
|
||||
local currentMenu = menu({filter = true, show_filter=true, autodiscard = true,
|
||||
disable_markup=true,fkeys_prefix=not auto_release,width=(((capi.screen[capi.client.focus and capi.client.focus.screen or capi.mouse.screen]).geometry.width)/2)})
|
||||
disable_markup=true,fkeys_prefix=not auto_release,width=(((capi.screen[capi.client.focus and capi.client.focus.screen or capi.mouse.screen]).geometry.width)/2),
|
||||
icon_transformation = beautiful.alttab_icon_transformation})
|
||||
|
||||
|
||||
currentMenu:add_key_hook({}, "Tab", "press", select_next)
|
||||
|
@ -102,7 +103,7 @@ local function new(args)
|
|||
l.fit = function (s,w,h) return 5*h,h end
|
||||
currentMenu:add_item({
|
||||
text = v.name,
|
||||
icon = module.icon_transform and module.icon_transform(v.icon or module.default_icon) or v.icon or module.default_icon,
|
||||
icon = v.icon or module.default_icon,
|
||||
suffix_widget = not auto_release and l or nil,
|
||||
selected = capi.client.focus and capi.client.focus == v,
|
||||
underlay = underlays,
|
|
@ -0,0 +1,3 @@
|
|||
### Beautiful options
|
||||
|
||||
tasklist_icon_transformation | function(image) |
|
|
@ -157,7 +157,8 @@ local function new(screen)
|
|||
disable_markup = true,
|
||||
overlay = function(data,item,cd,w,h)
|
||||
-- print("foo!")
|
||||
end
|
||||
end,
|
||||
icon_transformation = beautiful.tasklist_icon_transformation
|
||||
}
|
||||
|
||||
-- Clear the menu and repopulate it
|
||||
|
|
|
@ -33,6 +33,14 @@ function module.paint_underlay(data,item,cr,width,height)
|
|||
cr:restore()
|
||||
end
|
||||
|
||||
-- Apply icon transformation
|
||||
function module.set_icon(self,image)
|
||||
if self._data.icon_transformation then
|
||||
image = self._data.icon_transformation(image,self._data,self._item)
|
||||
end
|
||||
wibox.widget.imagebox.set_image(self,image)
|
||||
end
|
||||
|
||||
-- Setup the item icon
|
||||
function module:setup_icon(item,data)
|
||||
local icon = wibox.widget.imagebox()
|
||||
|
@ -40,6 +48,9 @@ function module:setup_icon(item,data)
|
|||
local w,h = wibox.widget.imagebox.fit(...)
|
||||
return w+3,h
|
||||
end
|
||||
icon._data = data
|
||||
icon._item = item
|
||||
icon.set_image = module.set_icon
|
||||
if item.icon then
|
||||
icon:set_image(item.icon)
|
||||
end
|
||||
|
|
|
@ -55,6 +55,8 @@ local function create_item(item,data,args)
|
|||
local icon_flex = wibox.layout.align.horizontal()
|
||||
local icon = wibox.widget.imagebox()
|
||||
icon.fit = function(...) return icon_fit(data,...) end
|
||||
icon._data = data
|
||||
icon.set_image = horizontal.set_icon
|
||||
if args.icon then
|
||||
icon:set_image(args.icon)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue