Skip to content
Browse files

Bring back tile ratio

  • Loading branch information...
1 parent e8d23f1 commit 63fd1227dfb729355341047cb0922ce4ebd2394a @Elv13 committed
Showing with 31 additions and 39 deletions.
  1. +1 −1 rc.lua
  2. +2 −0 ultiLayout/decoration.lua
  3. +14 −19 ultiLayout/layouts/linear.lua
  4. +10 −16 ultiLayout/layouts/stack.lua
  5. +4 −3 ultiLayout/layouts/tile.lua
View
2 rc.lua
@@ -113,7 +113,7 @@ cpuinfo = drawer.cpuInfo ( nil
netinfo = drawer.netInfo ( nil )
-- Create the volume box
-soundWidget = drawer.soundInfo ( wiboxTop3 )
+--soundWidget = drawer.soundInfo ( wiboxTop3 )
-- Create the keyboard layout switcher, feel free to add your contry and push it to master
keyboardSwitcherWidget = widgets.keyboardSwitcher ( nil )
View
2 ultiLayout/decoration.lua
@@ -154,6 +154,8 @@ function decoration(cg)
for k,v in ipairs(validDeco) do
if type(v.update_callback) == "function" then
v.update_callback()
+ elseif type(v.wibox.update) == "function" then
+ v.wibox:update()
end
if v.wibox.visible ~= cg.visible then
v.wibox.visible = cg.visible
View
33 ultiLayout/layouts/linear.lua
@@ -1,17 +1,14 @@
local ipairs = ipairs
-local pairs = pairs
-local common = require( "ultiLayout.common" )
-local edge = require( "ultiLayout.edge" )
+local common = require( "ultiLayout.common" )
+local edge = require( "ultiLayout.edge" )
local splitter = require( "ultiLayout.widgets.splitter" )
module("ultiLayout.layouts.linear")
-local function new(cg,orientation)
- local data = { ratio = {} }
- local splitter1 = splitter(cg,{direction=(orientation == "horizontal") and "bottom" or "right", index=1})
- local splitter2 = splitter(cg,{direction=(orientation == "horizontal") and "top" or "left" , })
- cg.decorations:add_decoration(splitter1,{class="splitter",position="top",align="beginning",ontop=true,update_callback= function() splitter1:update() end})
- cg.decorations:add_decoration(splitter2,{class="splitter",position="top",align="beginning",ontop=true,update_callback= function() splitter2:update() end})
+local function new(cg,ori)
+ local data = { ratio = {} }
+ cg.decorations:add_decoration(splitter(cg,{direction=(ori == "horizontal") and "bottom" or "right", index=1}),{class="splitter",position="top",align="beginning",ontop=true})
+ cg.decorations:add_decoration(splitter(cg,{direction=(ori == "horizontal") and "top" or "left" , }),{class="splitter",position="top",align="beginning",ontop=true})
local function sum_ratio(only_visible)
local sumratio = 0
@@ -24,12 +21,11 @@ local function new(cg,orientation)
end
local function get_average(only_visible)
- if #cg:childs() == 0 then return 1 end
- return (sum_ratio(only_visible) / #((only_visible == true) and cg:visible_childs() or cg:childs())) or 1
+ return (#cg:childs() > 0) and (sum_ratio(only_visible) / #((only_visible == true) and cg:visible_childs() or cg:childs())) or 1
end
- local function size(ratio,w_or_h,ori)
- return ( orientation == ori ) and cg.workarea[w_or_h] or ((ratio or get_average(true)) / sum_ratio(true))*cg.workarea[w_or_h]
+ local function size(ratio,w_or_h,orientation)
+ return ( ori == orientation ) and cg.workarea[w_or_h] or ((ratio or get_average(true)) / sum_ratio(true))*cg.workarea[w_or_h]
end
function data:update()
@@ -37,21 +33,20 @@ local function new(cg,orientation)
for k,v in ipairs(cg:childs()) do
if v.visible ~= false and (#v:childs() > 0 or v:has_client() == true) then --TODO visible childs
v:geometry({width = size(data.ratio[k],"width","horizontal"), height = size(data.ratio[k],"height","vertical"), x = relX, y = relY })
- relY = relY + (( orientation == "horizontal" ) and v.height or 0)
- relX = relX + (( orientation == "vertical" ) and v.width or 0)
+ relY,relX = relY + (( ori == "horizontal" ) and v.height or 0),relX + (( ori == "vertical" ) and v.width or 0)
end
end
end
function data:add_child(child_cg,index)
- local index,anEdge = index or #cg:childs()+1,edge({cg=child_cg,orientation=orientation})
- data.ratio[#cg:childs()+1] = child_cg.default_percent and (child_cg.default_percent*sum_ratio()) or get_average()
+ local index,anEdge = index or #cg:childs()+1,edge({cg=child_cg,orientation=ori})
+ data.ratio[#cg:childs()+1] = child_cg.default_percent or get_average()
anEdge:add_signal("distance_change::request",function(_e, delta)
- local diff,idx = (sum_ratio()/cg[(orientation == "horizontal") and "height" or "width"])*delta,cg:cg_to_idx(child_cg)
+ local diff,idx = (sum_ratio()/cg[(ori == "horizontal") and "height" or "width"])*delta,cg:cg_to_idx(child_cg)
data.ratio[idx-1],data.ratio[idx] = data.ratio[ idx-1 ] + diff,data.ratio[ idx ] - diff
cg:repaint()
end)
- child_cg.decorations:add_decoration(anEdge,{class="edge",position=((orientation == "vertical") and "left" or "top"),align="ajust",index=1,update_callback= function() anEdge:update() end})
+ child_cg.decorations:add_decoration(anEdge,{class="edge",position=((ori == "vertical") and "left" or "top"),align="ajust",index=1,update_callback= function() anEdge:update() end})
return child_cg
end
return data
View
26 ultiLayout/layouts/stack.lua
@@ -1,32 +1,27 @@
local ipairs = ipairs
-local pairs = pairs
-local print = print
-local common = require( "ultiLayout.common" )
-local beautiful = require( "beautiful" )
-local titlebar = require( "ultiLayout.widgets.titlebar" )
+local common = require( "ultiLayout.common" )
+local beautiful = require( "beautiful" )
+local titlebar = require( "ultiLayout.widgets.titlebar" )
local splitter = require( "ultiLayout.widgets.splitter" )
module("ultiLayout.layouts.stack")
function new(cg,have_tiltebar)
if not cg then return end
- local data = {}
- local tb = nil
- local asplitter = splitter.create_splitter_bar(cg)
- cg.swapable = true
-
+ local data,tb,asplitter = {},nil,splitter.create_splitter_bar(cg)
+ cg.swapable = true
+
function data:update()
local margin = (cg.width-(2*(beautiful.client_margin or 0)) < 0 or cg.height-(2*(beautiful.client_margin or 0)) < 0) and 0 or beautiful.client_margin or 0
for k,v in ipairs(cg:childs()) do
v:geometry({width = cg.workarea.width-(margin*2), height = cg.workarea.height-(margin*2), x = cg.workarea.x+(margin/2), y = cg.workarea.y+(margin/2)})
- --v:repaint()
end
asplitter:update()
end
-
+
function data:set_active(sub_cg)
- for k,v in pairs(cg:childs()) do
- v.visible = v == sub_cg
+ for k,v in ipairs(cg:childs()) do
+ v.visible = (v == sub_cg)
end
if tb then tb:select_tab(sub_cg) end
end
@@ -34,13 +29,12 @@ function new(cg,have_tiltebar)
function data:add_child(child_cg)
if not tb and have_tiltebar == true then
tb = titlebar(cg)
- cg.decorations:add_decoration(tb.wibox,{class="titlebar",position="top",align="ajust",update_callback= function() tb:update() end})
+ cg.decorations:add_decoration(tb.wibox,{class="titlebar",position="top",align="ajust"})
end
if tb then tb:add_tab(child_cg) end
data:set_active(sub_cg)
return child_cg
end
-
return data
end
View
7 ultiLayout/layouts/tile.lua
@@ -5,8 +5,9 @@ local common = require( "ultiLayout.common" )
local clientGroup = require( "ultiLayout.clientGroup" )
module("ultiLayout.layouts.tile")
-local function create_cg(parent, layout, tile_layout)
+local function create_cg(parent, layout, tile_layout,percent)
local tile = clientGroup()
+ tile.default_percent = percent
tile:set_layout(common.get_layout_list()[tile_layout])
layout:add_child(tile)
parent:attach(tile)
@@ -17,9 +18,9 @@ local function tile(cg,main_l_name,sub_l_name,right)
local layout = common.get_layout_list()[main_l_name](cg)
local m_tile,s_tile
if right == true then
- m_tile, s_tile = create_cg(cg,layout,sub_l_name),create_cg(cg,layout,sub_l_name)
+ m_tile, s_tile = create_cg(cg,layout,sub_l_name,65),create_cg(cg,layout,sub_l_name,35)
else
- s_tile, m_tile = create_cg(cg,layout,sub_l_name),create_cg(cg,layout,sub_l_name)
+ s_tile, m_tile = create_cg(cg,layout,sub_l_name,65),create_cg(cg,layout,sub_l_name,35)
end
layout.add_child_orig = layout.add_child
layout.add_child = function(self,new_cg)

0 comments on commit 63fd122

Please sign in to comment.
Something went wrong with that request. Please try again.