Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fixed:fit(ow,oh)
- local pos, c = 0, 0
- local w,h
- for k, v in pairs(self.widgets) do
- c = c + 1
- w, h = base.fit_widget(v, ow, oh)
- if math.fmod(k,2) == 0 then
- if self.dir == "y" then
- pos = pos + h
- else
- pos = pos + w
- end
- end
- end
- if self.dir == "y" then
- return ow, pos + math.fmod(c,2) * h
- else
- return pos + math.fmod(c,2) * w, oh
- end
- end
- function fixed:draw(wibox, cr, width, height)
- local pos = 0
- local aw, ah = width/2, height/2
- for k, v in pairs(self.widgets) do
- local x, y, w, h, _
- local in_dir
- if self.dir == "y" then
- if math.fmod(k,2) == 0 then
- x = aw
- else
- x = 0
- end
- y = pos
- w, h = aw, height - pos
- if k ~= #self.widgets or not self._fill_space then
- _, h = base.fit_widget(v, w, h);
- end
- if math.fmod(k,2) == 0 then
- pos = pos + h
- end
- in_dir = h
- else
- if math.fmod(k,2) == 0 then
- y = ah
- else
- y = 0
- end
- x = pos
- w, h = width - pos, ah
- if k ~= #self.widgets or not self._fill_space then
- w, _ = base.fit_widget(v, w, height);
- end
- if math.fmod(k,2) == 0 then
- pos = pos + w
- end
- in_dir = w
- end
- if (self.dir == "y" and pos > height) or
- (self.dir ~= "y" and pos > width) then
- break
- end
- base.draw_widget(wibox, cr, v, x, y, w, h)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement