diff --git a/button.lua b/button.lua index f365654..c063ffa 100644 --- a/button.lua +++ b/button.lua @@ -6,7 +6,6 @@ return function(core, text, ...) local opt, x,y,w,h = core.getOptionsAndSize(...) opt.id = opt.id or text opt.font = opt.font or love.graphics.getFont() - opt.color = opt.color or core.theme.color w = w or opt.font:getWidth(text) + 4 h = h or opt.font:getHeight() + 4 @@ -19,10 +18,6 @@ return function(core, text, ...) hit = core:mouseReleasedOn(opt.id), hovered = core:isHovered(opt.id), entered = core:isHovered(opt.id) and not core:wasHovered(opt.id), - left = not core:isHovered(opt.id) and core:wasHovered(opt.id), - x = x, - y = y, - w = w, - h = h + left = not core:isHovered(opt.id) and core:wasHovered(opt.id) } end diff --git a/core.lua b/core.lua index f2442bc..5b4d2ee 100644 --- a/core.lua +++ b/core.lua @@ -100,7 +100,7 @@ function suit:mouseInRect(x,y,w,h) end function suit:registerMouseHit(id, ul_x, ul_y, hit) - if not self.hovered and hit(self.mouse_x - ul_x, self.mouse_y - ul_y) then + if hit(self.mouse_x - ul_x, self.mouse_y - ul_y) then self.hovered = id if self.active == nil and self.mouse_button_down then self.active = id @@ -176,24 +176,15 @@ function suit:keyPressedOn(id, key) end -- state update -function suit:enterFrame(mouseX, mouseY) +function suit:enterFrame() if not self.mouse_button_down then self.active = nil elseif self.active == nil then self.active = NONE end - local mx = mouseX - local my = mouseY - - if mx == nil then - mx = love.mouse.getX() - end - if my == nil then - my = love.mouse.getY() - end self.hovered_last, self.hovered = self.hovered, nil - self:updateMouse(mx, my, love.mouse.isDown(1)) + self:updateMouse(love.mouse.getX(), love.mouse.getY(), love.mouse.isDown(1)) self.key_down, self.textchar = nil, "" self:grabKeyboardFocus(NONE) self.hit = nil @@ -213,14 +204,14 @@ function suit:registerDraw(f, ...) end function suit:draw() - -- self:exitFrame() -- CALL these manually in your update method + self:exitFrame() love.graphics.push('all') for i = self.draw_queue.n,1,-1 do self.draw_queue[i]() end love.graphics.pop() self.draw_queue.n = 0 - -- self:enterFrame() -- CALL these manually in your update method + self:enterFrame() end return suit diff --git a/docs/gettingstarted.rst b/docs/gettingstarted.rst index 3f0e560..51605f3 100644 --- a/docs/gettingstarted.rst +++ b/docs/gettingstarted.rst @@ -5,7 +5,7 @@ Before actually getting started, it is important to understand the motivation and mechanics behind SUIT: - **Immediate mode is better than retained mode** -- **Layout should not care about content** +- **Layout does not care about widgets** - **Less is more** Immediate mode? @@ -68,11 +68,11 @@ to design a user interface. SUIT is not a complete GUI library: It does not take control of the runtime. You have to do everything yourself [1]_. -**SUIT is not good at processing words!** +**SUIT is not good at word processors!** -Hello, World! -------------- +Hello, World +------------ SUITing up is is straightforward: Define your GUI in ``love.update()``, and draw it in ``love.draw()``:: @@ -96,19 +96,15 @@ draw it in ``love.draw()``:: suit.draw() end -This will produce this UI: +This will produce this UI (after clicking the button): .. image:: _static/hello-world.gif -The two widgets (the button and the label) are each created by a function call +As written above, the two widgets are each created by a function call (:func:`suit.Button