34#include <magic_enum.hpp>
35#include <wx/listctrl.h>
133 const std::vector<TOOL_ACTION*>& aTools,
134 const std::vector<ACTION_TOOLBAR_CONTROL*>& aControls ) :
142 for(
auto& tool : aTools )
145 for(
auto& control : aControls )
176 m_actionFilter->SetMinSize( wxSize( -1, GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
205 auto hasPrefix = [&](
const char* aPrefix ) ->
bool
207 return name.rfind( aPrefix, 0 ) == 0;
212 if( hasPrefix(
"3DViewer." ) )
219 if( hasPrefix(
"common." ) )
237 default:
return false;
248 for(
auto& tb : magic_enum::enum_values<TOOLBAR_LOC>() )
253 if( !tbConfig.has_value() )
272 wxArrayString tbChoices;
278 for(
auto& tb : magic_enum::enum_values<TOOLBAR_LOC>() )
283 if( !tbConfig.has_value() )
293 wxString::Format(
"Unknown toolbar: %s", magic_enum::enum_name( tb ) ) );
295 tbChoices.Add( tbName->second );
326 if( currentTb.has_value() )
343 wxTreeItemIdValue mainCookie;
350 while( mainId.IsOk() )
352 wxTreeItemData* treeData =
m_toolbarTree->GetItemData( mainId );
356 wxCHECK2( tbData,
continue );
381 wxTreeItemIdValue childCookie;
382 wxTreeItemId childId =
m_toolbarTree->GetFirstChild( mainId, childCookie );
384 while( childId.IsOk() )
386 wxTreeItemData* childTreeData =
m_toolbarTree->GetItemData( childId );
390 wxCHECK2( childTbData,
break );
392 switch( childTbData->
GetType() )
398 wxASSERT_MSG(
false,
"Invalid entry in a group" );
406 childId =
m_toolbarTree->GetNextChild( mainId, childCookie );
410 config.AppendGroup( grpConfig );
443 switch( item.m_Type )
449 m_toolbarTree->AppendItem( root,
_(
"Separator" ), -1, -1, sepTreeItem );
457 spacerTreeItem->
SetSize( item.m_Size );
458 m_toolbarTree->AppendItem( root, wxString::Format(
_(
"Spacer: %i" ), item.m_Size ), -1, -1,
469 wxASSERT_MSG(
false, wxString::Format(
"Unable to find control %s", item.m_ControlName ) );
475 controlTreeItem->
SetControl( controlIter->second );
476 m_toolbarTree->AppendItem( root, controlIter->second->GetUiName(), -1, -1, controlTreeItem );
487 wxASSERT_MSG(
false, wxString::Format(
"Unable to find tool %s", item.m_ActionName ) );
495 toolTreeItem->
SetAction( toolIter->second );
501 imgIdx = imgMap->second;
503 m_toolbarTree->AppendItem( root, toolIter->second->GetFriendlyName(), imgIdx, -1, toolTreeItem );
511 groupTreeItem->
SetName( item.m_GroupName );
513 wxTreeItemId groupId =
m_toolbarTree->AppendItem( root, item.m_GroupName, -1, -1, groupTreeItem );
514 bool haveVisibleGroupItems =
false;
523 wxASSERT_MSG(
false, wxString::Format(
"Unable to find group tool %s", groupItem.
m_ActionName ) );
531 toolTreeItem->
SetAction( toolMap->second );
537 imgIdx = imgMap->second;
539 m_toolbarTree->AppendItem( groupId, toolMap->second->GetFriendlyName(), imgIdx, -1, toolTreeItem );
541 haveVisibleGroupItems =
true;
544 if( !haveVisibleGroupItems )
554 wxTreeItemIdValue temp;
555 wxTreeItemId firstItem =
m_toolbarTree->GetFirstChild( root, temp );
557 if( firstItem.IsOk() )
567 const int c_defSize = 24;
577 m_actionsList->InsertColumn( 0,
"", wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE );
588 entry.
label = tool->GetFriendlyName();
589 entry.
tooltip = tool->GetDescription();
607 entry.
label = control->GetUiName();
608 entry.
tooltip = control->GetDescription();
610 entry.
search_text = entry.
label.Upper() + wxS(
" " ) + control->GetDescription().Upper();
617 return a.label.CmpNoCase( b.label ) < 0;
626 const wxString& aFilter )
const
628 if( aFilter.IsEmpty() )
631 return aEntry.
search_text.Contains( aFilter.Upper() );
654 item.SetText( entry.
label );
655 item.SetFont( listFont );
656 item.SetData(
static_cast<long>( idx ) );
663 m_actionsList->SetItemState( 0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
673 wxTreeItemId newItem;
679 wxTreeItemId parent =
m_toolbarTree->GetItemParent( selItem );
683 wxTreeItemId secondParent =
m_toolbarTree->GetItemParent( parent );
685 if( secondParent.IsOk() )
713 wxString label = wxString::Format(
"Spacer: %i", treeItem->
GetSize() );
715 wxTreeItemId newItem;
721 wxTreeItemId parent =
m_toolbarTree->GetItemParent( selItem );
726 wxTreeItemId secondParent =
m_toolbarTree->GetItemParent( parent );
728 if( secondParent.IsOk() )
735 newItem =
m_toolbarTree->InsertItem( parent, selItem, label, -1, -1, treeItem );
754 wxTreeItemId newItem;
760 wxTreeItemId parent =
m_toolbarTree->GetItemParent( selItem );
765 wxTreeItemId secondParent =
m_toolbarTree->GetItemParent( parent );
767 if( secondParent.IsOk() )
774 newItem =
m_toolbarTree->InsertItem( parent, selItem,
_(
"Separator" ), -1, -1, treeItem );
832 if( !item.IsOk() && prev.IsOk() )
855 long actionIdx =
m_actionsList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
883 imgIdx = imgMap->second;
888 wxTreeItemId newItem;
898 newItem =
m_toolbarTree->AppendItem( selItem, entry.
label, imgIdx, -1, toolTreeItem );
903 wxTreeItemId parent =
m_toolbarTree->GetItemParent( selItem );
904 newItem =
m_toolbarTree->InsertItem( parent, selItem, entry.
label, imgIdx, -1, toolTreeItem );
919 if( ++actionIdx < m_actionsList->GetItemCount() )
920 m_actionsList->SetItemState( actionIdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
936 if( aEvent.Leaving() )
944 long item =
m_actionsList->HitTest( aEvent.GetPosition(), flags );
948 long entryIdx =
static_cast<long>(
m_actionsList->GetItemData( item ) );
950 if( entryIdx >= 0 && entryIdx <
static_cast<long>(
m_actionEntries.size() ) )
956 if(
const wxString& tooltip =
m_actionEntries[entryIdx].tooltip; tooltip.IsEmpty() )
976 wxTreeItemId
id =
event.GetItem();
984 switch( tbData->GetType() )
1014 if( currentTb.has_value() )
1017 int idx =
event.GetInt();
1029 wxCommandEvent
dummy;
wxBitmapBundle KiBitmapBundleDef(BITMAPS aBitmap, int aDefHeight)
Constructs and returns a bitmap bundle for the given icon ID, with the default bitmap size being aDef...
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
static TOOL_ACTION zoomRedraw
static TOOL_ACTION zoomOutCenter
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION zoomInCenter
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
@ FRAME_SCH_SYMBOL_EDITOR
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
std::vector< FAB_LAYER_COLOR > dummy
ACTION_TOOLBAR_CONTROL * control
Functions to provide common constants and other functions to assist in making a consistent UI.