Add some filter options

This commit is contained in:
Emmanuel Lepage Vallee 2014-03-12 22:56:56 -04:00
parent 231eef25bc
commit 5d21035698
4 changed files with 11 additions and 4 deletions

View File

@ -137,7 +137,7 @@ mytextbox:set_tooltip("foo bar")
The "underlay" is the opposite of an overlay. Think of it as a background label. The "underlay" is the opposite of an overlay. Think of it as a background label.
Radical add this option to all Awesome widget by calling the `set_underlay` Radical add this option to all Awesome widget by calling the `set_underlay`
method. The first argument is the text (or table of string) and the second is method. The first argument is the text (or table of string) and the second is
an array with the `style` and `alpha` keys. an array with the `style`, `color` and `alpha` keys.
## Options ## Options

View File

@ -276,6 +276,7 @@ local function new(args)
fkeys_prefix = args.fkeys_prefix or false, fkeys_prefix = args.fkeys_prefix or false,
underlay_alpha = args.underlay_alpha or beautiful.underlay_alpha or 0.7, underlay_alpha = args.underlay_alpha or beautiful.underlay_alpha or 0.7,
underlay_style = args.underlay_style or nil, underlay_style = args.underlay_style or nil,
filter_underlay = args.filter_underlay or nil,
filter_prefix = args.filter_prefix or "Filter:", filter_prefix = args.filter_prefix or "Filter:",
enable_keyboard = (args.enable_keyboard ~= false), enable_keyboard = (args.enable_keyboard ~= false),
max_items = args.max_items or nil, max_items = args.max_items or nil,
@ -287,6 +288,9 @@ local function new(args)
overlay = args.overlay or nil, overlay = args.overlay or nil,
opacity = args.opacity or beautiful.menu_opacity or 1, opacity = args.opacity or beautiful.menu_opacity or 1,
icon_transformation = args.icon_transformation or nil, icon_transformation = args.icon_transformation or nil,
filter_underlay_style = args.filter_underlay_style or nil,
filter_underlay_color = args.filter_underlay_color,
filter_placeholder = args.filter_placeholder or "",
}, },
force_private = { force_private = {
parent = true, parent = true,

View File

@ -37,7 +37,7 @@ end
local function _underlay_draw(self,w, cr, width, height) local function _underlay_draw(self,w, cr, width, height)
cr:save() cr:save()
local udl = underlay.draw(self._underlay,{height=height,style = self._underlay_style}) local udl = underlay.draw(self._underlay,{height=height,style = self._underlay_style,bg=self._underlay_color})
cr:set_source_surface(udl,width-udl:get_width()-3) cr:set_source_surface(udl,width-udl:get_width()-3)
cr:paint_with_alpha(self._underlay_alpha or beautiful.underlay_alpha or 0.7) cr:paint_with_alpha(self._underlay_alpha or beautiful.underlay_alpha or 0.7)
cr:restore() cr:restore()
@ -53,6 +53,7 @@ local function set_underlay(self,udl,args)
self._underlay = udl self._underlay = udl
self._underlay_style = args.style self._underlay_style = args.style
self._underlay_alpha = args.alpha self._underlay_alpha = args.alpha
self._underlay_color = args.color
self:emit_signal("widget::updated") self:emit_signal("widget::updated")
end end

View File

@ -13,12 +13,14 @@ local function new(data)
local bg = wibox.widget.background() local bg = wibox.widget.background()
bg:set_bg(data.bg_highlight) bg:set_bg(data.bg_highlight)
bg:set_widget(filter_tb) bg:set_widget(filter_tb)
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> ") filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..data.filter_placeholder)
filter_tb.fit = function(tb,width,height) filter_tb.fit = function(tb,width,height)
return width,data.item_height return width,data.item_height
end end
filter_tb:set_underlay(data.filter_underlay,{alpha=data.filter_underlay_alpha,color=data.filter_underlay_color})
data:connect_signal("filter_string::changed",function() data:connect_signal("filter_string::changed",function()
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..data.filter_string) local is_empty = data.filter_string == ""
filter_tb:set_markup(" <b>".. data.filter_prefix .."</b> "..(is_empty and data.filter_placeholder or data.filter_string))
end) end)
bg.widget = filter_tb bg.widget = filter_tb
return bg return bg