-------------------------
-- Sphere Font Creator --
-------------------------
local addon, ns = ...
local ss = ns.SS

local CreateFrame = CreateFrame

local mtFont = {}

--- Creates new sphere text displays.
-- @param parent The parent container
-- @param displayMode The sphere display mode.
-- @param c1 The color for font 1.
-- @param c2 The color for font 2.
-- @param dual Flag for split textures.
-- @return The fonts frames.
--
function mtFont:New(parent, displayMode, c1, c2, dual)
  local fontFrameLevel = (displayMode == "active") and 4 or (4 + ss.private.layout.config.frameLevelAdjust)
  local frameStrata    = ((displayMode == "active") and "MEDIUM" or "HIGH")

  local fontHolder = CreateFrame("FRAME", ss._f..parent.configName.."_fontholder", parent)
  fontHolder:SetFrameStrata(frameStrata)
  fontHolder:SetAllPoints  (parent)
  fontHolder:SetFrameLevel (fontFrameLevel)

  local font1 = fontHolder:CreateFontString(nil,"OVERLAY")
  local font2 = fontHolder:CreateFontString(nil,"OVERLAY")

  self:SetFonts(font1,font2,dual)

  font1:SetTextColor(ss.Utils:GetRGBAValues(c1))
  font2:SetTextColor(ss.Utils:GetRGBAValues(c2))

  return fontHolder, font1, font2
end

--- Updates the displayed fonts.
-- @param font1 The font to use for font 1.
-- @param font2 The font to use for font 2.
-- @param dual Flag for split textures.
--
function mtFont:SetFonts(font1, font2, dual)
  if dual then
    font1:SetFont (ss.private.font.sphere, ss.private.fontSize.sphereSmall, ss.private.fontFlag.sphere)
    font1:SetPoint("CENTER",-20,5)
    font2:SetFont (ss.private.font.sphere, ss.private.fontSize.sphereSmall, ss.private.fontFlag.sphere)
    font2:SetPoint("CENTER",20,5)
  else
    font1:SetFont (ss.private.font.sphere, ss.private.fontSize.sphereLarge, ss.private.fontFlag.sphere)
    font1:SetPoint("CENTER",0,15)
    font2:SetFont (ss.private.font.sphere, ss.private.fontSize.sphereMedium, ss.private.fontFlag.sphere)
    font2:SetPoint("CENTER",0,-5)
  end
end

ss.Utils.addModule("FontCreator", mtFont)
