@ -31,7 +31,6 @@ end
-- and @{yui.Widget.WidgetCallbacks|callbacks}.
-- and @{yui.Widget.WidgetCallbacks|callbacks}.
--
--
-- @field text (string) text displayed inside the Input
-- @field text (string) text displayed inside the Input
-- @field cornerRadius (number) radius for rounded corners
-- @table InputAttributes
-- @table InputAttributes
@ -41,8 +40,6 @@ function Input:new(args)
self = setmetatable ( args , self )
self = setmetatable ( args , self )
self.text = self.text or " "
self.text = self.text or " "
self.color = self.color or core.theme . color
self.cornerRadius = self.cornerRadius or core.theme . cornerRadius
self.cursor = math.max ( 1 , math.min ( utf8.len ( self.text ) + 1 ,
self.cursor = math.max ( 1 , math.min ( utf8.len ( self.text ) + 1 ,
self.cursor or utf8.len ( self.text ) + 1 ) )
self.cursor or utf8.len ( self.text ) + 1 ) )
self.candidate = { text = " " , start = 0 , length = 0 }
self.candidate = { text = " " , start = 0 , length = 0 }
@ -155,7 +152,7 @@ function Input:draw()
-- position 6: hello|
-- position 6: hello|
local x , y , w , h = self.x , self.y , self.w , self.h
local x , y , w , h = self.x , self.y , self.w , self.h
local font = self.font or love.graphics . getFont ( )
local color, font , cornerRadius = core.themeForWidget ( self )
local th = font : getHeight ( )
local th = font : getHeight ( )
local tw = font : getWidth ( self.text )
local tw = font : getWidth ( self.text )
@ -199,7 +196,7 @@ function Input:draw()
end
end
-- Perform actual draw
-- Perform actual draw
core.drawBox ( x , y , w , h , self. color . normal, self. cornerRadius)
core.drawBox ( x , y , w , h , color.normal, cornerRadius)
-- Apply text margins
-- Apply text margins
x = math.min ( x + 3 , x + w )
x = math.min ( x + 3 , x + w )
@ -212,7 +209,7 @@ function Input:draw()
x = x - self.drawofs
x = x - self.drawofs
-- Text
-- Text
love.graphics . setColor ( self. color . normal.fg)
love.graphics . setColor ( color.normal . fg)
love.graphics . setFont ( font )
love.graphics . setFont ( font )
love.graphics . print ( self.text , x , y + ( h - th ) / 2 )
love.graphics . print ( self.text , x , y + ( h - th ) / 2 )
@ -220,7 +217,7 @@ function Input:draw()
-- Candidate text
-- Candidate text
local ctw = font : getWidth ( self.candidate . text )
local ctw = font : getWidth ( self.candidate . text )
love.graphics . setColor ( self. color . normal.fg)
love.graphics . setColor ( color.normal . fg)
love.graphics . print ( self.candidate . text , x + tw , y + ( h - th ) / 2 )
love.graphics . print ( self.candidate . text , x + tw , y + ( h - th ) / 2 )
-- Candidate text rectangle box
-- Candidate text rectangle box