mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-07 11:31:08 +02:00
Some refactoring with the goal to support "move by" with "clone interactive"
This commit is contained in:
@@ -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 () { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user