- Added scale options.

- New API: instance:GetRealSize() return the width and height scaled.
- New API: instance:GetPositionOnScreen() return the window x, y position on screen.
- New API: instance:SetWindowScale (scale) set the window scale.
- New API: instance:IsGroupedWith (instance) return if self is groupped with instance.
- New API: instance:GetInstanceGroup([,instance id]) return a table with instance in the group.
This commit is contained in:
tercio
2014-10-03 16:53:42 -03:00
parent 635d3eba65
commit 28de6a9065
10 changed files with 227 additions and 58 deletions
+5 -4
View File
File diff suppressed because one or more lines are too long
+27 -3
View File
@@ -644,13 +644,18 @@ function _detalhes:EstaAgrupada (esta_instancia, lado) --> lado //// 1 = encosto
end
function _detalhes:BaseFrameSnap()
for meu_id, instancia in _ipairs (_detalhes.tabela_instancias) do
if (instancia:IsAtiva()) then
instancia.baseframe:ClearAllPoints()
end
end
local group = self:GetInstanceGroup()
local scale = self.window_scale
for _, instance in _ipairs (group) do
instance:SetWindowScale (scale)
end
local my_baseframe = self.baseframe
for lado, snap_to in _pairs (self.snap) do
--print ("DEBUG instancia " .. snap_to .. " lado "..lado)
@@ -774,12 +779,14 @@ end
function _detalhes:agrupar_janelas (lados)
local instancia = self
for lado, esta_instancia in _pairs (lados) do
if (esta_instancia) then
instancia.baseframe:ClearAllPoints()
esta_instancia = _detalhes.tabela_instancias [esta_instancia]
instancia:SetWindowScale (esta_instancia.window_scale)
if (lado == 3) then --> direita
--> mover frame
instancia.baseframe:SetPoint ("TOPRIGHT", esta_instancia.baseframe, "TOPLEFT")
@@ -1624,7 +1631,24 @@ function _detalhes:SetBackgroundAlpha (alpha)
end
function _detalhes:GetSize()
return self.bgframe:GetWidth(), self.bgframe:GetHeight()
return self.baseframe:GetWidth(), self.baseframe:GetHeight()
end
function _detalhes:GetRealSize()
return self.baseframe:GetWidth() * self.baseframe:GetScale(), self.baseframe:GetHeight() * self.baseframe:GetScale()
end
function _detalhes:GetPositionOnScreen()
local xOfs, yOfs = self.baseframe:GetCenter()
if (not xOfs) then
return
end
-- credits to ckknight (http://www.curseforge.com/profiles/ckknight/)
local _scale = self.baseframe:GetEffectiveScale()
local _UIscale = UIParent:GetScale()
xOfs = xOfs*_scale - GetScreenWidth()*_UIscale/2
yOfs = yOfs*_scale - GetScreenHeight()*_UIscale/2
return xOfs/_UIscale, yOfs/_UIscale
end
--> alias
+2
View File
@@ -45,6 +45,8 @@ _detalhes.instance_defaults = {
--skin
skin = "Minimalistic v2",
--scale
window_scale = 1.0,
--baseframe backdrop
bg_alpha = 0.7,
bg_r = 0.0941,
+4
View File
@@ -655,6 +655,10 @@ end
--> todo: remove the function creation everytime this function run.
function gump:Fade (frame, tipo, velocidade, parametros)
--if (frame.GetObjectType and frame:GetObjectType() == "Frame" and frame.GetName and type (frame:GetName()) == "string" and frame:GetName():find ("DetailsBaseFrame")) then
-- print (debugstack())
--end
if (_type (frame) == "table") then
if (frame.meu_id) then --> ups, é uma instância
if (parametros == "barras") then --> hida todas as barras da instância
+39 -34
View File
@@ -133,34 +133,35 @@
end
function _detalhes:AtualizaPontos()
local xOfs, yOfs = self.baseframe:GetCenter()
if (not xOfs) then
local _x, _y = self:GetPositionOnScreen()
if (not _x) then
return
end
-- credits to ckknight (http://www.curseforge.com/profiles/ckknight/)
local _scale = self.baseframe:GetEffectiveScale()
local _UIscale = _UIParent:GetScale()
xOfs = xOfs*_scale - _GetScreenWidth()*_UIscale/2
yOfs = yOfs*_scale - _GetScreenHeight()*_UIscale/2
local _x = xOfs/_UIscale
local _y = yOfs/_UIscale
local _w = self.baseframe:GetWidth()
local _h = self.baseframe:GetHeight()
local _w, _h = self:GetRealSize()
local metade_largura = _w/2
local metade_altura = _h/2
local statusbar_y_mod = 0
if (not self.show_statusbar) then
statusbar_y_mod = 14
statusbar_y_mod = 14 * self.baseframe:GetScale()
end
self.ponto1 = {x = _x - metade_largura, y = _y + metade_altura + (statusbar_y_mod*-1)} --topleft
self.ponto2 = {x = _x - metade_largura, y = _y - metade_altura + statusbar_y_mod} --bottomleft
self.ponto3 = {x = _x + metade_largura, y = _y - metade_altura + statusbar_y_mod} --bottomright
self.ponto4 = {x = _x + metade_largura, y = _y + metade_altura + (statusbar_y_mod*-1)} --topright
if (not self.ponto1) then
self.ponto1 = {x = _x - metade_largura, y = _y + metade_altura + (statusbar_y_mod*-1)} --topleft
self.ponto2 = {x = _x - metade_largura, y = _y - metade_altura + statusbar_y_mod} --bottomleft
self.ponto3 = {x = _x + metade_largura, y = _y - metade_altura + statusbar_y_mod} --bottomright
self.ponto4 = {x = _x + metade_largura, y = _y + metade_altura + (statusbar_y_mod*-1)} --topright
else
self.ponto1.x = _x - metade_largura
self.ponto1.y = _y + metade_altura + (statusbar_y_mod*-1)
self.ponto2.x = _x - metade_largura
self.ponto2.y = _y - metade_altura + statusbar_y_mod
self.ponto3.x = _x + metade_largura
self.ponto3.y = _y - metade_altura + statusbar_y_mod
self.ponto4.x = _x + metade_largura
self.ponto4.y = _y + metade_altura + (statusbar_y_mod*-1)
end
end
function _detalhes:SaveMainWindowPosition (instance)
@@ -178,21 +179,14 @@
end
--> calc position
local xOfs, yOfs = self.baseframe:GetCenter()
if (not xOfs) then
local _x, _y = self:GetPositionOnScreen()
if (not _x) then
return _detalhes:ScheduleTimer ("SaveMainWindowPosition", 1, self)
end
local _scale = self.baseframe:GetEffectiveScale()
local _UIscale = _UIParent:GetScale()
--
xOfs = xOfs*_scale - _GetScreenWidth()*_UIscale/2
yOfs = yOfs*_scale - _GetScreenHeight()*_UIscale/2
--> save the position
local _w = baseframe_width
local _h = baseframe_height
local _x = xOfs/_UIscale
local _y = yOfs/_UIscale
self.posicao[mostrando].x = _x
self.posicao[mostrando].y = _y
@@ -208,14 +202,25 @@
statusbar_y_mod = 14
end
self.ponto1 = {x = _x - metade_largura, y = _y + metade_altura + (statusbar_y_mod*-1)} --topleft
self.ponto2 = {x = _x - metade_largura, y = _y - metade_altura + statusbar_y_mod} --bottomleft
self.ponto3 = {x = _x + metade_largura, y = _y - metade_altura + statusbar_y_mod} --bottomright
self.ponto4 = {x = _x + metade_largura, y = _y + metade_altura + (statusbar_y_mod*-1)} --topright
if (not self.ponto1) then
self.ponto1 = {x = _x - metade_largura, y = _y + metade_altura + (statusbar_y_mod*-1)} --topleft
self.ponto2 = {x = _x - metade_largura, y = _y - metade_altura + statusbar_y_mod} --bottomleft
self.ponto3 = {x = _x + metade_largura, y = _y - metade_altura + statusbar_y_mod} --bottomright
self.ponto4 = {x = _x + metade_largura, y = _y + metade_altura + (statusbar_y_mod*-1)} --topright
else
self.ponto1.x = _x - metade_largura
self.ponto1.y = _y + metade_altura + (statusbar_y_mod*-1)
self.ponto2.x = _x - metade_largura
self.ponto2.y = _y - metade_altura + statusbar_y_mod
self.ponto3.x = _x + metade_largura
self.ponto3.y = _y - metade_altura + statusbar_y_mod
self.ponto4.x = _x + metade_largura
self.ponto4.y = _y + metade_altura + (statusbar_y_mod*-1)
end
self.baseframe.BoxBarrasAltura = self.baseframe:GetHeight() - end_window_spacement --> espaço para o final da janela
return {altura = self.baseframe:GetHeight(), largura = self.baseframe:GetWidth(), x = xOfs/_UIscale, y = yOfs/_UIscale}
return {altura = self.baseframe:GetHeight(), largura = self.baseframe:GetWidth(), x = _x, y = _y}
end
function _detalhes:RestoreMainWindowPosition (pre_defined)
+2
View File
@@ -485,6 +485,8 @@ function _detalhes:SaveProfile (saveas)
exported.__snapV = instance.verticalSnap
profile.instances [index] = exported
end
_detalhes:SaveLocalInstanceConfig()
--> end
return profile
+18
View File
@@ -5531,7 +5531,21 @@ function window:CreateFrame6()
g:NewLabel (frame6, _, "$parentStatusbarColorLabel", "statusbarColorLabel", Loc ["STRING_OPTIONS_INSTANCE_STATUSBARCOLOR"], "GameFontHighlightLeft")
frame6.statusbarColorPick:SetPoint ("left", frame6.statusbarColorLabel, "right", 2, 0)
window:CreateLineBackground2 (frame6, "statusbarColorPick", "statusbarColorLabel", Loc ["STRING_OPTIONS_INSTANCE_STATUSBARCOLOR_DESC"])
--> window scale
local s = g:NewSlider (frame6, _, "$parentWindowScaleSlider", "WindowScaleSlider", SLIDER_WIDTH, 20, 0.65, 1.5, 0.02, instance.window_scale, true)
s:SetBackdrop (slider_backdrop)
s:SetBackdropColor (unpack (slider_backdrop_color))
s:SetThumbSize (50)
frame6.WindowScaleSlider:SetHook ("OnValueChange", function (self, instance, amount)
instance:SetWindowScale (amount, true)
end)
g:NewLabel (frame6, _, "$parentWindowScaleLabel", "WindowScaleLabel", Loc ["STRING_OPTIONS_WINDOW_SCALE"], "GameFontHighlightLeft")
frame6.WindowScaleSlider:SetPoint ("left", frame6.WindowScaleLabel, "right", 2)
window:CreateLineBackground2 (frame6, "WindowScaleSlider", "WindowScaleLabel", Loc ["STRING_OPTIONS_WINDOW_SCALE_DESC"])
--general anchor
g:NewLabel (frame6, _, "$parentAdjustmentsAnchor", "AdjustmentsAnchorLabel", Loc ["STRING_OPTIONS_WINDOW_ANCHOR"], "GameFontNormal")
@@ -5552,6 +5566,7 @@ function window:CreateFrame6()
{"stretchAlwaysOnTopLabel", 7},
{"backdropLabel", 9},
{"strataLabel", 10},
{"WindowScaleLabel", 11},
}
window:arrange_menu (frame6, left_side, x, window.top_start_at)
@@ -8106,6 +8121,9 @@ function window:update_all (editing_instance)
_G.DetailsOptionsWindow6InstanceMicroDisplaysSideSlider.MyObject:SetFixedParameter (editing_instance)
_G.DetailsOptionsWindow6InstanceMicroDisplaysSideSlider.MyObject:SetValue (editing_instance.micro_displays_side)
_G.DetailsOptionsWindow6WindowScaleSlider.MyObject:SetFixedParameter (editing_instance)
_G.DetailsOptionsWindow6WindowScaleSlider.MyObject:SetValue (editing_instance.window_scale)
--> window 7
_G.DetailsOptionsWindow7AutoHideLeftMenuSwitch.MyObject:SetFixedParameter (editing_instance)
+122 -9
View File
@@ -386,9 +386,9 @@ end
local function VPB (instancia, esta_instancia)
--> conferir baixo
if (instancia.ponto1.y+20 < esta_instancia.ponto2.y-16) then --> a janela esta em baixo
if (instancia.ponto1.y+(20 * instancia.window_scale) < esta_instancia.ponto2.y - (16 * esta_instancia.window_scale)) then --> a janela esta em baixo
if (instancia.ponto1.x > esta_instancia.ponto2.x-100 and instancia.ponto1.x < esta_instancia.ponto2.x+100) then --> a janela esta a 20 pixels de distância para a esquerda ou para a direita
if (instancia.ponto1.y+20 > esta_instancia.ponto2.y-16-20) then --> esta a 20 pixels de distância
if (instancia.ponto1.y+(20 * instancia.window_scale) > esta_instancia.ponto2.y - (36 * esta_instancia.window_scale)) then --> esta a 20 pixels de distância
return 2
end
end
@@ -410,9 +410,9 @@ end
local function VPT (instancia, esta_instancia)
--> conferir cima
if (instancia.ponto3.y-16 > esta_instancia.ponto4.y+20) then --> a janela esta em cima
if (instancia.ponto3.y - (16 * instancia.window_scale) > esta_instancia.ponto4.y + (20 * esta_instancia.window_scale)) then --> a janela esta em cima
if (instancia.ponto3.x > esta_instancia.ponto4.x-100 and instancia.ponto3.x < esta_instancia.ponto4.x+100) then --> a janela esta a 20 pixels de distância para a esquerda ou para a direita
if (esta_instancia.ponto4.y+20+20 > instancia.ponto3.y-16) then
if (esta_instancia.ponto4.y+(40 * esta_instancia.window_scale) > instancia.ponto3.y - (16 * instancia.window_scale)) then
return 4
end
end
@@ -426,8 +426,11 @@ local color_green = {0.2, 1, 0.2}
local update_line = function (self, target_frame)
--> based on weak auras frame movement code
local selfX, selfY = target_frame:GetCenter()
local anchorX, anchorY = self:GetCenter()
--local selfX, selfY = target_frame:GetCenter()
local selfX, selfY = target_frame.instance:GetPositionOnScreen()
--local anchorX, anchorY = self:GetCenter()
local anchorX, anchorY = self.instance:GetPositionOnScreen()
selfX, selfY = selfX or 0, selfY or 0
anchorX, anchorY = anchorX or 0, anchorY or 0
@@ -647,6 +650,11 @@ local function move_janela (baseframe, iniciando, instancia)
instancia:BaseFrameSnap()
baseframe:StartMoving()
local group = instancia:GetInstanceGroup()
for _, this_instance in _ipairs (group) do
this_instance.baseframe:SetClampRectInsets (0, 0, 0, 0)
end
local _, ClampLeft, ClampRight = instancia:InstanciasHorizontais()
local _, ClampBottom, ClampTop = instancia:InstanciasVerticais()
@@ -793,7 +801,7 @@ local function move_janela (baseframe, iniciando, instancia)
if (esquerda or baixo or direita or cima) then
instancia:agrupar_janelas ({esquerda, baixo, direita, cima})
end
--aqui
for _, esta_instancia in _ipairs (_detalhes.tabela_instancias) do
if (not esta_instancia:IsAtiva() and esta_instancia.iniciada) then
esta_instancia:ResetaGump()
@@ -4981,6 +4989,9 @@ function _detalhes:ChangeSkin (skin_name)
end
end
--> set the scale
self:SetWindowScale()
if (not just_updating or _detalhes.initializing) then
if (this_skin.callback) then
this_skin:callback (self, just_updating)
@@ -5425,6 +5436,103 @@ function _detalhes:MicroDisplaysSide (side, fromuser)
end
function _detalhes:IsGroupedWith (instance)
local id = instance:GetId()
for side, instanceId in _pairs (self.snap) do
if (instanceId == id) then
return true
end
end
return false
end
function _detalhes:GetInstanceGroup (instance_id)
local instance = self
if (instance_id) then
instance = _detalhes:GetInstance (instance_id)
if (not instance or not instance:IsEnabled()) then
return
end
end
local current_group = {instance}
for side, insId in _pairs (instance.snap) do
if (insId < instance:GetId()) then
local last_id = instance:GetId()
for i = insId, 1, -1 do
local this_instance = _detalhes:GetInstance (i)
local got = false
if (this_instance and this_instance:IsEnabled()) then
for side, id in _pairs (this_instance.snap) do
if (id == last_id) then
tinsert (current_group, this_instance)
got = true
last_id = i
end
end
end
if (not got) then
break
end
end
else
local last_id = instance:GetId()
for i = insId, _detalhes.instances_amount do
local this_instance = _detalhes:GetInstance (i)
local got = false
if (this_instance and this_instance:IsEnabled()) then
for side, id in _pairs (this_instance.snap) do
if (id == last_id) then
tinsert (current_group, this_instance)
got = true
last_id = i
end
end
end
if (not got) then
break
end
end
end
end
return current_group
end
function _detalhes:SetWindowScale (scale, from_options)
if (not scale) then
scale = self.window_scale
end
self.window_scale = scale
self.baseframe:SetScale (scale)
self.rowframe:SetScale (scale)
if (from_options) then
local group = self:GetInstanceGroup()
for _, instance in _ipairs (group) do
instance.baseframe:SetScale (scale)
instance.rowframe:SetScale (scale)
instance.window_scale = scale
end
for _, instance in _ipairs (group) do
_detalhes.move_janela_func (instance.baseframe, true, instance)
_detalhes.move_janela_func (instance.baseframe, false, instance)
end
for _, instance in _ipairs (group) do
instance:SaveMainWindowPosition()
end
end
end
function _detalhes:ToolbarSide (side)
if (not side) then
@@ -6642,8 +6750,13 @@ function gump:CriaCabecalho (baseframe, instancia)
end
if (ClosedInstances == 0) then
CoolTip:AddMenu (1, _detalhes.CriarInstancia, true, nil, nil, Loc ["STRING_NOCLOSED_INSTANCES"], _, true)
CoolTip:AddIcon ([[Interface\Buttons\UI-AttributeButton-Encourage-Up]], 1, 1, 16, 16)
if (_detalhes:GetNumInstancesAmount() == _detalhes:GetMaxInstancesAmount()) then
CoolTip:AddMenu (1, _detalhes.CriarInstancia, true, nil, nil, Loc ["STRING_NOMORE_INSTANCES"], _, true)
CoolTip:AddIcon ([[Interface\Buttons\UI-PlusButton-Up]], 1, 1, 16, 16)
else
CoolTip:AddMenu (1, _detalhes.CriarInstancia, true, nil, nil, Loc ["STRING_NOCLOSED_INSTANCES"], _, true)
CoolTip:AddIcon ([[Interface\Buttons\UI-AttributeButton-Encourage-Up]], 1, 1, 16, 16)
end
end
GameCooltip:SetWallpaper (1, [[Interface\SPELLBOOK\Spellbook-Page-1]], {.6, 0.1, 0, 0.64453125}, {1, 1, 1, 0.1}, true)
+1
View File
@@ -143,6 +143,7 @@ function _detalhes.switch:ShowMe (instancia)
_detalhes.switch:Resize()
_detalhes.switch:Update()
_detalhes.switch.frame:SetScale (instancia.window_scale)
_detalhes.switch.frame:Show()
if (not _detalhes.tutorial.bookmark_tutorial) then
+7 -8
View File
@@ -157,18 +157,17 @@ function _G._detalhes:Start()
self.RefreshAfterStartup = nil
function _detalhes:CheckWallpaperAfterStartup()
for _, instance in ipairs (self.tabela_instancias) do
if (not instance.wallpaper.enabled) then
if (instance:IsAtiva()) then
for i = 1, self.instances_amount do
local instance = self:GetInstance (i)
if (instance and instance:IsEnabled()) then
if (not instance.wallpaper.enabled) then
instance:InstanceWallpaper (false)
end
self.move_janela_func (instance.baseframe, true, instance)
self.move_janela_func (instance.baseframe, false, instance)
end
if (instance:IsEnabled()) then
_detalhes.move_janela_func (instance.baseframe, true, instance)
_detalhes.move_janela_func (instance.baseframe, false, instance)
end
self.CheckWallpaperAfterStartup = nil
end
self.CheckWallpaperAfterStartup = nil
end
_detalhes:ScheduleTimer ("CheckWallpaperAfterStartup", 5)