UI - Renamed structures for keyboard modifiers
This commit is contained in:
parent
fa242b08a4
commit
bcf8843436
11 changed files with 34 additions and 34 deletions
|
@ -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 "<space>";
|
||||
|
|
|
@ -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 }
|
||||
{}
|
||||
|
||||
|
|
|
@ -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;
|
||||
})() );
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 >;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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( );
|
||||
|
|
|
@ -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_ ) {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue