diff options
| author | jussi | 2024-04-17 00:35:58 +0300 |
|---|---|---|
| committer | jussi | 2024-04-17 00:35:58 +0300 |
| commit | 70b40f67824b3d612235c382aa83821c054fa51e (patch) | |
| tree | 5d594cc457d6fed8af87e31977a0b9352677a4f5 /examples/ReiLuaGui_examples/calculator.lua | |
| parent | 41b67398247d9031aed4ca6e3ffd6799ec8b1bca (diff) | |
| download | reilua-enhanced-70b40f67824b3d612235c382aa83821c054fa51e.tar.gz reilua-enhanced-70b40f67824b3d612235c382aa83821c054fa51e.tar.bz2 reilua-enhanced-70b40f67824b3d612235c382aa83821c054fa51e.zip | |
Object libraries like Vector2 optimizations.
Diffstat (limited to 'examples/ReiLuaGui_examples/calculator.lua')
| -rw-r--r-- | examples/ReiLuaGui_examples/calculator.lua | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/ReiLuaGui_examples/calculator.lua b/examples/ReiLuaGui_examples/calculator.lua index a2ddfdf..f6fcb7c 100644 --- a/examples/ReiLuaGui_examples/calculator.lua +++ b/examples/ReiLuaGui_examples/calculator.lua @@ -20,7 +20,7 @@ function Calculator:new( pos ) padding = 10, onClicked = function() object:set2Top() - object.dragPos = Vec2:new( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y ) + object.dragPos = Vec2:newT( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y ) Gui.heldCallback = function() object:drag() end end, } ) @@ -30,7 +30,7 @@ function Calculator:new( pos ) texture = BgrTexture, HAling = Gui.ALING.CENTER, VAling = Gui.ALING.CENTER, - color = Color:new( RL.LIGHTGRAY ), + color = Color:newT( RL.LIGHTGRAY ), } ) ) object.handle:add( Gui.texture:new( { @@ -38,7 +38,7 @@ function Calculator:new( pos ) texture = BorderTexture, HAling = Gui.ALING.CENTER, VAling = Gui.ALING.CENTER, - color = Color:new( RL.LIGHTGRAY ), + color = Color:newT( RL.LIGHTGRAY ), nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH }, } ) ) @@ -51,8 +51,8 @@ function Calculator:new( pos ) onClicked = function() object:setVisible( false ) end, - onMouseOver = function( self ) self.items[1].color = Color:new( RL.WHITE ) end, - notMouseOver = function( self ) self.items[1].color = Color:new( RL.BLACK ) end, + onMouseOver = function( this ) this.items[1].color = Color:newT( RL.WHITE ) end, + notMouseOver = function( this ) this.items[1].color = Color:newT( RL.BLACK ) end, } ) object.closeButton:add( Gui.texture:new( { @@ -73,7 +73,7 @@ function Calculator:new( pos ) texture = BgrTexture, HAling = Gui.ALING.CENTER, VAling = Gui.ALING.CENTER, - color = Color:new( RL.GRAY ), + color = Color:newT( RL.GRAY ), } ) ) object.panel:add( Gui.texture:new( { @@ -81,7 +81,7 @@ function Calculator:new( pos ) texture = BorderTexture, HAling = Gui.ALING.CENTER, VAling = Gui.ALING.CENTER, - color = Color:new( RL.LIGHTGRAY ), + color = Color:newT( RL.LIGHTGRAY ), nPatchInfo = { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = RL.NPATCH_NINE_PATCH }, } ) ) @@ -91,7 +91,7 @@ function Calculator:new( pos ) bounds = Rect:new( 0, 0, object.windowRect.width - 16, object.DISPLAY_HIGHT ), padding = 10, drawBounds = true, - color = Color:new( RL.WHITE ) + color = Color:newT( RL.WHITE ) } ) object.display:add( Gui.text:new( { text = "", fontSize = 30, VAling = Gui.ALING.CENTER, maxTextLen = 8 } ) ) @@ -108,8 +108,8 @@ function Calculator:new( pos ) table.insert( object.buttons, Gui.element:new( { bounds = Rect:new( 0, 0, 40, 32 ), drawBounds = true, - onMouseOver = function( self ) self.color = Color:new( RL.WHITE ) end, - notMouseOver = function( self ) self.color = Color:new( RL.LIGHTGRAY ) end, + onMouseOver = function( self ) self.color = Color:newT( RL.WHITE ) end, + notMouseOver = function( self ) self.color = Color:newT( RL.LIGHTGRAY ) end, } ) ) object.buttons[ #object.buttons ].pos = Vec2:new( 8 + x * 46, object.HANDLE_HIGHT + object.DISPLAY_HIGHT + 16 + y * 38 ) @@ -161,7 +161,7 @@ function Calculator:setPosition( pos ) end function Calculator:drag() - local mousePos = Vec2:new( RL.GetMousePosition() ) + local mousePos = Vec2:newT( RL.GetMousePosition() ) local winPos = Vec2:new( self.handle.bounds.x, self.handle.bounds.y ) self:setPosition( mousePos - self.dragPos ) |
