Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ls- committed Nov 9, 2022
2 parents 4cef59a + 82095fc commit 4d86a2a
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 59 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## Version 100000.02

- Added horizontal and vertical padding options for messages.
- Fixed an issue where messages' background gradient wouldn't resize properly.
- Fixed an issue where fast forwarding would break the message display.
- Reduced the minimal possible chat frame size to 176x64, making it smaller will break stuff.
The max is uncapped.
- Added French translation. Translated by Braincell1980@Curse.

## Version 100000.01

- The initial release.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LS: Glass

Smooth as glass.
Replacement for the default chat. Smooth as glass!

![Imgur](https://i.imgur.com/8lj13ch.gif)

Expand All @@ -23,8 +23,11 @@ Feel free to add and/or review translations on [Curse](https://www.curseforge.co

## FAQ

**Q:** How is this addon related to Glass by mixxorz?
**A:** Originally, the goal was to take over that addon and maintain it. However, after reviewing the original code to figure out what I needed to do to update it for the Dragonflight expansion I decided to start from scratch. But it's fair to say that the addon is inspired by Glass, hence its name.
**`Q:`** How is this addon related to Glass by mixxorz?
**`A:`** Originally, the goal was to take over that addon and maintain it. However, after reviewing the original code to figure out what I needed to do to update it for the Dragonflight expansion I decided to start from scratch. But it's fair to say that the addon is inspired by Glass, hence its name.

**`Q:`** How do I move and/or resize the chat frame?
**`A:`** Use "Edit Mode". There's a tiny triangle in the bottom right corner of the "Chat Frame" mover that's used for resizing. Hopefully, Blizz will change it to something more noticeable in the future.

## License

Expand Down
7 changes: 6 additions & 1 deletion ls_Glass/core/changelog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ local _G = getfenv(0)

-- Mine
E.CHANGELOG = [[
- The initial release.
- Added horizontal and vertical padding options for messages.
- Fixed an issue where messages' background gradient wouldn't resize properly.
- Fixed an issue where fast forwarding would break the message display.
- Reduced the minimal possible chat frame size to 176x64, making it smaller will break stuff.
The max is uncapped.
- Added French translation. Translated by Braincell1980@Curse.
]]
42 changes: 29 additions & 13 deletions ls_Glass/core/components/messageline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ do
self.Text:SetText(text)
self.Text:SetTextColor(r or 1, g or 1, b or 1, a)

self:SetHeight(self.Text:GetStringHeight() + 4)
self:SetHeight(self.Text:GetStringHeight() + C.db.profile.chat.y_padding * 2)
end

function message_line_proto:UpdateGradient()
Expand All @@ -30,38 +30,40 @@ local function createMessageLine(parent)
local width = parent:GetWidth()

local frame = Mixin(CreateFrame("Frame", nil, parent, "LSGlassHyperlinkPropagator"), message_line_proto)
frame:SetSize(width, C.db.profile.chat.font.size + 4)
frame:SetSize(width, C.db.profile.chat.font.size + C.db.profile.chat.y_padding * 2)
frame:SetAlpha(0)
frame:Hide()

E:CreateGradientBackground(frame, E:Round(width * 0.1), E:Round(width * 0.5), 0, 0, 0, C.db.profile.chat.alpha)

frame.Text = frame:CreateFontString(nil, "ARTWORK", "LSGlassMessageFont")
frame.Text:SetPoint("LEFT", 15, 0)
frame.Text:SetPoint("RIGHT", -15, 0)
frame.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, 0)
frame.Text:SetPoint("RIGHT", -C.db.profile.chat.x_padding, 0)

return frame
end

local function resetMessageLine(messageLine, parent)
local function resetMessageLine(messageLine)
messageLine.Text:SetText("")
messageLine:ClearAllPoints()
messageLine:Hide()
messageLine:SetSize(parent:GetWidth(), C.db.profile.chat.font.size + 4)
messageLine:UpdateGradient()
E:StopFading(messageLine, 0)
end

local pools = {}

function E:CreateMessageLinePool(parent)
return CreateObjectPool(function(pool)
t_insert(pools, pool)

local pool = CreateObjectPool(function()
return createMessageLine(parent)
end, function(_, messageLine)
resetMessageLine(messageLine, parent)
resetMessageLine(messageLine)
end)

pool.parent = parent

t_insert(pools, pool)

return pool
end

function E:UpdateMessageLinesBackgrounds()
Expand All @@ -79,11 +81,25 @@ end
function E:UpdateMessageLinesHeights()
for _, pool in next, pools do
for messageLine in pool:EnumerateActive() do
messageLine:SetHeight(messageLine.Text:GetStringHeight() + 4)
messageLine:SetHeight(messageLine.Text:GetStringHeight() + C.db.profile.chat.y_padding * 2)
end

for _, messageLine in pool:EnumerateInactive() do
messageLine:SetHeight(messageLine.Text:GetStringHeight() + C.db.profile.chat.y_padding * 2)
end
end
end

function E:UpdateMessageLinesHorizPadding()
for _, pool in next, pools do
for messageLine in pool:EnumerateActive() do
messageLine.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, 0)
messageLine.Text:SetPoint("RIGHT", -C.db.profile.chat.x_padding, 0)
end

for _, messageLine in pool:EnumerateInactive() do
messageLine:SetHeight(messageLine.Text:GetStringHeight() + 4)
messageLine.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, 0)
messageLine.Text:SetPoint("RIGHT", -C.db.profile.chat.x_padding, 0)
end
end
end
93 changes: 55 additions & 38 deletions ls_Glass/core/components/slidingmessageframe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ local function chatFrame_OnSizeChanged(self, width, height)

