]> 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:

#91 pull + clean useless lines
[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 beautiful = require("beautiful")
12 local gears     = require("gears")
13
14 -- Lain cairo separators util submodule
15 -- lain.util.separators
16 local separators = {}
17
18 local height = beautiful.awful_widget_height or 0
19 local width  = beautiful.separators_width or 9
20
21 -- [[ Arrow
22
23 -- Right
24 function separators.arrow_right(col1, col2)
25     local widget = wibox.widget.base.make_widget()
26
27     widget.fit = function(m, w, h) return width, height end
28
29     widget.draw = function(mycross, wibox, cr, width, height)
30         if col2 ~= "alpha" then
31             cr:set_source_rgb(gears.color.parse_color(col2))
32             cr:new_path()
33             cr:move_to(0, 0)
34             cr:line_to(width, height/2)
35             cr:line_to(width, 0)
36             cr:close_path()
37             cr:fill()
38
39             cr:new_path()
40             cr:move_to(0, height)
41             cr:line_to(width, height/2)
42             cr:line_to(width, height)
43             cr:close_path()
44             cr:fill()
45         end
46
47         if col1 ~= "alpha" then
48             cr:set_source_rgb(gears.color.parse_color(col1))
49             cr:new_path()
50             cr:move_to(0, 0)
51             cr:line_to(width, height/2)
52             cr:line_to(0, height)
53             cr:close_path()
54             cr:fill()
55         end
56    end
57
58    return widget
59 end
60
61 -- Left
62 function separators.arrow_left(col1, col2)
63     local widget = wibox.widget.base.make_widget()
64
65     widget.fit = function(m, w, h) return width, height 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