-- Copyright 2023 -- -- This file is part of Omicron Frames -- -- Omicron Frames is free software: you can redistribute it and/or modify it -- under the terms of the GNU General Public License as published by the Free -- Software Foundation, either version 3 of the License, or (at your option) -- any later version. -- -- Omicron Frames is distributed in the hope that it will be useful, but -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -- more details. -- -- You should have received a copy of the GNU General Public License along with -- Omicron Frames. If not, see . local omi = select(2, ...) local types = omi.GetModule("types") types.StatusBar = types.CreateClass("StatusBar") local StatusBar = types.StatusBar function StatusBar:Init(parent, width, height, level, top) if top == nil then top = true end level = level or 0 -- parent: the parent frame self.parent = parent local parentFrame = parent.secureFrame local bar = CreateFrame("StatusBar", nil, parentFrame) bar:SetFrameStrata("MEDIUM") bar:SetFrameLevel(level) if top then bar:SetPoint("TOPLEFT", parentFrame, "TOPLEFT", 0, 0) else bar:SetPoint("BOTTOMLEFT", parentFrame, "BOTTOMLEFT", 0, 0) end bar:SetSize(width, height) bar:SetStatusBarTexture("Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal") bar:GetStatusBarTexture():SetHorizTile(false) bar:GetStatusBarTexture():SetVertTile(false) self.bar = bar local bg = bar:CreateTexture(nil, "BACKGROUND") bg:SetTexture("Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal") bg:SetAllPoints(true) self.bg = bg self:SetRange(0, 1) self:SetValue(1) bar:Show() end function StatusBar:SetRange(min, max) self.bar:SetMinMaxValues(min, max) end function StatusBar:SetValue(value) self.bar:SetValue(value) end function StatusBar:Show() self.bar:Show() end function StatusBar:Hide() self.bar:Hide() end function StatusBar:SetInterpolatedColor(start, stop, progress) local r = start[1] + (stop[1] - start[1])*progress local g = start[2] + (stop[2] - start[2])*progress local b = start[3] + (stop[3] - start[3])*progress self:SetColor(r, g, b) end function StatusBar:SetColor(r, g, b) self.bar:SetStatusBarColor(r, g, b) self.bg:SetVertexColor(0.2*r, 0.2*g, 0.2*b) end