make slider slightly less ugly

This commit is contained in:
nobody
2016-02-08 14:31:30 -05:00
parent a5f1a9b1da
commit 1a75af526e
3 changed files with 17 additions and 13 deletions

View File

@@ -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

View File

@@ -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' },

View File

@@ -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