]> git.madduck.net Git - etc/awesome.git/blob - util/separators.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

weather: set UTC directly #310
[etc/awesome.git] / util / separators.lua
1
2 --[[
3                                                    
4      Licensed under GNU General Public License v2  
5       * (c) 2015, Luke Bonham                      
6       * (c) 2015, plotnikovanton                   
7                                                    
8 --]]
9
10 local wibox     = require("wibox")
11 local gears     = require("gears")
12
13 -- Lain Cairo separators util submodule
14 -- lain.util.separators
15 local separators = { height = 0, width = 9 }
16
17 -- [[ Arrow
18
19 -- Right
20 function separators.arrow_right(col1, col2)
21     local widget = wibox.widget.base.make_widget()
22
23     widget.fit = function(m, w, h)
24         return separators.width, separators.height
25     end
26
27     widget.draw = function(mycross, wibox, cr, width, height)
28         if col2 ~= "alpha" then
29             cr:set_source_rgb(gears.color.parse_color(col2))
30             cr:new_path()
31             cr:move_to(0, 0)
32             cr:line_to(width, height/2)
33             cr:line_to(width, 0)
34             cr:close_path()
35             cr:fill()
36
37             cr:new_path()
38             cr:move_to(0, height)
39             cr:line_to(width, height/2)
40             cr:line_to(width, height)
41             cr:close_path()
42             cr:fill()
43         end
44
45         if col1 ~= "alpha" then
46             cr:set_source_rgb(gears.color.parse_color(col1))
47             cr:new_path()
48             cr:move_to(0, 0)
49             cr:line_to(width, height/2)
50             cr:line_to(0, height)
51             cr:close_path()
52             cr:fill()
53         end
54    end
55
56    return widget
57 end
58
59 -- Left
60 function separators.arrow_left(col1, col2)
61     local widget = wibox.widget.base.make_widget()
62
63     widget.fit = function(m, w, h)
64         return separators.width, separators.height
65     end
66
67     widget.draw = function(mycross, wibox, cr, width, height)
68         if col1 ~= "alpha" then
69             cr:set_source_rgb(gears.color.parse_color(col1))
70             cr:new_path()
71             cr:move_to(width, 0)
72             cr:line_to(0, height/2)
73             cr:line_to(0, 0)
74             cr:close_path()
75             cr:fill()
76
77             cr:new_path()
78             cr:move_to(width, height)
79             cr:line_to(0, height/2)
80             cr:line_to(0, height)
81             cr:close_path()
82             cr:fill()
83         end
84
85         if col2 ~= "alpha" then
86             cr:new_path()
87             cr:move_to(width, 0)
88             cr:line_to(0, height/2)
89             cr:line_to(width, height)
90             cr:close_path()
91
92             cr:set_source_rgb(gears.color.parse_color(col2))
93             cr:fill()
94         end
95    end
96
97    return widget
98 end
99
100 -- ]]
101
102 return separators