mirror of
https://github.com/airstruck/luigi.git
synced 2026-01-09 15:58:22 +00:00
make slider slightly less ugly
This commit is contained in:
@@ -138,10 +138,8 @@ function Painter:paintIconAndText ()
|
|||||||
if w < 1 or h < 1 then return end
|
if w < 1 or h < 1 then return end
|
||||||
|
|
||||||
-- calculate position for icon and text based on alignment and padding
|
-- calculate position for icon and text based on alignment and padding
|
||||||
local iconX, iconY, x1, y1, x2, y2 = self:positionIcon(
|
local iconX, iconY, x1, y1, x2, y2 = self:positionIcon(x, y, x + w, y + h)
|
||||||
x, y, x + w, y + h)
|
local font, textX, textY = self:positionText(x1, y1, x2, y2)
|
||||||
local font, textX, textY = self:positionText(
|
|
||||||
x1, y1, x2, y2)
|
|
||||||
|
|
||||||
local icon = widget.icon and self:loadImage(widget.icon)
|
local icon = widget.icon and self:loadImage(widget.icon)
|
||||||
local text = widget.text
|
local text = widget.text
|
||||||
@@ -208,15 +206,13 @@ end
|
|||||||
|
|
||||||
function Painter:paint ()
|
function Painter:paint ()
|
||||||
local widget = self.widget
|
local widget = self.widget
|
||||||
|
local x, y, w, h = widget:getRectangle()
|
||||||
|
|
||||||
|
-- if the drawable area has no width or height, don't paint
|
||||||
|
if w < 1 or h < 1 then return end
|
||||||
|
|
||||||
Event.PreDisplay:emit(widget, { target = widget }, function()
|
Event.PreDisplay:emit(widget, { target = widget }, function()
|
||||||
|
|
||||||
local x, y, w, h = widget:getRectangle()
|
|
||||||
|
|
||||||
-- if the drawable area has no width or height, don't paint
|
|
||||||
if w < 1 or h < 1 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
Backend.push()
|
Backend.push()
|
||||||
|
|
||||||
if widget.parent then
|
if widget.parent then
|
||||||
|
|||||||
@@ -90,6 +90,14 @@ return function (config)
|
|||||||
return self.parent and self.parent.flow == 'x' and 4
|
return self.parent and self.parent.flow == 'x' and 4
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getSliderThumbWidth (self)
|
||||||
|
return self.parent.flow == 'x' and 32 or false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getSliderThumbHeight (self)
|
||||||
|
return self.parent.flow ~= 'x' and 32 or false
|
||||||
|
end
|
||||||
|
|
||||||
local function getStepperBeforeIcon (self)
|
local function getStepperBeforeIcon (self)
|
||||||
return self.parent.flow == 'x' and triangle_left or triangle_up
|
return self.parent.flow == 'x' and triangle_left or triangle_up
|
||||||
end
|
end
|
||||||
@@ -188,6 +196,8 @@ return function (config)
|
|||||||
type = { 'button' },
|
type = { 'button' },
|
||||||
align = 'middle center',
|
align = 'middle center',
|
||||||
margin = 0,
|
margin = 0,
|
||||||
|
width = getSliderThumbWidth,
|
||||||
|
height = getSliderThumbHeight,
|
||||||
},
|
},
|
||||||
status = {
|
status = {
|
||||||
type = { 'Line', 'Control' },
|
type = { 'Line', 'Control' },
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ return function (self)
|
|||||||
self:onReshape(function (event)
|
self:onReshape(function (event)
|
||||||
local x1, y1, w, h = self:getRectangle(true, true)
|
local x1, y1, w, h = self:getRectangle(true, true)
|
||||||
local x2, y2 = x1 + w, y1 + h
|
local x2, y2 = x1 + w, y1 + h
|
||||||
local dim = math.min(w, h)
|
|
||||||
thumb.width, thumb.height = dim, dim
|
|
||||||
if self.flow == 'x' then
|
if self.flow == 'x' then
|
||||||
local halfThumb = thumb:getWidth() / 2
|
local halfThumb = thumb:getWidth() / 2
|
||||||
x1, x2 = x1 + halfThumb, x2 - halfThumb
|
x1, x2 = x1 + halfThumb, x2 - halfThumb
|
||||||
|
|||||||
Reference in New Issue
Block a user