Skip to content

Commit

Permalink
[ColorPicker]
Browse files Browse the repository at this point in the history
Options to set the initial position.

[SlabDebug]
Modify the color picker's position with the style editor.

[Window]
GetWindowPosition now returns the Y coordinate that includes the title offset.
  • Loading branch information
coding-jackalope committed Jun 18, 2020
1 parent fcbccab commit 6444ec1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Internal/UI/ColorPicker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ function ColorPicker.Begin(Options)
Options = Options == nil and {} or Options
Options.Color = Options.Color == nil and {1.0, 1.0, 1.0, 1.0} or Options.Color
Options.Refresh = Options.Refresh == nil and false or Options.Refresh
Options.X = Options.X == nil and nil or Options.X
Options.Y = Options.Y == nil and nil or Options.Y

if SaturationMeshes == nil then
InitializeSaturationMeshes()
Expand All @@ -268,7 +270,7 @@ function ColorPicker.Begin(Options)
InitializeAlphaMesh()
end

Window.Begin('ColorPicker', {Title = "Color Picker"})
Window.Begin('ColorPicker', {Title = "Color Picker", X = Options.X, Y = Options.Y})

if Window.IsAppearing() or Options.Refresh then
CurrentColor[1] = Options.Color[1]
Expand Down
6 changes: 5 additions & 1 deletion Internal/UI/Window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,11 @@ end

function Window.GetPosition()
if ActiveInstance ~= nil then
return ActiveInstance.X, ActiveInstance.Y
local X, Y = ActiveInstance.X, ActiveInstance.Y
if ActiveInstance.Title ~= "" then
Y = Y - Style.Font:getHeight()
end
return X, Y
end
return 0.0, 0.0
end
Expand Down
4 changes: 3 additions & 1 deletion SlabDebug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ end

local function DrawStyleEditor()
Slab.BeginWindow('SlabDebug_StyleEditor', SlabDebug_StyleEditor)
local X, Y = Slab.GetWindowPosition()
local W, H = Slab.GetWindowSize()

local Style = Slab.GetStyle()
local Names = Style.API.GetStyleNames()
Expand Down Expand Up @@ -289,7 +291,7 @@ local function DrawStyleEditor()
Slab.EndWindow()

if Style_EditingColor ~= nil then
local Result = Slab.ColorPicker({Color = Style_ColorStore, Refresh = Refresh})
local Result = Slab.ColorPicker({Color = Style_ColorStore, X = X + W, Y = Y})
Style_EditingColor[1] = Result.Color[1]
Style_EditingColor[2] = Result.Color[2]
Style_EditingColor[3] = Result.Color[3]
Expand Down
1 change: 0 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
v0.7.0 RELEASE
==========
[Color Picker]: Set initial position.
[Dock]: Initial implementation of docking.
[Text]: Support for HTTP link.
[Bug]: Issue #20
Expand Down

0 comments on commit 6444ec1

Please sign in to comment.