mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Add jump-to-bottom indicator in chat when scrolled up
Shows a "New messages" button below the chat history area when the user has scrolled away from the latest messages. Clicking it jumps back to the most recent messages.
This commit is contained in:
parent
c433188edb
commit
88436fa400
2 changed files with 25 additions and 3 deletions
|
|
@ -1462,9 +1462,18 @@ void GameScreen::renderChatWindow(game::GameHandler& gameHandler) {
|
|||
ImGui::PopID();
|
||||
}
|
||||
|
||||
// Auto-scroll to bottom
|
||||
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
|
||||
ImGui::SetScrollHereY(1.0f);
|
||||
// Auto-scroll to bottom; track whether user has scrolled up
|
||||
{
|
||||
float scrollY = ImGui::GetScrollY();
|
||||
float scrollMaxY = ImGui::GetScrollMaxY();
|
||||
bool atBottom = (scrollMaxY <= 0.0f) || (scrollY >= scrollMaxY - 2.0f);
|
||||
if (atBottom || chatForceScrollToBottom_) {
|
||||
ImGui::SetScrollHereY(1.0f);
|
||||
chatScrolledUp_ = false;
|
||||
chatForceScrollToBottom_ = false;
|
||||
} else {
|
||||
chatScrolledUp_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
|
|
@ -1472,6 +1481,17 @@ void GameScreen::renderChatWindow(game::GameHandler& gameHandler) {
|
|||
// Reset font scale after chat history
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
|
||||
// "Jump to bottom" indicator when scrolled up
|
||||
if (chatScrolledUp_) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.35f, 0.7f, 0.9f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.3f, 0.5f, 0.9f, 1.0f));
|
||||
if (ImGui::SmallButton(" v New messages ")) {
|
||||
chatForceScrollToBottom_ = true;
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
ImGui::Spacing();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue