mirror of
https://github.com/airstruck/luigi.git
synced 2025-11-18 12:25:06 +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
|
||||
|
||||
-- calculate position for icon and text based on alignment and padding
|
||||
local iconX, iconY, x1, y1, x2, y2 = self:positionIcon(
|
||||
x, y, x + w, y + h)
|
||||
local font, textX, textY = self:positionText(
|
||||
x1, y1, x2, y2)
|
||||
local iconX, iconY, x1, y1, x2, y2 = self:positionIcon(x, y, x + w, y + h)
|
||||
local font, textX, textY = self:positionText(x1, y1, x2, y2)
|
||||
|
||||
local icon = widget.icon and self:loadImage(widget.icon)
|
||||
local text = widget.text
|
||||
@@ -208,15 +206,13 @@ end
|
||||
|
||||
function Painter:paint ()
|
||||
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()
|
||||
|
||||
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()
|
||||
|
||||
if widget.parent then
|
||||
|
||||
@@ -90,6 +90,14 @@ return function (config)
|
||||
return self.parent and self.parent.flow == 'x' and 4
|
||||
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)
|
||||
return self.parent.flow == 'x' and triangle_left or triangle_up
|
||||
end
|
||||
@@ -188,6 +196,8 @@ return function (config)
|
||||
type = { 'button' },
|
||||
align = 'middle center',
|
||||
margin = 0,
|
||||
width = getSliderThumbWidth,
|
||||
height = getSliderThumbHeight,
|
||||
},
|
||||
status = {
|
||||
type = { 'Line', 'Control' },
|
||||
|
||||
@@ -73,8 +73,6 @@ return function (self)
|
||||
self:onReshape(function (event)
|
||||
local x1, y1, w, h = self:getRectangle(true, true)
|
||||
local x2, y2 = x1 + w, y1 + h
|
||||
local dim = math.min(w, h)
|
||||
thumb.width, thumb.height = dim, dim
|
||||
if self.flow == 'x' then
|
||||
local halfThumb = thumb:getWidth() / 2
|
||||
x1, x2 = x1 + halfThumb, x2 - halfThumb
|
||||
|
||||
Reference in New Issue
Block a user