mirror of https://github.com/KLayout/klayout.git
Some refactoring with the goal to support "move by" with "clone interactive"
This commit is contained in:
parent
84c4f31a9c
commit
5578b01f03
|
|
@ -1382,9 +1382,6 @@ dragging_what (const ant::Object *robj, const db::DBox &search_dbox, ant::Servic
|
|||
bool
|
||||
Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::angle_constraint_type /*ac*/)
|
||||
{
|
||||
// cancel any pending move or drag operations, reset mp_active_ruler
|
||||
ui ()->drag_cancel (); // KLUDGE: every service does this to the same service manager
|
||||
|
||||
clear_transient_selection ();
|
||||
|
||||
// choose move mode
|
||||
|
|
|
|||
|
|
@ -588,9 +588,6 @@ Service::mouse_move_event (const db::DPoint & /*p*/, unsigned int /*buttons*/, b
|
|||
bool
|
||||
Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::angle_constraint_type /*ac*/)
|
||||
{
|
||||
// cancel any pending move or drag operations
|
||||
widget ()->drag_cancel (); // KLUDGE: every service does this to the same service manager
|
||||
|
||||
// compute search box
|
||||
double l = catch_distance ();
|
||||
db::DBox search_dbox = db::DBox (p, p).enlarged (db::DVector (l, l));
|
||||
|
|
|
|||
|
|
@ -165,9 +165,9 @@ Editables::selection_catch_bbox ()
|
|||
}
|
||||
|
||||
void
|
||||
Editables::transform (const db::DCplxTrans &t, db::Transaction *transaction)
|
||||
Editables::transform (const db::DCplxTrans &t)
|
||||
{
|
||||
std::unique_ptr<db::Transaction> trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Transform"))));
|
||||
std::unique_ptr<db::Transaction> trans_holder (new db::Transaction (manager (), tl::to_string (tr ("Transform"))));
|
||||
|
||||
if (has_selection ()) {
|
||||
|
||||
|
|
@ -639,15 +639,31 @@ Editables::edit_cancel ()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editables::edit_finish ()
|
||||
{
|
||||
clear_previous_selection ();
|
||||
for (iterator e = begin (); e != end (); ++e) {
|
||||
e->edit_finish ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editables::cancel_edits ()
|
||||
{
|
||||
// cancel any edit operations
|
||||
for (iterator e = begin (); e != end (); ++e) {
|
||||
e->edit_cancel ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editables::finish_edits ()
|
||||
{
|
||||
for (iterator e = begin (); e != end (); ++e) {
|
||||
e->edit_finish ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editables::show_properties ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -332,6 +332,20 @@ public:
|
|||
// .. by default, nothing is implemented ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Finishes any pending operations
|
||||
*
|
||||
* This event is sent whenever a pending operation such as
|
||||
* a move operation should be finished.
|
||||
* In contrast to "edit_cancel", this version is supposed
|
||||
* not to rollback, for example if transactions are involved.
|
||||
*/
|
||||
virtual void edit_finish ()
|
||||
{
|
||||
// by default maps to edit_cancel
|
||||
edit_cancel ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicates if any objects are selected
|
||||
*/
|
||||
|
|
@ -457,14 +471,11 @@ public:
|
|||
db::DBox selection_bbox ();
|
||||
|
||||
/**
|
||||
* @brief transform the selection
|
||||
* @brief Transforms the selection
|
||||
*
|
||||
* The transformation is given in micron units.
|
||||
*
|
||||
* If a transaction is given, the operation will be appended to this pending transaction.
|
||||
* The Editables object takes ownership over the Transaction object.
|
||||
*/
|
||||
void transform (const db::DCplxTrans &tr, db::Transaction *transaction = 0);
|
||||
virtual void transform (const db::DCplxTrans &tr);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable a certain editable
|
||||
|
|
@ -565,9 +576,18 @@ public:
|
|||
|
||||
/**
|
||||
* @brief Cancel any pending operations
|
||||
*
|
||||
* This method calls "edit_cancel" on all services and resets selection tracking.
|
||||
*/
|
||||
void edit_cancel ();
|
||||
|
||||
/**
|
||||
* @brief Finishes any pending operations
|
||||
*
|
||||
* This method calls "edit_finish" on all services and resets selection tracking.
|
||||
*/
|
||||
void edit_finish ();
|
||||
|
||||
/**
|
||||
* @brief Editable iterator: begin
|
||||
*/
|
||||
|
|
@ -633,11 +653,21 @@ protected:
|
|||
* @brief Cancel all edit operations
|
||||
*
|
||||
* This method can be overridden in order to implement special behaviour on cancel
|
||||
* of edits (i.e. release the mouse).
|
||||
* of edits (e.g. clean up markers).
|
||||
* Make sure, the base implementation is called as well.
|
||||
*/
|
||||
virtual void cancel_edits ();
|
||||
|
||||
/**
|
||||
* @brief Finishes all edit operations
|
||||
*
|
||||
* This method can be overridden in order to implement special behaviour on finishing
|
||||
* of edits (e.g. clean up markers). In contrast to "cancel_edits", this method
|
||||
* is expected not to rollback any operations - i.e. undo transactions.
|
||||
* Make sure, the base implementation is called as well.
|
||||
*/
|
||||
virtual void finish_edits ();
|
||||
|
||||
private:
|
||||
friend class Editable;
|
||||
|
||||
|
|
|
|||
|
|
@ -3983,12 +3983,41 @@ LayoutViewBase::redraw ()
|
|||
mp_canvas->redraw_new (layers);
|
||||
}
|
||||
|
||||
void
|
||||
LayoutViewBase::transform (const db::DCplxTrans &tr)
|
||||
{
|
||||
finish_edits ();
|
||||
lay::Editables::transform (tr);
|
||||
}
|
||||
|
||||
void
|
||||
LayoutViewBase::cancel_edits ()
|
||||
{
|
||||
// the move service takes a special role here as it manages the
|
||||
// transaction for the collective move operation.
|
||||
mp_move_service->cancel ();
|
||||
|
||||
// cancel all drag and pending edit operations such as move operations.
|
||||
mp_canvas->drag_cancel ();
|
||||
lay::Editables::cancel_edits ();
|
||||
|
||||
// re-enable edit mode
|
||||
enable_edits (true);
|
||||
}
|
||||
|
||||
void
|
||||
LayoutViewBase::finish_edits ()
|
||||
{
|
||||
// the move service takes a special role here as it manages the
|
||||
// transaction for the collective move operation.
|
||||
mp_move_service->finish ();
|
||||
|
||||
// cancel all drag operations
|
||||
mp_canvas->drag_cancel ();
|
||||
lay::Editables::finish_edits ();
|
||||
|
||||
// re-enable edit mode
|
||||
enable_edits (true);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -3996,8 +4025,6 @@ LayoutViewBase::cancel ()
|
|||
{
|
||||
// cancel all drags and pending edit operations such as move operations.
|
||||
cancel_edits ();
|
||||
// re-enable edit mode
|
||||
enable_edits (true);
|
||||
// and clear the selection
|
||||
clear_selection ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2666,6 +2666,13 @@ public:
|
|||
*/
|
||||
void cancel_edits ();
|
||||
|
||||
/**
|
||||
* @brief Finishes all edit operations and maintains selection
|
||||
*
|
||||
* In contrast to "cancel_edits" there is no rollback of operations applied already.
|
||||
*/
|
||||
void finish_edits ();
|
||||
|
||||
/**
|
||||
* @brief Select all levels of hierarchy available
|
||||
*/
|
||||
|
|
@ -2696,7 +2703,14 @@ public:
|
|||
*/
|
||||
void ensure_selection_visible ();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Transforms the selection
|
||||
*
|
||||
* The transformation is given in micron units.
|
||||
*/
|
||||
virtual void transform (const db::DCplxTrans &tr);
|
||||
|
||||
/**
|
||||
* @brief Select a cell by index for a certain cell view
|
||||
*
|
||||
* This will be forwarded to select_cell or select_cell_fit depending
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_
|
|||
if (! m_dragging) {
|
||||
|
||||
mp_transaction.reset (trans_holder.release ());
|
||||
ui ()->drag_cancel ();
|
||||
|
||||
if (mp_editables->begin_move (p, ac_from_buttons (buttons))) {
|
||||
|
||||
|
|
@ -337,21 +338,31 @@ MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_
|
|||
}
|
||||
|
||||
void
|
||||
MoveService::drag_cancel ()
|
||||
{
|
||||
MoveService::drag_cancel ()
|
||||
{
|
||||
m_shift = db::DPoint ();
|
||||
if (m_dragging) {
|
||||
|
||||
mp_editables->edit_cancel ();
|
||||
ui ()->ungrab_mouse (this);
|
||||
|
||||
m_dragging = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MoveService::cancel ()
|
||||
{
|
||||
if (m_dragging) {
|
||||
if (mp_transaction.get ()) {
|
||||
mp_transaction->cancel ();
|
||||
}
|
||||
mp_transaction.reset (0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MoveService::finish ()
|
||||
{
|
||||
if (m_dragging) {
|
||||
mp_transaction.reset (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
bool configure (const std::string &name, const std::string &value);
|
||||
bool begin_move (db::Transaction *transaction = 0, bool transient_selection = false);
|
||||
void finish ();
|
||||
void cancel ();
|
||||
|
||||
private:
|
||||
virtual bool mouse_press_event (const db::DPoint &p, unsigned int buttons, bool prio);
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ public:
|
|||
virtual void set_colors (tl::Color /*background*/, tl::Color /*text*/) { }
|
||||
|
||||
/**
|
||||
* @brief This method is called when a drag operation should be cancelled
|
||||
* @brief This method is called when a mouse tracking operation should be cancelled
|
||||
*/
|
||||
virtual void drag_cancel () { }
|
||||
|
||||
|
|
|
|||
|
|
@ -1199,8 +1199,7 @@ LayoutViewFunctions::do_cm_duplicate (bool interactive)
|
|||
try {
|
||||
bool transient_mode = ! view ()->has_selection ();
|
||||
view ()->copy_view_objects ();
|
||||
view ()->clear_selection ();
|
||||
view ()->cancel ();
|
||||
view ()->cancel_edits ();
|
||||
if (interactive) {
|
||||
view ()->paste_interactive (transient_mode);
|
||||
} else {
|
||||
|
|
@ -1217,8 +1216,7 @@ void
|
|||
LayoutViewFunctions::do_cm_paste (bool interactive)
|
||||
{
|
||||
if (! db::Clipboard::instance ().empty ()) {
|
||||
view ()->cancel ();
|
||||
view ()->clear_selection ();
|
||||
view ()->cancel_edits ();
|
||||
if (interactive) {
|
||||
view ()->paste_interactive ();
|
||||
} else {
|
||||
|
|
@ -1330,9 +1328,7 @@ LayoutViewFunctions::cm_reload ()
|
|||
void
|
||||
LayoutViewFunctions::do_transform (const db::DCplxTrans &tr)
|
||||
{
|
||||
// end move operations, cancel edit operations
|
||||
view ()->cancel_edits ();
|
||||
view ()->lay::Editables::transform (tr);
|
||||
view ()->transform (tr);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1545,6 +1541,7 @@ LayoutViewFunctions::cm_sel_scale ()
|
|||
void
|
||||
LayoutViewFunctions::cm_sel_move_interactive ()
|
||||
{
|
||||
view ()->cancel_edits ();
|
||||
if (view ()->move_service ()->begin_move ()) {
|
||||
view ()->switch_mode (-1); // move mode
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1439,6 +1439,17 @@ LayoutView::cancel_edits ()
|
|||
LayoutViewBase::cancel_edits ();
|
||||
}
|
||||
|
||||
void
|
||||
LayoutView::finish_edits ()
|
||||
{
|
||||
// closes the property dialog
|
||||
if (mp_properties_dialog) {
|
||||
mp_properties_dialog->hide ();
|
||||
}
|
||||
|
||||
LayoutViewBase::finish_edits ();
|
||||
}
|
||||
|
||||
void
|
||||
LayoutView::activate ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -459,6 +459,11 @@ public:
|
|||
*/
|
||||
void cancel_edits ();
|
||||
|
||||
/**
|
||||
* @brief Finishes all edit operations and maintains selection
|
||||
*/
|
||||
void finish_edits ();
|
||||
|
||||
/**
|
||||
* @brief Select all levels of hierarchy available
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue