# HG changeset patch # User Nenue # Date 1477491463 14400 # Node ID 33bc8baba8582d3d7742fac6c65091bfc76af882 # Parent 34131d11e61b1f801be61bd51a1c80cc85fad502 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 diff -r 34131d11e61b -r 33bc8baba858 Console.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Console.lua Wed Oct 26 10:17:43 2016 -0400 @@ -0,0 +1,146 @@ +-- Mixin for console +local _, D = ... +DevianConsoleMixin = {} + +function DevianConsoleMixin:OnLoad() + self:SetMaxResize(GetScreenWidth(), GetScreenHeight()) + self:SetMinResize(100, 24) + + self:EnableMouse(true) + self:RegisterForDrag('LeftButton') + self:SetMovable(true) + self:SetResizable(true) + self.out:SetFont("Interface\\Addons\\Devian\\font\\SourceCodePro-Regular.ttf", 13, 'NORMAL') + self.out:SetJustifyH('LEFT') + self.out:SetFading(false) + + self.width = self:GetWidth() + self.height = self:GetWidth() +end + +function DevianConsoleMixin:Setup(info) + for k,v in pairs(info) do + self[k] = v + --oldprint(k,v) + end + self.Dock = DevianDock:GetDockButton(self) + self:Update() +end + +function DevianConsoleMixin:Update() + self.title:SetText(self.index..' '.. (self.signature or '?')) + self:SetSize(self.width, self.height) + self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', self.x, self.y) + -- oldprint(self:GetName(), self.x, self.y) + + local isFront = D.currentProfile.current_channel == self.index + local r,g,b,a = unpack(D.db.backborder) + if isFront then + r,g,b,a = unpack(D.db.frontborder) + self.backdrop:SetColorTexture(0,0,0,1) + else + self.backdrop:SetColorTexture(0,0,0,0.5) + + end + for name, region in pairs(self.border) do + region:SetColorTexture(r,g,b,a) + end + + --oldprint(self:GetID(), self.enabled, self.minimized, self.x, self.y) + self.isFront = isFront + self:SetShown(self.enabled) + self.out:SetShown(self.enabled) +end + + +function DevianConsoleMixin:OnShow() + self:Update() +end + + + +function DevianConsoleMixin:OnHide() end + +function DevianConsoleMixin:OnMouseWheel(delta) + + local up = delta > 0 + if IsControlKeyDown() then + if up then self.out:ScrollToTop() + else self.out:ScrollToBottom() end + elseif IsShiftKeyDown() then + if up then self.out:PageUp() + else self.out:PageDown() end + else + if up then self.out:ScrollUp() + else self.out:ScrollDown() end + end +end +function DevianConsoleMixin:MinMax(minimized) + minimized = minimized or self.minimized + if minimized then + self:Maximize() + else + self:Minimize() + end +end + +function DevianConsoleMixin:Minimize() + self:SetHeight(20) + self:SetMaxResize(GetScreenWidth(),20) + self.minimized = true + self.out:Hide() + D.channels[self.index].minimized = true +end + +function DevianConsoleMixin:Maximize() + local db = D.channels[self.index] + self:SetHeight(db.height) + self:SetMaxResize(GetScreenWidth(),GetScreenHeight()) + self.minimized = nil + self.out:Show() + D.channels[self.index].minimized = nil +end + +function DevianConsoleMixin:OnMouseUp(button) + if button == 'LeftButton' then + self:ToFront() + else + self:MinMax() + end +end + +function DevianConsoleMixin:OnLeave() +end + +function DevianConsoleMixin:OnEnter() +end + +function DevianConsoleMixin:OnDragStart() + + self:StartMoving() +end + +function DevianConsoleMixin:OnDragStop() + self.x = self:GetLeft() + self.y = self:GetTop() - GetScreenHeight() + D.currentProfile.channels[self:GetID()].x = self:GetLeft() + D.currentProfile.channels[self:GetID()].y = self:GetTop() - GetScreenHeight() + self:StopMovingOrSizing() +end + +function DevianConsoleMixin:Reset() +end + +function DevianConsoleMixin:ToFront() + self:Raise() + D.currentProfile.current_channel = self.index + for index, channel in ipairs(D.console) do + channel:Update() + end +end + +function DevianConsoleMixin:Toggle() + self.enabled = (not self.enabled) + --oldprint(self:GetID(), self.enabled) + self:Update() +end \ No newline at end of file diff -r 34131d11e61b -r 33bc8baba858 Console.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Console.xml Wed Oct 26 10:17:43 2016 -0400 @@ -0,0 +1,154 @@ + +