t_wipe(slidingFrame.visibleLines)

if slidingFrame:GetNumActiveMessageLines() > 0 then
slidingFrame:ReleaseAllMessageLines()
-- TODO: Refactor it later...
if slidingFrame.messageFramePool then
if slidingFrame:GetNumActiveMessageLines() > 0 then
slidingFrame:ReleaseAllMessageLines()
end

for _, messageLine in slidingFrame.messageFramePool:EnumerateInactive() do
messageLine:SetWidth(width)
messageLine:SetGradientBackgroundSize(E:Round(width * 0.1), E:Round(width * 0.4))
end
end

slidingFrame:SetFirstMessageIndex(0)
Expand Down Expand Up @@ -86,24 +94,7 @@ local scroll_down_button_proto = {}
do
function scroll_down_button_proto:OnClick()
local frame = self:GetParent()
local num = m_min(frame:GetNumHistoryElements(), frame:GetMaxMessages(), frame:GetFirstMessageIndex())

frame:ScrollTo(num, true)

if num == frame:GetFirstMessageIndex() then
num = num + 1
end

local messages = {}
for i = num - 1, 1, -1 do
local messageInfo = frame:GetHistoryEntryAtIndex(i)
if messageInfo then
t_insert(messages, {messageInfo.message, messageInfo.r, messageInfo.g, messageInfo.b})
end
end

frame:SetFirstMessageIndex(0)
frame:ProcessIncoming(messages, true)
frame:FastForward()

