-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release Docker placeholders v1.0 (#1212)
- Loading branch information
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
-- @description Docker placeholders | ||
-- @author cfillion | ||
-- @version 1.0 | ||
-- @link Request thread https://forum.cockos.com/showthread.php?p=2693350 | ||
-- @screenshot https://i.imgur.com/UxnT1pp.gif | ||
-- @donation https://reapack.com/donate | ||
-- @about | ||
-- # Docker placeholders | ||
-- | ||
-- Open a placeholder window in any of REAPER's 16 dockers. | ||
|
||
local positions, placeholders = { | ||
[-1]='not found', | ||
[ 0]='bottom', | ||
[ 1]='left', | ||
[ 2]='top', | ||
[ 3]='right', | ||
[ 4]='floating' | ||
}, {} | ||
|
||
dofile(reaper.GetResourcePath() .. | ||
'/Scripts/ReaTeam Extensions/API/imgui.lua')('0.8') | ||
|
||
local ImGui = {} | ||
for name, func in pairs(reaper) do | ||
name = name:match('^ImGui_(.+)$') | ||
if name then ImGui[name] = func end | ||
end | ||
|
||
local ctx = ImGui.CreateContext('Docker placeholder') | ||
|
||
local function checkbox(id) | ||
local pos, toggled = positions[reaper.DockGetPosition(id)] | ||
local label = ('Docker %02d: %s'):format(id + 1, pos) | ||
toggled, placeholders[id] = ImGui.Checkbox(ctx, label, placeholders[id]) | ||
end | ||
|
||
local function placeholder(id) | ||
ImGui.SetNextWindowDockID(ctx, ~id) | ||
local label = ('Docker %d'):format(id + 1) | ||
local visible, open = ImGui.Begin(ctx, label, true, | ||
ImGui.WindowFlags_NoSavedSettings() | | ||
ImGui.WindowFlags_NoFocusOnAppearing()) | ||
if visible then | ||
ImGui.Text(ctx, label) | ||
ImGui.End(ctx) | ||
end | ||
if not open then | ||
placeholders[id] = false | ||
end | ||
end | ||
|
||
function loop() | ||
local visible, open = ImGui.Begin(ctx, 'Docker placeholders', true, | ||
ImGui.WindowFlags_AlwaysAutoResize()) | ||
if visible then | ||
ImGui.TextWrapped(ctx, 'Click on a docker in the list below to open a placeholder window in that docker.') | ||
ImGui.Spacing(ctx) | ||
ImGui.PushStyleVar(ctx, ImGui.StyleVar_FramePadding(), 0, 0) | ||
for i=0,15 do checkbox(i) end | ||
ImGui.PopStyleVar(ctx) | ||
ImGui.End(ctx) | ||
end | ||
|
||
for id, checked in pairs(placeholders) do | ||
if checked then placeholder(id) end | ||
end | ||
|
||
if open then | ||
reaper.defer(loop) | ||
end | ||
end | ||
|
||
reaper.defer(loop) |