Minor enhancements in 3D viewer hotkey code

This commit is contained in:
jean-pierre charras 2019-01-31 10:00:29 +01:00
parent b6a06aa129
commit 4543bde56b
5 changed files with 36 additions and 21 deletions

View File

@ -45,8 +45,6 @@
#include <hotkeys_basic.h> #include <hotkeys_basic.h>
#include <menus_helpers.h> #include <menus_helpers.h>
extern struct EDA_HOTKEY_CONFIG g_3DViewer_Hokeys_Descr[];
/** /**
* Flag to enable 3D canvas debug tracing. * Flag to enable 3D canvas debug tracing.
@ -660,71 +658,71 @@ void EDA_3D_CANVAS::OnRightClick( wxMouseEvent &event )
pos.x = event.GetX(); pos.x = event.GetX();
pos.y = event.GetY(); pos.y = event.GetY();
msg = AddHotkeyName( _( "Zoom +" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Zoom +" ), GetHotkeyConfig(),
ID_POPUP_ZOOMIN ); ID_POPUP_ZOOMIN );
AddMenuItem( &PopUpMenu, ID_POPUP_ZOOMIN, AddMenuItem( &PopUpMenu, ID_POPUP_ZOOMIN,
msg, KiBitmap( zoom_in_xpm ) ); msg, KiBitmap( zoom_in_xpm ) );
msg = AddHotkeyName( _( "Zoom -" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Zoom -" ), GetHotkeyConfig(),
ID_POPUP_ZOOMOUT ); ID_POPUP_ZOOMOUT );
AddMenuItem( &PopUpMenu, ID_POPUP_ZOOMOUT, AddMenuItem( &PopUpMenu, ID_POPUP_ZOOMOUT,
msg, KiBitmap( zoom_out_xpm ) ); msg, KiBitmap( zoom_out_xpm ) );
PopUpMenu.AppendSeparator(); PopUpMenu.AppendSeparator();
msg = AddHotkeyName( _( "Top View" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Top View" ), GetHotkeyConfig(),
ID_POPUP_VIEW_ZPOS ); ID_POPUP_VIEW_ZPOS );
AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZPOS, AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZPOS,
msg, KiBitmap( axis3d_top_xpm ) ); msg, KiBitmap( axis3d_top_xpm ) );
msg = AddHotkeyName( _( "Bottom View" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Bottom View" ), GetHotkeyConfig(),
ID_POPUP_VIEW_ZNEG ); ID_POPUP_VIEW_ZNEG );
AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZNEG, AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZNEG,
msg, KiBitmap( axis3d_bottom_xpm ) ); msg, KiBitmap( axis3d_bottom_xpm ) );
PopUpMenu.AppendSeparator(); PopUpMenu.AppendSeparator();
msg = AddHotkeyName( _( "Right View" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Right View" ), GetHotkeyConfig(),
ID_POPUP_VIEW_XPOS ); ID_POPUP_VIEW_XPOS );
AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_XPOS, AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_XPOS,
msg, KiBitmap( axis3d_right_xpm ) ); msg, KiBitmap( axis3d_right_xpm ) );
msg = AddHotkeyName( _( "Left View" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Left View" ), GetHotkeyConfig(),
ID_POPUP_VIEW_XNEG ); ID_POPUP_VIEW_XNEG );
AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_XNEG, AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_XNEG,
msg, KiBitmap( axis3d_left_xpm ) ); msg, KiBitmap( axis3d_left_xpm ) );
PopUpMenu.AppendSeparator(); PopUpMenu.AppendSeparator();
msg = AddHotkeyName( _( "Front View" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Front View" ), GetHotkeyConfig(),
ID_POPUP_VIEW_YPOS ); ID_POPUP_VIEW_YPOS );
AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_YPOS, AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_YPOS,
msg, KiBitmap( axis3d_front_xpm ) ); msg, KiBitmap( axis3d_front_xpm ) );
msg = AddHotkeyName( _( "Back View" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Back View" ), GetHotkeyConfig(),
ID_POPUP_VIEW_YNEG ); ID_POPUP_VIEW_YNEG );
AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_YNEG, AddMenuItem( &PopUpMenu, ID_POPUP_VIEW_YNEG,
msg, KiBitmap( axis3d_back_xpm ) ); msg, KiBitmap( axis3d_back_xpm ) );
PopUpMenu.AppendSeparator(); PopUpMenu.AppendSeparator();
msg = AddHotkeyName( _( "Move Left <-" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Move Left <-" ), GetHotkeyConfig(),
ID_POPUP_MOVE3D_LEFT ); ID_POPUP_MOVE3D_LEFT );
AddMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_LEFT, AddMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_LEFT,
msg, KiBitmap( left_xpm ) ); msg, KiBitmap( left_xpm ) );
msg = AddHotkeyName( _( "Move Right ->" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Move Right ->" ), GetHotkeyConfig(),
ID_POPUP_MOVE3D_RIGHT ); ID_POPUP_MOVE3D_RIGHT );
AddMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_RIGHT, AddMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_RIGHT,
msg, KiBitmap( right_xpm ) ); msg, KiBitmap( right_xpm ) );
msg = AddHotkeyName( _( "Move Up ^" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Move Up ^" ), GetHotkeyConfig(),
ID_POPUP_MOVE3D_UP ); ID_POPUP_MOVE3D_UP );
AddMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_UP, AddMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_UP,
msg, KiBitmap( up_xpm ) ); msg, KiBitmap( up_xpm ) );
msg = AddHotkeyName( _( "Move Down" ), g_3DViewer_Hokeys_Descr, msg = AddHotkeyName( _( "Move Down" ), GetHotkeyConfig(),
ID_POPUP_MOVE3D_DOWN ); ID_POPUP_MOVE3D_DOWN );
AddMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_DOWN, AddMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_DOWN,
msg, KiBitmap( down_xpm ) ); msg, KiBitmap( down_xpm ) );

View File

@ -128,6 +128,11 @@ class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
bool IsOpenGLInitialized() const { return m_is_opengl_initialized; } bool IsOpenGLInitialized() const { return m_is_opengl_initialized; }
/**
* Return a structure containing currently used hotkey mapping.
*/
EDA_HOTKEY_CONFIG* GetHotkeyConfig() const;
private: private:
void OnPaint( wxPaintEvent &event ); void OnPaint( wxPaintEvent &event );

