/trunk
-- CL3.lua |
-- ==================================================================== |
-- CL3.lua |
-- Contains code for performing operations on list data |
-- ==================================================================== |
local Torta = Torta; |
local Checklist3 = Torta.cl3; |
local gui = Torta.gui; |
end |
end |
percent = format("%.1f", (checked / total) * 100); |
-- Fix this sometime. |
-- widgets.statsButton:SetFormattedText("Tasks: %d/%d (%s(%))", checked, total, percent); |
widgets.statsButton:SetText("Tasks: " .. checked .. "/" .. total .. " (" .. percent .. "%)"); |
widgets.statsButton:SetFormattedText("Tasks: %d/%d (%s)", checked, total, percent .. "%"); |
else |
widgets.statsButton:SetText(""); |
end |
end |
-- Drop handler functions |
function Checklist3:MoveTask(SrcID, DestID) |
local list = self:GetLoadedList(); |
local text = list.text[SrcID]; |
local stat = list.stat[SrcID]; |
if DestID > #list.text then -- If the button was dragged to be below the last item |
DestID = #list.text; |
end |
tremove(list.text, SrcID); |
tremove(list.stat, SrcID); |
tinsert(list.text, DestID, text); |
tinsert(list.stat, DestID, stat); |
gui:UpdateCLScrollBar(); |
end |
function Torta.gui:OnTabClicked(tabID) |
assert(type(tabID) == "number"); |
PanelTemplates_SetTab(mainWindow, tabID); |
if Torta.cl3.HideTaskEditor then |
Torta.cl3:HideTaskEditor(); |
end |
if tabID == 1 then |
startPage:Show(); |
mainPage:Hide(); |
self.tab = tabID; |
startPage:Hide(); |
mainPage:Show(); |
self:UpdateExplorerScrollBar(); |
if tabID == 2 then |
clDisplayWindow:Show(); |
clTaskBar:Show(); |
nbDisplayWindow:Show(); |
nbTaskBar:Show(); |
end |
self:UpdateExplorerScrollBar(); |
end |
if Torta.cl3.HideTaskEditor then |
Torta.cl3:HideTaskEditor(); |
end |
end |
function Torta.gui:Initialize() |
Torta.gui:clHideDropHandlers(); |
end |
-- Explorer listbox code |
button.check:SetID(lineplusoffset); |
button:SetID(lineplusoffset); |
local topText = "Insert above task " .. lineplusoffset; |
local btmText = "Insert below task " .. lineplusoffset; |
button.topDropHandler:SetFormattedText("%s - %s - %s", topText, topText, topText); |
button.topDropHandler.destLoc = lineplusoffset; |
button.bottomDropHandler:SetFormattedText("%s - %s - %s", btmText, btmText, btmText); |
button.bottomDropHandler.destLoc = lineplusoffset + 1; |
if lineplusoffset ~= Torta.cl3.openTask then |
button:UnlockHighlight(); |
else |
end |
FauxScrollFrame_SetOffset(clScrollBar, offset); |
FauxScrollFrame_Update(clScrollBar, #self:GetLoadedList().text, #self.clListButtons, 32, nil, nil, nil, nil, nil, nil, true) |
FauxScrollFrame_Update(clScrollBar, #Torta.cl3:GetLoadedList().text, #self.clListButtons, 32, nil, nil, nil, nil, nil, nil, true) |
self:CheckCLButtons(); |
self:UpdateCLScrollBar(); |
offset = offset + 1 |
end |
-- ==================================================================== |
-- Drop handler functions |
-- Drag and drop functions |
-- ==================================================================== |
function Torta.gui:clShowDropHandlers() |
for _, button in pairs(self.clListButtons) do |
button.topDropHandler:Show(); |
button.bottomDropHandler:Show(); |
UIFrameFadeOut(button.text, 0.3, button.text:GetAlpha(), 0.5); |
UIFrameFadeOut(button.check, 0.3, button.check:GetAlpha(), 0.5); |
end |
end |
for _, button in pairs(self.clListButtons) do |
button.topDropHandler:Hide(); |
button.bottomDropHandler:Hide(); |
UIFrameFadeIn(button.text, 0.3, button.text:GetAlpha(), 1); |
UIFrameFadeIn(button.check, 0.3, button.check:GetAlpha(), 1); |
end |
end |
function Torta.gui:clTaskDragStart(taskButton) |
PlaySound("INTERFACESOUND_CURSORGRABOBJECT"); |
local text = taskButton.text:GetText(); |
local stat = taskButton.check:GetChecked(); |
TortaDragThingy.text:SetText(text); |
TortaDragThingy.check:SetChecked(stat); |
TortaDragThingy:Show(); |
UIFrameFadeIn(TortaDragThingy, 0.25, 0.5, 1); |
UIFrameFadeIn(TortaDragThingy, 0.25, 0, 1); |
self:clShowDropHandlers(); |
self.dragSrcID = taskButton:GetID(); |
end |
function Torta.gui:clTaskDragStop() |
PlaySound("INTERFACESOUND_CURSORDROPOBJECT"); |
TortaDragThingy:Hide(); |
if GetMouseFocus().tortaDropType == "CLTASK" then |
UIErrorsFrame:AddMessage("This is a valid drop area!"); |
Torta.cl3:MoveTask(self.dragSrcID, GetMouseFocus().destLoc); |
GetMouseFocus():Hide(); -- If this line isn't here, the drop handler under the mouse will fail to hide |
end |
self:clHideDropHandlers(); |
end |
-- Note: |
Torta.cl3:ModifyOpenTask( getglobal( self:GetParent():GetName() .. "EditBox" ):GetText() ); |
Torta.gui:UpdateCLScrollBar(); |
Torta.cl3:HideTaskEditor(); |
else |
-- Add a setting that stops the editor from closing when escape is pressed sometime later. |
Torta.cl3:HideTaskEditor(); |
end |
</OnEscapePressed> |
<OnEnterPressed> |
fs:SetJustifyV("TOP"); |
self.text = fs; |
</OnLoad> |
<OnEnter> |
if self.text:GetStringWidth() >= (self:GetWidth() - 10) then |
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT"); |
GameTooltip:AddLine(self.text:GetText()); |
GameTooltip:Show(); |
end |
</OnEnter> |
<OnLeave> |
if GameTooltip:IsOwned(self) then |
GameTooltip:Hide(); |
end |
</OnLeave> |
</Scripts> |
</Button> |
self.dragFlag = true; |
</OnMouseDown> |
<OnMouseUp> |
if not self.dragFlag then |
Torta.gui:clTaskDragStop(); |
end |
self.dragFlag = false; |
Torta.gui:clTaskDragStop(); |
</OnMouseUp> |
<OnLeave> |
if self.dragFlag then |
Torta.gui:clTaskDragStart(self); |
self.dragFlag = false; |
end |
</OnLeave> |
</Scripts> |
</Scripts> |
</CheckButton> |
<!-- Drop areas --> |
<Button name="$parentTopDropHandler" text="Top" hidden="true"> |
<Button name="$parentTopDropHandler" text="Above this task" hidden="true" alpha="0"> |
<NormalFont style="GameFontNormal"/> |
<Anchors> |
<Anchor point="TOPLEFT"/> |
self.tortaDropType = "CLTASK"; |
self:GetParent().topDropHandler = self; |
</OnLoad> |
<OnEnter> |
UIFrameFadeIn(self, 0.3, self:GetAlpha(), 1); |
</OnEnter> |
<OnLeave> |
UIFrameFadeOut(self, 0.3, self:GetAlpha(), 0); |
</OnLeave> |
<OnUpdate> |
</OnUpdate> |
</Scripts> |
</Button> |
<Button name="$parentBottomDropHandler" text="Bottom" hidden="true"> |
<Button name="$parentBottomDropHandler" text="Below this task" hidden="true" alpha="0"> |
<NormalFont style="GameFontNormal"/> |
<Anchors> |
<Anchor point="TOPLEFT" relativePoint="LEFT"/> |
self.tortaDropType = "CLTASK"; |
self:GetParent().bottomDropHandler = self; |
</OnLoad> |
<OnEnter> |
UIFrameFadeIn(self, 0.3, self:GetAlpha(), 1); |
</OnEnter> |
<OnLeave> |
UIFrameFadeOut(self, 0.3, self:GetAlpha(), 0); |
</OnLeave> |
<OnUpdate> |
</OnUpdate> |
</Scripts> |
</Button> |
<!-- End of drop areas --> |
</Layers> |
</ScrollFrame> |
<Frame name="TortaDragThingy" inherits="TortaTooltipStyleFrameTemplate" parent="UIParent" frameStrata="TOOLTIP"> |
<Frame name="TortaDragThingy" inherits="TortaTooltipStyleFrameTemplate" parent="UIParent" |
frameStrata="TOOLTIP" hidden="true"> |
<Size x="200" y="40"/> |
<Anchors> |
<Anchor point="CENTER"/> |
Torta.gui:CheckExplorerWindow(); |
</OnMouseUp> |
<OnEnter> |
GameTooltip:SetOwner(self, "ANCHOR_CURSOR"); |
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT"); |
GameTooltip:AddLine("Drag here to resize the Torta window."); |
GameTooltip:Show(); |
</OnEnter> |
Torta.gui:CheckExplorerWindow(); |
</OnMouseUp> |
<OnEnter> |
GameTooltip:SetOwner(self, "ANCHOR_CURSOR"); |
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT"); |
GameTooltip:AddLine("Drag here to resize the Torta window."); |
GameTooltip:Show(); |
</OnEnter> |