Skip to content

Commit 73e65f2

Browse files
committed
use proper widgets for the minimize button
1 parent a4365f4 commit 73e65f2

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

plugins/lua/buildingplan/planneroverlay.lua

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,6 @@ function PlannerOverlay:init()
262262
self.selected = 1
263263
self.minimized = false
264264

265-
local function is_minimized() return self.minimized end
266-
local function not_is_minimized() return not self.minimized end
267-
268265
local main_panel = widgets.Panel{
269266
view_id='main',
270267
frame={t=0, l=0, r=0, h=14},
@@ -273,6 +270,17 @@ function PlannerOverlay:init()
273270
visible=function() return not self.minimized end,
274271
}
275272

273+
local minimized_panel = widgets.Label{
274+
frame={t=0, r=1, w=1, h=1},
275+
text={
276+
{
277+
text=function() return string.char(self.minimized and 31 or 30) end,
278+
pen=COLOR_RED,
279+
},
280+
},
281+
on_click=function() self.minimized = not self.minimized end,
282+
}
283+
276284
local function make_is_selected_fn(idx)
277285
return function() return self.selected == idx end
278286
end
@@ -476,6 +484,7 @@ function PlannerOverlay:init()
476484

477485
self:addviews{
478486
main_panel,
487+
minimized_panel,
479488
error_panel,
480489
}
481490
end
@@ -582,21 +591,17 @@ function PlannerOverlay:onInput(keys)
582591
return true
583592
end
584593
if PlannerOverlay.super.onInput(self, keys) then
585-
return true
594+
return not self.minimized
586595
end
587596
if keys._MOUSE_L_DOWN then
588597
if is_over_options_panel() then return false end
589598
local detect_rect = copyall(self.frame_rect)
590599
detect_rect.height = self.subviews.main.frame_rect.height +
591600
self.subviews.errors.frame_rect.height
592601
detect_rect.y2 = detect_rect.y1 + detect_rect.height - 1
593-
local x, y = self.subviews.main:getMousePos(gui.ViewRect{rect=detect_rect})
594-
if x or self.subviews.errors:getMousePos() then
595-
if x and x == detect_rect.width-2 and y == 0 then
596-
self.minimized = not self.minimized
597-
return true
598-
end
599-
return not self.minimized
602+
if self.subviews.main:getMousePos(gui.ViewRect{rect=detect_rect})
603+
or self.subviews.errors:getMousePos() then
604+
return true
600605
end
601606
if self.minimized then return false end
602607
if not is_construction() and #uibs.errors > 0 then return true end
@@ -658,9 +663,6 @@ function PlannerOverlay:render(dc)
658663
if not is_plannable() then return end
659664
self.subviews.errors:updateLayout()
660665
PlannerOverlay.super.render(self, dc)
661-
-- render "minimize" button
662-
dc:seek(self.frame_rect.x2-1, self.frame_rect.y1)
663-
dc:char(string.char(self.minimized and 31 or 30), COLOR_RED)
664666
end
665667

666668
local ONE_BY_ONE = xy2pos(1, 1)

0 commit comments

Comments
 (0)