From 77674a48300d92c6fb7db8efd25cda995ff3d060 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Tue, 21 Feb 2012 14:48:20 +0100 Subject: Remove widget shadow when hot/active. --- style-default.lua | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/style-default.lua b/style-default.lua index 7c85e46..5ae9dda 100644 --- a/style-default.lua +++ b/style-default.lua @@ -12,10 +12,6 @@ end local function Button(state, title, x,y,w,h) local c = color[state] - if state ~= 'normal' then - love.graphics.setColor(c.fg) - love.graphics.rectangle('fill', x+3,y+3,w,h) - end love.graphics.setColor(c.bg) love.graphics.rectangle('fill', x,y,w,h) love.graphics.setColor(c.fg) @@ -39,10 +35,6 @@ end local function Slider(state, fraction, x,y,w,h, vertical) local c = color[state] - if state ~= 'normal' then - love.graphics.setColor(c.fg) - love.graphics.rectangle('fill', x+3,y+3,w,h) - end love.graphics.setColor(c.bg) love.graphics.rectangle('fill', x,y,w,h) @@ -59,10 +51,6 @@ end local function Slider2D(state, fraction, x,y,w,h, vertical) local c = color[state] - if state ~= 'normal' then - love.graphics.setColor(c.fg) - love.graphics.rectangle('fill', x+3,y+3,w,h) - end love.graphics.setColor(c.bg) love.graphics.rectangle('fill', x,y,w,h) @@ -83,10 +71,6 @@ end local function Input(state, text, cursor, x,y,w,h) local c = color[state] - if state ~= 'normal' then - love.graphics.setColor(c.fg) - love.graphics.rectangle('fill', x+3,y+3,w,h) - end love.graphics.setColor(c.bg) love.graphics.rectangle('fill', x,y,w,h) love.graphics.setColor(c.fg) @@ -107,17 +91,13 @@ end local function Checkbox(state, checked, x,y,w,h) local c = color[state] - if state ~= 'normal' then - love.graphics.setColor(c.fg) - love.graphics.rectangle('fill', x+3,y+3,w,h) - end love.graphics.setColor(c.bg) love.graphics.rectangle('fill', x,y,w,h) love.graphics.setColor(c.fg) love.graphics.rectangle('line', x,y,w,h) if checked then - local r = math.max(math.min(w/2,h/2) - 3, 2) - love.graphics.circle('fill', x+w/2,y+h/2,r) + local r = math.max(math.min(w/7,h/7), 2) + love.graphics.rectangle('fill', x+r,y+r, w-2*r,h-2*r) end end -- cgit v1.2.3-54-g00ecf From a094675a49cf4ab011ddb15fd1bc21632caceb9c Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Tue, 21 Feb 2012 14:52:30 +0100 Subject: Better require regexps for submodules --- button.lua | 2 +- checkbox.lua | 2 +- core.lua | 4 ++-- init.lua | 2 +- input.lua | 3 ++- label.lua | 2 +- slider.lua | 2 +- slider2d.lua | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/button.lua b/button.lua index 2374645..94ff634 100644 --- a/button.lua +++ b/button.lua @@ -1,4 +1,4 @@ -local core = require((...):match("^(.+)%.[^%.]+") .. '.core') +local core = require((...):match("(.-)[^%.]+$") .. 'core') -- the widget return function(title, x,y, w,h, draw) diff --git a/checkbox.lua b/checkbox.lua index c5f5fce..306fc8f 100644 --- a/checkbox.lua +++ b/checkbox.lua @@ -1,4 +1,4 @@ -local core = require((...):match("^(.+)%.[^%.]+") .. '.core') +local core = require((...):match("(.-)[^%.]+$") .. 'core') return function(info, x,y, w,h, draw) local id = core.generateID() diff --git a/core.lua b/core.lua index f57caa9..08cda79 100644 --- a/core.lua +++ b/core.lua @@ -1,5 +1,6 @@ -- state local context = {maxid = 0} +local draw_items = {n = 0} local NO_WIDGET = function()end local function generateID() @@ -87,7 +88,6 @@ local function save_unpack(t, i) return t[i], save_unpack(t, i+1) end -local draw_items = {n = 0} local function registerDraw(id, f, ...) assert(type(f) == 'function' or (getmetatable(f) or {}).__call, 'Drawing function is not a callable type!') @@ -141,7 +141,7 @@ return { hasKeyFocus = hasKeyFocus, makeTabable = makeTabable, - style = require((...):match("^(.+)%.[^%.]+") .. '.style-default'), + style = require((...):match("(.-)[^%.]+$") .. '.style-default'), color = color, registerDraw = registerDraw, draw = draw, diff --git a/init.lua b/init.lua index 3b4e70c..7396e98 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ -local BASE = (...) .. '.' +local BASE = ((...):match('(.+)%.') or ...) .. '.' return { core = require(BASE .. 'core'), diff --git a/input.lua b/input.lua index 2ba29b5..7fe399d 100644 --- a/input.lua +++ b/input.lua @@ -1,4 +1,4 @@ -local core = require((...):match("^(.+)%.[^%.]+") .. '.core') +local core = require((...):match("(.-)[^%.]+$") .. 'core') return function(info, x,y,w,h, draw) info.text = info.text or "" @@ -10,6 +10,7 @@ return function(info, x,y,w,h, draw) if core.isActive(id) then core.setKeyFocus(id) end core.registerDraw(id, draw or core.style.Input, info.text, info.cursor, x,y,w,h) + if not core.hasKeyFocus(id) then return false end local changed = false -- editing diff --git a/label.lua b/label.lua index 76f3c92..34d32b4 100644 --- a/label.lua +++ b/label.lua @@ -1,4 +1,4 @@ -local core = require((...):match("^(.+)%.[^%.]+") .. '.core') +local core = require((...):match("(.-)[^%.]+$") .. 'core') return function(text, x,y,w,h,align, draw) local id = core.generateID() diff --git a/slider.lua b/slider.lua index ae75c01..feed65c 100644 --- a/slider.lua +++ b/slider.lua @@ -1,4 +1,4 @@ -local core = require((...):match("^(.+)%.[^%.]+") .. '.core') +local core = require((...):match("(.-)[^%.]+$") .. 'core') return function(info, x,y,w,h, draw) assert(type(info) == 'table' and info.value, "Incomplete slider value info") diff --git a/slider2d.lua b/slider2d.lua index 023d16f..f20a05b 100644 --- a/slider2d.lua +++ b/slider2d.lua @@ -1,4 +1,4 @@ -local core = require((...):match("^(.+)%.[^%.]+") .. '.core') +local core = require((...):match("(.-)[^%.]+$") .. 'core') return function(info, x,y,w,h, draw) assert(type(info) == 'table' and type(info.value) == "table", "Incomplete slider value info") -- cgit v1.2.3-54-g00ecf