Fix arrow menu, improve tag/task menu

This commit is contained in:
Emmanuel Lepage Vallee 2014-03-26 23:21:42 -04:00
parent ef7e46f865
commit 5efc2d89e0
7 changed files with 104 additions and 28 deletions

View File

@ -1,8 +1,26 @@
local radical = require("radical")
local capi = { screen = screen, }
local capi = { screen = screen, client=client}
local awful = require( "awful" )
local beautiful = require("beautiful")
local suits = require("awful.layout.suit")
local module = {}
local fallback_layouts = {
suits.floating,
suits.tile,
suits.tile.left,
suits.tile.bottom,
suits.tile.top,
suits.fair,
suits.fair.horizontal,
suits.spiral,
suits.spiral.dwindle,
suits.max,
suits.max.fullscreen,
suits.magnifier
}
local function createTagList(aScreen)
local tagList = radical.context({autodiscard = true})
for _, v in ipairs(awful.tag.gettags(aScreen)) do
@ -23,5 +41,23 @@ function module.listTags()
end
end
function module.layouts(menu,layouts)
local cur = awful.layout.get(awful.tag.getscreen(awful.tag.selected(capi.client.focus and capi.client.focus.screen)))
local screenSelect = menu or radical.context(({autodiscard = true}))
local layouts = layouts or fallback_layouts
for i, layout_real in ipairs(layouts) do
local layout2 = awful.layout.getname(layout_real)
if layout2 and beautiful["layout_" ..layout2] then
screenSelect:add_item({icon=beautiful["layout_" ..layout2],button1 = function(_,mod)
if mod then
screenSelect[mod[1] == "Shift" and "previous_item" or "next_item"].selected = true
end
awful.layout.set(layouts[screenSelect.current_index] or layouts[1],awful.tag.selected(capi.client.focus and capi.client.focus.screen))
end, selected = (layout_real == cur), item_layout = radical.item.layout.icon})
end
end
return screenSelect
end
return setmetatable(module, { __call = function(_, ...) return module.listTags(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on;

View File

@ -65,6 +65,7 @@ local function create_item(t,s)
tw:set_markup(" <b>"..(index).."</b> ")
w:add(tw)
local item = menu:add_item { text = t.name, prefix_widget = w}
item._internal.icon_w = ib
-- item:connect_signal("index::changed",function(_,value)
-- tw:set_markup(" <b>"..(index).."</b> ")
-- end)
@ -170,7 +171,7 @@ local function init()
capi.tag.connect_signal("property::icon", function(t)
local item = cache[t]
if item then
item.icon = tag.geticon(t) or beautiful.taglist_default_icon
item._internal.icon_w:set_image(tag.geticon(t) or beautiful.taglist_default_icon)
end
end)
is_init = true

View File

@ -4,7 +4,7 @@ local ipairs = ipairs
local tag = require( "awful.tag" )
local config = require( "forgotten" )
local menu = require( "radical.context" )
local listTags = require( "radical.impl.common.tag" ).listTags
local com_tag = require( "radical.impl.common.tag" )
local awful = require("awful")
local radical = require("radical")
local capi = { screen = screen }
@ -41,7 +41,7 @@ local function new(t)
end
end
aTagMenu:add_item({text = "Merge With", sub_menu = listTags})
aTagMenu:add_item({text = "Merge With", sub_menu = com_tag.listTags})
function createTagList(aScreen)
local tagList = menu()
@ -72,7 +72,8 @@ local function new(t)
aTagMenu:add_item({text= "Set Icon", sub_menu = mainMenu2})
aTagMenu:add_item({text= "Layout", sub_menu = function()
local m = radical.context({filter=false,item_style=radical.item.style.rounded,item_height=30,column=4,layout=radical.layout.grid})
return com_tag.layouts(m)
end})
aTagMenu:add_item({text= "Flags", sub_menu = function()

View File

@ -3,6 +3,7 @@
local capi = {tag=tag}
local tag = require( "awful.tag" )
local object = require( "radical.object" )
local awful = require("awful")
local cache = {}
local init = false
@ -27,6 +28,25 @@ local function reload(t,s)
tracker._internal.old_tags = new_tags
end
--[[awful.tag.setscreen = function(t, s)
if not tag or type(t) ~= "tag" or not s then return end
-- Keeping the old index make very little sense when chaning screen
awful.tag.setproperty(t, "index", nil)
local old_screen = awful.tag.getproperty(t,"screen")
-- Change the screen
awful.tag.setproperty(t, "screen", s)
--Prevent some very strange side effects, does create some issue with multitag clients
for k,c in ipairs(t:clients()) do
c.screen = s --Move all clients
c:tags({t})
end
awful.tag.history.restore(old_screen,1)
end]]--
local function new(s)
if cache[s] then return cache[s] end

View File

@ -16,11 +16,12 @@ local function createNewTag()
return awful.tag.add(module.client.class,{})
end
local above,below,ontop
local above,below,ontop,normal
local function layer_button1()
above.checked = module.client.above
ontop.checked = module.client.ontop
below.checked = module.client.below
above.checked = module.client.above
ontop.checked = module.client.ontop
below.checked = module.client.below
normal.checked = not (module.client.above or module.client.ontop or module.client.below)
end
local layer_m = nil
local function layerMenu()
@ -29,6 +30,12 @@ local function layerMenu()
end
layer_m = radical.context{}
normal = layer_m:add_item({text="Normal" , checked=true , button1 = function()
module.client.above = false
module.client.below = false
module.client.ontop = false
layer_button1()
end})
above = layer_m:add_item({text="Above" , checked=true , button1 = function()
module.client.above = not module.client.above
layer_button1()

View File

@ -45,7 +45,7 @@ local function draw(item,args)
item.widget._overlay_init = true
end
local ih = item.height
local ih = item.height or 1
if not focussed or not focussed[ih] then
if not focussed then
focussed,default,alt={},{},{}

View File

@ -31,6 +31,7 @@ local function do_gen_menu_top(data, width, height, radius,padding,args)
local cr = cairo.Context(img)
local no_arrow = data.arrow_type == base.arrow_type.NONE
local top_padding = (data.arrow_type == base.arrow_type.NONE) and 0 or 13
local arrow_x = data._arrow_x or 20
cr:set_operator(cairo.Operator.SOURCE)
cr:set_source( color(args.bg) )
cr:paint()
@ -38,9 +39,10 @@ local function do_gen_menu_top(data, width, height, radius,padding,args)
cr:rectangle(10, top_padding+padding, width - 20 +1 , 10)
if not no_arrow then
for i=1,13 do
cr:rectangle((data._arrow_x or 20) + 13 - i, i+padding , 2*i , 1)
cr:rectangle((arrow_x) + 13 - i, i+padding , 2*i , 1)
end
end
cr:rectangle(arrow_x+padding,top_padding+padding,26+padding,10)
cr:rectangle(padding or 0,no_arrow and 10 or 23, width-2*padding, height-33 + (no_arrow and 13 or 0))
cr:rectangle(10+padding-1,height-10, width-20, 10-padding)
cr:fill()
@ -52,7 +54,33 @@ local function do_gen_menu_top(data, width, height, radius,padding,args)
return img
end
local function get_arrow_x(data,direction)
local at = data.arrow_type
local par_center_x = data.parent_geometry and (data.parent_geometry.x + data.parent_geometry.width/2) or -1
local par_center_y = data.parent_geometry and (data.parent_geometry.y + data.parent_geometry.height/2) or -1
local menu_beg_x = data.x
local menu_end_x = data.x + data.width
if at == base.arrow_type.PRETTY or not at then
if direction == "left" then
data._arrow_x = data.height -20 - (data.arrow_x or 20)
elseif direction == "right" then
--TODO
elseif direction == "bottom" then
data._arrow_x = data.width -20 - (data.arrow_x or 20)
if par_center_x >= menu_beg_x then
data._arrow_x = data.width - (par_center_x - menu_beg_x) - 13
end
elseif direction == "top" then
--TODO
end
elseif at == base.arrow_type.CENTERED then
data._arrow_x = data.width/2 - 13
end
end
local function _set_direction(data,direction)
get_arrow_x(data,direction)
local geometry = (direction == "left" or direction == "right") and {width = data.height, height = data.width} or {height = data.height, width = data.width}
local top_clip_surface = do_gen_menu_top(data,geometry.width,geometry.height,10,data.border_width,{bg=beautiful.fg_normal or "#0000ff",fg=data.bg or "#00ffff"})
local top_bounding_surface = do_gen_menu_top(data,geometry.width,geometry.height,10,0,{bg="#00000000",fg="#ffffffff"})
@ -87,23 +115,6 @@ local function draw(data,args)
local args = args or {}
local direction = data.direction or "top"
--BEGIN set_arrow, this used to be a function, but was only called once
local at = data.arrow_type
if at == base.arrow_type.PRETTY or not at then
if direction == "left" then
data._arrow_x = data.height -20 - (data.arrow_x or 20)
elseif direction == "right" then
--TODO
elseif direction == "bottom" then
data._arrow_x = data.width -20 - (data.arrow_x or 20)
elseif direction == "top" then
--TODO
end
elseif at == base.arrow_type.CENTERED then
data._arrow_x = data.width/2 - 13
end
--END set_arrow
set_direction(data,direction)
-- data._internal.set_position(data) --TODO DEAD CODE?