WIP, e.g. avoiding sticky selection when aborting 'move' by chosing a different mode

This commit is contained in:
Matthias Koefferlein
2026-01-12 17:05:42 +01:00
parent c738cf7255
commit 0b9a0c3af1
8 changed files with 76 additions and 26 deletions
@@ -31,6 +31,14 @@
namespace lay
{
// ------------------------------------------------------------------
// EditorOptionsPageCollection implementation
EditorOptionsPageCollection::EditorOptionsPageCollection ()
{
// .. nothing yet ..
}
// ------------------------------------------------------------------
// EditorOptionsPage implementation
@@ -115,6 +123,11 @@ EditorOptionsPage::activate (bool active)
if (mp_owner) {
mp_owner->activate_page (this);
}
if (m_active) {
activated ();
} else {
deactivated ();
}
}
}
@@ -191,6 +204,12 @@ EditorOptionsPageWidget::set_focus ()
QWidget::focusNextPrevChild (true);
}
void
EditorOptionsPageWidget::set_visible (bool visible)
{
setVisible (visible);
}
#endif
}
@@ -53,6 +53,7 @@ class EditorOptionsPageWidget;
class LAYBASIC_PUBLIC EditorOptionsPageCollection
{
public:
EditorOptionsPageCollection ();
virtual ~EditorOptionsPageCollection () { }
virtual void unregister_page (EditorOptionsPage *page) = 0;
@@ -64,6 +65,7 @@ public:
virtual bool exec_modal (EditorOptionsPage *page) = 0;
virtual std::vector<lay::EditorOptionsPage *> editor_options_pages (const lay::PluginDeclaration *plugin) = 0;
virtual std::vector<lay::EditorOptionsPage *> editor_options_pages () = 0;
virtual lay::EditorOptionsPage *page_with_name (const std::string &name) = 0;
};
/**
@@ -79,11 +81,13 @@ public:
virtual std::string title () const = 0;
virtual int order () const = 0;
virtual const char *name () const { return 0; }
virtual void apply (lay::Dispatcher * /*root*/) { }
virtual void setup (lay::Dispatcher * /*root*/) { }
virtual void commit_recent (lay::Dispatcher * /*root*/) { }
virtual void config_recent_for_layer (lay::Dispatcher * /*root*/, const db::LayerProperties & /*lp*/, int /*cv_index*/) { }
virtual void set_focus () { }
virtual void set_visible (bool /*visible*/) { }
virtual EditorOptionsPageWidget *widget () { return 0; }
bool is_focus_page () const { return m_focus_page; }
@@ -123,6 +127,8 @@ public:
protected:
virtual void active_cellview_changed () { }
virtual void technology_changed (const std::string & /*tech*/) { }
virtual void activated () { }
virtual void deactivated () { }
private:
EditorOptionsPageCollection *mp_owner;
@@ -153,6 +159,7 @@ public:
virtual ~EditorOptionsPageWidget ();
virtual void set_focus ();
virtual void set_visible (bool visible);
virtual EditorOptionsPageWidget *widget () { return this; }
protected slots:
-11
View File
@@ -360,17 +360,6 @@ public:
// the base implementation does nothing
}
/**
* @brief Shows or hides a toolbox widget with the given name
*
* Initially toolbox widgets are invisible. They are made visible
* by using this method.
*/
virtual void show_toolbox_widget (const std::string & /*name*/, bool /*visible*/)
{
// the base implementation does nothing
}
/**
* @brief Adds an editor options page as a toolbox widget
*/
+33 -3
View File
@@ -37,6 +37,8 @@
namespace lay
{
const char *move_editor_options_name = "move-editor-options";
// -------------------------------------------------------------
// MoveService implementation
@@ -62,7 +64,11 @@ MoveService::deactivated ()
EditorServiceBase::deactivated ();
m_shift = db::DPoint ();
mp_editables->clear_transient_selection ();
drag_cancel ();
if (m_dragging) {
// we don't just call drag_cancel() - this way avoids pending selections with the wrong coordinates
mp_view->edit_cancel ();
}
}
bool
@@ -127,6 +133,15 @@ MoveService::key_event (unsigned int key, unsigned int buttons)
}
}
void
MoveService::show_toolbox (bool visible)
{
lay::EditorOptionsPage *op = mp_view->editor_options_pages () ? mp_view->editor_options_pages ()->page_with_name (move_editor_options_name) : 0;
if (op) {
op->set_visible (visible);
}
}
int
MoveService::focus_page_open ()
{
@@ -320,6 +335,8 @@ MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_
m_dragging = true;
m_dragging_transient = drag_transient;
show_toolbox (true);
ui ()->grab_mouse (this, false);
m_shift = db::DPoint ();
@@ -332,7 +349,9 @@ MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_
m_dragging = false;
show_toolbox (false);
ui ()->ungrab_mouse (this);
mp_editables->end_move (p, ac_from_buttons (buttons), mp_transaction.release ());
if (m_dragging_transient) {
@@ -350,6 +369,7 @@ MoveService::drag_cancel ()
{
m_shift = db::DPoint ();
if (m_dragging) {
show_toolbox (false);
ui ()->ungrab_mouse (this);
m_dragging = false;
}
@@ -394,8 +414,7 @@ public:
mp_layout->addWidget (mp_y_le);
mp_layout->addStretch (1);
// @@@
hide ();
set_toolbox_widget (true);
}
@@ -404,11 +423,21 @@ public:
return "Move Options";
}
virtual const char *name () const
{
return move_editor_options_name;
}
virtual int order () const
{
return 0;
}
virtual void deactivated ()
{
hide ();
}
private:
QHBoxLayout *mp_layout;
QLineEdit *mp_x_le, *mp_y_le;
@@ -436,6 +465,7 @@ public:
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const
{
pages.push_back (new MoveToolboxPage (view, dispatcher));
pages.back ()->set_plugin_declaration (this);
}
#endif
};
+1
View File
@@ -57,6 +57,7 @@ private:
virtual void drag_cancel ();
virtual void deactivated ();
int focus_page_open ();
void show_toolbox (bool visible);
bool handle_click (const db::DPoint &p, unsigned int buttons, bool drag_transient, db::Transaction *transaction);