From bcf8843436aa7bf38904b6a8397cafbcaa883a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Fri, 24 Nov 2017 11:48:08 +0100 Subject: [PATCH] UI - Renamed structures for keyboard modifiers --- ui-actions.cc | 6 +++--- ui-actions.hh | 4 ++-- ui-app.cc | 8 ++++---- ui-app.hh | 2 +- ui-input.hh | 4 ++-- ui-mousectrl.hh | 4 ++-- ui-overrides.cc | 10 +++++----- ui-sync.cc | 8 ++++---- ui-sync.hh | 4 ++-- ui-utilities.cc | 14 +++++++------- ui-utilities.hh | 4 ++-- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/ui-actions.cc b/ui-actions.cc index b6ae5da..24dbec5 100644 --- a/ui-actions.cc +++ b/ui-actions.cc @@ -12,13 +12,13 @@ void T_KeyboardShortcut::toString( const size_t size ) const noexcept { const char ch[ 2 ] = { - char( ( modifiers & E_KeyboardModifier::SHIFT ) + char( ( modifiers & E_KbdMod::SHIFT ) ? toupper( character ) : tolower( character ) ) , 0 }; snprintf( buffer , size , "%s%s%s" , - ( modifiers & E_KeyboardModifier::CTRL ) ? "C-" : "" , - ( modifiers & E_KeyboardModifier::ALT ) ? "A-" : "" , + ( modifiers & E_KbdMod::CTRL ) ? "C-" : "" , + ( modifiers & E_KbdMod::ALT ) ? "A-" : "" , [&]( ) { switch ( character ) { case ' ': return ""; diff --git a/ui-actions.hh b/ui-actions.hh index 0939ba9..fc76b9e 100644 --- a/ui-actions.hh +++ b/ui-actions.hh @@ -7,11 +7,11 @@ struct T_KeyboardShortcut { char character; - T_KeyboardModifiers modifiers; + T_KbdMods modifiers; explicit constexpr T_KeyboardShortcut( char character , - T_KeyboardModifiers modifiers = { } ) noexcept + T_KbdMods modifiers = { } ) noexcept : character{ character } , modifiers{ modifiers } {} diff --git a/ui-app.cc b/ui-app.cc index fbc7130..60dbca1 100644 --- a/ui-app.cc +++ b/ui-app.cc @@ -155,15 +155,15 @@ void T_UIApp::handleEvents( ) noexcept auto& io( ImGui::GetIO( ) ); io.MouseDrawCursor = true; kbMods_ = ( ([&io]() { - T_KeyboardModifiers kb; + T_KbdMods kb; if ( io.KeyCtrl ) { - kb |= E_KeyboardModifier::CTRL; + kb |= E_KbdMod::CTRL; } if ( io.KeyShift ) { - kb |= E_KeyboardModifier::SHIFT; + kb |= E_KbdMod::SHIFT; } if ( io.KeyAlt ) { - kb |= E_KeyboardModifier::ALT; + kb |= E_KbdMod::ALT; } return kb; })() ); diff --git a/ui-app.hh b/ui-app.hh index 218e1c7..5202b78 100644 --- a/ui-app.hh +++ b/ui-app.hh @@ -72,7 +72,7 @@ struct T_UIApp bool exiting_{ false }; // Keyboard events / state - T_KeyboardModifiers kbMods_; + T_KbdMods kbMods_; T_AutoArray< char , 32 > kbKeys_; // Mouse capture diff --git a/ui-input.hh b/ui-input.hh index 16d32dc..c83fdf4 100644 --- a/ui-input.hh +++ b/ui-input.hh @@ -13,10 +13,10 @@ using T_MouseButtons = T_Flags< E_MouseButton >; /*------------------------------------------------------------------------------*/ -enum class E_KeyboardModifier +enum class E_KbdMod { CTRL , SHIFT , ALT , }; -using T_KeyboardModifiers = T_Flags< E_KeyboardModifier >; +using T_KbdMods = T_Flags< E_KbdMod >; diff --git a/ui-mousectrl.hh b/ui-mousectrl.hh index b18f798..3d700c2 100644 --- a/ui-mousectrl.hh +++ b/ui-mousectrl.hh @@ -11,13 +11,13 @@ class A_MouseCtrl virtual void handleDragAndDrop( ImVec2 const& move , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept = 0; virtual void handleWheel( float wheel , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept = 0; }; diff --git a/ui-overrides.cc b/ui-overrides.cc index 7d38e69..66f8527 100644 --- a/ui-overrides.cc +++ b/ui-overrides.cc @@ -274,12 +274,12 @@ struct T_MouseCam_ : public virtual A_MouseCtrl void handleDragAndDrop( ImVec2 const& move , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept override; void handleWheel( float wheel , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept override; }; @@ -287,7 +287,7 @@ struct T_MouseCam_ : public virtual A_MouseCtrl void T_MouseCam_::handleDragAndDrop( ImVec2 const& move , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept { auto& sync( Common::Sync( ) ); @@ -313,7 +313,7 @@ void T_MouseCam_::handleDragAndDrop( void T_MouseCam_::handleWheel( const float wheel , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept { auto& sync( Common::Sync( ) ); @@ -327,7 +327,7 @@ void T_MouseCam_::handleWheel( auto& sinp( sync.inputs( ) ); auto& cam{ camera.camera }; auto const& ovip{ ov.inputPositions( ) }; - if ( modifiers & E_KeyboardModifier::SHIFT ) { + if ( modifiers & E_KbdMod::SHIFT ) { auto const& fc( ov.fovConfig( ) ); if ( fc.mode == T_CamOverride::FM_FOV ) { sinp[ ovip[ fc.inputIndex ] ] = cam.fieldOfView( ); diff --git a/ui-sync.cc b/ui-sync.cc index 6dc98c0..a5bce7f 100644 --- a/ui-sync.cc +++ b/ui-sync.cc @@ -30,7 +30,7 @@ T_UISync::T_UISync( ) } }.setEnabledCheck( []() { return Common::Sync( ).curvesModified( ); } ).setIcon( ICON_FA_FLOPPY_O ) - .setShortcut( T_KeyboardShortcut{ 's' , E_KeyboardModifier::CTRL } ) ); + .setShortcut( T_KeyboardShortcut{ 's' , E_KbdMod::CTRL } ) ); //----------------------------------------------------------------------------- UI::Main( ).addAction( T_UIAction{ "Reload curves" , []() { UI::Main( ).msgbox( @@ -46,7 +46,7 @@ T_UISync::T_UISync( ) return Common::Sync( ).curvesModified( ); } ).setIcon( ICON_FA_DOWNLOAD ) .setShortcut( T_KeyboardShortcut{ 'r' , - { E_KeyboardModifier::CTRL , E_KeyboardModifier::SHIFT } } ) ); + { E_KbdMod::CTRL , E_KbdMod::SHIFT } } ) ); //----------------------------------------------------------------------------- const auto addui{ [this]( char const* type , F_Override ov ) { const bool ok{ sovuis_.add( T_String{ type } , std::move( ov ) ) }; @@ -208,7 +208,7 @@ void T_UISync::clearMouseDelegate( ) noexcept void T_UISync::handleDragAndDrop( ImVec2 const& move , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept { if ( mouseDelegate_ ) { @@ -218,7 +218,7 @@ void T_UISync::handleDragAndDrop( void T_UISync::handleWheel( const float wheel , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept { if ( mouseDelegate_ ) { diff --git a/ui-sync.hh b/ui-sync.hh index f965717..cc377b6 100644 --- a/ui-sync.hh +++ b/ui-sync.hh @@ -37,11 +37,11 @@ class T_UISync : public A_MouseCtrl void handleDragAndDrop( ImVec2 const& move , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept override; void handleWheel( float wheel , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept override; private: diff --git a/ui-utilities.cc b/ui-utilities.cc index 1a8fcd8..16de7ed 100644 --- a/ui-utilities.cc +++ b/ui-utilities.cc @@ -65,17 +65,17 @@ void ImGui::ToolbarSeparator( ) noexcept void T_CameraMouseControl::handleDragAndDrop( ImVec2 const& move , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept { if ( move.x == 0 || move.y == 0 ) { return; } - const float fdx( move.x * .1f * ( ( modifiers & E_KeyboardModifier::CTRL ) ? 1.f : .1f ) ); - const float fdy( move.y * .1f * ( ( modifiers & E_KeyboardModifier::CTRL ) ? 1.f : .1f ) ); + const float fdx( move.x * .1f * ( ( modifiers & E_KbdMod::CTRL ) ? 1.f : .1f ) ); + const float fdy( move.y * .1f * ( ( modifiers & E_KbdMod::CTRL ) ? 1.f : .1f ) ); - if ( ( buttons & E_MouseButton::LEFT ) && ( modifiers & E_KeyboardModifier::SHIFT ) ) { + if ( ( buttons & E_MouseButton::LEFT ) && ( modifiers & E_KbdMod::SHIFT ) ) { // Left mouse button, shift - move camera const auto side( normalize( cross( camera.upVector( ) , camera.direction( ) ) ) ); camera.lookAt( ) += .1f * ( side * fdx + camera.upVector( ) * fdy ); @@ -92,11 +92,11 @@ void T_CameraMouseControl::handleDragAndDrop( void T_CameraMouseControl::handleWheel( const float wheel , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons /* buttons */ ) noexcept { - const float delta( wheel * ( ( modifiers & E_KeyboardModifier::CTRL ) ? 1.f : .1f) ); - if ( modifiers & E_KeyboardModifier::SHIFT ) { + const float delta( wheel * ( ( modifiers & E_KbdMod::CTRL ) ? 1.f : .1f) ); + if ( modifiers & E_KbdMod::SHIFT ) { camera.fieldOfView( ) = ImClamp( camera.fieldOfView( ) + delta , 1.f , 179.f ); camera.cvtFov2Np( ); } else { diff --git a/ui-utilities.hh b/ui-utilities.hh index 8876de2..e23a685 100644 --- a/ui-utilities.hh +++ b/ui-utilities.hh @@ -60,11 +60,11 @@ struct T_CameraMouseControl : public A_MouseCtrl void handleDragAndDrop( ImVec2 const& move , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept override; void handleWheel( float wheel , - T_KeyboardModifiers modifiers , + T_KbdMods modifiers , T_MouseButtons buttons ) noexcept override; };