From 2d143ce516cfd3e3a937ad82444fbdc5883daea4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 22 Dec 2018 17:36:20 +0100 Subject: [PATCH] Add support for handling keyboard shortcuts. --- server/TracyView.cpp | 12 +++++++++++- server/TracyView.hpp | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index d3bf86b3..7d0911f6 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -482,6 +482,17 @@ bool View::DrawImpl() return !wasCancelled; } + const auto& io = ImGui::GetIO(); + + assert( m_shortcut == ShortcutAction::None ); + if( io.KeyCtrl ) + { + if( ImGui::IsKeyPressed( 'F' ) ) + { + m_shortcut = ShortcutAction::OpenFind; + } + } + if( !m_frames ) m_frames = m_worker.GetFramesBase(); const auto th = ImGui::GetTextLineHeight(); @@ -700,7 +711,6 @@ bool View::DrawImpl() if( m_goToFrame ) DrawGoToFrame(); if( m_lockInfoWindow != InvalidId ) DrawLockInfoWindow(); - const auto& io = ImGui::GetIO(); if( m_zoomAnim.active ) { m_zoomAnim.progress += io.DeltaTime * m_zoomAnim.lenMod; diff --git a/server/TracyView.hpp b/server/TracyView.hpp index bbd75f97..2c734119 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -64,6 +64,12 @@ private: Short }; + enum class ShortcutAction : uint8_t + { + None, + OpenFind + }; + enum { InvalidId = 0xFFFFFFFF }; void InitTextEditor(); @@ -256,6 +262,7 @@ private: bool m_showCallstackFrameAddress = false; bool m_showUnknownFrames = true; + ShortcutAction m_shortcut = ShortcutAction::None; Namespace m_namespace = Namespace::Full; Animation m_zoomAnim; BuzzAnim m_callstackBuzzAnim;