GetMouseOffset and GetMouseScale.
This commit is contained in:
16
API.md
16
API.md
@@ -5066,6 +5066,22 @@ Set mouse scaling
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> offset = RL.GetMouseOffset()
|
||||||
|
|
||||||
|
Get mouse offset
|
||||||
|
|
||||||
|
- Success return Vector2
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> scale = RL.GetMouseScale()
|
||||||
|
|
||||||
|
Get mouse scale
|
||||||
|
|
||||||
|
- Success return Vector2
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
> movement = RL.GetMouseWheelMove()
|
> movement = RL.GetMouseWheelMove()
|
||||||
|
|
||||||
Get mouse wheel movement for X or Y, whichever is larger
|
Get mouse wheel movement for X or Y, whichever is larger
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ List of some MISSING features that are planned to be included. For specific func
|
|||||||
|
|
||||||
* v0.8
|
* v0.8
|
||||||
* Thorough search for any missing raylib functions that should get implemented.
|
* Thorough search for any missing raylib functions that should get implemented.
|
||||||
|
* v0.9
|
||||||
|
* Move to raylib 5.5.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@@ -2309,6 +2309,16 @@ function RL.SetMouseOffset( offset ) end
|
|||||||
---@return any RL.SetMouseScale
|
---@return any RL.SetMouseScale
|
||||||
function RL.SetMouseScale( scale ) end
|
function RL.SetMouseScale( scale ) end
|
||||||
|
|
||||||
|
---Get mouse offset
|
||||||
|
---- Success return Vector2
|
||||||
|
---@return any offset
|
||||||
|
function RL.GetMouseOffset() end
|
||||||
|
|
||||||
|
---Get mouse scale
|
||||||
|
---- Success return Vector2
|
||||||
|
---@return any scale
|
||||||
|
function RL.GetMouseScale() end
|
||||||
|
|
||||||
---Get mouse wheel movement for X or Y, whichever is larger
|
---Get mouse wheel movement for X or Y, whichever is larger
|
||||||
---- Success return float
|
---- Success return float
|
||||||
---@return any movement
|
---@return any movement
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ DETAILED CHANGES:
|
|||||||
- CHANGE: Naming of gui functions set2Top and set2Back to setToTop and setToBack.
|
- CHANGE: Naming of gui functions set2Top and set2Back to setToTop and setToBack.
|
||||||
- FIXED: GuiGetIcons was returning just first int. Now returns a Buffer.
|
- FIXED: GuiGetIcons was returning just first int. Now returns a Buffer.
|
||||||
- ADDED: GuiSetIcons.
|
- ADDED: GuiSetIcons.
|
||||||
|
- ADDED: GetMouseOffset and GetMouseScale.
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
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
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ if table.unpack == nil then
|
|||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
end
|
end
|
||||||
|
|
||||||
local Vector3 = require( "vector3" )
|
local Vector3 = Vector3 or require( "vector3" )
|
||||||
|
|
||||||
local BoundingBox = {}
|
local BoundingBox = {}
|
||||||
local metatable = {
|
local metatable = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local Vec2 = require( "vector2" )
|
local Vector2 = Vector2 or require( "vector2" )
|
||||||
local Vec3 = require( "vector3" )
|
local Vector3 = Vector3 or require( "vector3" )
|
||||||
|
|
||||||
Camera3D = {}
|
Camera3D = {}
|
||||||
Camera3D.meta = {
|
Camera3D.meta = {
|
||||||
@@ -62,15 +62,15 @@ function Camera3D:setProjection( projection )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Camera3D:getPosition()
|
function Camera3D:getPosition()
|
||||||
return Vec3:newT( RL.GetCamera3DPosition( self.camera ) )
|
return Vector3:newT( RL.GetCamera3DPosition( self.camera ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Camera3D:getTarget()
|
function Camera3D:getTarget()
|
||||||
return Vec3:newT( RL.GetCamera3DTarget( self.camera ) )
|
return Vector3:newT( RL.GetCamera3DTarget( self.camera ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Camera3D:getUp()
|
function Camera3D:getUp()
|
||||||
return Vec3:newT( RL.GetCamera3DUp( self.camera ) )
|
return Vector3:newT( RL.GetCamera3DUp( self.camera ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Camera3D:getFoyv()
|
function Camera3D:getFoyv()
|
||||||
@@ -83,12 +83,12 @@ end
|
|||||||
|
|
||||||
--- Returns the cameras forward vector ( normalized )
|
--- Returns the cameras forward vector ( normalized )
|
||||||
function Camera3D:getForward()
|
function Camera3D:getForward()
|
||||||
return Vec3:newT( RL.GetCamera3DForward( self.camera ) )
|
return Vector3:newT( RL.GetCamera3DForward( self.camera ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the cameras up vector ( normalized ) Note: The up vector might not be perpendicular to the forward vector
|
--- Returns the cameras up vector ( normalized ) Note: The up vector might not be perpendicular to the forward vector
|
||||||
function Camera3D:getUpward()
|
function Camera3D:getUpward()
|
||||||
return Vec3:newT( RL.GetCamera3DUpNormalized( self.camera ) )
|
return Vector3:newT( RL.GetCamera3DUpNormalized( self.camera ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Camera3D:update( delta )
|
function Camera3D:update( delta )
|
||||||
@@ -96,7 +96,7 @@ function Camera3D:update( delta )
|
|||||||
|
|
||||||
if self.mode == self.MODES.FREE then
|
if self.mode == self.MODES.FREE then
|
||||||
if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_MIDDLE ) then
|
if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_MIDDLE ) then
|
||||||
local mouseDelta = Vec2:newT( RL.GetMouseDelta() )
|
local mouseDelta = Vector2:newT( RL.GetMouseDelta() )
|
||||||
|
|
||||||
if RL.IsKeyDown( self.KEYS.PAN ) then
|
if RL.IsKeyDown( self.KEYS.PAN ) then
|
||||||
mouseDelta = mouseDelta:scale( self.MOUSE_MOVE_SPEED * delta )
|
mouseDelta = mouseDelta:scale( self.MOUSE_MOVE_SPEED * delta )
|
||||||
@@ -119,13 +119,13 @@ function Camera3D:update( delta )
|
|||||||
RL.Camera3DMoveToTarget( self.camera, self.ZOOM_AMOUNT * self:getTargetDistance() * -mouseScroll )
|
RL.Camera3DMoveToTarget( self.camera, self.ZOOM_AMOUNT * self:getTargetDistance() * -mouseScroll )
|
||||||
end
|
end
|
||||||
elseif self.mode == self.MODES.FIRST_PERSON then
|
elseif self.mode == self.MODES.FIRST_PERSON then
|
||||||
local mouseDelta = Vec2:newT( RL.GetMouseDelta() )
|
local mouseDelta = Vector2:newT( RL.GetMouseDelta() )
|
||||||
|
|
||||||
mouseDelta = mouseDelta:scale( self.TURN_SPEED * delta )
|
mouseDelta = mouseDelta:scale( self.TURN_SPEED * delta )
|
||||||
|
|
||||||
RL.Camera3DYaw( self.camera, -mouseDelta.x, false )
|
RL.Camera3DYaw( self.camera, -mouseDelta.x, false )
|
||||||
RL.Camera3DPitch( self.camera, -mouseDelta.y, false, false, false )
|
RL.Camera3DPitch( self.camera, -mouseDelta.y, false, false, false )
|
||||||
RL.SetMousePosition( Vec2:newT( RL.GetScreenSize() ):scale( 0.5 ) )
|
RL.SetMousePosition( Vector2:newT( RL.GetScreenSize() ):scale( 0.5 ) )
|
||||||
|
|
||||||
local distance = self.KEYBOARD_MOVE_SPEED * delta
|
local distance = self.KEYBOARD_MOVE_SPEED * delta
|
||||||
local forward = RL.GetCamera3DForward( self.camera )[2]
|
local forward = RL.GetCamera3DForward( self.camera )[2]
|
||||||
@@ -162,9 +162,9 @@ end
|
|||||||
function Camera3D:draw()
|
function Camera3D:draw()
|
||||||
local targetPos = self:getTarget()
|
local targetPos = self:getTarget()
|
||||||
|
|
||||||
RL.DrawLine3D( targetPos + Vec3:new( -0.5, 0, 0 ), targetPos + Vec3:new( 0.5, 0, 0 ), RL.GREEN )
|
RL.DrawLine3D( targetPos + Vector3:new( -0.5, 0, 0 ), targetPos + Vector3:new( 0.5, 0, 0 ), RL.GREEN )
|
||||||
RL.DrawLine3D( targetPos + Vec3:new( 0, -0.5, 0 ), targetPos + Vec3:new( 0, 0.5, 0 ), RL.BLUE )
|
RL.DrawLine3D( targetPos + Vector3:new( 0, -0.5, 0 ), targetPos + Vector3:new( 0, 0.5, 0 ), RL.BLUE )
|
||||||
RL.DrawLine3D( targetPos + Vec3:new( 0, 0, -0.5 ), targetPos + Vec3:new( 0, 0, 0.5 ), RL.RED )
|
RL.DrawLine3D( targetPos + Vector3:new( 0, 0, -0.5 ), targetPos + Vector3:new( 0, 0, 0.5 ), RL.RED )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Camera3D:getTargetDistance()
|
function Camera3D:getTargetDistance()
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ if table.unpack == nil then
|
|||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
end
|
end
|
||||||
|
|
||||||
local Vector3 = require( "vector3" )
|
local Vector3 = Vector3 or require( "vector3" )
|
||||||
local Matrix = require( "matrix" )
|
local Matrix = Matrix or require( "matrix" )
|
||||||
|
|
||||||
local Quaternion = {}
|
local Quaternion = {}
|
||||||
local metatable = {
|
local metatable = {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
-- Wrapper for raygui.
|
-- Wrapper for raygui.
|
||||||
|
|
||||||
local Util = require( "utillib" )
|
local Util = Util or require( "utillib" )
|
||||||
local Rect = require( "rectangle" )
|
local Rectangle = Rectangle or require( "rectangle" )
|
||||||
local Vec2 = require( "vector2" )
|
local Vector2 = Vector2 or require( "vector2" )
|
||||||
local Color = require( "color" )
|
local Color = Color or require( "color" )
|
||||||
|
|
||||||
local function getItemCount( text )
|
local function getItemCount( text )
|
||||||
local count, rowItemCounts = 1, { 1 }
|
local count, rowItemCounts = 1, { 1 }
|
||||||
@@ -259,7 +259,7 @@ function ScrollPanel:new( bounds, text, content, scroll, callbacks, styles, tool
|
|||||||
object.text = text
|
object.text = text
|
||||||
object.content = content:clone()
|
object.content = content:clone()
|
||||||
object.scroll = scroll:clone()
|
object.scroll = scroll:clone()
|
||||||
object.view = Rect:new( 0, 0, 0, 0 )
|
object.view = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.callbacks = callbacks -- scroll, grab, drag.
|
object.callbacks = callbacks -- scroll, grab, drag.
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
@@ -507,8 +507,8 @@ function ToggleGroup:updateFocusBounds()
|
|||||||
|
|
||||||
for y, rowItemCount in ipairs( rowItemCounts ) do
|
for y, rowItemCount in ipairs( rowItemCounts ) do
|
||||||
for x = 1, rowItemCount do
|
for x = 1, rowItemCount do
|
||||||
local pos = Vec2:new( x - 1, y - 1 )
|
local pos = Vector2:new( x - 1, y - 1 )
|
||||||
local focusBound = Rect:new(
|
local focusBound = Rectangle:new(
|
||||||
self.bounds.x + pos.x * ( self.bounds.width + RL.GuiGetStyle( RL.TOGGLE, RL.GROUP_PADDING ) ),
|
self.bounds.x + pos.x * ( self.bounds.width + RL.GuiGetStyle( RL.TOGGLE, RL.GROUP_PADDING ) ),
|
||||||
self.bounds.y + pos.y * ( self.bounds.height + RL.GuiGetStyle( RL.TOGGLE, RL.GROUP_PADDING ) ),
|
self.bounds.y + pos.y * ( self.bounds.height + RL.GuiGetStyle( RL.TOGGLE, RL.GROUP_PADDING ) ),
|
||||||
self.bounds.width,
|
self.bounds.width,
|
||||||
@@ -581,10 +581,10 @@ function CheckBox:new( bounds, text, checked, callbacks, styles, tooltip )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
object.textBounds = Rect:new( 0, 0, 0, 0 )
|
object.textBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.focusBounds = bounds:clone()
|
object.focusBounds = bounds:clone()
|
||||||
|
|
||||||
object._focusBoundsOffset = Vec2:new( 0, 0 ) -- Used in set position.
|
object._focusBoundsOffset = Vector2:new( 0, 0 ) -- Used in set position.
|
||||||
object.styles = styles
|
object.styles = styles
|
||||||
object.tooltip = tooltip
|
object.tooltip = tooltip
|
||||||
|
|
||||||
@@ -758,10 +758,10 @@ function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbac
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
object.textBounds = Rect:new( 0, 0, 0, 0 )
|
object.textBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.viewBounds = bounds:clone()
|
object.viewBounds = bounds:clone()
|
||||||
|
|
||||||
object._viewBoundsOffset = Vec2:new( 0, 0 )
|
object._viewBoundsOffset = Vector2:new( 0, 0 )
|
||||||
object.styles = styles
|
object.styles = styles
|
||||||
object.tooltip = tooltip
|
object.tooltip = tooltip
|
||||||
|
|
||||||
@@ -829,10 +829,10 @@ function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callba
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
object.textBounds = Rect:new( 0, 0, 0, 0 )
|
object.textBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.viewBounds = bounds:clone()
|
object.viewBounds = bounds:clone()
|
||||||
|
|
||||||
object._viewBoundsOffset = Vec2:new( 0, 0 )
|
object._viewBoundsOffset = Vector2:new( 0, 0 )
|
||||||
object.styles = styles
|
object.styles = styles
|
||||||
object.tooltip = tooltip
|
object.tooltip = tooltip
|
||||||
|
|
||||||
@@ -949,11 +949,11 @@ function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, cal
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
object.textLeftBounds = Rect:new( 0, 0, 0, 0 )
|
object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.textRightBounds = Rect:new( 0, 0, 0, 0 )
|
object.textRightBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.viewBounds = bounds:clone()
|
object.viewBounds = bounds:clone()
|
||||||
|
|
||||||
object._viewBoundsOffset = Vec2:new( 0, 0 )
|
object._viewBoundsOffset = Vector2:new( 0, 0 )
|
||||||
object.styles = styles
|
object.styles = styles
|
||||||
object.tooltip = tooltip
|
object.tooltip = tooltip
|
||||||
|
|
||||||
@@ -1013,11 +1013,11 @@ function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue,
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
object.textLeftBounds = Rect:new( 0, 0, 0, 0 )
|
object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.textRightBounds = Rect:new( 0, 0, 0, 0 )
|
object.textRightBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.viewBounds = bounds:clone()
|
object.viewBounds = bounds:clone()
|
||||||
|
|
||||||
object._viewBoundsOffset = Vec2:new( 0, 0 )
|
object._viewBoundsOffset = Vector2:new( 0, 0 )
|
||||||
object.styles = styles
|
object.styles = styles
|
||||||
object.tooltip = tooltip
|
object.tooltip = tooltip
|
||||||
|
|
||||||
@@ -1077,11 +1077,11 @@ function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
object.textLeftBounds = Rect:new( 0, 0, 0, 0 )
|
object.textLeftBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.textRightBounds = Rect:new( 0, 0, 0, 0 )
|
object.textRightBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.viewBounds = bounds:clone()
|
object.viewBounds = bounds:clone()
|
||||||
|
|
||||||
object._viewBoundsOffset = Vec2:new( 0, 0 )
|
object._viewBoundsOffset = Vector2:new( 0, 0 )
|
||||||
object.styles = styles
|
object.styles = styles
|
||||||
object.tooltip = tooltip
|
object.tooltip = tooltip
|
||||||
|
|
||||||
@@ -1204,7 +1204,7 @@ function Grid:new( bounds, text, spacing, subdivs, callbacks, styles, tooltip )
|
|||||||
object.subdivs = subdivs
|
object.subdivs = subdivs
|
||||||
object.callbacks = callbacks -- cellChange.
|
object.callbacks = callbacks -- cellChange.
|
||||||
|
|
||||||
object.mouseCell = Vec2:new( 0, 0 )
|
object.mouseCell = Vector2:new( 0, 0 )
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
object.styles = styles
|
object.styles = styles
|
||||||
@@ -1455,7 +1455,7 @@ function ColorPicker:new( bounds, text, color, callbacks, styles, tooltip )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.disabled = false
|
object.disabled = false
|
||||||
object.focusBounds = Rect:new( 0, 0, 0, 0 )
|
object.focusBounds = Rectangle:new( 0, 0, 0, 0 )
|
||||||
object.styles = styles
|
object.styles = styles
|
||||||
object.tooltip = tooltip
|
object.tooltip = tooltip
|
||||||
|
|
||||||
@@ -1470,7 +1470,7 @@ function ColorPicker:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ColorPicker:updateFocusBounds()
|
function ColorPicker:updateFocusBounds()
|
||||||
local boundsHue = Rect:new(
|
local boundsHue = Rectangle:new(
|
||||||
self.bounds.x + self.bounds.width + RL.GuiGetStyle( RL.COLORPICKER, RL.HUEBAR_PADDING ),
|
self.bounds.x + self.bounds.width + RL.GuiGetStyle( RL.COLORPICKER, RL.HUEBAR_PADDING ),
|
||||||
self.bounds.y,
|
self.bounds.y,
|
||||||
RL.GuiGetStyle( RL.COLORPICKER, RL.HUEBAR_WIDTH ),
|
RL.GuiGetStyle( RL.COLORPICKER, RL.HUEBAR_WIDTH ),
|
||||||
@@ -1718,25 +1718,25 @@ function Raygui:new()
|
|||||||
object.controls = {}
|
object.controls = {}
|
||||||
object.focused = 0
|
object.focused = 0
|
||||||
object.dragging = nil
|
object.dragging = nil
|
||||||
object.grabPos = Vec2:new( 0, 0 )
|
object.grabPos = Vector2:new( 0, 0 )
|
||||||
object.scrolling = false
|
object.scrolling = false
|
||||||
object.textEdit = false
|
object.textEdit = false
|
||||||
object.textEditControl = nil
|
object.textEditControl = nil
|
||||||
object.defaultTexture = RL.GetTextureDefault()
|
object.defaultTexture = RL.GetTextureDefault()
|
||||||
object.defaultRect = Rect:new( 0, 0, 1, 1 ) -- For texture.
|
object.defaultRect = Rectangle:new( 0, 0, 1, 1 ) -- For texture.
|
||||||
object.defaultFont = RL.GuiGetFont()
|
object.defaultFont = RL.GuiGetFont()
|
||||||
object.mouseOffset = Vec2:new( 0, 0 )
|
object.mouseOffset = Vector2:new( 0, 0 )
|
||||||
object.view = Rect:new( 0, 0, 0, 0 ) -- Active if larger than 0. Then only controls in view will be updated and drawn.
|
object.view = Rectangle:new( 0, 0, 0, 0 ) -- Active if larger than 0. Then only controls in view will be updated and drawn.
|
||||||
object.tooltip = {
|
object.tooltip = {
|
||||||
text = nil,
|
text = nil,
|
||||||
offset = Vec2:new( 12, 24 ),
|
offset = Vector2:new( 12, 24 ),
|
||||||
delay = 0.5,
|
delay = 0.5,
|
||||||
timer = 0.0,
|
timer = 0.0,
|
||||||
focused = 0
|
focused = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
object._lastProperties = {}
|
object._lastProperties = {}
|
||||||
object._mousePressPos = Vec2:new( -1, -1 ) -- Use to check if release and check are inside bounds.
|
object._mousePressPos = Vector2:new( -1, -1 ) -- Use to check if release and check are inside bounds.
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
@@ -1784,7 +1784,7 @@ function Raygui:update()
|
|||||||
self.tooltip.timer = self.tooltip.timer + RL.GetFrameTime()
|
self.tooltip.timer = self.tooltip.timer + RL.GetFrameTime()
|
||||||
else
|
else
|
||||||
self.tooltip.text = control.tooltip
|
self.tooltip.text = control.tooltip
|
||||||
self.tooltip.position = Vec2:newT( RL.GetMousePosition() ) + self.tooltip.offset
|
self.tooltip.position = Vector2:newT( RL.GetMousePosition() ) + self.tooltip.offset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1802,12 +1802,12 @@ function Raygui:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:drag( control )
|
function Raygui:drag( control )
|
||||||
local mousePos = Vec2:tempT( RL.GetMousePosition() )
|
local mousePos = Vector2:tempT( RL.GetMousePosition() )
|
||||||
local mouseOver = RL.CheckCollisionPointRec( mousePos, control.bounds )
|
local mouseOver = RL.CheckCollisionPointRec( mousePos, control.bounds )
|
||||||
|
|
||||||
if not control.disabled and control.draggable and control ~= self.dragging and RL.IsMouseButtonPressed( RL.MOUSE_BUTTON_LEFT )
|
if not control.disabled and control.draggable and control ~= self.dragging and RL.IsMouseButtonPressed( RL.MOUSE_BUTTON_LEFT )
|
||||||
and mouseOver and mousePos.y - control.bounds.y <= self.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT then
|
and mouseOver and mousePos.y - control.bounds.y <= self.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT then
|
||||||
self.grabPos = mousePos - Vec2:temp( control.bounds.x, control.bounds.y )
|
self.grabPos = mousePos - Vector2:temp( control.bounds.x, control.bounds.y )
|
||||||
|
|
||||||
if control.callbacks.grab ~= nil then
|
if control.callbacks.grab ~= nil then
|
||||||
control.callbacks.grab( control )
|
control.callbacks.grab( control )
|
||||||
@@ -1843,17 +1843,17 @@ function Raygui:_addLastProperty( property )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:drawTooltip()
|
function Raygui:drawTooltip()
|
||||||
local textSize = Vec2:tempT( RL.MeasureTextEx(
|
local textSize = Vector2:tempT( RL.MeasureTextEx(
|
||||||
self.defaultFont,
|
self.defaultFont,
|
||||||
self.tooltip.text,
|
self.tooltip.text,
|
||||||
RL.GuiGetStyle( RL.DEFAULT, RL.TEXT_SIZE ),
|
RL.GuiGetStyle( RL.DEFAULT, RL.TEXT_SIZE ),
|
||||||
RL.GuiGetStyle( RL.DEFAULT, RL.TEXT_SPACING )
|
RL.GuiGetStyle( RL.DEFAULT, RL.TEXT_SPACING )
|
||||||
) )
|
) )
|
||||||
local tooltipRect = Rect:new( self.tooltip.position.x, self.tooltip.position.y, textSize.x, textSize.y )
|
local tooltipRect = Rectangle:new( self.tooltip.position.x, self.tooltip.position.y, textSize.x, textSize.y )
|
||||||
local view = self.view:clone()
|
local view = self.view:clone()
|
||||||
-- If no view size, clamp to window size.
|
-- If no view size, clamp to window size.
|
||||||
if view.width == 0 or view.height == 0 then
|
if view.width == 0 or view.height == 0 then
|
||||||
local screenSize = Vec2:tempT( RL.GetScreenSize() )
|
local screenSize = Vector2:tempT( RL.GetScreenSize() )
|
||||||
view.width = screenSize.x
|
view.width = screenSize.x
|
||||||
view.height = screenSize.y
|
view.height = screenSize.y
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ if table.unpack == nil then
|
|||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
end
|
end
|
||||||
|
|
||||||
local Vector2 = require( "vector2" )
|
local Vector2 = Vector2 or require( "vector2" )
|
||||||
|
|
||||||
local Rectangle = {}
|
local Rectangle = {}
|
||||||
local metatable = {
|
local metatable = {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ if table.unpack == nil then
|
|||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
end
|
end
|
||||||
|
|
||||||
local Vector2 = require( "vector2" )
|
local Vector2 = Vector2 or require( "vector2" )
|
||||||
|
|
||||||
local Vector3 = {}
|
local Vector3 = {}
|
||||||
local metatable = {
|
local metatable = {
|
||||||
|
|||||||
@@ -193,6 +193,8 @@ int lcoreGetMouseDelta( lua_State* L );
|
|||||||
int lcoreSetMousePosition( lua_State* L );
|
int lcoreSetMousePosition( lua_State* L );
|
||||||
int lcoreSetMouseOffset( lua_State* L );
|
int lcoreSetMouseOffset( lua_State* L );
|
||||||
int lcoreSetMouseScale( lua_State* L );
|
int lcoreSetMouseScale( lua_State* L );
|
||||||
|
int lcoreGetMouseOffset( lua_State* L );
|
||||||
|
int lcoreGetMouseScale( lua_State* L );
|
||||||
int lcoreGetMouseWheelMove( lua_State* L );
|
int lcoreGetMouseWheelMove( lua_State* L );
|
||||||
int lcoreGetMouseWheelMoveV( lua_State* L );
|
int lcoreGetMouseWheelMoveV( lua_State* L );
|
||||||
int lcoreSetMouseCursor( lua_State* L );
|
int lcoreSetMouseCursor( lua_State* L );
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ typedef struct {
|
|||||||
bool run;
|
bool run;
|
||||||
bool gcUnload;
|
bool gcUnload;
|
||||||
int lineSpacing; /* We need to store copy here since raylib has it in static. */
|
int lineSpacing; /* We need to store copy here since raylib has it in static. */
|
||||||
|
Vector2 mouseOffset;
|
||||||
|
Vector2 mouseScale;
|
||||||
lua_State* luaState;
|
lua_State* luaState;
|
||||||
Vector2 resolution;
|
Vector2 resolution;
|
||||||
int logLevelInvalid;
|
int logLevelInvalid;
|
||||||
|
|||||||
28
src/core.c
28
src/core.c
@@ -2585,6 +2585,7 @@ int lcoreSetMouseOffset( lua_State* L ) {
|
|||||||
Vector2 offset = uluaGetVector2( L, 1 );
|
Vector2 offset = uluaGetVector2( L, 1 );
|
||||||
|
|
||||||
SetMouseOffset( offset.x, offset.y );
|
SetMouseOffset( offset.x, offset.y );
|
||||||
|
state->mouseOffset = offset;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2598,10 +2599,37 @@ int lcoreSetMouseScale( lua_State* L ) {
|
|||||||
Vector2 scale = uluaGetVector2( L, 1 );
|
Vector2 scale = uluaGetVector2( L, 1 );
|
||||||
|
|
||||||
SetMouseScale( scale.x, scale.y );
|
SetMouseScale( scale.x, scale.y );
|
||||||
|
state->mouseScale = scale;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> offset = RL.GetMouseOffset()
|
||||||
|
|
||||||
|
Get mouse offset
|
||||||
|
|
||||||
|
- Success return Vector2
|
||||||
|
*/
|
||||||
|
int lcoreGetMouseOffset( lua_State* L ) {
|
||||||
|
uluaPushVector2( L, state->mouseOffset );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> scale = RL.GetMouseScale()
|
||||||
|
|
||||||
|
Get mouse scale
|
||||||
|
|
||||||
|
- Success return Vector2
|
||||||
|
*/
|
||||||
|
int lcoreGetMouseScale( lua_State* L ) {
|
||||||
|
uluaPushVector2( L, state->mouseScale );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> movement = RL.GetMouseWheelMove()
|
> movement = RL.GetMouseWheelMove()
|
||||||
|
|
||||||
|
|||||||
@@ -1455,6 +1455,8 @@ void luaRegister() {
|
|||||||
assingGlobalFunction( "SetMousePosition", lcoreSetMousePosition );
|
assingGlobalFunction( "SetMousePosition", lcoreSetMousePosition );
|
||||||
assingGlobalFunction( "SetMouseOffset", lcoreSetMouseOffset );
|
assingGlobalFunction( "SetMouseOffset", lcoreSetMouseOffset );
|
||||||
assingGlobalFunction( "SetMouseScale", lcoreSetMouseScale );
|
assingGlobalFunction( "SetMouseScale", lcoreSetMouseScale );
|
||||||
|
assingGlobalFunction( "GetMouseOffset", lcoreGetMouseOffset );
|
||||||
|
assingGlobalFunction( "GetMouseScale", lcoreGetMouseScale );
|
||||||
assingGlobalFunction( "GetMouseWheelMove", lcoreGetMouseWheelMove );
|
assingGlobalFunction( "GetMouseWheelMove", lcoreGetMouseWheelMove );
|
||||||
assingGlobalFunction( "GetMouseWheelMoveV", lcoreGetMouseWheelMoveV );
|
assingGlobalFunction( "GetMouseWheelMoveV", lcoreGetMouseWheelMoveV );
|
||||||
assingGlobalFunction( "SetMouseCursor", lcoreSetMouseCursor );
|
assingGlobalFunction( "SetMouseCursor", lcoreSetMouseCursor );
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ bool stateInit( int argn, const char** argc, const char* basePath ) {
|
|||||||
state->logLevelInvalid = LOG_ERROR;
|
state->logLevelInvalid = LOG_ERROR;
|
||||||
state->gcUnload = true;
|
state->gcUnload = true;
|
||||||
state->lineSpacing = 15;
|
state->lineSpacing = 15;
|
||||||
|
state->mouseOffset = (Vector2){ 0, 0 };
|
||||||
|
state->mouseScale = (Vector2){ 1, 1 };
|
||||||
|
|
||||||
InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
|
InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user