-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_view.lua
More file actions
48 lines (40 loc) · 1.99 KB
/
settings_view.lua
File metadata and controls
48 lines (40 loc) · 1.99 KB
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
---Sets up the view of the example addon settings window.
---@return Window
function SetViewOfExampleAddonSettings()
-- Create a window.
local window = UIParent:CreateWidget("window", "exampleaddonsettings", "UIParent")
local background = window:CreateDrawable(TEXTURE_PATH.DEFAULT, "main_bg", "background")
local decoration = window:CreateDrawable(TEXTURE_PATH.DEFAULT, "main_bg_deco", "background")
-- Create a title bar.
local titleBar = window:CreateChildWidget("window", "titleBar", 0, true)
titleBar.titleStyle:SetAlign(ALIGN_CENTER)
titleBar.titleStyle:SetSnap(true)
titleBar.titleStyle:SetFont(FONT_PATH.SUB, FONT_SIZE.XLARGE)
titleBar.titleStyle:SetColorByKey("title")
titleBar:SetTitleText(locale.addon.title .. " - " .. locale.addon.settingsTitle)
titleBar:EnableDrag(true)
titleBar:SetHeight(45)
-- Create a close button for the title bar.
local closeButton = titleBar:CreateChildWidget("button", "closeButton", 0, true)
closeButton:SetStyle("btn_close_default")
-- Create a body textbox.
local bodyTextbox = window:CreateChildWidget("textbox", "bodyTextbox", 0, true)
bodyTextbox.style:SetFontSize(FONT_SIZE.LARGE)
bodyTextbox.style:SetAlign(ALIGN_TOP_LEFT)
bodyTextbox.style:SetColorByKey("default")
bodyTextbox.style:SetSnap(true)
bodyTextbox:SetLineSpace(7)
bodyTextbox:SetText("UI_ADDON")
window:AddAnchor("CENTER", "UIParent", 0, 0)
window:SetExtent(WINDOW.WIDTH, WINDOW.HEIGHT)
background:AddAnchor("TOPLEFT", window, -5, -5)
background:AddAnchor("BOTTOMRIGHT", window, 5, 5)
decoration:AddAnchor("TOPLEFT", window, 0, -5)
decoration:AddAnchor("TOPRIGHT", window, 0, -5)
titleBar:AddAnchor("TOPLEFT", window, 0, 0)
titleBar:AddAnchor("TOPRIGHT", window, 0, 0)
closeButton:AddAnchor("TOPRIGHT", titleBar, WINDOW.CLOSE_BUTTON_OFFSET, -WINDOW.CLOSE_BUTTON_OFFSET)
bodyTextbox:AddAnchor("TOPLEFT", titleBar, "BOTTOMLEFT", WINDOW.MARGIN, 0)
bodyTextbox:AddAnchor("TOPRIGHT", titleBar, "BOTTOMRIGHT", -WINDOW.MARGIN, 0)
return window
end