Mercurial > wow > devian
comparison Console.lua @ 98:33bc8baba858
start of a lot of v3 groundwork based on better knowledge of the addon interface:
- use of mixin as a lexical center for generated frames
- removal of unfinished segments
author | Nenue |
---|---|
date | Wed, 26 Oct 2016 10:17:43 -0400 |
parents | |
children | 7d94df3804a7 |
comparison
equal
deleted
inserted
replaced
97:34131d11e61b | 98:33bc8baba858 |
---|---|
1 -- Mixin for console | |
2 local _, D = ... | |
3 DevianConsoleMixin = {} | |
4 | |
5 function DevianConsoleMixin:OnLoad() | |
6 self:SetMaxResize(GetScreenWidth(), GetScreenHeight()) | |
7 self:SetMinResize(100, 24) | |
8 | |
9 self:EnableMouse(true) | |
10 self:RegisterForDrag('LeftButton') | |
11 self:SetMovable(true) | |
12 self:SetResizable(true) | |
13 self.out:SetFont("Interface\\Addons\\Devian\\font\\SourceCodePro-Regular.ttf", 13, 'NORMAL') | |
14 self.out:SetJustifyH('LEFT') | |
15 self.out:SetFading(false) | |
16 | |
17 self.width = self:GetWidth() | |
18 self.height = self:GetWidth() | |
19 end | |
20 | |
21 function DevianConsoleMixin:Setup(info) | |
22 for k,v in pairs(info) do | |
23 self[k] = v | |
24 --oldprint(k,v) | |
25 end | |
26 self.Dock = DevianDock:GetDockButton(self) | |
27 self:Update() | |
28 end | |
29 | |
30 function DevianConsoleMixin:Update() | |
31 self.title:SetText(self.index..' '.. (self.signature or '?')) | |
32 self:SetSize(self.width, self.height) | |
33 self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', self.x, self.y) | |
34 -- oldprint(self:GetName(), self.x, self.y) | |
35 | |
36 local isFront = D.currentProfile.current_channel == self.index | |
37 local r,g,b,a = unpack(D.db.backborder) | |
38 if isFront then | |
39 r,g,b,a = unpack(D.db.frontborder) | |
40 self.backdrop:SetColorTexture(0,0,0,1) | |
41 else | |
42 self.backdrop:SetColorTexture(0,0,0,0.5) | |
43 | |
44 end | |
45 for name, region in pairs(self.border) do | |
46 region:SetColorTexture(r,g,b,a) | |
47 end | |
48 | |
49 --oldprint(self:GetID(), self.enabled, self.minimized, self.x, self.y) | |
50 self.isFront = isFront | |
51 self:SetShown(self.enabled) | |
52 self.out:SetShown(self.enabled) | |
53 end | |
54 | |
55 | |
56 function DevianConsoleMixin:OnShow() | |
57 self:Update() | |
58 end | |
59 | |
60 | |
61 | |
62 function DevianConsoleMixin:OnHide() end | |
63 | |
64 function DevianConsoleMixin:OnMouseWheel(delta) | |
65 | |
66 local up = delta > 0 | |
67 if IsControlKeyDown() then | |
68 if up then self.out:ScrollToTop() | |
69 else self.out:ScrollToBottom() end | |
70 elseif IsShiftKeyDown() then | |
71 if up then self.out:PageUp() | |
72 else self.out:PageDown() end | |
73 else | |
74 if up then self.out:ScrollUp() | |
75 else self.out:ScrollDown() end | |
76 end | |
77 end | |
78 function DevianConsoleMixin:MinMax(minimized) | |
79 minimized = minimized or self.minimized | |
80 if minimized then | |
81 self:Maximize() | |
82 else | |
83 self:Minimize() | |
84 end | |
85 end | |
86 | |
87 function DevianConsoleMixin:Minimize() | |
88 self:SetHeight(20) | |
89 self:SetMaxResize(GetScreenWidth(),20) | |
90 self.minimized = true | |
91 self.out:Hide() | |
92 D.channels[self.index].minimized = true | |
93 end | |
94 | |
95 function DevianConsoleMixin:Maximize() | |
96 local db = D.channels[self.index] | |
97 self:SetHeight(db.height) | |
98 self:SetMaxResize(GetScreenWidth(),GetScreenHeight()) | |
99 self.minimized = nil | |
100 self.out:Show() | |
101 D.channels[self.index].minimized = nil | |
102 end | |
103 | |
104 function DevianConsoleMixin:OnMouseUp(button) | |
105 if button == 'LeftButton' then | |
106 self:ToFront() | |
107 else | |
108 self:MinMax() | |
109 end | |
110 end | |
111 | |
112 function DevianConsoleMixin:OnLeave() | |
113 end | |
114 | |
115 function DevianConsoleMixin:OnEnter() | |
116 end | |
117 | |
118 function DevianConsoleMixin:OnDragStart() | |
119 | |
120 self:StartMoving() | |
121 end | |
122 | |
123 function DevianConsoleMixin:OnDragStop() | |
124 self.x = self:GetLeft() | |
125 self.y = self:GetTop() - GetScreenHeight() | |
126 D.currentProfile.channels[self:GetID()].x = self:GetLeft() | |
127 D.currentProfile.channels[self:GetID()].y = self:GetTop() - GetScreenHeight() | |
128 self:StopMovingOrSizing() | |
129 end | |
130 | |
131 function DevianConsoleMixin:Reset() | |
132 end | |
133 | |
134 function DevianConsoleMixin:ToFront() | |
135 self:Raise() | |
136 D.currentProfile.current_channel = self.index | |
137 for index, channel in ipairs(D.console) do | |
138 channel:Update() | |
139 end | |
140 end | |
141 | |
142 function DevianConsoleMixin:Toggle() | |
143 self.enabled = (not self.enabled) | |
144 --oldprint(self:GetID(), self.enabled) | |
145 self:Update() | |
146 end |