diff --git a/classes/include_instance.lua b/classes/include_instance.lua index c0258ea0..a094a177 100644 --- a/classes/include_instance.lua +++ b/classes/include_instance.lua @@ -193,9 +193,10 @@ _detalhes.instance_defaults = { fontstrings_text2_anchor = 73, --title bar + titlebar_shown = false, titlebar_height = 16, - titlebar_texture = "", - titlebar_color = {0, 0, 0, 0}, + titlebar_texture = "Details Serenity", + titlebar_texture_color = {.2, .2, .2, 0.8}, --full border fullborder_shown = false, diff --git a/frames/window_main.lua b/frames/window_main.lua index 802cad57..a8468c06 100644 --- a/frames/window_main.lua +++ b/frames/window_main.lua @@ -3493,6 +3493,11 @@ function gump:CriaJanelaPrincipal (ID, instancia, criando) titleBar:EnableMouse(false) baseframe.titleBar = titleBar + titleBar.texture = titleBar:CreateTexture("$parentTexture", "artwork") + titleBar.texture:SetAllPoints() + titleBar.texture:SetTexture([[Interface\AddOns\Details\images\bar_serenity]]) + titleBar.texture:SetVertexColor(0, 0, 0, 0) + --a background frame that anchors in the topleft of the title bar and bottom right of the baseframe --this frame does not attack to statusbar (yet) local fullWindowFrame = CreateFrame("frame", baseframe:GetName() .. "FullWindowFrame", baseframe, "BackdropTemplate") @@ -4305,6 +4310,43 @@ function _detalhes:SetBarBackdropSettings (enabled, size, color, use_class_color self:ReajustaGump() end +function Details:SetTitleBarSettings(shown, height, texture, color) + if (type(shown) ~= "boolean") then + shown = self.titlebar_shown + end + + if (not height) then + height = self.titlebar_height + end + + if (not texture) then + texture = self.titlebar_texture + end + + if (not color) then + color = self.titlebar_texture_color + end + + self.titlebar_shown = shown + self.titlebar_height = height + self.titlebar_texture = texture + self.titlebar_texture_color = color +end + +function Details:RefreshTitleBar() + local shown = self.titlebar_shown + local height = self.titlebar_height + local texture = self.titlebar_texture + local color = self.titlebar_texture_color + + local texturePath = SharedMedia:Fetch("statusbar", texture) + + self.baseframe.titleBar:SetShown(shown) + self.baseframe.titleBar:SetHeight(height) + self.baseframe.titleBar.texture:SetTexture(texturePath) + self.baseframe.titleBar.texture:SetVertexColor(DetailsFramework:ParseColors(color)) +end + function _detalhes:SetBarModel (upper_enabled, upper_model, upper_alpha, lower_enabled, lower_model, lower_alpha) --> is enabled @@ -7237,8 +7279,12 @@ function Details:ChangeSkin(skin_name) --> refresh lock buttons self:RefreshLockedState() - self:UpdateFullBorder() - self:UpdateRowAreaBorder() + --> update borders + self:UpdateFullBorder() + self:UpdateRowAreaBorder() + + --> update title bar + self:RefreshTitleBar() --> clear any control sscript running in this instance self.bgframe:SetScript ("OnUpdate", nil) diff --git a/frames/window_options2_sections.lua b/frames/window_options2_sections.lua index 2261c46b..ede57f24 100644 --- a/frames/window_options2_sections.lua +++ b/frames/window_options2_sections.lua @@ -2094,7 +2094,23 @@ do editInstanceSetting(currentInstance, "ChangeSkin") afterUpdate() end - + + --> custom title bar texture + local onSelectCustomTitleBarTexture = function(_, instance, textureName) + editInstanceSetting(currentInstance, "SetTitleBarSettings", nil, nil, textureName) + editInstanceSetting(currentInstance, "RefreshTitleBar") + end + + local buildTextureCustomTitleBar = function() + local textures = SharedMedia:HashTable("statusbar") + local texTable = {} + for name, texturePath in pairs (textures) do + texTable[#texTable+1] = {value = name, label = name, statusbar = texturePath, onclick = onSelectCustomTitleBarTexture} + end + table.sort(texTable, function (t1, t2) return t1.label < t2.label end) + return texTable + end + local buildIconStyleMenu = function() local iconMenu = { {value = "Interface\\AddOns\\Details\\images\\toolbar_icons", label = "Set 1", icon = "Interface\\AddOns\\Details\\images\\toolbar_icons", texcoord = {0, 0.125, 0, 1}, onclick = on_select_icon_set}, @@ -2109,7 +2125,80 @@ do local buildSection = function(sectionFrame) local sectionOptions = { - {type = "label", get = function() return Loc ["STRING_OPTIONS_ROW_SETTING_ANCHOR"] end, text_template = subSectionTitleTextTemplate}, + + {type = "label", get = function() return "Title Bar" end, text_template = subSectionTitleTextTemplate}, + + {--use custom titlebar + type = "toggle", + get = function() return currentInstance.titlebar_shown end, + set = function (self, fixedparam, value) + editInstanceSetting(currentInstance, "SetTitleBarSettings", value) + editInstanceSetting(currentInstance, "RefreshTitleBar") + afterUpdate() + end, + name = "Enable Custom Title Bar", + desc = "Use an alternative title bar instead of the title bar builtin in the Skin file.\n\n|cFFFFFF00Important|r: To disable the title bar from the Skin file, go to 'Window Body' and make the 'skin color' fully transparent.", + }, + + {--custom title bar height + type = "range", + get = function() return currentInstance.titlebar_height end, + set = function (self, fixedparam, value) + editInstanceSetting(currentInstance, "SetTitleBarSettings", nil, value) + editInstanceSetting(currentInstance, "RefreshTitleBar") + afterUpdate() + end, + min = 0, + max = 32, + step = 1, + name = "Height", + desc = "Height", + }, + + {--custom title bar texture + type = "select", + get = function() return currentInstance.titlebar_texture end, + values = function() + return buildTextureCustomTitleBar() + end, + name = Loc ["STRING_TEXTURE"], + desc = Loc ["STRING_TEXTURE"], + }, + + {--texture color + type = "color", + get = function() + local r, g, b, a = unpack(currentInstance.titlebar_texture_color) + return {r, g, b, a} + end, + set = function (self, r, g, b, a) + editInstanceSetting(currentInstance, "SetTitleBarSettings", nil, nil, nil, {r, g, b, a}) + editInstanceSetting(currentInstance, "RefreshTitleBar") + afterUpdate() + end, + name = "Color", + desc = "Color", + }, + + + --SetTitleBarSettings(shown, height, texture, color) + + {--disable all displays + type = "toggle", + get = function() return currentInstance.disable_alldisplays_window end, + set = function (self, fixedparam, value) + _detalhes.disable_alldisplays_window = value + afterUpdate() + end, + name = Loc ["STRING_OPTIONS_DISABLE_ALLDISPLAYSWINDOW"], + desc = Loc ["STRING_OPTIONS_DISABLE_ALLDISPLAYSWINDOW_DESC"], + }, + + + + {type = "blank"}, + + {type = "label", get = function() return Loc ["STRING_OPTIONS_TITLEBAR_MENUBUTTONS_HEADER"] end, text_template = subSectionTitleTextTemplate}, {type = "label", get = function() return Loc ["STRING_OPTIONS_MENU_SHOWBUTTONS"] end, text_template = options_text_template}, {--button orange gear @@ -2314,33 +2403,6 @@ do desc = Loc ["STRING_OPTIONS_PICONS_DIRECTION_DESC"], }, - {type = "blank"}, - {type = "label", get = function() return Loc ["STRING_OPTIONS_LEFT_MENU_ANCHOR"] end, text_template = subSectionTitleTextTemplate}, - - {--menu text size - type = "range", - get = function() return Details.font_sizes.menus end, - set = function (self, fixedparam, value) - Details.font_sizes.menus = value - afterUpdate() - end, - min = 5, - max = 32, - step = 1, - name = Loc ["STRING_OPTIONS_TEXT_SIZE"], - desc = Loc ["STRING_OPTIONS_MENU_FONT_SIZE_DESC"], - }, - - {--menu text font - type = "select", - get = function() return Details.font_faces.menus end, - values = function() - return buildFontMenu() - end, - name = Loc ["STRING_OPTIONS_MENU_FONT_FACE"], - desc = Loc ["STRING_OPTIONS_MENU_FONT_FACE_DESC"], - }, - {--disable reset button type = "toggle", get = function() return _detalhes.disable_reset_button end, @@ -2374,17 +2436,6 @@ do desc = Loc ["STRING_OPTIONS_MENU_AUTOHIDE_DESC"], }, - {--disable all displays - type = "toggle", - get = function() return currentInstance.disable_alldisplays_window end, - set = function (self, fixedparam, value) - _detalhes.disable_alldisplays_window = value - afterUpdate() - end, - name = Loc ["STRING_OPTIONS_DISABLE_ALLDISPLAYSWINDOW"], - desc = Loc ["STRING_OPTIONS_DISABLE_ALLDISPLAYSWINDOW_DESC"], - }, - {type = "breakline"}, {type = "label", get = function() return Loc ["STRING_OPTIONS_ATTRIBUTE_TEXT"] end, text_template = subSectionTitleTextTemplate}, @@ -2498,6 +2549,31 @@ do desc = Loc ["STRING_OPTIONS_MENU_ATTRIBUTE_SIDE_DESC"], }, + {type = "blank"}, + {--menu text font + type = "select", + get = function() return Details.font_faces.menus end, + values = function() + return buildFontMenu() + end, + name = Loc ["STRING_OPTIONS_MENU_FONT_FACE"], + desc = Loc ["STRING_OPTIONS_MENU_FONT_FACE_DESC"], + }, + + {--menu text size + type = "range", + get = function() return Details.font_sizes.menus end, + set = function (self, fixedparam, value) + Details.font_sizes.menus = value + afterUpdate() + end, + min = 5, + max = 32, + step = 1, + name = Loc ["STRING_OPTIONS_TEXT_SIZE"], + desc = Loc ["STRING_OPTIONS_MENU_FONT_SIZE_DESC"], + }, + } sectionFrame.sectionOptions = sectionOptions