-
-
Save Industrial/7887be32564ddd737535 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local _G = _G | |
local TL, TC, TR = 'TOPLEFT', 'TOP', 'TOPRIGHT' | |
local ML, MC, MR = 'LEFT', 'CENTER', 'RIGHT' | |
local BL, BC, BR = 'BOTTOMLEFT', 'BOTTOM', 'BOTTOMRIGHT' | |
local CreateFrame = _G.CreateFrame | |
local M = _G.idAddon:NewModule( | |
'ChatFrame', | |
'AceConsole-3.0', | |
'AceEvent-3.0' | |
) | |
local frame_width = 400 | |
local frame_height = 300 | |
local padding = 5 | |
local spacing = 0 | |
local line_height = 20 | |
local num_lines = 50 | |
local function backdrop(f, r, g, b, a) | |
f:SetBackdrop({ | |
bgFile = 'Interface/Tooltips/UI-Tooltip-Background', | |
edgeFile = '', | |
tile = true, | |
tileSize = 16, | |
edgeSize = 0, | |
insets = { | |
left = 0, | |
right = 0, | |
top = 0, | |
bottom = 0 | |
} | |
}) | |
f:SetBackdropColor(r, g, b, a) | |
end | |
function M:OnInitialize() | |
local frame = CreateFrame('Frame', 'idAddon_ChatFrame_Frame', UIParent) | |
frame:SetWidth(frame_width) | |
frame:SetHeight(frame_height) | |
frame:SetPoint(MC, UIParent, MC) | |
frame:Show() | |
backdrop(frame, 0, 0, 0, 1) | |
local scroll_frame = CreateFrame('ScrollFrame', 'idAddon_ChatFrame_Frame_ScrollFrame', frame, 'UIPanelScrollFrameTemplate') | |
scroll_frame:SetAllPoints(frame) | |
backdrop(scroll_frame, 1, 0, 0, 1) | |
local scroll_child = CreateFrame('Frame', nil, scroll_frame) | |
scroll_child:SetPoint(TL, scroll_frame, TL) | |
scroll_child:SetWidth(frame_width) | |
scroll_child:SetHeight(line_height * num_lines + padding * 2) | |
scroll_frame:SetScrollChild(scroll_child) | |
backdrop(scroll_child, 0, 1, 0, 1) | |
local lines = {} | |
local line | |
for i = 1, num_lines do | |
line = CreateFrame('Frame', nil, scroll_child) | |
line:SetWidth(frame_width - padding * 2) | |
line:SetHeight(line_height) | |
line:Show() | |
line.text = line:CreateFontString(nil, 'ARTWORK', 'GameFontNormal') | |
line.text:SetPoint(ML, line, ML) | |
line.text:SetPoint(MR, line, MR) | |
line.text:SetText('test test test test test test') | |
if i == 1 then | |
line:SetPoint(TL, scroll_child, TL, padding, -padding) | |
else | |
line:SetPoint(TL, lines[i - 1], BL, 0, -spacing) | |
end | |
lines[i] = line | |
end | |
end | |
function M:OnEnable() | |
end | |
function M:OnDisable() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment