add shortcuts to scroll the message log (j/k and page up/down)
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / dumpsyms (push) Blocked by required conditions
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / linux-arm (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android-23]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android-23]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android-23]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run

also end to jump to ...
This commit is contained in:
Green Sky
2025-08-01 23:09:55 +02:00
parent 6e029a13a8
commit 0c9fb6b322

View File

@@ -672,6 +672,28 @@ void ChatGui4::sendFilePath(std::string_view file_path) {
}
void ChatGui4::renderChatLog(Contact4 c, bool window_focused, const std::vector<Contact4>* sub_contacts) {
const float scroll_amount {2.f * TEXT_BASE_HEIGHT};
bool manually_scrolled {false};
// TODO: replace with IsKeyPressed version in the future
if (ImGui::Shortcut(ImGuiKey_J, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteGlobal)) {
ImGui::SetScrollY(ImGui::GetScrollY() + scroll_amount);
manually_scrolled = true;
}
if (ImGui::Shortcut(ImGuiKey_K, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteGlobal)) {
ImGui::SetScrollY(ImGui::GetScrollY() - scroll_amount);
manually_scrolled = true;
}
// TODO: figure ot page size
if (ImGui::Shortcut(ImGuiKey_PageDown, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteGlobal)) {
ImGui::SetScrollY(ImGui::GetScrollY() + scroll_amount*10.f);
manually_scrolled = true;
}
if (ImGui::Shortcut(ImGuiKey_PageUp, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteGlobal)) {
ImGui::SetScrollY(ImGui::GetScrollY() - scroll_amount*10.f);
manually_scrolled = true;
}
auto* msg_reg_ptr = _rmm.get(c);
constexpr ImGuiTableFlags table_flags =
@@ -1051,8 +1073,13 @@ void ChatGui4::renderChatLog(Contact4 c, bool window_focused, const std::vector<
ImGui::EndTable();
}
if (ImGui::Shortcut(ImGuiKey_End, ImGuiInputFlags_RouteGlobal)) {
ImGui::SetScrollHereY(1.f);
manually_scrolled = true;
}
// follow if at bottom (this is a frame delayed, but thats just how it works)
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
if (!manually_scrolled && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
ImGui::SetScrollHereY(1.f);
}
}