From 27a5970277910845a4fe1ec742ff9b1d5abbda3c Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 13 Jan 2014 00:46:33 -0500 Subject: [PATCH] Add partial arrow_prefix item style (1/3) --- bar.lua | 3 +- item_style/arrow_alt.lua | 4 +-- item_style/arrow_prefix.lua | 59 +++++++++++++++++++++++++++++++++++++ item_style/basic.lua | 2 +- item_style/init.lua | 9 +++--- 5 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 item_style/arrow_prefix.lua diff --git a/bar.lua b/bar.lua index 2c720e6..7f1e8ab 100644 --- a/bar.lua +++ b/bar.lua @@ -9,7 +9,7 @@ local util = require( "awful.util" ) local fkey = require( "radical.widgets.fkey" ) local button = require( "awful.button" ) local checkbox = require( "radical.widgets.checkbox" ) -local item_style = require( "radical.item_style.arrow_alt" ) +local item_style = require( "radical.item_style.arrow_prefix" ) local vertical = require( "radical.layout.vertical" ) local capi,module = { mouse = mouse , screen = screen, keygrabber = keygrabber },{} @@ -129,6 +129,7 @@ local function create_item(item,data,args) align._item = item align._data = data align.fit = align_fit + item._internal.align = align -- Tooltip item.widget:set_tooltip(item.tooltip) diff --git a/item_style/arrow_alt.lua b/item_style/arrow_alt.lua index 8270125..81323f8 100644 --- a/item_style/arrow_alt.lua +++ b/item_style/arrow_alt.lua @@ -13,8 +13,8 @@ local module = { margins = { TOP = 2, BOTTOM = 2, - RIGHT = 10, - LEFT = 10 + RIGHT = 20, + LEFT = 3 } } diff --git a/item_style/arrow_prefix.lua b/item_style/arrow_prefix.lua new file mode 100644 index 0000000..6866461 --- /dev/null +++ b/item_style/arrow_prefix.lua @@ -0,0 +1,59 @@ +local setmetatable = setmetatable +local print = print +local debug=debug +local ipairs = ipairs +local math = math +local base = require( "radical.base" ) +local beautiful = require("beautiful") +local color = require("gears.color") +local cairo = require("lgi").cairo +local wibox = require("wibox") +-- local arrow_alt = require("radical.item_style.arrow_alt") + +local module = { + margins = { + TOP = 2, + BOTTOM = 2, + RIGHT = 20, + LEFT = 3 + } +} + +local function prefix_draw(self, w, cr, width, height) + print("Hello",width,height,self) + cr:save() + cr:set_source_rgba(1,0,0,1) + cr:rectangle(0,0,width+30,height) + cr:fill() + cr:restore() + self._draw(self, w, cr, width, height) +end + +local function prefix_fit(box,w,h) + local width,height = box._fit(box,w,h) + print("in fit",width,width+30,box) + return width + 30,height +end + +local function draw(data,item,args) + local args,flags = args or {},{} + for _,v in pairs(args) do flags[v] = true end + + if not item._internal.align._setup then + item._internal.align._setup = true + item._internal.align.first._fit = item._internal.align.first.fit + item._internal.align.first._draw = item._internal.align.first.draw + item._internal.align.first.fit = prefix_fit + item._internal.align.first.draw = prefix_draw +-- item._internal.align.first:emit_signal("widget::updated") + end + + if flags[base.item_flags.SELECTED] or (item._tmp_menu) then + item.widget:set_bg(args.color or data.bg_focus) + else + item.widget:set_bg(args.color or nil) + end +end + +return setmetatable(module, { __call = function(_, ...) return draw(...) end }) +-- kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/item_style/basic.lua b/item_style/basic.lua index 7903d29..7f2be47 100644 --- a/item_style/basic.lua +++ b/item_style/basic.lua @@ -14,7 +14,7 @@ local module = { local function draw(data,item,args) local args,flags = args or {},{} - for _,v in pairs(args) do print("ici",v);flags[v] = true end + for _,v in pairs(args) do flags[v] = true end if flags[base.item_flags.SELECTED] or (item._tmp_menu) then item.widget:set_bg(args.color or data.bg_focus) diff --git a/item_style/init.lua b/item_style/init.lua index 71c4900..d68441b 100644 --- a/item_style/init.lua +++ b/item_style/init.lua @@ -1,6 +1,7 @@ return { - basic = require("radical.item_style.basic"), - classic = require("radical.item_style.classic"), - rounded = require("radical.item_style.rounded"), - arrow_alt = require("radical.item_style.arrow_alt"), + basic = require("radical.item_style.basic" ), + classic = require("radical.item_style.classic" ), + rounded = require("radical.item_style.rounded" ), + arrow_alt = require("radical.item_style.arrow_alt" ), + arrow_prefix = require("radical.item_style.arrow_prefix" ), } \ No newline at end of file