mirror of https://github.com/KLayout/klayout.git
Merge pull request #964 from KLayout/issue-963-show-snapped-position
Implemented request: show snapped cursor position in lower left posit…
This commit is contained in:
commit
b78a8d58c8
|
|
@ -1545,11 +1545,12 @@ PartialService::mouse_move_event (const db::DPoint &p, unsigned int buttons, boo
|
|||
// thus, we can bring the point on grid or to an object's edge or vertex
|
||||
snap_details = snap2 (p);
|
||||
m_current = snap_details.snapped_point;
|
||||
mouse_cursor_from_snap_details (snap_details);
|
||||
} else {
|
||||
m_current = m_start + snap (p - m_start);
|
||||
clear_mouse_cursors ();
|
||||
}
|
||||
|
||||
mouse_cursor_from_snap_details (snap_details);
|
||||
selection_to_view ();
|
||||
|
||||
m_alt_ac = lay::AC_Global;
|
||||
|
|
|
|||
|
|
@ -268,6 +268,24 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool has_tracking_position () const
|
||||
{
|
||||
if (f_has_tracking_position.can_issue ()) {
|
||||
return f_has_tracking_position.issue<lay::ViewService, bool> (&lay::ViewService::has_tracking_position);
|
||||
} else {
|
||||
return lay::ViewService::has_tracking_position ();
|
||||
}
|
||||
}
|
||||
|
||||
virtual db::DPoint tracking_position () const
|
||||
{
|
||||
if (f_tracking_position.can_issue ()) {
|
||||
return f_tracking_position.issue<lay::ViewService, db::DPoint> (&lay::ViewService::tracking_position);
|
||||
} else {
|
||||
return lay::ViewService::tracking_position ();
|
||||
}
|
||||
}
|
||||
|
||||
gsi::Callback f_menu_activated;
|
||||
gsi::Callback f_configure;
|
||||
gsi::Callback f_config_finalize;
|
||||
|
|
@ -284,6 +302,8 @@ public:
|
|||
gsi::Callback f_deactivated;
|
||||
gsi::Callback f_drag_cancel;
|
||||
gsi::Callback f_update;
|
||||
gsi::Callback f_has_tracking_position;
|
||||
gsi::Callback f_tracking_position;
|
||||
};
|
||||
|
||||
class PluginFactoryBase
|
||||
|
|
@ -793,7 +813,7 @@ Class<gsi::PluginBase> decl_Plugin ("lay", "Plugin",
|
|||
"If the plugin implements some press-and-drag or a click-and-drag operation, this callback should "
|
||||
"cancel this operation and return in some state waiting for a new mouse event."
|
||||
) +
|
||||
callback ("update", &gsi::PluginBase::update, &gsi::PluginBase::f_update,
|
||||
callback ("update", &gsi::PluginBase::update, &gsi::PluginBase::f_update,
|
||||
"@brief Gets called when the view has changed\n"
|
||||
"This method is called in particular if the view has changed the visible rectangle, i.e. after zooming in or out or panning. "
|
||||
"This callback can be used to update any internal states that depend on the view's state."
|
||||
|
|
@ -810,6 +830,20 @@ Class<gsi::PluginBase> decl_Plugin ("lay", "Plugin",
|
|||
"in the mouse move handler unless a button is pressed or the cursor is explicitly set again in the mouse_move_event.\n"
|
||||
"\n"
|
||||
"The cursor type is one of the cursor constants in the \\Cursor class, i.e. 'CursorArrow' for the normal cursor."
|
||||
) +
|
||||
callback ("has_tracking_position", &gsi::PluginBase::has_tracking_position, &gsi::PluginBase::f_has_tracking_position,
|
||||
"@brief Gets a value indicating whether the plugin provides a tracking position\n"
|
||||
"The tracking position is shown in the lower-left corner of the layout window to indicate the current position.\n"
|
||||
"If this method returns true for the active service, the application will fetch the position by calling \\tracking_position "
|
||||
"rather than displaying the original mouse position.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.27.6."
|
||||
) +
|
||||
callback ("tracking_position", &gsi::PluginBase::tracking_position, &gsi::PluginBase::f_tracking_position,
|
||||
"@brief Gets the tracking position\n"
|
||||
"See \\has_tracking_position for details.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.27.6."
|
||||
),
|
||||
"@brief The plugin object\n"
|
||||
"\n"
|
||||
|
|
|
|||
|
|
@ -206,7 +206,8 @@ EditorServiceBase::EditorServiceBase (lay::LayoutView *view)
|
|||
: lay::ViewService (view->view_object_widget ()),
|
||||
lay::Editable (view),
|
||||
lay::Plugin (view),
|
||||
m_cursor_enabled (true)
|
||||
m_cursor_enabled (true),
|
||||
m_has_tracking_position (false)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
@ -219,6 +220,8 @@ EditorServiceBase::~EditorServiceBase ()
|
|||
void
|
||||
EditorServiceBase::add_mouse_cursor (const db::DPoint &pt, bool emphasize)
|
||||
{
|
||||
m_has_tracking_position = true;
|
||||
m_tracking_position = pt;
|
||||
m_mouse_cursor_markers.push_back (new MouseCursorViewObject (this, widget (), pt, emphasize));
|
||||
}
|
||||
|
||||
|
|
@ -231,6 +234,7 @@ EditorServiceBase::add_edge_marker (const db::DEdge &e, bool emphasize)
|
|||
void
|
||||
EditorServiceBase::clear_mouse_cursors ()
|
||||
{
|
||||
m_has_tracking_position = false;
|
||||
for (std::vector<lay::ViewObject *>::iterator r = m_mouse_cursor_markers.begin (); r != m_mouse_cursor_markers.end (); ++r) {
|
||||
delete *r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,22 @@ public:
|
|||
return m_cursor_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether a cursor position it set
|
||||
*/
|
||||
virtual bool has_tracking_position () const
|
||||
{
|
||||
return m_has_tracking_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the cursor position if one is set
|
||||
*/
|
||||
virtual db::DPoint tracking_position () const
|
||||
{
|
||||
return m_tracking_position;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool configure (const std::string &name, const std::string &value);
|
||||
virtual void deactivated ();
|
||||
|
|
@ -114,6 +130,9 @@ private:
|
|||
std::vector<lay::ViewObject *> m_mouse_cursor_markers;
|
||||
QColor m_cursor_color;
|
||||
bool m_cursor_enabled;
|
||||
lay::LayoutView *mp_view;
|
||||
bool m_has_tracking_position;
|
||||
db::DPoint m_tracking_position;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,20 @@ bool
|
|||
MouseTracker::mouse_move_event (const db::DPoint &p, unsigned int /*buttons*/, bool prio)
|
||||
{
|
||||
if (prio) {
|
||||
mp_view->current_pos (p.x (), p.y ());
|
||||
|
||||
// NOTE: because the tracker grabs first and grabbers are registered first gets served last, the
|
||||
// tracker will receive the event after all other mouse grabbers have been served and had their
|
||||
// chance to set the tracking position.
|
||||
lay::ViewService *vs = mp_view->view_object_widget ()->active_service ();
|
||||
db::DPoint tp = p;
|
||||
if (vs && vs->enabled () && vs->has_tracking_position ()) {
|
||||
tp = vs->tracking_position ();
|
||||
}
|
||||
|
||||
mp_view->current_pos (tp.x (), tp.y ());
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -380,6 +380,16 @@ public:
|
|||
*/
|
||||
virtual void drag_cancel () { }
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether a cursor position it set
|
||||
*/
|
||||
virtual bool has_tracking_position () const { return false; }
|
||||
|
||||
/**
|
||||
* @brief Gets the cursor position if one is set
|
||||
*/
|
||||
virtual db::DPoint tracking_position () const { return db::DPoint (); }
|
||||
|
||||
/**
|
||||
* @brief Enable or disable a service
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue