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

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