-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimeGui_Window.lua
More file actions
157 lines (126 loc) · 4.42 KB
/
Copy pathPrimeGui_Window.lua
File metadata and controls
157 lines (126 loc) · 4.42 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
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
151
152
153
154
155
156
157
--[[
====================================================
LibPrime
Author: Ivan Leben
====================================================
--]]
--Window frame
--=====================================================================
function PrimeGui.Window_New( name, title, resizable, close )
--Frame
local f = CreateFrame( "Frame", name, UIParent );
f:SetFrameStrata( "DIALOG" );
f:SetToplevel( true );
f:SetBackdrop(
{bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/DialogFrame/UI-DialogBox-Border",
tile = true, tileSize = 32, edgeSize = 32,
insets = { left = 11, right = 12, top = 12, bottom = 11 }});
f:SetBackdropColor(0,0,0,0.8);
--Make movable
f:SetMovable( true );
f:SetResizable( true );
f:EnableMouse( true );
f:SetScript( "OnMouseDown", PrimeGui.Window_OnDragStart );
f:SetScript( "OnMouseUp", PrimeGui.Window_OnDragStop );
if (title) then
--Create the title frame
local fTitle = CreateFrame( "Frame", name.."Title", f );
fTitle:SetWidth( 185 );
fTitle:SetHeight( 40 );
fTitle:SetPoint( "TOP", 0, 15 );
fTitle:SetFrameStrata( "DIALOG" );
fTitle.frame = f;
--Make the title move the whole frame
fTitle:EnableMouse( true );
fTitle:SetScript( "OnMouseDown", PrimeGui.Window_Title_OnDragStart );
fTitle:SetScript( "OnMouseUp", PrimeGui.Window_Title_OnDragStop );
--Create the title texture
--(the texture is larger and has transparent space around it
-- so we have to scale it up around the title frame)
local texTitle = fTitle:CreateTexture( nil, "BACKGROUND" );
texTitle:SetTexture( "Interface/DialogFrame/UI-DialogBox-Header" );
texTitle:SetPoint( "TOPRIGHT", 57, 0 );
texTitle:SetPoint( "BOTTOMLEFT", -58, -24 );
--Create the title text
local txtTitle = fTitle:CreateFontString( nil, "OVERLAY", nil );
txtTitle:SetFont( "Fonts/MORPHEUS.ttf", 15 );
txtTitle:SetText( title );
txtTitle:SetWidth( 300 );
txtTitle:SetHeight( 64 );
txtTitle:SetPoint( "TOP", 0, 12 );
end
if (resizable) then
local sizer = CreateFrame("Frame",nil,f)
sizer:SetPoint("BOTTOMRIGHT",f,"BOTTOMRIGHT",0,0);
sizer:SetWidth(25);
sizer:SetHeight(25);
sizer:EnableMouse( true );
sizer:SetScript("OnMouseDown", PrimeGui.Window_Sizer_OnMouseDown);
sizer:SetScript("OnMouseUp", PrimeGui.Window_Sizer_OnMouseUp);
sizer.frame = f;
f.sizer = sizer;
local line1 = sizer:CreateTexture(nil, "BACKGROUND");
line1:SetWidth(14);
line1:SetHeight(14);
line1:SetPoint("BOTTOMRIGHT", -8, 8);
line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border");
local x = 0.1 * 14/17;
line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5);
f.line1 = line1;
local line2 = sizer:CreateTexture(nil, "BACKGROUND");
line2:SetWidth(8);
line2:SetHeight(8);
line2:SetPoint("BOTTOMRIGHT", -8, 8);
line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border");
local x = 0.1 * 8/17;
line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5);
f.line2 = line2;
end
if (close) then
--Close button
local btnClose = CreateFrame( "Button", name.."CloseBtn", f, "UIPanelCloseButton" );
btnClose.myframe = f;
btnClose:SetPoint( "TOPRIGHT", -5, -7 );
btnClose:SetScript( "OnClick", function (self) self.myframe:Hide() end );
btnClose:Show();
end
--Container
local pad = 25;
local c = CreateFrame( "Frame", name.."Container", f );
c:SetPoint( "BOTTOMLEFT", pad, pad );
c:SetPoint( "TOPRIGHT", -pad, -pad-15 );
c.frame = f;
f.container = c;
--Functions
PrimeGui.Object_New( f );
--PrimeGui.Container_New( f );
--f.SizeToContent = PrimeGui.Window_SizeToContent;
return f;
end
function PrimeGui.Window_SizeToContent( frame )
--CB.Print( "Content height "..tostring( frame:GetContentHeight() ));
--frame.container:SetHeight( frame:GetContentHeight() + 1 );
end
function PrimeGui.Window_OnScrollSizeChanged( scroll, width, height )
local frame = scroll.frame;
--frame.container:SetWidth( width );
end
function PrimeGui.Window_OnDragStart( frame )
frame:StartMoving();
end
function PrimeGui.Window_OnDragStop( frame )
frame:StopMovingOrSizing();
end
function PrimeGui.Window_Title_OnDragStart( title )
title.frame:StartMoving();
end
function PrimeGui.Window_Title_OnDragStop( title )
title.frame:StopMovingOrSizing();
end
function PrimeGui.Window_Sizer_OnMouseDown( sizer )
sizer.frame:StartSizing("BOTTOMRIGHT");
end
function PrimeGui.Window_Sizer_OnMouseUp( sizer )
sizer.frame:StopMovingOrSizing();
end