diff --git a/Core.lua b/Core.lua
index 5bd8aa1..8dfa71d 100644
--- a/Core.lua
+++ b/Core.lua
@@ -1,26 +1,3 @@
---[[
- Copyright (c) 2014 Eyal Shilony <Lynxium>
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-]]
-
local addonName, addon = ...
local core = LibStub("Libra"):NewAddon(addonName, addon)
diff --git a/DefaultCastingBar.toc b/DefaultCastingBar.toc
index 0355a4c..731afe0 100644
--- a/DefaultCastingBar.toc
+++ b/DefaultCastingBar.toc
@@ -3,7 +3,7 @@
## Author: Lynxium
## Title: Default: |cffEAE669CastingBar|r
-## Notes: A lightweight casting bar that you can move.
+## Notes: A lightweight casting bar that you can move and resize.
## Version: @project-version@
## X-Category: Combat
@@ -12,15 +12,20 @@
## X-License: MIT.
## SavedVariables: DefaultCastingBarDb
-libs\LibStub.lua
-libs\CallbackHandler-1.0.lua
-libs\AceLocale-3.0\AceLocale-3.0.xml
-libs\AceDB-3.0\AceDB-3.0.xml
-libs\Libra-34\Libra.xml
+Libs\LibStub.lua
+Libs\CallbackHandler-1.0.lua
+Libs\AceLocale-3.0\AceLocale-3.0.xml
+Libs\AceDB-3.0\AceDB-3.0.xml
+Libs\Libra-36\Libra.xml
-loc\enUS.lua
+Locale\enUS.lua
Core.lua
-DragFrame.xml
+
+Features\Timer.lua
+Features\Icon.lua
+Features\DragFrame.xml
+
CastingBar.lua
+
Options.lua
\ No newline at end of file
diff --git a/DragFrame.lua b/DragFrame.lua
deleted file mode 100644
index 0f5a970..0000000
--- a/DragFrame.lua
+++ /dev/null
@@ -1,120 +0,0 @@
---[[
- Copyright (c) 2014 Eyal Shilony <Lynxium>
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-]]
-
-local _, addon = ...
-local dragFrame = addon:NewModule("DragFrame")
-
-local MIN_RESIZE_WIDTH = 128
-local MAX_RESIZE_WIDTH = 512
-
-dragFrame.frame = DefaultCastingBar_DragFrame
-
-local function savePositionAndDimensions(self)
- if not addon.db.profile.position then
- addon.db.profile.position = {}
- end
- local point, _, relpoint, x, y = self:GetPoint()
- addon.db.profile.position = { point, relpoint, x, y }
- addon.db.profile.width = self:GetWidth()
-end
-
-local function initPositionAndDimensions()
- local position = addon.db.profile.position
- if position then
- local point, relpoint, x, y = unpack(position)
- dragFrame.frame:ClearAllPoints()
- dragFrame.frame:SetPoint(point, UIParent, relpoint, x, y)
- end
- dragFrame.frame:SetSize(addon.db.profile.width, addon.barMaxHeight)
- dragFrame.frame.resizeButton:SetSize(addon.barMaxHeight, addon.barMaxHeight)
-end
-
-function dragFrame:OnInitialize()
- addon.db.RegisterCallback(addon, "OnProfileChanged", initPositionAndDimensions)
- addon.db.RegisterCallback(addon, "OnProfileCopied", initPositionAndDimensions)
- addon.db.RegisterCallback(addon, "OnProfileReset", initPositionAndDimensions)
-
- initPositionAndDimensions()
-
- SLASH_DEFAULTCASTINGBAR1 = "/dcb"
- SlashCmdList["DEFAULTCASTINGBAR"] = function(input)
- if dragFrame.frame:IsVisible() then
- dragFrame.frame:Hide()
- dragFrame.frame.resizeButton:Hide()
- else
- dragFrame.frame:Show()
- dragFrame.frame.resizeButton:Show()
- end
- end
-
- self.frame:SetBackdropColor(0, 1, 0, 0.5)
- self.frame.text = _G[self.frame:GetName().."Pos"]
-
- self.frame:EnableMouse(true)
-
- self.frame:SetResizable(true)
- self.frame:SetMinResize(MIN_RESIZE_WIDTH, addon.barMaxHeight)
- self.frame:SetMaxResize(MAX_RESIZE_WIDTH, addon.barMaxHeight)
-
- self.frame:SetMovable(true)
- self.frame:SetClampedToScreen(true)
- self.frame:Hide()
-end
-
-dragFrame.frame:RegisterForDrag("LeftButton")
-dragFrame.frame:SetScript("OnDragStart", function(self, button)
- if button == "LeftButton" then
- self:StartMoving()
- end
-end)
-
-dragFrame.frame:SetScript("OnDragStop", function(self)
- savePositionAndDimensions(self)
-
- self:StopMovingOrSizing()
-end)
-
-dragFrame.frame:SetScript('OnUpdate', function(self)
- local x, y = self:GetLeft(), self:GetBottom()
- if x and y then
- self.text:SetText(("Left: %d Bottom: %d"):format(x , y))
- end
-end)
-
-dragFrame.frame.resizeButton:SetScript('OnMouseDown', function(self)
- self:SetButtonState("PUSHED", true)
-
- self:GetHighlightTexture():Hide()
-
- dragFrame.frame:StartSizing("BOTTOMRIGHT")
-end)
-
-dragFrame.frame.resizeButton:SetScript('OnMouseUp', function(self)
- self:SetButtonState("NORMAL", false)
-
- self:GetHighlightTexture():Show()
-
- savePositionAndDimensions(dragFrame.frame)
-
- dragFrame.frame:StopMovingOrSizing()
-end)
\ No newline at end of file
diff --git a/DragFrame.xml b/DragFrame.xml
deleted file mode 100644
index fb5bfae..0000000
--- a/DragFrame.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<Ui xmlns="http://www.blizzard.com/wow/ui/">
- <Frame name="DefaultCastingBar_DragFrame" parent="UIParent">
- <Anchors>
- <Anchor point="CENTER" relativeTo="UIParent">
- <Offset>
- <AbsDimension x="0" y="0"/>
- </Offset>
- </Anchor>
- </Anchors>
- <Layers>
- <Layer>
- <FontString name="$parentPos" font="GameFontHighlight" setAllPoints="true" text="Tooltip" maxLines="1" justifyH="CENTER" />
- </Layer>
- </Layers>
- <Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" tile="true">
- <EdgeSize>
- <AbsValue val="16"/>
- </EdgeSize>
- <TileSize>
- <AbsValue val="16"/>
- </TileSize>
- </Backdrop>
- <Frames>
- <Button name="$parentResizeButton" parentKey="resizeButton">
- <Anchors>
- <Anchor point="BOTTOMRIGHT" relativeTo="$parent" x="0" y="0"/>
- </Anchors>
- <NormalTexture file="Interface\ChatFrame\UI-ChatIM-SizeGrabber-Up"/>
- <HighlightTexture file="Interface\ChatFrame\UI-ChatIM-SizeGrabber-Highlight"/>
- <PushedTexture file="Interface\ChatFrame\UI-ChatIM-SizeGrabber-Down"/>
- </Button>
- </Frames>
- </Frame>
-
- <Script file="DragFrame.lua"/>
-</Ui>
\ No newline at end of file
diff --git a/Features/DragFrame.lua b/Features/DragFrame.lua
new file mode 100644
index 0000000..f6a022e
--- /dev/null
+++ b/Features/DragFrame.lua
@@ -0,0 +1,97 @@
+local _, addon = ...
+local dragFrame = addon:NewModule("DragFrame")
+
+local MIN_RESIZE_WIDTH = 128
+local MAX_RESIZE_WIDTH = 512
+
+dragFrame.frame = DefaultCastingBar_DragFrame
+
+local function savePositionAndDimensions(self)
+ if not addon.db.profile.position then
+ addon.db.profile.position = {}
+ end
+ local point, _, relpoint, x, y = self:GetPoint()
+ addon.db.profile.position = { point, relpoint, x, y }
+ addon.db.profile.width = self:GetWidth()
+end
+
+local function initPositionAndDimensions()
+ local position = addon.db.profile.position
+ if position then
+ local point, relpoint, x, y = unpack(position)
+ dragFrame.frame:ClearAllPoints()
+ dragFrame.frame:SetPoint(point, UIParent, relpoint, x, y)
+ end
+ dragFrame.frame:SetSize(addon.db.profile.width, addon.barMaxHeight)
+ dragFrame.frame.resizeButton:SetSize(addon.barMaxHeight, addon.barMaxHeight)
+end
+
+function dragFrame:OnInitialize()
+ addon.db.RegisterCallback(addon, "OnProfileChanged", initPositionAndDimensions)
+ addon.db.RegisterCallback(addon, "OnProfileCopied", initPositionAndDimensions)
+ addon.db.RegisterCallback(addon, "OnProfileReset", initPositionAndDimensions)
+
+ initPositionAndDimensions()
+
+ SLASH_DEFAULTCASTINGBAR1 = "/dcb"
+ SlashCmdList["DEFAULTCASTINGBAR"] = function(input)
+ if dragFrame.frame:IsVisible() then
+ dragFrame.frame:Hide()
+ dragFrame.frame.resizeButton:Hide()
+ else
+ dragFrame.frame:Show()
+ dragFrame.frame.resizeButton:Show()
+ end
+ end
+
+ self.frame:SetBackdropColor(0, 1, 0, 0.5)
+ self.frame.text = _G[self.frame:GetName().."Pos"]
+
+ self.frame:EnableMouse(true)
+
+ self.frame:SetResizable(true)
+ self.frame:SetMinResize(MIN_RESIZE_WIDTH, addon.barMaxHeight)
+ self.frame:SetMaxResize(MAX_RESIZE_WIDTH, addon.barMaxHeight)
+
+ self.frame:SetMovable(true)
+ self.frame:SetClampedToScreen(true)
+ self.frame:Hide()
+end
+
+dragFrame.frame:RegisterForDrag("LeftButton")
+dragFrame.frame:SetScript("OnDragStart", function(self, button)
+ if button == "LeftButton" then
+ self:StartMoving()
+ end
+end)
+
+dragFrame.frame:SetScript("OnDragStop", function(self)
+ savePositionAndDimensions(self)
+
+ self:StopMovingOrSizing()
+end)
+
+dragFrame.frame:SetScript('OnUpdate', function(self)
+ local x, y = self:GetLeft(), self:GetBottom()
+ if x and y then
+ self.text:SetText(("Left: %d Bottom: %d"):format(x , y))
+ end
+end)
+
+dragFrame.frame.resizeButton:SetScript('OnMouseDown', function(self)
+ self:SetButtonState("PUSHED", true)
+
+ self:GetHighlightTexture():Hide()
+
+ dragFrame.frame:StartSizing("BOTTOMRIGHT")
+end)
+
+dragFrame.frame.resizeButton:SetScript('OnMouseUp', function(self)
+ self:SetButtonState("NORMAL", false)
+
+ self:GetHighlightTexture():Show()
+
+ savePositionAndDimensions(dragFrame.frame)
+
+ dragFrame.frame:StopMovingOrSizing()
+end)
\ No newline at end of file
diff --git a/Features/DragFrame.xml b/Features/DragFrame.xml
new file mode 100644
index 0000000..fb5bfae
--- /dev/null
+++ b/Features/DragFrame.xml
@@ -0,0 +1,36 @@
+<Ui xmlns="http://www.blizzard.com/wow/ui/">
+ <Frame name="DefaultCastingBar_DragFrame" parent="UIParent">
+ <Anchors>
+ <Anchor point="CENTER" relativeTo="UIParent">
+ <Offset>
+ <AbsDimension x="0" y="0"/>
+ </Offset>
+ </Anchor>
+ </Anchors>
+ <Layers>
+ <Layer>
+ <FontString name="$parentPos" font="GameFontHighlight" setAllPoints="true" text="Tooltip" maxLines="1" justifyH="CENTER" />
+ </Layer>
+ </Layers>
+ <Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" tile="true">
+ <EdgeSize>
+ <AbsValue val="16"/>
+ </EdgeSize>
+ <TileSize>
+ <AbsValue val="16"/>
+ </TileSize>
+ </Backdrop>
+ <Frames>
+ <Button name="$parentResizeButton" parentKey="resizeButton">
+ <Anchors>
+ <Anchor point="BOTTOMRIGHT" relativeTo="$parent" x="0" y="0"/>
+ </Anchors>
+ <NormalTexture file="Interface\ChatFrame\UI-ChatIM-SizeGrabber-Up"/>
+ <HighlightTexture file="Interface\ChatFrame\UI-ChatIM-SizeGrabber-Highlight"/>
+ <PushedTexture file="Interface\ChatFrame\UI-ChatIM-SizeGrabber-Down"/>
+ </Button>
+ </Frames>
+ </Frame>
+
+ <Script file="DragFrame.lua"/>
+</Ui>
\ No newline at end of file
diff --git a/Features/Icon.lua b/Features/Icon.lua
new file mode 100644
index 0000000..d10058c
--- /dev/null
+++ b/Features/Icon.lua
@@ -0,0 +1,39 @@
+local _, addon = ...
+local icon = addon:NewModule("Icon")
+
+local frame
+
+function icon:Create(castingBar)
+ local name = castingBar:GetName()
+
+ frame = _G[name .. "Icon"]
+ frame:SetSize(22, 22)
+ frame:SetTexCoord(0.07, 0.93, 0.07, 0.93)
+
+ return icon
+end
+
+function icon:Hide()
+ frame:Hide()
+end
+
+function icon:Show()
+ frame:Show()
+end
+
+function icon:IsHidden()
+ return addon.db.profile.hideIcon
+end
+
+function icon:SetPosition(parent)
+ -- NYI
+end
+
+function timer:SetVisibility(parent)
+ if not self:IsHidden() then
+ self:SetPosition(parent)
+ self:Show()
+ else
+ self:Hide()
+ end
+end
\ No newline at end of file
diff --git a/Features/Timer.lua b/Features/Timer.lua
new file mode 100644
index 0000000..6ae1994
--- /dev/null
+++ b/Features/Timer.lua
@@ -0,0 +1,68 @@
+local _, addon = ...
+local timer = addon:NewModule("Timer")
+
+local frame
+
+function timer:Create(castingBar)
+ frame = castingBar:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
+ return timer
+end
+
+function timer:SetValue(castingBar)
+ if castingBar.casting then
+ local value = self.maxValue - self.value
+ if timer:IsHidden() then
+ frame:SetText(nil)
+ elseif timer:HasTotalTimeOnly() then
+ frame:SetFormattedText("%.1f", self.maxValue)
+ elseif timer:HasCastTimeOnly() then
+ frame:SetFormattedText("%.1f", value)
+ else
+ frame:SetFormattedText("%.1f/%.1f", value, self.maxValue)
+ end
+ elseif castingBar.channeling then
+ frame:SetFormattedText("%.1f", self.value)
+ end
+end
+
+function timer:Hide()
+ frame:Hide()
+end
+
+function timer:Show()
+ frame:Show()
+end
+
+function timer:IsHidden()
+ return addon.db.profile.timerDisplay == "Hide"
+end
+
+function timer:HasTotalTimeOnly()
+ return not timer:IsHidden() and addon.db.profile.timerDisplay == "Hide Total Time"
+end
+
+function timer:HasCastTimeOnly()
+ return not timer:IsHidden() and addon.db.profile.timerDisplay == "Hide Cast Time"
+end
+
+function timer:SetPosition(parent)
+ local parent = self:GetParent()
+ -- NYI
+end
+
+function timer:SetDisplay(timerDisplay)
+ addon.db.profile.timerDisplay = timerDisplay
+end
+
+function timer:GetDisplay()
+ return addon.db.profile.timerDisplay
+end
+
+function timer:SetVisibility(parent)
+ if not self:IsHidden() then
+ self:SetPosition(parent)
+ self:Show()
+ else
+ self:Hide()
+ end
+end
\ No newline at end of file
diff --git a/Locale/enUS.lua b/Locale/enUS.lua
new file mode 100644
index 0000000..588eda9
--- /dev/null
+++ b/Locale/enUS.lua
@@ -0,0 +1,14 @@
+local addonName = ...
+local L = LibStub("AceLocale-3.0"):NewLocale(addonName, "enUS", true, false)
+
+L["Use Class Colors"] = true
+L["Icon Position"] = true
+L["Hide Icon"] = true
+L["Time Position"] = true
+L["Hide Total Time"] = true
+L["Hide Time"] = true
+
+L["Profiles"] = true
+L["You can change the active database profile, so you can have different settings for every character."] = true
+
+-- todo: Add localization for dropdown options.
\ No newline at end of file
diff --git a/Options.lua b/Options.lua
index d5e9fa3..d01d3d0 100644
--- a/Options.lua
+++ b/Options.lua
@@ -1,26 +1,3 @@
---[[
- Copyright (c) 2014 Eyal Shilony <Lynxium>
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-]]
-
local addonName, addon = ...
local options = addon:NewModule("Options")
local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
diff --git a/loc/enUS.lua b/loc/enUS.lua
deleted file mode 100644
index 5ec4085..0000000
--- a/loc/enUS.lua
+++ /dev/null
@@ -1,37 +0,0 @@
---[[
- Copyright (c) 2014 Eyal Shilony <Lynxium>
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-]]
-
-local addonName = ...
-local L = LibStub("AceLocale-3.0"):NewLocale(addonName, "enUS", true, false)
-
-L["Use Class Colors"] = true
-L["Icon Position"] = true
-L["Hide Icon"] = true
-L["Time Position"] = true
-L["Hide Total Time"] = true
-L["Hide Time"] = true
-
-L["Profiles"] = true
-L["You can change the active database profile, so you can have different settings for every character."] = true
-
--- todo: Add localization for dropdown options.
\ No newline at end of file