File size: 4,729 Bytes
b6a38d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
-- ========== GENERATED BY XTemplate Editor (Alt-F3) DO NOT EDIT MANUALLY! ==========
PlaceObj('XTemplate', {
__is_kind_of = "XDarkModeAwareDialog",
group = "Editor",
id = "XEditorRoomTools",
save_in = "Libs/Volumes",
PlaceObj('XTemplateWindow', {
'__class', "XDarkModeAwareDialog",
'Dock', "right",
'FoldWhenHidden', true,
'Background', RGBA(64, 64, 66, 255),
'HandleMouse', true,
'FocusOnOpen', "",
}, {
PlaceObj('XTemplateWindow', {
'__class', "XScrollArea",
'Id', "idScrollArea",
'IdNode', false,
'LayoutMethod', "VList",
'VScroll', "idScroll",
}, {
PlaceObj('XTemplateWindow', {
'__class', "XToolBar",
'MaxWidth', 213,
'LayoutMethod', "VList",
'Background', RGBA(64, 64, 66, 255),
'Toolbar', "EditorRoomWallSelection",
'Show', "text",
'ButtonTemplate', "XEditorRoomToolsButton",
'ToggleButtonTemplate', "XEditorRoomToolsCheckbox",
'ToolbarSectionTemplate', "XEditorToolbarSection",
}, {
PlaceObj('XTemplateFunc', {
'name', "GetActionsHost(self)",
'func', function (self)
return XShortcutsTarget
end,
}),
}),
PlaceObj('XTemplateWindow', {
'__class', "XToolBar",
'Id', "idToolbar",
'LayoutMethod', "VList",
'Background', RGBA(64, 64, 66, 255),
'Toolbar', "EditorRoomTools",
'Show', "text",
'ButtonTemplate', "XEditorRoomToolsButton",
'ToggleButtonTemplate', "XEditorRoomToolsCheckbox",
'ToolbarSectionTemplate', "XEditorRoomToolsSection",
}, {
PlaceObj('XTemplateFunc', {
'name', "GetActionsHost(self)",
'func', function (self)
return XShortcutsTarget
end,
}),
}),
PlaceObj('XTemplateWindow', {
'__class', "XSleekScroll",
'Id', "idScroll",
'Dock', "right",
'MinWidth', 5,
'Target', "idScrollArea",
'AutoHide', true,
}),
}),
PlaceObj('XTemplateWindow', {
'__class', "XText",
'Dock', "bottom",
'Text', "Hold Ctrl for preview\nRight-click to edit programs",
'TextHAlign', "center",
}),
PlaceObj('XTemplateFunc', {
'comment', "highlight related actions, right-click disabled actions",
'name', "Open",
'func', function (self, ...)
self:CreateThread("Rollover", function()
local old_related = {}
local old_hovered_with_ctrl, just_executed
local selection_after_execute
while true do
Sleep(100)
local buttons = GetChildrenOfKind(self, "XTextButton")
for _, button in ipairs(buttons) do
button.Press = function(self, alt, force, gamepad)
if alt then
self:OnAltPress(gamepad) -- activate alt click even if button is disabled
elseif not alt and self.enabled and old_hovered_with_ctrl == self.action then
just_executed = self.action
old_hovered_with_ctrl = nil
editor.ClearSel()
editor.AddToSel(selection_after_execute)
else
XButton.Press(self, alt, force, gamepad)
end
end
end
for _, win in ipairs(old_related) do
win:SetTextStyle(GetDarkModeSetting() and "GedDefaultDarkMode" or "GedDefault")
end
local new_hovered_with_ctrl
local win = self:GetMouseTarget(terminal.GetMousePos())
if win and rawget(win, "action") and rawget(win.action, "GetRelatedActions") then
-- highlight related actions
local related = win.action:GetRelatedActions(XShortcutsTarget) or empty_table
related = table.map(related, function(action) return table.find_value(buttons, "action", action) end)
for _, win in ipairs(related) do win:SetTextStyle("GedHighlight") end
old_related = related
-- from action for speculative execution for a "preview" while holding Ctrl
if terminal.IsKeyPressed(const.vkControl) and win.enabled and win.action ~= just_executed then
new_hovered_with_ctrl = win.action
end
end
-- update "preview"
if new_hovered_with_ctrl ~= old_hovered_with_ctrl then
if old_hovered_with_ctrl then
local sel = editor.GetSel()
if selection_after_execute then
editor.ClearSel()
editor.AddToSel(selection_after_execute)
selection_after_execute = nil
end
XEditorUndo:UndoRedo("undo")
editor.ClearSel()
editor.AddToSel(sel)
end
if new_hovered_with_ctrl then
local sel = editor.GetSel()
GenExtras(new_hovered_with_ctrl.ActionId)
selection_after_execute = editor.GetSel()
editor.ClearSel()
editor.AddToSel(sel)
end
old_hovered_with_ctrl = new_hovered_with_ctrl
end
end
end)
XDarkModeAwareDialog.Open(self, ...)
end,
}),
}),
})
|