GuiScrollBar.
This commit is contained in:
8
API.md
8
API.md
@@ -8841,6 +8841,14 @@ Grid control, returns mouse cell position
|
||||
|
||||
---
|
||||
|
||||
> value = RL.GuiScrollBar( Rectangle bounds, int value, int minValue, int maxValue )
|
||||
|
||||
Scroll bar control
|
||||
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
## Gui - Advance controls set
|
||||
|
||||
---
|
||||
|
||||
@@ -6006,6 +6006,15 @@ function RL.GuiDummyRec( bounds, text ) end
|
||||
---@return any mouseCell
|
||||
function RL.GuiGrid( bounds, text, spacing, subdivs, mouseCell ) end
|
||||
|
||||
---Scroll bar control
|
||||
---- Success return int
|
||||
---@param bounds table
|
||||
---@param value integer
|
||||
---@param minValue integer
|
||||
---@param maxValue integer
|
||||
---@return any value
|
||||
function RL.GuiScrollBar( bounds, value, minValue, maxValue ) end
|
||||
|
||||
-- Gui - Advance controls set
|
||||
|
||||
---List View control, returns selected list item index
|
||||
|
||||
@@ -26,6 +26,7 @@ KEY CHANGES:
|
||||
- ADDED: RLGL Hello triangle example.
|
||||
- ADDED: Rest of rlRenderBatch functions.
|
||||
- ADDED: DrawTextureNPatchRepeat.
|
||||
- ADDED: GuiScrollBar and made it puplic in raygui.h.
|
||||
|
||||
DETAILED CHANGES:
|
||||
- REMOVED: DrawLineBezierQuad, DrawLineBezierCubic.
|
||||
|
||||
@@ -301,6 +301,13 @@ function RL.init()
|
||||
"Color Panel",
|
||||
1.0
|
||||
)
|
||||
local scrollbar = Gui:GuiScrollBar(
|
||||
Rect:new( 50, 760, 256, 16 ),
|
||||
0,
|
||||
0,
|
||||
256,
|
||||
function( self ) print( "Scrollbar value: ", self.value ) end
|
||||
)
|
||||
end
|
||||
|
||||
function RL.process( delta )
|
||||
|
||||
@@ -892,7 +892,7 @@ function Slider:draw()
|
||||
_, self.value = RL.GuiSlider( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
||||
|
||||
if self.value ~= oldValue then
|
||||
self._parentscrolling = true
|
||||
self._parent.scrolling = true
|
||||
|
||||
if self.callback ~= nil then
|
||||
self.callback( self )
|
||||
@@ -939,7 +939,7 @@ function SliderBar:draw()
|
||||
_, self.value = RL.GuiSliderBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
||||
|
||||
if self.value ~= oldValue then
|
||||
self._parentscrolling = true
|
||||
self._parent.scrolling = true
|
||||
|
||||
if self.callback ~= nil then
|
||||
self.callback( self )
|
||||
@@ -1144,7 +1144,7 @@ function ListView:draw()
|
||||
_, self.scrollIndex, self.active = RL.GuiListView( self.bounds, self.text, self.scrollIndex, self.active )
|
||||
|
||||
if self.scrollIndex ~= oldScrollIndex then
|
||||
self._parentscrolling = true
|
||||
self._parent.scrolling = true
|
||||
end
|
||||
if oldActive ~= self.active and self.callback ~= nil then
|
||||
self.callback( self )
|
||||
@@ -1194,7 +1194,7 @@ function ListViewEx:draw()
|
||||
_, self.scrollIndex, self.active, self.focus = RL.GuiListViewEx( self.bounds, self.text, self.scrollIndex, self.active, self.focus )
|
||||
|
||||
if self.scrollIndex ~= oldScrollIndex then
|
||||
self._parentscrolling = true
|
||||
self._parent.scrolling = true
|
||||
end
|
||||
if oldActive ~= self.active and self.callback ~= nil then
|
||||
self.callback( self )
|
||||
@@ -1349,7 +1349,7 @@ function ColorPicker:draw()
|
||||
self.color = Color:new( color )
|
||||
|
||||
if self.color ~= oldColor then
|
||||
self._parentscrolling = true
|
||||
self._parent.scrolling = true
|
||||
|
||||
if self.callback ~= nil then
|
||||
self.callback( self )
|
||||
@@ -1433,7 +1433,7 @@ function ColorBarAlpha:draw()
|
||||
_, self.alpha = RL.GuiColorBarAlpha( self.bounds, self.text, self.alpha )
|
||||
|
||||
if self.alpha ~= oldAlpha then
|
||||
self._parentscrolling = true
|
||||
self._parent.scrolling = true
|
||||
|
||||
if self.callback ~= nil then
|
||||
self.callback( self )
|
||||
@@ -1489,6 +1489,51 @@ function ColorBarHue:setPosition( pos )
|
||||
self.bounds.y = pos.y
|
||||
end
|
||||
|
||||
-- ColorBarHue.
|
||||
|
||||
--- Color Bar Hue control
|
||||
local GuiScrollBar = {}
|
||||
GuiScrollBar.__index = GuiScrollBar
|
||||
|
||||
function GuiScrollBar:new( bounds, value, minValue, maxValue, callback )
|
||||
local object = setmetatable( {}, self )
|
||||
object._parent = nil
|
||||
|
||||
object.bounds = bounds:clone()
|
||||
object.value = value
|
||||
object.minValue = minValue
|
||||
object.maxValue = maxValue
|
||||
object.callback = callback
|
||||
|
||||
object.visible = true
|
||||
object.disabled = false
|
||||
|
||||
return object
|
||||
end
|
||||
|
||||
function GuiScrollBar:process()
|
||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||
end
|
||||
|
||||
function GuiScrollBar:draw()
|
||||
local oldValue = self.value
|
||||
-- Note. Scrollbar style should be determined by the control that uses it.
|
||||
self.value = RL.GuiScrollBar( self.bounds, self.value, self.minValue, self.maxValue )
|
||||
|
||||
if self.value ~= oldValue then
|
||||
self._parent.scrolling = true
|
||||
|
||||
if self.callback ~= nil then
|
||||
self.callback( self )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function GuiScrollBar:setPosition( pos )
|
||||
self.bounds.x = pos.x
|
||||
self.bounds.y = pos.y
|
||||
end
|
||||
|
||||
-- Raygui class.
|
||||
|
||||
local Raygui = {}
|
||||
@@ -2002,4 +2047,14 @@ function Raygui:ColorBarHue( bounds, text, value, callback )
|
||||
return self:addElement( ColorBarHue:new( bounds, text, value, callback ) )
|
||||
end
|
||||
|
||||
---@param bounds Rectangle
|
||||
---@param value integer
|
||||
---@param minValue integer
|
||||
---@param maxValue integer
|
||||
---@param callback function|nil
|
||||
---@return table ColorBarHue
|
||||
function Raygui:GuiScrollBar( bounds, value, minValue, maxValue, callback )
|
||||
return self:addElement( GuiScrollBar:new( bounds, value, minValue, maxValue, callback ) )
|
||||
end
|
||||
|
||||
return Raygui
|
||||
|
||||
@@ -1475,7 +1475,7 @@ static const char **GuiTextSplit(const char *text, char delimiter, int *count, i
|
||||
static Vector3 ConvertHSVtoRGB(Vector3 hsv); // Convert color data from HSV to RGB
|
||||
static Vector3 ConvertRGBtoHSV(Vector3 rgb); // Convert color data from RGB to HSV
|
||||
|
||||
static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue); // Scroll bar control, used by GuiScrollPanel()
|
||||
int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue); // Scroll bar control, used by GuiScrollPanel()
|
||||
static void GuiTooltip(Rectangle controlRec); // Draw tooltip using control rec position
|
||||
|
||||
static Color GuiFade(Color color, float alpha); // Fade color by an alpha factor
|
||||
@@ -5137,7 +5137,7 @@ static Vector3 ConvertHSVtoRGB(Vector3 hsv)
|
||||
}
|
||||
|
||||
// Scroll bar control (used by GuiScrollPanel())
|
||||
static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
|
||||
int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
|
||||
{
|
||||
GuiState state = guiState;
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ int lguiGuiProgressBar( lua_State *L );
|
||||
int lguiGuiStatusBar( lua_State *L );
|
||||
int lguiGuiDummyRec( lua_State *L );
|
||||
int lguiGuiGrid( lua_State *L );
|
||||
int lguiGuiScrollBar( lua_State *L );
|
||||
/* Advance controls set. */
|
||||
int lguiGuiListView( lua_State *L );
|
||||
int lguiGuiListViewEx( lua_State *L );
|
||||
|
||||
@@ -1940,6 +1940,7 @@ void luaRegister() {
|
||||
assingGlobalFunction( "GuiStatusBar", lguiGuiStatusBar );
|
||||
assingGlobalFunction( "GuiDummyRec", lguiGuiDummyRec );
|
||||
assingGlobalFunction( "GuiGrid", lguiGuiGrid );
|
||||
assingGlobalFunction( "GuiScrollBar", lguiGuiScrollBar );
|
||||
/* Advance controls set. */
|
||||
assingGlobalFunction( "GuiListView", lguiGuiListView );
|
||||
assingGlobalFunction( "GuiListViewEx", lguiGuiListViewEx );
|
||||
|
||||
18
src/rgui.c
18
src/rgui.c
@@ -764,6 +764,24 @@ int lguiGuiGrid( lua_State *L ) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
> value = RL.GuiScrollBar( Rectangle bounds, int value, int minValue, int maxValue )
|
||||
|
||||
Scroll bar control
|
||||
|
||||
- Success return int
|
||||
*/
|
||||
int lguiGuiScrollBar( lua_State *L ) {
|
||||
Rectangle bounds = uluaGetRectangle( L, 1 );
|
||||
int value = luaL_checkinteger( L, 2 );
|
||||
int minValue = luaL_checkinteger( L, 3 );
|
||||
int maxValue = luaL_checkinteger( L, 4 );
|
||||
|
||||
lua_pushinteger( L, GuiScrollBar( bounds, value, minValue, maxValue ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## Gui - Advance controls set
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user