Tuning status popup for point editor.
This commit is contained in:
parent
bb74445dda
commit
d916e650f1
|
@ -45,7 +45,7 @@ class STATUS_POPUP: public wxPopupWindow
|
|||
{
|
||||
public:
|
||||
STATUS_POPUP( wxWindow* aParent );
|
||||
virtual ~STATUS_POPUP() {}
|
||||
virtual ~STATUS_POPUP() { Hide(); }
|
||||
|
||||
virtual void Popup( wxWindow* aFocus = nullptr );
|
||||
virtual void PopupFor( int aMsecs );
|
||||
|
|
|
@ -1063,6 +1063,49 @@ public:
|
|||
this );
|
||||
}
|
||||
|
||||
void UpdateStatus( GENERATOR_TOOL* aTool, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
STATUS_TEXT_POPUP* aPopup ) override
|
||||
{
|
||||
auto* placer = dynamic_cast<PNS::MEANDER_PLACER_BASE*>( aTool->Router()->Placer() );
|
||||
|
||||
if( !placer )
|
||||
return;
|
||||
|
||||
aPopup->SetText( placer->TuningInfo( aFrame->GetUserUnits() ) );
|
||||
|
||||
// Determine the background color first and choose a contrasting value
|
||||
COLOR4D bg( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
|
||||
double h, s, l;
|
||||
bg.ToHSL( h, s, l );
|
||||
|
||||
switch( placer->TuningStatus() )
|
||||
{
|
||||
case PNS::MEANDER_PLACER_BASE::TUNED:
|
||||
if( l < 0.5 )
|
||||
aPopup->SetTextColor( wxColor( 127, 200, 127 ) );
|
||||
else
|
||||
aPopup->SetTextColor( wxColor( 0, 92, 0 ) );
|
||||
|
||||
break;
|
||||
|
||||
case PNS::MEANDER_PLACER_BASE::TOO_SHORT:
|
||||
if( l < 0.5 )
|
||||
aPopup->SetTextColor( wxColor( 242, 100, 126 ) );
|
||||
else
|
||||
aPopup->SetTextColor( wxColor( 122, 0, 0 ) );
|
||||
|
||||
break;
|
||||
|
||||
case PNS::MEANDER_PLACER_BASE::TOO_LONG:
|
||||
if( l < 0.5 )
|
||||
aPopup->SetTextColor( wxColor( 66, 184, 235 ) );
|
||||
else
|
||||
aPopup->SetTextColor( wxColor( 19, 19, 195 ) );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
VECTOR2I m_end;
|
||||
|
||||
|
@ -1199,7 +1242,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
|
|||
m_statusPopup->Popup();
|
||||
canvas()->SetStatusPopup( m_statusPopup.get() );
|
||||
|
||||
m_statusPopup->UpdateStatus( generatorTool->Router() );
|
||||
m_meander->UpdateStatus( generatorTool, m_frame, m_statusPopup.get() );
|
||||
m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, 20 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class BOARD;
|
|||
class BOARD_ITEM;
|
||||
class PCB_BASE_EDIT_FRAME;
|
||||
class GENERATOR_TOOL;
|
||||
class STATUS_TEXT_POPUP;
|
||||
|
||||
|
||||
class PCB_GENERATOR : public PCB_GROUP
|
||||
|
@ -92,7 +93,10 @@ public:
|
|||
|
||||
virtual std::vector<std::pair<wxString, wxVariant>> GetRowData();
|
||||
|
||||
virtual void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ){};
|
||||
virtual void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ) {};
|
||||
|
||||
virtual void UpdateStatus( GENERATOR_TOOL* aTool, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
STATUS_TEXT_POPUP* aPopup ) {};
|
||||
|
||||
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
|
||||
|
||||
|
|
|
@ -41,10 +41,6 @@ public:
|
|||
STATUS_TEXT_POPUP( aParent )
|
||||
{ }
|
||||
|
||||
// Ensure the widgets is hidden before deleting it
|
||||
// Otherwise we have a crash
|
||||
~PNS_TUNE_STATUS_POPUP() override { Hide(); }
|
||||
|
||||
void UpdateStatus( PNS::ROUTER* aRouter );
|
||||
};
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <preview_items/two_point_geom_manager.h>
|
||||
#include <ratsnest/ratsnest_data.h>
|
||||
#include <router/router_tool.h>
|
||||
#include <router/pns_tune_status_popup.h>
|
||||
#include <status_popup.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/pcb_grid_helper.h>
|
||||
|
@ -290,7 +290,7 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
|
|||
m_textAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT;
|
||||
m_textAttrs.m_Valign = GR_TEXT_V_ALIGN_TOP;
|
||||
|
||||
m_statusPopup = std::make_unique<PNS_TUNE_STATUS_POPUP>( m_frame );
|
||||
m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( m_frame );
|
||||
|
||||
UpdateStatusBar();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class PCB_BASE_EDIT_FRAME;
|
|||
class PCB_SHAPE;
|
||||
class POLYGON_GEOM_MANAGER;
|
||||
class PCB_GENERATOR_MEANDERS;
|
||||
class PNS_TUNE_STATUS_POPUP;
|
||||
class STATUS_TEXT_POPUP;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -356,7 +356,7 @@ private:
|
|||
BOARD_CONNECTED_ITEM* m_pickerItem;
|
||||
PCB_GENERATOR_MEANDERS* m_meander;
|
||||
|
||||
std::unique_ptr<PNS_TUNE_STATUS_POPUP> m_statusPopup;
|
||||
std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
|
||||
|
||||
|
||||
static const unsigned int WIDTH_STEP; // Amount of width change for one -/+ key press
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
using namespace std::placeholders;
|
||||
#include <advanced_config.h>
|
||||
#include <kiplatform/ui.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
@ -37,6 +38,7 @@ using namespace std::placeholders;
|
|||
#include <tools/pcb_selection_tool.h>
|
||||
#include <tools/pcb_point_editor.h>
|
||||
#include <tools/pcb_grid_helper.h>
|
||||
#include <tools/generator_tool.h>
|
||||
#include <dialogs/dialog_unit_entry.h>
|
||||
#include <board_commit.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
|
@ -124,6 +126,8 @@ void PCB_POINT_EDITOR::Reset( RESET_REASON aReason )
|
|||
m_editPoints.reset();
|
||||
m_altConstraint.reset();
|
||||
getViewControls()->SetAutoPan( false );
|
||||
|
||||
m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -649,6 +653,8 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
m_statusPopup->Hide();
|
||||
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>(
|
||||
PCB_ACTIONS::genPushEdit, &commit, static_cast<PCB_GENERATOR*>( item ) );
|
||||
}
|
||||
|
@ -1493,11 +1499,16 @@ void PCB_POINT_EDITOR::updateItem( BOARD_COMMIT* aCommit )
|
|||
|
||||
case PCB_GENERATOR_T:
|
||||
{
|
||||
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( item );
|
||||
generator->UpdateFromEditPoints( m_editPoints, aCommit );
|
||||
GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool<GENERATOR_TOOL>();
|
||||
PCB_GENERATOR* generatorItem = static_cast<PCB_GENERATOR*>( item );
|
||||
generatorItem->UpdateFromEditPoints( m_editPoints, aCommit );
|
||||
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>( PCB_ACTIONS::genUpdateEdit, aCommit,
|
||||
generator );
|
||||
generatorItem );
|
||||
|
||||
m_statusPopup->Popup();
|
||||
generatorItem->UpdateStatus( generatorTool, frame(), m_statusPopup.get() );
|
||||
m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, 20 ) );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,18 +173,17 @@ private:
|
|||
///< Change the edit method for arcs.
|
||||
int changeArcEditMode( const TOOL_EVENT& aEvent );
|
||||
|
||||
PCB_SELECTION_TOOL* m_selectionTool;
|
||||
mutable std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
|
||||
std::shared_ptr<EDIT_POINTS> m_editPoints;
|
||||
private:
|
||||
PCB_SELECTION_TOOL* m_selectionTool;
|
||||
std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
|
||||
std::shared_ptr<EDIT_POINTS> m_editPoints;
|
||||
|
||||
EDIT_POINT* m_editedPoint;
|
||||
EDIT_POINT* m_hoveredPoint;
|
||||
EDIT_POINT* m_editedPoint;
|
||||
EDIT_POINT* m_hoveredPoint;
|
||||
|
||||
EDIT_POINT m_original; ///< Original position for the current drag point.
|
||||
EDIT_POINT m_original; ///< Original pos for the current drag point.
|
||||
|
||||
bool m_refill;
|
||||
|
||||
ARC_EDIT_MODE m_arcEditMode;
|
||||
ARC_EDIT_MODE m_arcEditMode;
|
||||
|
||||
// Alternative constraint, enabled while a modifier key is held
|
||||
std::shared_ptr<EDIT_CONSTRAINT<EDIT_POINT>> m_altConstraint;
|
||||
|
|
Loading…
Reference in New Issue