Framework update

This commit is contained in:
Tercio Jose
2020-02-25 22:39:46 -03:00
parent 5d371f4e94
commit ff5cccb40c
4 changed files with 122 additions and 38 deletions
+73 -15
View File
@@ -1072,8 +1072,15 @@ function TextEntryMetaFunctions:SetAsAutoComplete (poolName, poolTable, shouldOp
end
function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent)
local set_speciallua_editor_font_size = function(borderFrame, newSize)
local file, size, flags = borderFrame.editbox:GetFont()
borderFrame.editbox:SetFont (file, newSize, flags)
borderFrame.editboxlines:SetFont (file, newSize, flags)
end
function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, showLineNumbers)
if (name:find ("$parent")) then
local parentName = DF.GetParentName (parent)
name = name:gsub ("$parent", parentName)
@@ -1087,32 +1094,82 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent)
end
local scrollframe = CreateFrame ("ScrollFrame", name, borderframe, "UIPanelScrollFrameTemplate")
scrollframe:SetSize (232, 20)
local scrollframeNumberLines = CreateFrame ("ScrollFrame", name .. "NumberLines", borderframe, "UIPanelScrollFrameTemplate")
scrollframe.editbox = CreateFrame ("editbox", "$parentEditBox", scrollframe)
scrollframe.editbox:SetMultiLine (true)
scrollframe.editbox:SetAutoFocus (false)
scrollframe.editbox:SetSize (232, 20)
scrollframe.editbox:SetAllPoints()
scrollframe.editbox:SetScript ("OnCursorChanged", _G.ScrollingEdit_OnCursorChanged)
scrollframe.editbox:SetScript ("OnEscapePressed", _G.EditBox_ClearFocus)
scrollframe.editbox:SetFontObject ("GameFontHighlightSmall")
scrollframe:SetScrollChild (scrollframe.editbox)
--letters="255"
--countInvisibleLetters="true"
--line number
if (showLineNumbers) then
scrollframeNumberLines.editbox = CreateFrame ("editbox", "$parentLineNumbers", scrollframeNumberLines)
scrollframeNumberLines.editbox:SetMultiLine (true)
scrollframeNumberLines.editbox:SetAutoFocus (false)
scrollframeNumberLines.editbox:SetFontObject ("GameFontHighlightSmall")
scrollframeNumberLines.editbox:SetJustifyH ("left")
scrollframeNumberLines.editbox:SetJustifyV ("top")
scrollframeNumberLines.editbox:SetTextColor(.3, .3, .3, .5)
scrollframeNumberLines.editbox:SetPoint ("topleft", borderframe, "topleft", 10, -10)
scrollframeNumberLines.editbox:SetPoint ("bottomright", borderframe, "bottomright", -30, 10)
scrollframeNumberLines:SetScrollChild (scrollframeNumberLines.editbox)
for i = 1, 1000 do
scrollframeNumberLines.editbox:Insert (i .. "\n")
end
--place the lua code field 20 pixels to the right to make run to the lines scroll
scrollframe:SetPoint ("topleft", borderframe, "topleft", 30, -10)
scrollframe:SetPoint ("bottomright", borderframe, "bottomright", -10, 10)
--when the lua code field scrolls, make the lua field scroll too
scrollframe:SetScript ("OnVerticalScroll", function (self, offset)
scrollframeNumberLines:SetVerticalScroll(scrollframe:GetVerticalScroll())
scrollframeNumberLines.ScrollBar:Hide()
end)
--place the number lines scroll in the begining of the editing code space
scrollframeNumberLines:SetPoint ("topleft", borderframe, "topleft", 10, -10)
scrollframeNumberLines:SetPoint ("bottomright", borderframe, "bottomright", -10, 10)
scrollframeNumberLines.editbox:SetJustifyH ("left")
scrollframeNumberLines.editbox:SetJustifyV ("top")
scrollframeNumberLines:SetScript ("OnSizeChanged", function (self)
scrollframeNumberLines.editbox:SetSize (self:GetSize())
scrollframeNumberLines.ScrollBar:Hide()
end)
scrollframeNumberLines.ScrollBar:HookScript("OnShow", function(self)
self:Hide()
end)
borderframe.scrollnumberlines = scrollframeNumberLines
borderframe.editboxlines = scrollframeNumberLines.editbox
borderframe.editboxlines.borderframe = borderframe
scrollframeNumberLines.ScrollBar:Hide()
scrollframeNumberLines:SetBackdrop(nil)
scrollframeNumberLines.editbox:SetBackdrop(nil)
else
scrollframe:SetPoint ("topleft", borderframe, "topleft", 10, -10)
scrollframe:SetPoint ("bottomright", borderframe, "bottomright", -10, 10)
scrollframeNumberLines:SetPoint ("topleft", borderframe, "topleft", 10, -10)
scrollframeNumberLines:SetPoint ("bottomright", borderframe, "bottomright", -10, 10)
scrollframeNumberLines:Hide()
end
--16:40
borderframe.SetAsAutoComplete = TextEntryMetaFunctions.SetAsAutoComplete
scrollframe:SetScript ("OnSizeChanged", function (self)
scrollframe.editbox:SetSize (self:GetSize())
end)
scrollframe:SetPoint ("topleft", borderframe, "topleft", 10, -10)
scrollframe:SetPoint ("bottomright", borderframe, "bottomright", -30, 10)
scrollframe.editbox:SetMultiLine (true)
scrollframe.editbox:SetJustifyH ("left")
scrollframe.editbox:SetJustifyV ("top")
scrollframe.editbox:SetMaxBytes (1024000)
@@ -1122,6 +1179,7 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent)
borderframe.SetText = function_settext
borderframe.ClearFocus = function_clearfocus
borderframe.SetFocus = function_setfocus
borderframe.SetTextSize = set_speciallua_editor_font_size
borderframe.Enable = TextEntryMetaFunctions.Enable
borderframe.Disable = TextEntryMetaFunctions.Disable
@@ -1131,7 +1189,7 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent)
if (not nointent) then
IndentationLib.enable (scrollframe.editbox, nil, 4)
end
borderframe:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
tile = 1, tileSize = 16, edgeSize = 16, insets = {left = 5, right = 5, top = 5, bottom = 5}})