E:FadeOut(self, 0, 0.1, function()
self:SetText(L["JUMP_TO_PRESENT"], true)
Expand Down Expand Up @@ -200,7 +191,7 @@ function object_proto:CaptureChatFrame(chatFrame)

chatFrame:SetClampedToScreen(false)
chatFrame:SetClampRectInsets(0, 0, 0, 0)
chatFrame:SetResizeBounds(CHAT_FRAME_MIN_WIDTH, CHAT_FRAME_NORMAL_MIN_HEIGHT)
chatFrame:SetResizeBounds(176, 64)
chatFrame:EnableMouse(false)

E:ForceHide(chatFrame.ScrollBar)
Expand Down Expand Up @@ -265,19 +256,17 @@ end
function object_proto:OnShow()
LibEasing:StopEasing(self:GetScrollingHandler())
self:SetScrollingHandler(nil)

self:SetVerticalScroll(0)
self:ScrollTo(self:GetFirstMessageIndex(), true)

self:SetFirstMessageIndex(0)
self:ProcessIncoming({t_removemulti(self.incomingMessages, 1, #self.incomingMessages)}, true)
self:FastForward()

self.ScrollDownButon:Hide()
end

function object_proto:OnHide()
LibEasing:StopEasing(self:GetScrollingHandler())
self:SetScrollingHandler(nil)

t_wipe(self.visibleLines)
self:ReleaseAllMessageLines()
end

function object_proto:GetNumHistoryElements()
Expand Down Expand Up @@ -325,7 +314,7 @@ function object_proto:ReleaseMessageLine(messageLine)
end

function object_proto:GetMaxMessages()
return m_ceil(self.ChatFrame:GetHeight() / (C.db.profile.chat.font.size + 4))
return m_ceil(self.ChatFrame:GetHeight() / (C.db.profile.chat.font.size + C.db.profile.chat.y_padding * 2))
end

function object_proto:ScrollTo(index, refreshFading, tryToFadeIn)
Expand All @@ -348,7 +337,6 @@ function object_proto:ScrollTo(index, refreshFading, tryToFadeIn)
end

-- bail out if we're beyond the frame capacity
if not messageLine:GetBottom() then break end
if messageLine:GetBottom() > self:GetTop() then break end

local messageInfo = self:GetHistoryEntryAtIndex(index + i)
Expand Down Expand Up @@ -400,6 +388,33 @@ function object_proto:ScrollTo(index, refreshFading, tryToFadeIn)
self:SetFirstMessageIndex(index)
end

function object_proto:FastForward()
if self:GetNumHistoryElements() > 0 then
t_wipe(self.incomingMessages)

local num = m_min(self:GetNumHistoryElements(), self:GetMaxMessages(), self:GetFirstMessageIndex())

self:SetVerticalScroll(0)
self:ScrollTo(num, true)

if num == 0 then return end
if num == self:GetFirstMessageIndex() then
num = num + 1
end

local messages = {}
for i = num - 1, 1, -1 do
local messageInfo = self:GetHistoryEntryAtIndex(i)
if messageInfo then
t_insert(messages, {messageInfo.message, messageInfo.r, messageInfo.g, messageInfo.b})
end
end

self:ProcessIncoming(messages, true)
self:SetFirstMessageIndex(0)
end
end

function object_proto:Refresh(delta, refreshFading, tryToFadeIn)
if not self:IsShown() then return end

Expand Down Expand Up @@ -461,6 +476,10 @@ function object_proto:AddMessage(_, ...)

t_insert(self.incomingMessages, {...})
end
else
-- the frame might be hidden due to a bunch of factors, just bump the index of
-- the first message, OnShow will take care of the rest
self:SetFirstMessageIndex(self:GetFirstMessageIndex() + 1)
end
end

Expand Down Expand Up @@ -609,7 +628,7 @@ function object_proto:ProcessIncoming(incoming, doNotFade)
function()
self:SetVerticalScroll(0)
self:Refresh(0, doNotFade)
self:SetScrollingHandler()
self:SetScrollingHandler(nil)
end
))
end
Expand Down Expand Up @@ -680,21 +699,19 @@ do
end

function E:ResetSlidingFrameDockFading()
for i, frame in next, frames do
for _, frame in next, frames do
if frame:IsShown() then
frame.isMouseOver = nil

E:StopFading(frame.ChatTab, 1)
E:StopFading(frame.ButtonFrame, 1)

-- ? I don't like this... Should I attach to the first frame?
if i == 1 then
LSGlassUpdater.isMouseOver = nil

E:StopFading(GeneralDockManager, 1)
end
end
end

-- ? I don't like this... Should I attach to the first frame?
LSGlassUpdater.isMouseOver = nil

E:StopFading(GeneralDockManager, 1)
end

function E:ResetSlidingFrameChatFading()
Expand Down
2 changes: 2 additions & 0 deletions ls_Glass/core/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ D.profile = {
alpha = 0.4,
tooltips = true,
slide_in_duration = 0.3,
x_padding = 14,
y_padding = 2,
font = {
size = 12,
shadow = true,
Expand Down
30 changes: 28 additions & 2 deletions ls_Glass/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,40 @@ function E:OnInitialize()
end
end,
},
slide_in_duration = {
x_padding = {
order = 2,
type = "range",
name = L["X_PADDING"],
min = 0, max = 20, step = 1,
set = function(_, value)
if C.db.profile.chat.x_padding ~= value then
C.db.profile.chat.x_padding = value

E:UpdateMessageLinesHorizPadding()
end
end,
},
y_padding = {
order = 3,
type = "range",
name = L["Y_PADDING"],
min = 0, max = 10, step = 1,
set = function(_, value)
if C.db.profile.chat.y_padding ~= value then
C.db.profile.chat.y_padding = value

E:UpdateMessageLinesHeights()
end
end,
},
slide_in_duration = {
order = 4,
type = "range",
name = L["SLIDE_IN_DURATION"],
min = 0, max = 1, step = 0.05,
},
tooltips = {
order = 3,
order = 5,
type = "toggle",
name = L["MOUSEOVER_TOOLTIPS"],
},
Expand Down
2 changes: 2 additions & 0 deletions ls_Glass/locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ L["SIZE"] = "Size"
L["SLIDE_IN_DURATION"] = "Slide In Duration"
L["SUPPORT"] = "Support"
L["UNREAD_MESSAGES"] = "|TInterface\\CHATFRAME\\UI-ChatWhisperIcon:0:|t Unread Messages"
L["X_PADDING"] = "Horizontal Padding"
L["Y_PADDING"] = "Vertical Padding"
Loading

0 comments on commit 4d86a2a

Please sign in to comment.