Some raygui controls return 1 instead of 0 when pressed or scrolled.
This commit is contained in:
@@ -64,6 +64,7 @@ DETAILED CHANGES:
|
|||||||
- CHANGE: Raymath *Equals functions return bool instead of int.
|
- CHANGE: Raymath *Equals functions return bool instead of int.
|
||||||
- FIXED: ColorToInt cast to unsigned int.
|
- FIXED: ColorToInt cast to unsigned int.
|
||||||
- ADDED: Many Gui controls accept now nil for text.
|
- ADDED: Many Gui controls accept now nil for text.
|
||||||
|
- ADDED: Some raygui controls return 1 instead of 0 when pressed or scrolled.
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
||||||
|
|||||||
1
devnotes
1
devnotes
@@ -3,7 +3,6 @@ Current {
|
|||||||
|
|
||||||
Backlog {
|
Backlog {
|
||||||
* Raygui
|
* Raygui
|
||||||
* GuiToggleSlider.
|
|
||||||
* ICON_ defines.
|
* ICON_ defines.
|
||||||
* Raygui lib
|
* Raygui lib
|
||||||
* Check if could remove flickering from changing draw order by making queue for order
|
* Check if could remove flickering from changing draw order by making queue for order
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ function RL.draw()
|
|||||||
|
|
||||||
_, comboBoxActive = RL.GuiComboBox( { 5, 150, 80, 20 }, "One;Two;Three", comboBoxActive )
|
_, comboBoxActive = RL.GuiComboBox( { 5, 150, 80, 20 }, "One;Two;Three", comboBoxActive )
|
||||||
|
|
||||||
result, scrollPanel.scroll, scrollPanel.view = RL.GuiScrollPanel(
|
_, scrollPanel.scroll, scrollPanel.view = RL.GuiScrollPanel(
|
||||||
{ 64, 640, 320, 200 },
|
{ 64, 640, 320, 200 },
|
||||||
"Scroll panel",
|
"Scroll panel",
|
||||||
{ 0, 0, 640, 400 },
|
{ 0, 0, 640, 400 },
|
||||||
|
|||||||
@@ -245,7 +245,8 @@ function RL.init()
|
|||||||
"Cat;Dog;Horse;Cow;Dog;Horse;Cow",
|
"Cat;Dog;Horse;Cow;Dog;Horse;Cow",
|
||||||
0,
|
0,
|
||||||
{ -- Callbacks.
|
{ -- Callbacks.
|
||||||
close = closeTab
|
close = closeTab,
|
||||||
|
select = function( self ) print( self:getItem( self.active ) ) end
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
local scrollpanel = Gui:ScrollPanel(
|
local scrollpanel = Gui:ScrollPanel(
|
||||||
|
|||||||
@@ -219,22 +219,23 @@ function GuiTabBar:update()
|
|||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
end
|
end
|
||||||
|
|
||||||
function GuiTabBar:draw()
|
function GuiTabBar:getItem( id )
|
||||||
local oldActive = self.active
|
return getItems( self.text )[ id + 1 ]
|
||||||
local result = -1
|
|
||||||
|
|
||||||
result, self.active = RL.GuiTabBar( self.bounds, self.text, self.active )
|
|
||||||
|
|
||||||
if self.active ~= oldActive then
|
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
|
||||||
self.active = oldActive
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GuiTabBar:draw()
|
||||||
|
local result, active = RL.GuiTabBar( self.bounds, self.text, self.active )
|
||||||
|
|
||||||
|
if self.active ~= active then
|
||||||
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
|
self.active = active
|
||||||
|
|
||||||
if self.callbacks.select ~= nil then
|
if self.callbacks.select ~= nil then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if 0 <= result and self.callbacks.close ~= nil and self._gui:clickedInBounds( self.bounds ) then
|
if 0 <= result and self.callbacks.close ~= nil and self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.callbacks.close( self, result )
|
self.callbacks.close( self, result )
|
||||||
end
|
end
|
||||||
@@ -276,12 +277,11 @@ function ScrollPanel:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ScrollPanel:draw()
|
function ScrollPanel:draw()
|
||||||
local oldScroll = self.scroll:clone()
|
local result, scroll, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
||||||
local _, scroll, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
|
||||||
self.view:setT( view )
|
self.view:setT( view )
|
||||||
self.scroll:setT( scroll )
|
self.scroll:setT( scroll )
|
||||||
|
|
||||||
if self.scroll ~= oldScroll then
|
if 0 < result then
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
|
||||||
if self.callbacks.scroll ~= nil then
|
if self.callbacks.scroll ~= nil then
|
||||||
@@ -438,15 +438,10 @@ function Toggle:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Toggle:draw()
|
function Toggle:draw()
|
||||||
local oldActive = self.active
|
local result, active = RL.GuiToggle( self.bounds, self.text, self.active )
|
||||||
|
|
||||||
_, self.active = RL.GuiToggle( self.bounds, self.text, self.active )
|
if 0 < result and self._gui:clickedInBounds( self.bounds ) then
|
||||||
|
self.active = active
|
||||||
if self.active ~= oldActive then
|
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
|
||||||
self.active = oldActive
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.callbacks.pressed ~= nil then
|
if self.callbacks.pressed ~= nil then
|
||||||
self.callbacks.pressed( self )
|
self.callbacks.pressed( self )
|
||||||
@@ -532,11 +527,9 @@ function ToggleGroup:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ToggleGroup:draw()
|
function ToggleGroup:draw()
|
||||||
local oldActive = self.active
|
local result, active = RL.GuiToggleGroup( self.bounds, self.text, self.active )
|
||||||
|
|
||||||
_, self.active = RL.GuiToggleGroup( self.bounds, self.text, self.active )
|
if 0 < result then
|
||||||
|
|
||||||
if self.active ~= oldActive then
|
|
||||||
local inBounds = false
|
local inBounds = false
|
||||||
|
|
||||||
for _, bounds in ipairs( self.focusBounds ) do
|
for _, bounds in ipairs( self.focusBounds ) do
|
||||||
@@ -545,17 +538,15 @@ function ToggleGroup:draw()
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if inBounds then
|
||||||
if not inBounds then
|
self.active = active
|
||||||
self.active = oldActive
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.callbacks.select ~= nil then
|
if self.callbacks.select ~= nil then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ToggleGroup:setPosition( pos )
|
function ToggleGroup:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -596,24 +587,21 @@ function CheckBox:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function CheckBox:draw()
|
function CheckBox:draw()
|
||||||
local oldChecked = self.checked
|
local result, checked, textBounds = RL.GuiCheckBox( self.bounds, self.text, self.checked )
|
||||||
local textBounds = nil
|
|
||||||
|
|
||||||
_, self.checked, textBounds = RL.GuiCheckBox( self.bounds, self.text, self.checked )
|
|
||||||
self.textBounds:setT( textBounds )
|
self.textBounds:setT( textBounds )
|
||||||
self.focusBounds = self.bounds:fit( self.textBounds )
|
self.focusBounds = self.bounds:fit( self.textBounds )
|
||||||
self._focusBoundsOffset:set( self.focusBounds.x - self.bounds.x, self.focusBounds.y - self.bounds.y )
|
self._focusBoundsOffset:set( self.focusBounds.x - self.bounds.x, self.focusBounds.y - self.bounds.y )
|
||||||
|
|
||||||
if self.checked ~= oldChecked then
|
if 0 < result then
|
||||||
if not self._gui:clickedInBounds( self.focusBounds ) then
|
if self._gui:clickedInBounds( self.focusBounds ) then
|
||||||
self.checked = oldChecked
|
self.checked = checked
|
||||||
end
|
|
||||||
|
|
||||||
if self.callbacks.pressed ~= nil then
|
if self.callbacks.pressed ~= nil then
|
||||||
self.callbacks.pressed( self )
|
self.callbacks.pressed( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function CheckBox:setPosition( pos )
|
function CheckBox:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -650,21 +638,18 @@ function ComboBox:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ComboBox:draw()
|
function ComboBox:draw()
|
||||||
local oldActive = self.active
|
local result, active = RL.GuiComboBox( self.bounds, self.text, self.active )
|
||||||
|
|
||||||
_, self.active = RL.GuiComboBox( self.bounds, self.text, self.active )
|
if 0 < result then
|
||||||
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
if self.active ~= oldActive then
|
self.active = active
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
|
||||||
self.active = oldActive
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.callbacks.select ~= nil then
|
if self.callbacks.select ~= nil then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ComboBox:setPosition( pos )
|
function ComboBox:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -777,11 +762,7 @@ function Spinner:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Spinner:draw()
|
function Spinner:draw()
|
||||||
local result = 0
|
local result, value, textBounds = RL.GuiSpinner( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
|
||||||
local oldValue = self.value
|
|
||||||
local textBounds
|
|
||||||
|
|
||||||
result, self.value, textBounds = RL.GuiSpinner( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
|
|
||||||
self.textBounds:setT( textBounds )
|
self.textBounds:setT( textBounds )
|
||||||
self.viewBounds = self.bounds:fit( self.textBounds )
|
self.viewBounds = self.bounds:fit( self.textBounds )
|
||||||
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
|
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
|
||||||
@@ -790,16 +771,16 @@ function Spinner:draw()
|
|||||||
self._gui:editMode( self )
|
self._gui:editMode( self )
|
||||||
self.editMode = not self.editMode
|
self.editMode = not self.editMode
|
||||||
end
|
end
|
||||||
if self.value ~= oldValue then
|
if self.value ~= value then
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.value = oldValue
|
self.value = value
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit ~= nil then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Spinner:setPosition( pos )
|
function Spinner:setPosition( pos )
|
||||||
@@ -965,26 +946,23 @@ function Slider:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Slider:draw()
|
function Slider:draw()
|
||||||
local oldValue, textLeftBounds, textRightBounds = self.value, nil, nil
|
local result, value, textLeftBounds, textRightBounds = RL.GuiSlider( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
||||||
|
|
||||||
_, self.value, textLeftBounds, textRightBounds = RL.GuiSlider( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
|
||||||
self.textLeftBounds:setT( textLeftBounds )
|
self.textLeftBounds:setT( textLeftBounds )
|
||||||
self.textRightBounds:setT( textRightBounds )
|
self.textRightBounds:setT( textRightBounds )
|
||||||
self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds )
|
self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds )
|
||||||
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
|
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
|
||||||
|
|
||||||
if self.value ~= oldValue then
|
if 0 < result then
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.value = oldValue
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit ~= nil then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Slider:setPosition( pos )
|
function Slider:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -1029,26 +1007,23 @@ function SliderBar:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SliderBar:draw()
|
function SliderBar:draw()
|
||||||
local oldValue, textLeftBounds, textRightBounds = self.value, nil, nil
|
local result, value, textLeftBounds, textRightBounds = RL.GuiSliderBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
||||||
|
|
||||||
_, self.value, textLeftBounds, textRightBounds = RL.GuiSliderBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
|
||||||
self.textLeftBounds:setT( textLeftBounds )
|
self.textLeftBounds:setT( textLeftBounds )
|
||||||
self.textRightBounds:setT( textRightBounds )
|
self.textRightBounds:setT( textRightBounds )
|
||||||
self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds )
|
self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds )
|
||||||
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
|
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
|
||||||
|
|
||||||
if self.value ~= oldValue then
|
if 0 < result then
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.value = oldValue
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit ~= nil then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function SliderBar:setPosition( pos )
|
function SliderBar:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -1093,25 +1068,22 @@ function ProgressBar:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ProgressBar:draw()
|
function ProgressBar:draw()
|
||||||
local oldValue, textLeftBounds, textRightBounds = self.value, nil, nil
|
local result, value, textLeftBounds, textRightBounds = RL.GuiProgressBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
||||||
|
|
||||||
_, self.value, textLeftBounds, textRightBounds = RL.GuiProgressBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
|
||||||
self.textLeftBounds:setT( textLeftBounds )
|
self.textLeftBounds:setT( textLeftBounds )
|
||||||
self.textRightBounds:setT( textRightBounds )
|
self.textRightBounds:setT( textRightBounds )
|
||||||
self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds )
|
self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds )
|
||||||
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
|
self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y )
|
||||||
|
|
||||||
if self.value ~= oldValue then
|
if 0 < result then
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.value = oldValue
|
self.value = value
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit ~= nil then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ProgressBar:setPosition( pos )
|
function ProgressBar:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -1218,13 +1190,10 @@ function Grid:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Grid:draw()
|
function Grid:draw()
|
||||||
local oldCell = self.mouseCell:clone()
|
local result, mouseCell = RL.GuiGrid( self.bounds, self.text, self.spacing, self.subdivs, self.mouseCell )
|
||||||
local mouseCell = {}
|
|
||||||
|
|
||||||
_, mouseCell = RL.GuiGrid( self.bounds, self.text, self.spacing, self.subdivs, self.mouseCell )
|
|
||||||
self.mouseCell:setT( mouseCell )
|
self.mouseCell:setT( mouseCell )
|
||||||
|
|
||||||
if oldCell ~= self.mouseCell and self.callbacks.cellChange ~= nil then
|
if 0 < result and self.callbacks.cellChange ~= nil then
|
||||||
self.callbacks.cellChange( self )
|
self.callbacks.cellChange( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1271,15 +1240,14 @@ function ListView:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ListView:draw()
|
function ListView:draw()
|
||||||
local oldActive = self.active
|
local result, oldScrollIndex = 0, self.scrollIndex
|
||||||
local oldScrollIndex = self.scrollIndex
|
|
||||||
|
|
||||||
_, self.scrollIndex, self.active = RL.GuiListView( self.bounds, self.text, self.scrollIndex, self.active )
|
result, self.scrollIndex, self.active = RL.GuiListView( self.bounds, self.text, self.scrollIndex, self.active )
|
||||||
|
|
||||||
if self.scrollIndex ~= oldScrollIndex then
|
if self.scrollIndex ~= oldScrollIndex then
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
end
|
end
|
||||||
if oldActive ~= self.active and self.callbacks.select ~= nil then
|
if 0 < result and self.callbacks.select ~= nil then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1323,15 +1291,14 @@ function ListViewEx:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ListViewEx:draw()
|
function ListViewEx:draw()
|
||||||
local oldActive = self.active
|
local result, oldScrollIndex = 0, self.scrollIndex
|
||||||
local oldScrollIndex = self.scrollIndex
|
|
||||||
|
|
||||||
_, self.scrollIndex, self.active, self.focus = RL.GuiListViewEx( self.bounds, self.text, self.scrollIndex, self.active, self.focus )
|
result, self.scrollIndex, self.active, self.focus = RL.GuiListViewEx( self.bounds, self.text, self.scrollIndex, self.active, self.focus )
|
||||||
|
|
||||||
if self.scrollIndex ~= oldScrollIndex then
|
if self.scrollIndex ~= oldScrollIndex then
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
end
|
end
|
||||||
if oldActive ~= self.active and self.callbacks.select ~= nil then
|
if 0 < result and self.callbacks.select ~= nil then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1480,15 +1447,11 @@ function ColorPicker:updateFocusBounds()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ColorPicker:draw()
|
function ColorPicker:draw()
|
||||||
local oldColor = self.color:clone()
|
local result, color = RL.GuiColorPicker( self.bounds, self.text, self.color )
|
||||||
local _, color = RL.GuiColorPicker( self.bounds, self.text, self.color )
|
|
||||||
|
|
||||||
|
if 0 < result then
|
||||||
|
if self._gui:clickedInBounds( self.focusBounds ) then
|
||||||
self.color = Color:newT( color )
|
self.color = Color:newT( color )
|
||||||
|
|
||||||
if self.color ~= oldColor then
|
|
||||||
if not self._gui:clickedInBounds( self.focusBounds ) then
|
|
||||||
self.color = oldColor
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
|
||||||
@@ -1532,22 +1495,18 @@ function ColorPanel:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ColorPanel:draw()
|
function ColorPanel:draw()
|
||||||
local oldColor = self.color:clone()
|
local result, color = RL.GuiColorPanel( self.bounds, self.text, self.color )
|
||||||
local _, color = RL.GuiColorPanel( self.bounds, self.text, self.color )
|
|
||||||
|
|
||||||
self.color = Color:newT( color )
|
if 0 < result then
|
||||||
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
if oldColor ~= self.color then
|
self.color:setT( color )
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
|
||||||
self.color = oldColor
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit ~= nil then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ColorPanel:setPosition( pos )
|
function ColorPanel:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -1582,21 +1541,19 @@ function ColorBarAlpha:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ColorBarAlpha:draw()
|
function ColorBarAlpha:draw()
|
||||||
local oldAlpha = self.alpha
|
local result, alpha = RL.GuiColorBarAlpha( self.bounds, self.text, self.alpha )
|
||||||
_, self.alpha = RL.GuiColorBarAlpha( self.bounds, self.text, self.alpha )
|
|
||||||
|
|
||||||
if self.alpha ~= oldAlpha then
|
if 0 < result then
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.alpha = oldAlpha
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
self.alpha = alpha
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit ~= nil then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ColorBarAlpha:setPosition( pos )
|
function ColorBarAlpha:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -1631,21 +1588,19 @@ function ColorBarHue:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ColorBarHue:draw()
|
function ColorBarHue:draw()
|
||||||
local oldValue = self.value
|
local result, value = RL.GuiColorBarHue( self.bounds, self.text, self.value )
|
||||||
_, self.value = RL.GuiColorBarHue( self.bounds, self.text, self.value )
|
|
||||||
|
|
||||||
if self.value ~= oldValue then
|
if 0 < result then
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.value = oldValue
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit ~= nil then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ColorBarHue:setPosition( pos )
|
function ColorBarHue:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = pos.x
|
||||||
@@ -1666,7 +1621,7 @@ function GuiScrollBar:new( bounds, value, minValue, maxValue, callbacks, styles,
|
|||||||
object.value = value
|
object.value = value
|
||||||
object.minValue = minValue
|
object.minValue = minValue
|
||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.callbacks = callbacks -- edit.
|
object.callbacks = callbacks -- scroll.
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
@@ -1681,19 +1636,17 @@ function GuiScrollBar:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function GuiScrollBar:draw()
|
function GuiScrollBar:draw()
|
||||||
local oldValue = self.value
|
|
||||||
-- Note. Scrollbar style should be determined by the control that uses it.
|
-- Note. Scrollbar style should be determined by the control that uses it.
|
||||||
self.value = RL.GuiScrollBar( self.bounds, self.value, self.minValue, self.maxValue )
|
local value = RL.GuiScrollBar( self.bounds, self.value, self.minValue, self.maxValue )
|
||||||
|
|
||||||
if self.value ~= oldValue then
|
if self.value ~= value then
|
||||||
if not self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.value = oldValue
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.scroll ~= nil then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.scroll( self )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1775,6 +1775,7 @@ int GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector
|
|||||||
Rectangle temp = { 0 };
|
Rectangle temp = { 0 };
|
||||||
if (view == NULL) view = &temp;
|
if (view == NULL) view = &temp;
|
||||||
|
|
||||||
|
Vector2 oldScroll = *scroll;
|
||||||
Vector2 scrollPos = { 0.0f, 0.0f };
|
Vector2 scrollPos = { 0.0f, 0.0f };
|
||||||
if (scroll != NULL) scrollPos = *scroll;
|
if (scroll != NULL) scrollPos = *scroll;
|
||||||
|
|
||||||
@@ -1921,7 +1922,7 @@ int GuiScrollPanel(Rectangle bounds, const char *text, Rectangle content, Vector
|
|||||||
|
|
||||||
if (scroll != NULL) *scroll = scrollPos;
|
if (scroll != NULL) *scroll = scrollPos;
|
||||||
|
|
||||||
return result;
|
return !Vector2Equals( oldScroll, scrollPos );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label control
|
// Label control
|
||||||
@@ -2035,6 +2036,7 @@ int GuiToggle(Rectangle bounds, const char *text, bool *active)
|
|||||||
{
|
{
|
||||||
state = STATE_NORMAL;
|
state = STATE_NORMAL;
|
||||||
*active = !(*active);
|
*active = !(*active);
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
else state = STATE_FOCUSED;
|
else state = STATE_FOCUSED;
|
||||||
}
|
}
|
||||||
@@ -2094,13 +2096,18 @@ int GuiToggleGroup(Rectangle bounds, const char *text, int *active)
|
|||||||
if (i == (*active))
|
if (i == (*active))
|
||||||
{
|
{
|
||||||
toggle = true;
|
toggle = true;
|
||||||
GuiToggle(bounds, items[i], &toggle);
|
if ( GuiToggle( bounds, items[i], &toggle ) ) {
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
toggle = false;
|
toggle = false;
|
||||||
GuiToggle( bounds, items[i], &toggle );
|
GuiToggle( bounds, items[i], &toggle );
|
||||||
if (toggle) *active = i;
|
if (toggle) {
|
||||||
|
*active = i;
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds.x += (bounds.width + GuiGetStyle(TOGGLE, GROUP_PADDING));
|
bounds.x += (bounds.width + GuiGetStyle(TOGGLE, GROUP_PADDING));
|
||||||
@@ -2221,7 +2228,10 @@ int GuiCheckBox(Rectangle bounds, const char *text, bool *checked, Rectangle *te
|
|||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
|
||||||
else state = STATE_FOCUSED;
|
else state = STATE_FOCUSED;
|
||||||
|
|
||||||
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) *checked = !(*checked);
|
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) {
|
||||||
|
*checked = !(*checked);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
@@ -2280,6 +2290,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int *active)
|
|||||||
{
|
{
|
||||||
*active += 1;
|
*active += 1;
|
||||||
if (*active >= itemCount) *active = 0; // Cyclic combobox
|
if (*active >= itemCount) *active = 0; // Cyclic combobox
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
|
||||||
@@ -2969,6 +2980,7 @@ int GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight,
|
|||||||
|
|
||||||
// Get equivalent value and slider position from mousePosition.x
|
// Get equivalent value and slider position from mousePosition.x
|
||||||
*value = ((maxValue - minValue)*(mousePoint.x - (float)(bounds.x + sliderWidth/2)))/(float)(bounds.width - sliderWidth) + minValue;
|
*value = ((maxValue - minValue)*(mousePoint.x - (float)(bounds.x + sliderWidth/2)))/(float)(bounds.width - sliderWidth) + minValue;
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3253,6 +3265,7 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *scrollInd
|
|||||||
{
|
{
|
||||||
if (itemSelected == (startIndex + i)) itemSelected = -1;
|
if (itemSelected == (startIndex + i)) itemSelected = -1;
|
||||||
else itemSelected = startIndex + i;
|
else itemSelected = startIndex + i;
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3401,7 +3414,7 @@ int GuiColorPanel(Rectangle bounds, const char *text, Color *color)
|
|||||||
(unsigned char)(255.0f*rgb.y),
|
(unsigned char)(255.0f*rgb.y),
|
||||||
(unsigned char)(255.0f*rgb.z),
|
(unsigned char)(255.0f*rgb.z),
|
||||||
(unsigned char)(255.0f*(float)color->a/255.0f) };
|
(unsigned char)(255.0f*(float)color->a/255.0f) };
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
else state = STATE_FOCUSED;
|
else state = STATE_FOCUSED;
|
||||||
}
|
}
|
||||||
@@ -3459,6 +3472,7 @@ int GuiColorBarAlpha(Rectangle bounds, const char *text, float *alpha)
|
|||||||
*alpha = (mousePoint.x - bounds.x)/bounds.width;
|
*alpha = (mousePoint.x - bounds.x)/bounds.width;
|
||||||
if (*alpha <= 0.0f) *alpha = 0.0f;
|
if (*alpha <= 0.0f) *alpha = 0.0f;
|
||||||
if (*alpha >= 1.0f) *alpha = 1.0f;
|
if (*alpha >= 1.0f) *alpha = 1.0f;
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3545,6 +3559,7 @@ int GuiColorBarHue(Rectangle bounds, const char *text, float *hue)
|
|||||||
*hue = (mousePoint.y - bounds.y)*360/bounds.height;
|
*hue = (mousePoint.y - bounds.y)*360/bounds.height;
|
||||||
if (*hue <= 0.0f) *hue = 0.0f;
|
if (*hue <= 0.0f) *hue = 0.0f;
|
||||||
if (*hue >= 359.0f) *hue = 359.0f;
|
if (*hue >= 359.0f) *hue = 359.0f;
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3619,14 +3634,18 @@ int GuiColorPicker(Rectangle bounds, const char *text, Color *color)
|
|||||||
Color temp = { 200, 0, 0, 255 };
|
Color temp = { 200, 0, 0, 255 };
|
||||||
if (color == NULL) color = &temp;
|
if (color == NULL) color = &temp;
|
||||||
|
|
||||||
GuiColorPanel(bounds, NULL, color);
|
if ( GuiColorPanel(bounds, NULL, color) ) {
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
|
Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
|
||||||
//Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) };
|
//Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) };
|
||||||
|
|
||||||
Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ (*color).r/255.0f, (*color).g/255.0f, (*color).b/255.0f });
|
Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ (*color).r/255.0f, (*color).g/255.0f, (*color).b/255.0f });
|
||||||
|
|
||||||
GuiColorBarHue(boundsHue, NULL, &hsv.x);
|
if ( GuiColorBarHue(boundsHue, NULL, &hsv.x) ) {
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
//color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f);
|
//color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f);
|
||||||
Vector3 rgb = ConvertHSVtoRGB(hsv);
|
Vector3 rgb = ConvertHSVtoRGB(hsv);
|
||||||
@@ -3656,11 +3675,15 @@ int GuiColorPickerHSV(Rectangle bounds, const char *text, Vector3 *colorHsv)
|
|||||||
colorHsv = &tempHsv;
|
colorHsv = &tempHsv;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiColorPanelHSV(bounds, NULL, colorHsv);
|
if ( GuiColorPanelHSV(bounds, NULL, colorHsv) ) {
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
const Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
|
const Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
|
||||||
|
|
||||||
GuiColorBarHue(boundsHue, NULL, &colorHsv->x);
|
if ( GuiColorBarHue(boundsHue, NULL, &colorHsv->x) ) {
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -3707,6 +3730,7 @@ int GuiColorPanelHSV(Rectangle bounds, const char *text, Vector3 *colorHsv)
|
|||||||
|
|
||||||
colorHsv->y = colorPick.x;
|
colorHsv->y = colorPick.x;
|
||||||
colorHsv->z = 1.0f - colorPick.y;
|
colorHsv->z = 1.0f - colorPick.y;
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
else state = STATE_FOCUSED;
|
else state = STATE_FOCUSED;
|
||||||
}
|
}
|
||||||
@@ -3908,6 +3932,7 @@ int GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs, Vect
|
|||||||
// NOTE: Cell values must be the upper left of the cell the mouse is in
|
// NOTE: Cell values must be the upper left of the cell the mouse is in
|
||||||
currentMouseCell.x = floorf((mousePoint.x - bounds.x)/spacing);
|
currentMouseCell.x = floorf((mousePoint.x - bounds.x)/spacing);
|
||||||
currentMouseCell.y = floorf((mousePoint.y - bounds.y)/spacing);
|
currentMouseCell.y = floorf((mousePoint.y - bounds.y)/spacing);
|
||||||
|
result = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user