local name, addon = ...
function addon:CreateKeyboard()
local Keyboard = CreateFrame("Frame", 'KeyUIMainFrame', UIParent, "TooltipBorderedFrameTemplate") -- the frame holding the keys
tinsert(UISpecialFrames, "KeyUIMainFrame")
Keyboard:SetWidth(1099)
Keyboard:SetHeight(448)
Keyboard:SetBackdropColor(0, 0, 0, 0.9)
Keyboard:SetPoint("CENTER", UIParent, "CENTER", -300, 50)
Keyboard:SetScript("OnMouseDown", function(self) self:StartMoving() end)
Keyboard:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end)
Keyboard:SetMovable(true) -- make the keyboard moveable
Keyboard:SetScale(1)
addon.keyboardFrame = Keyboard
return Keyboard
end
function addon:CreateControls()
local Controls = CreateFrame("Frame", 'KBControlsFrame', UIParent, "TooltipBorderedFrameTemplate")
tinsert(UISpecialFrames, "KBControlsFrame")
local Keyboard = addon.keyboardFrame
local modif = self.modif
Controls:SetBackdropColor(0, 0, 0, 1)
Controls:SetPoint("BOTTOM", Keyboard, "TOP", 0, -2)
local function OnMaximize()
Controls:SetHeight(100)
Controls:SetWidth(Keyboard:GetWidth())
maximizeFlag = true
print("maximizeFlag is true")
if not Controls.Slider then
Controls.Slider = CreateFrame("Slider", "KUI_Slider1", Controls, "OptionsSliderTemplate")
Controls.Slider:SetMinMaxValues(0.5, 1)
Controls.Slider:SetValueStep(0.05)
Controls.Slider:SetValue(1)
_G[Controls.Slider:GetName().."Low"]:SetText("0.5")
_G[Controls.Slider:GetName().."High"]:SetText("1")
Controls.Slider:SetScript("OnValueChanged", function(self) Keyboard:SetScale(self:GetValue()) Controls:SetScale(self:GetValue()) end)
Controls.Slider:SetWidth(224)
Controls.Slider:SetHeight(20)
Controls.Slider:SetPoint("BOTTOM", Controls, "BOTTOM", 0, 0)
Controls.ShiftCB = CreateFrame("CheckButton", "KeyBindShiftCB", Controls, "ChatConfigCheckButtonTemplate")
_G[Controls.ShiftCB:GetName().."Text"]:SetText("Shift")
Controls.ShiftCB:SetHitRectInsets(0, -40, 0, 0)
Controls.ShiftCB:SetPoint("TOP", Controls, "TOPLEFT", 26, -84)
Controls.ShiftCB:SetScript("OnClick", function(s)
if s:GetChecked() then
modif.SHIFT = "SHIFT-"
else
modif.SHIFT = ""
end
addon:RefreshKeys()
end)
Controls.ShiftCB:SetSize(30, 30)
Controls.CtrlCB = CreateFrame("CheckButton", "KeyBindCtrlCB", Controls, "ChatConfigCheckButtonTemplate")
_G[Controls.CtrlCB:GetName().."Text"]:SetText("Ctrl")
Controls.CtrlCB:SetHitRectInsets(0, -40, 0, 0)
Controls.CtrlCB:SetPoint("TOP", Controls, "TOP", 0, -84)
Controls.CtrlCB:SetScript("OnClick", function(s)
if s:GetChecked() then
modif.CTRL = "CTRL-"
else
modif.CTRL = ""
end
addon:RefreshKeys()
end)
Controls.CtrlCB:SetSize(30, 30)
Controls.AltCB = CreateFrame("CheckButton", "KeyBindAltCB", Controls, "ChatConfigCheckButtonTemplate")
_G[Controls.AltCB:GetName().."Text"]:SetText("Alt")
Controls.AltCB:SetHitRectInsets(0, -40, 0, 0)
Controls.AltCB:SetPoint("TOP", Controls, "TOPRIGHT", -46, -84)
Controls.AltCB:SetScript("OnClick", function(s)
if s:GetChecked() then
modif.ALT = "ALT-"
else
modif.ALT = ""
end
addon:RefreshKeys()
end)
Controls.AltCB:SetSize(30, 30)
end
Controls.Slider:Show()
Controls.ShiftCB:Show()
Controls.CtrlCB:Show()
Controls.AltCB:Show()
end
local function OnMinimize()
Controls:SetHeight(26)
Controls:SetWidth(Keyboard:GetWidth())
maximizeFlag = false
print("maximizeFlag is false")
if Controls.Slider then
Controls.Slider:Hide()
Controls.ShiftCB:Hide()
Controls.CtrlCB:Hide()
Controls.AltCB:Hide()
end
end
Controls.Close = CreateFrame("Button", "$parentClose", Controls, "UIPanelCloseButton")
Controls.Close:SetSize(22, 22)
Controls.Close:SetPoint("TOPRIGHT", -2, -2)
Controls.Close:SetScript("OnClick", function(s) KeyUIMainFrame:Hide() KBControlsFrame:Hide() end) -- Toggle the Keyboard frame show/hide
Controls.MinMax = CreateFrame("Frame", "#parentMinMax", Controls, "MaximizeMinimizeButtonFrameTemplate")
Controls.MinMax:SetSize(22, 22)
Controls.MinMax:SetPoint("RIGHT", Controls.Close, "LEFT", 0, 0)
Controls.MinMax:SetOnMaximizedCallback(OnMaximize)
Controls.MinMax:SetOnMinimizedCallback(OnMinimize)
Controls.Refresh = CreateFrame("Button", "#parentRefresh", Controls, "RefreshButtonTemplate")
Controls.Refresh:SetSize(24, 24)
Controls.Refresh:SetPoint("RIGHT", Controls.MinMax, "LEFT", 0, 0)
Controls.Refresh:SetScript("OnClick", function(s) addon:RefreshKeys() end)
--Controls.MinMax.isMinimized = true -- Set the MinMax button & control frame size to Minimize -- this seems to have no effect?
Controls.MinMax:Minimize() -- Set the MinMax button & control frame size to Minimize
Controls.MinMax:SetMaximizedLook() -- Set the MinMax button & control frame size to Minimize
addon.controlsFrame = KBControlsFrame
return Controls
end