View File

@ -36,8 +36,6 @@
#include <3d_viewer_id.h> #include <3d_viewer_id.h>
#include "help_common_strings.h" #include "help_common_strings.h"
extern struct EDA_HOTKEY_CONFIG g_3DViewer_Hokeys_Descr[];
void EDA_3D_VIEWER::CreateMenuBar() void EDA_3D_VIEWER::CreateMenuBar()
{ {
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CreateMenuBar" ); wxLogTrace( m_logTrace, "EDA_3D_VIEWER::CreateMenuBar" );
@ -308,7 +306,7 @@ void EDA_3D_VIEWER::CreateMenuBar()
_( "Open \"Getting Started in KiCad\" guide for beginners" ), _( "Open \"Getting Started in KiCad\" guide for beginners" ),
KiBitmap( help_xpm ) ); KiBitmap( help_xpm ) );
wxString text = AddHotkeyName( _( "&List Hotkeys..." ), g_3DViewer_Hokeys_Descr, HK_HELP ); wxString text = AddHotkeyName( _( "&List Hotkeys..." ), GetHotkeyConfig(), HK_HELP );
AddMenuItem( helpMenu, ID_MENU3D_HELP_HOTKEY_SHOW_CURRENT_LIST, AddMenuItem( helpMenu, ID_MENU3D_HELP_HOTKEY_SHOW_CURRENT_LIST,
text, text,
_( "Displays the current hotkeys list and corresponding commands" ), _( "Displays the current hotkeys list and corresponding commands" ),

View File

@ -102,6 +102,11 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
*/ */
CINFO3D_VISU &GetSettings() { return m_settings; } CINFO3D_VISU &GetSettings() { return m_settings; }
/**
* Return a structure containing currently used hotkey mapping.
*/
EDA_HOTKEY_CONFIG* GetHotkeyConfig() const;
/** /**
* Get a SFVEC3D from a wx colour dialog * Get a SFVEC3D from a wx colour dialog
* @param aColor is the SFVEC3D to change * @param aColor is the SFVEC3D to change
@ -178,7 +183,10 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER
void CreateMenuBar(); void CreateMenuBar();
void DisplayHotKeys(); void DisplayHotKeys()
{
DisplayHotkeyList( this, GetHotkeyConfig() );
}
void ReCreateMainToolbar(); void ReCreateMainToolbar();

View File

@ -86,14 +86,20 @@ static EDA_HOTKEY* viewer3d_Hotkey_List[] =
// list of sections and corresponding hotkey list for the 3D Viewer // list of sections and corresponding hotkey list for the 3D Viewer
// (used to list current hotkeys) // (used to list current hotkeys)
struct EDA_HOTKEY_CONFIG g_3DViewer_Hokeys_Descr[] = static struct EDA_HOTKEY_CONFIG s_3DViewer_Hotkeys_Descr[] =
{ {
{ &g_CommonSectionTag, viewer3d_Hotkey_List, &viewer3DSectionTitle }, { &g_CommonSectionTag, viewer3d_Hotkey_List, &viewer3DSectionTitle },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
void EDA_3D_VIEWER::DisplayHotKeys() EDA_HOTKEY_CONFIG* EDA_3D_VIEWER::GetHotkeyConfig() const
{ {
DisplayHotkeyList( this, g_3DViewer_Hokeys_Descr ); return s_3DViewer_Hotkeys_Descr;
}
EDA_HOTKEY_CONFIG* EDA_3D_CANVAS::GetHotkeyConfig() const
{
return s_3DViewer_Hotkeys_Descr;
} }