Eeschema: Allow to edit an schematic item while dragging
This commit is contained in:
parent
40f4304b2f
commit
f4af52f94d
|
@ -539,6 +539,15 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
|
|||
|
||||
copyOptionsToPanel();
|
||||
|
||||
// disable some options inside the edit dialog
|
||||
// which can cause problems while dragging
|
||||
if( m_Cmp->IsDragging() )
|
||||
{
|
||||
orientationRadioBox->Disable();
|
||||
mirrorRadioBox->Disable();
|
||||
chipnameTextCtrl->Disable();
|
||||
}
|
||||
|
||||
// put focus on the list ctrl
|
||||
fieldListCtrl->SetFocus();
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text );
|
|||
static void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label );
|
||||
static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel );
|
||||
static void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* GLabel );
|
||||
static void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component );
|
||||
static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component );
|
||||
static void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field );
|
||||
static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame );
|
||||
|
@ -75,6 +76,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
{
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
bool BlockActive = GetScreen()->IsBlockActive();
|
||||
wxString msg;
|
||||
|
||||
// Do not start a block command on context menu.
|
||||
m_canvas->SetCanStartBlock( -1 );
|
||||
|
@ -83,6 +85,48 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
{
|
||||
AddMenusForBlock( PopMenu, this );
|
||||
PopMenu->AppendSeparator();
|
||||
|
||||
// If we have a block containing only one main element
|
||||
// we append its edition submenu
|
||||
if( item != NULL )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_COMPONENT_T:
|
||||
AddMenusForEditComponent( PopMenu, (SCH_COMPONENT *) item );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_TEXT_T:
|
||||
msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_HIERARCHICAL_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -295,13 +339,9 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
|
||||
wxString msg;
|
||||
LIB_ALIAS* libEntry;
|
||||
LIB_COMPONENT* libComponent = NULL;
|
||||
|
||||
libEntry = CMP_LIBRARY::FindLibraryEntry( Component->GetLibName() );
|
||||
|
||||
if( libEntry )
|
||||
libComponent = libEntry->GetComponent();
|
||||
|
||||
if( !Component->GetFlags() )
|
||||
{
|
||||
msg = _( "Move Component" );
|
||||
|
@ -327,6 +367,39 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
AddMenuItem( PopMenu, orientmenu, ID_POPUP_SCH_GENERIC_ORIENT_CMP,
|
||||
_( "Orient Component" ), KiBitmap( orient_xpm ) );
|
||||
|
||||
AddMenusForEditComponent( PopMenu, Component );
|
||||
|
||||
if( !Component->GetFlags() )
|
||||
{
|
||||
msg = AddHotkeyName( _( "Copy Component" ), s_Schematic_Hokeys_Descr,
|
||||
HK_COPY_COMPONENT_OR_LABEL );
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, KiBitmap( copy_button_xpm ) );
|
||||
msg = AddHotkeyName( _( "Delete Component" ), s_Schematic_Hokeys_Descr, HK_DELETE );
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CMP, msg, KiBitmap( delete_xpm ) );
|
||||
}
|
||||
|
||||
if( libEntry && !libEntry->GetDocFileName().IsEmpty() )
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ), KiBitmap( datasheet_xpm ) );
|
||||
}
|
||||
|
||||
|
||||
void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
||||
{
|
||||
if( Component->Type() != SCH_COMPONENT_T )
|
||||
{
|
||||
wxASSERT( 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
wxString msg;
|
||||
LIB_ALIAS* libEntry;
|
||||
LIB_COMPONENT* libComponent = NULL;
|
||||
|
||||
libEntry = CMP_LIBRARY::FindLibraryEntry( Component->GetLibName() );
|
||||
|
||||
if( libEntry )
|
||||
libComponent = libEntry->GetComponent();
|
||||
|
||||
wxMenu* editmenu = new wxMenu;
|
||||
msg = AddHotkeyName( _( "Edit" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( editmenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_component_xpm ) );
|
||||
|
@ -384,17 +457,6 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
AddMenuItem( PopMenu, editmenu, ID_SCH_EDIT_ITEM,
|
||||
_( "Edit Component" ), KiBitmap( edit_component_xpm ) );
|
||||
|
||||
if( !Component->GetFlags() )
|
||||
{
|
||||
msg = AddHotkeyName( _( "Copy Component" ), s_Schematic_Hokeys_Descr,
|
||||
HK_COPY_COMPONENT_OR_LABEL );
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, KiBitmap( copy_button_xpm ) );
|
||||
msg = AddHotkeyName( _( "Delete Component" ), s_Schematic_Hokeys_Descr, HK_DELETE );
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CMP, msg, KiBitmap( delete_xpm ) );
|
||||
}
|
||||
|
||||
if( libEntry && !libEntry->GetDocFileName().IsEmpty() )
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DISPLAYDOC_CMP, _( "Doc" ), KiBitmap( datasheet_xpm ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -774,6 +774,7 @@ void SCH_SCREEN::SelectBlockItems()
|
|||
for( ; ii < last_select_id; ii++ )
|
||||
{
|
||||
item = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
|
||||
item->SetFlags( IS_DRAGGED );
|
||||
|
||||
if( item->Type() == SCH_LINE_T )
|
||||
{
|
||||
|
@ -858,6 +859,8 @@ int SCH_SCREEN::UpdatePickList()
|
|||
{
|
||||
ITEM_PICKER picker;
|
||||
EDA_RECT area;
|
||||
unsigned count;
|
||||
|
||||
area.SetOrigin( m_BlockLocate.GetOrigin() );
|
||||
area.SetSize( m_BlockLocate.GetSize() );
|
||||
area.Normalize();
|
||||
|
@ -872,7 +875,19 @@ int SCH_SCREEN::UpdatePickList()
|
|||
}
|
||||
}
|
||||
|
||||
return m_BlockLocate.GetCount();
|
||||
// if the block is composed of one item,
|
||||
// select it as the current item
|
||||
count = m_BlockLocate.GetCount();
|
||||
if( count == 1 )
|
||||
{
|
||||
SetCurItem( (SCH_ITEM*) m_BlockLocate.GetItem( 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCurItem( NULL );
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -384,6 +384,12 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
|||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
{
|
||||
// trying to move an item when there is a block at the same time is not acceptable
|
||||
return;
|
||||
}
|
||||
|
||||
if( item == NULL )
|
||||
{
|
||||
// If we didn't get here by a hot key, then something has gone wrong.
|
||||
|
@ -725,15 +731,15 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
|||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
// Allows block rotate operation on hot key.
|
||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
{
|
||||
HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
|
||||
return;
|
||||
}
|
||||
|
||||
if( item == NULL )
|
||||
{
|
||||
// Allows block rotate operation on hot key.
|
||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
{
|
||||
HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
|
||||
return;
|
||||
}
|
||||
|
||||
// If we didn't get here by a hot key, then something has gone wrong.
|
||||
if( aEvent.GetInt() == 0 )
|
||||
return;
|
||||
|
@ -965,9 +971,6 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
|
|||
wxFAIL_MSG( wxString::Format( wxT( "Cannot drag schematic item type %s." ),
|
||||
GetChars( item->GetClass() ) ) );
|
||||
}
|
||||
|
||||
// Since the drag is actually a block command, clear the current item.
|
||||
screen->SetCurItem( NULL );
|
||||
}
|
||||
|
||||
|
||||
|
@ -978,21 +981,21 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
|||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
// Allows block rotate operation on hot key.
|
||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
{
|
||||
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
||||
HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc );
|
||||
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
||||
HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );
|
||||
else
|
||||
wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( item == NULL )
|
||||
{
|
||||
// Allows block rotate operation on hot key.
|
||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
{
|
||||
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
||||
HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc );
|
||||
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
||||
HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );
|
||||
else
|
||||
wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If we didn't get here by a hot key, then something has gone wrong.
|
||||
if( aEvent.GetInt() == 0 )
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue