diff options
| author | jussi | 2022-12-07 22:27:24 +0200 |
|---|---|---|
| committer | jussi | 2022-12-07 22:27:24 +0200 |
| commit | 79fbb36d2a4d73001c446f75b3b87dc84f1605b6 (patch) | |
| tree | 76f7ef8c31b4019f44f093f3b65dc556c7530d09 /examples/resources | |
| parent | 1a1c3cb28c7f9fe53f450bbdbb65ea4c77adc5ac (diff) | |
| download | reilua-enhanced-79fbb36d2a4d73001c446f75b3b87dc84f1605b6.tar.gz reilua-enhanced-79fbb36d2a4d73001c446f75b3b87dc84f1605b6.tar.bz2 reilua-enhanced-79fbb36d2a4d73001c446f75b3b87dc84f1605b6.zip | |
ReiLuaGui calculator example.
Diffstat (limited to 'examples/resources')
| -rw-r--r-- | examples/resources/images/LICENCE | 3 | ||||
| -rw-r--r-- | examples/resources/images/cancel.png | bin | 0 -> 8126 bytes | |||
| -rw-r--r-- | examples/resources/images/n-patch.png | bin | 6021 -> 0 bytes | |||
| -rw-r--r-- | examples/resources/images/ui_bgr.png | bin | 0 -> 2167 bytes | |||
| -rw-r--r-- | examples/resources/images/ui_border.png | bin | 0 -> 1170 bytes | |||
| -rw-r--r-- | examples/resources/lib/gui.lua | 34 |
6 files changed, 22 insertions, 15 deletions
diff --git a/examples/resources/images/LICENCE b/examples/resources/images/LICENCE index a1d1f46..bfe263f 100644 --- a/examples/resources/images/LICENCE +++ b/examples/resources/images/LICENCE @@ -4,6 +4,9 @@ arcade_platformerV2.png GrafxKid CC0 https://opengameart.org/content/ar apple.png Jussi Viitala CC0 grass.png Jussi Viitala CC0 snake.png Jussi Viitala CC0 +ui_border.png Jussi Viitala CC0 +ui_bgr.png Jussi Viitala CC0 check-mark.png Delapouite Creative Commons 3.0 https://game-icons.net Resized circle.png Delapouite Creative Commons 3.0 https://game-icons.net Resized plain-circle.png Delapouite Creative Commons 3.0 https://game-icons.net Resized +cancel.png Sbed Creative Commons 3.0 https://game-icons.net Resized
\ No newline at end of file diff --git a/examples/resources/images/cancel.png b/examples/resources/images/cancel.png Binary files differnew file mode 100644 index 0000000..1468f67 --- /dev/null +++ b/examples/resources/images/cancel.png diff --git a/examples/resources/images/n-patch.png b/examples/resources/images/n-patch.png Binary files differdeleted file mode 100644 index c6e738b..0000000 --- a/examples/resources/images/n-patch.png +++ /dev/null diff --git a/examples/resources/images/ui_bgr.png b/examples/resources/images/ui_bgr.png Binary files differnew file mode 100644 index 0000000..d7cbec6 --- /dev/null +++ b/examples/resources/images/ui_bgr.png diff --git a/examples/resources/images/ui_border.png b/examples/resources/images/ui_border.png Binary files differnew file mode 100644 index 0000000..85936fc --- /dev/null +++ b/examples/resources/images/ui_border.png diff --git a/examples/resources/lib/gui.lua b/examples/resources/lib/gui.lua index 341489b..c7609c1 100644 --- a/examples/resources/lib/gui.lua +++ b/examples/resources/lib/gui.lua @@ -3,8 +3,6 @@ Rect = require( "rectangle" ) Vec2 = require( "vector2" ) Color = require( "color" ) --- NOTE!!! Work in progress! Do not use. - --[[ To add repeat inputs to the keys pressed buffer, you could add GLFW_REPEAT in railib rcore.c in function "KeyCallback" by changing: @@ -43,15 +41,16 @@ Gui = { mouseButton = MOUSE_BUTTON_LEFT, font = 0, - fontSize = 30, + fontSize = 20, padding = 2, spacing = 4, scrollbarWidth = 8, scrollAmount = 10, + heldCallback = nil, + _cells = {}, _mousePos = Vec2:new( 0, 0 ), -- Last mouse position that was passed to Gui.process. - _heldCallback = nil, _inputElement = nil, _inputItem = nil, -- Must be type Text. } @@ -119,11 +118,11 @@ function Gui.process( mousePosition ) Gui._mousePos = mousePosition - if Gui._heldCallback ~= nil then + if Gui.heldCallback ~= nil then if RL_IsMouseButtonDown( Gui.mouseButton ) then - Gui._heldCallback() + Gui.heldCallback() else - Gui._heldCallback = nil + Gui.heldCallback = nil end return @@ -265,7 +264,7 @@ function Text:draw() return end - RL_DrawText( self.font, self.text, { self._prante.bounds.x + self.bounds.x, self._prante.bounds.y + self.bounds.y }, self.fontSize, self.spacing, self.color ) + RL_DrawText( self.font, self.text, { self._parent.bounds.x + self.bounds.x, self._parent.bounds.y + self.bounds.y }, self.fontSize, self.spacing, self.color ) end -- Texture. @@ -285,6 +284,7 @@ function Texture:new( set ) object.origin = setProperty( set, "origin", Vec2:new( 0, 0 ) ) object.rotation = setProperty( set, "rotation", 0 ) object.color = setProperty( set, "color", Color:new( WHITE ) ) + object.nPatchInfo = setProperty( set, "nPatchInfo", nil ) object.visible = setProperty( set, "visible", true ) object._parent = nil @@ -319,13 +319,17 @@ function Texture:draw() end local dst = { - self.bounds.x + self._prante.bounds.x, - self.bounds.y + self._prante.bounds.y, + self.bounds.x + self._parent.bounds.x, + self.bounds.y + self._parent.bounds.y, self.bounds.width, self.bounds.height } - RL_DrawTexturePro( self.texture, self.source, dst, self.origin, self.rotation, self.color ) + if self.nPatchInfo ~= nil then + RL_DrawTextureNPatch( self.texture, self.nPatchInfo, dst, self.origin, self.rotation, self.color ) + else + RL_DrawTexturePro( self.texture, self.source, dst, self.origin, self.rotation, self.color ) + end end -- Shape. @@ -385,7 +389,7 @@ function Shape:draw() return end - local pos = Vec2:new( self._prante.bounds.x, self._prante.bounds.y ) + local pos = Vec2:new( self._parent.bounds.x, self._parent.bounds.y ) if self.shape == Gui.SHAPE.LINE then RL_DrawLine( self.startPos + pos, self.endPos + pos, self.thickness, self.color ) @@ -472,7 +476,7 @@ end function Element:add( item ) table.insert( self.items, item ) - item._prante = self + item._parent = self self:update() end @@ -686,7 +690,7 @@ function Container:update() padding = 0, drawBounds = true, color = Color:new( GRAY ), - onClicked = function() Gui._heldCallback = function() self:mouseScroll( Vec2:new( 0, 1 ) ) end end, + onClicked = function() Gui.heldCallback = function() self:mouseScroll( Vec2:new( 0, 1 ) ) end end, } ) self._VScrollbar:add( Gui.shape:new( { @@ -703,7 +707,7 @@ function Container:update() padding = 0, drawBounds = true, color = Color:new( GRAY ), - onClicked = function() Gui._heldCallback = function() self:mouseScroll( Vec2:new( 1, 0 ) ) end end, + onClicked = function() Gui.heldCallback = function() self:mouseScroll( Vec2:new( 1, 0 ) ) end end, } ) self._HScrollbar:add( Gui.shape:new( { |
