diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 8e80edf82..52138e745 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -4333,7 +4333,8 @@ public: menu_entries.push_back (lay::menu_item ("cm_reset_window_state", "reset_window_state", at, tl::to_string (QObject::tr ("Restore Window")))), menu_entries.push_back (lay::separator ("selection_group", at)); menu_entries.push_back (lay::config_menu_item ("transient_selection", at, tl::to_string (QObject::tr ("Highlight Object Under Mouse")), cfg_sel_transient_mode, "?")); - menu_entries.push_back (lay::config_menu_item ("mouse_tracking", at, tl::to_string (QObject::tr ("Mouse tracking")), cfg_tracking_cursor_enabled, "?")); + menu_entries.push_back (lay::config_menu_item ("mouse_tracking", at, tl::to_string (QObject::tr ("Mouse Tracking")), cfg_tracking_cursor_enabled, "?")); + menu_entries.push_back (lay::config_menu_item ("crosshair_cursor", at, tl::to_string (QObject::tr ("Crosshair Cursor")), cfg_crosshair_cursor_enabled, "?")); at = "help_menu.end"; menu_entries.push_back (lay::menu_item ("cm_show_all_tips", "show_all_tips", at, tl::to_string (QObject::tr ("Show All Tips")))); diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 53056d630..ff7cec227 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -741,6 +741,10 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) return true; } + if (mp_tracker && mp_tracker->configure (name, value)) { + return true; + } + if (name == cfg_default_lyp_file) { m_def_lyp_file = value; diff --git a/src/laybasic/laybasic/layLayoutViewConfig.cc b/src/laybasic/laybasic/layLayoutViewConfig.cc index a21e172e4..519458b67 100644 --- a/src/laybasic/laybasic/layLayoutViewConfig.cc +++ b/src/laybasic/laybasic/layLayoutViewConfig.cc @@ -72,11 +72,15 @@ public: options.push_back (std::pair (cfg_sel_line_width, "1")); options.push_back (std::pair (cfg_sel_vertex_size, "3")); options.push_back (std::pair (cfg_sel_dither_pattern, "1")); + options.push_back (std::pair (cfg_sel_line_style, "0")); options.push_back (std::pair (cfg_sel_halo, "true")); options.push_back (std::pair (cfg_sel_transient_mode, "true")); options.push_back (std::pair (cfg_sel_inside_pcells_mode, "false")); options.push_back (std::pair (cfg_tracking_cursor_enabled, "true")); options.push_back (std::pair (cfg_tracking_cursor_color, cc.to_string (tl::Color ()))); + options.push_back (std::pair (cfg_crosshair_cursor_color, cc.to_string (tl::Color ()))); + options.push_back (std::pair (cfg_crosshair_cursor_line_style, "0")); + options.push_back (std::pair (cfg_crosshair_cursor_enabled, "false")); options.push_back (std::pair (cfg_background_color, cc.to_string (tl::Color ()))); options.push_back (std::pair (cfg_ctx_color, cc.to_string (tl::Color ()))); options.push_back (std::pair (cfg_ctx_dimming, "50")); diff --git a/src/laybasic/laybasic/layMouseTracker.cc b/src/laybasic/laybasic/layMouseTracker.cc index 818088d8f..93b9930fb 100644 --- a/src/laybasic/laybasic/layMouseTracker.cc +++ b/src/laybasic/laybasic/layMouseTracker.cc @@ -24,20 +24,69 @@ #include "layMouseTracker.h" #include "layLayoutCanvas.h" #include "layLayoutViewBase.h" +#include "layConverters.h" +#include "laybasicConfig.h" namespace lay { MouseTracker::MouseTracker (lay::LayoutViewBase *view) - : lay::ViewService (view->canvas ()), mp_view (view) + : lay::ViewService (view->canvas ()), mp_view (view), + m_cursor_color (tl::Color ()), m_cursor_line_style (0), m_cursor_enabled (false) { ui ()->grab_mouse (this, false); } +bool +MouseTracker::leave_event (bool) +{ + mp_markers.clear (); + return false; +} + +bool +MouseTracker::configure (const std::string &name, const std::string &value) +{ + if (name == cfg_crosshair_cursor_color) { + + tl::Color color; + lay::ColorConverter ().from_string (value, color); + + // Change the color + if (lay::test_and_set (m_cursor_color, color)) { + mp_markers.clear (); + } + + } else if (name == cfg_crosshair_cursor_line_style) { + + int dp = 0; + tl::from_string (value, dp); + + // Change the vertex_size + if (lay::test_and_set (m_cursor_line_style, dp)) { + mp_markers.clear (); + } + + } else if (name == cfg_crosshair_cursor_enabled) { + + bool f = m_cursor_enabled; + tl::from_string (value, f); + if (f != m_cursor_enabled) { + m_cursor_enabled = f; + mp_markers.clear (); + } + + } + + return false; // not taken +} + bool MouseTracker::mouse_move_event (const db::DPoint &p, unsigned int /*buttons*/, bool prio) { - if (prio) { + // NOTE: by catching events with low prio, the tracking position was already set by consumers + // with high prio + if (! prio) { // 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 @@ -50,6 +99,24 @@ MouseTracker::mouse_move_event (const db::DPoint &p, unsigned int /*buttons*/, b mp_view->current_pos (tp.x (), tp.y ()); + mp_markers.clear (); + + if (m_cursor_enabled) { + + double max_coord = 1e30; // big enough I guess + + mp_markers.push_back (new lay::DMarker (mp_view)); + mp_markers.back ()->set_line_style (m_cursor_line_style); + mp_markers.back ()->set_color (m_cursor_color); + mp_markers.back ()->set (db::DEdge (db::DPoint (tp.x (), -max_coord), db::DPoint (tp.x (), max_coord))); + + mp_markers.push_back (new lay::DMarker (mp_view)); + mp_markers.back ()->set_line_style (m_cursor_line_style); + mp_markers.back ()->set_color (m_cursor_color); + mp_markers.back ()->set (db::DEdge (db::DPoint (-max_coord, tp.y ()), db::DPoint (max_coord, tp.y ()))); + + } + } return false; diff --git a/src/laybasic/laybasic/layMouseTracker.h b/src/laybasic/laybasic/layMouseTracker.h index 0fe26f5a9..b2ecbb27b 100644 --- a/src/laybasic/laybasic/layMouseTracker.h +++ b/src/laybasic/laybasic/layMouseTracker.h @@ -25,6 +25,8 @@ #define HDR_layMouseTracker #include "layViewObject.h" +#include "layMarker.h" +#include "tlObject.h" class QMouseEvent; @@ -38,10 +40,17 @@ class MouseTracker { public: MouseTracker (lay::LayoutViewBase *view); + virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio); + bool leave_event (bool prio); + bool configure (const std::string &name, const std::string &value); private: lay::LayoutViewBase *mp_view; + tl::shared_collection mp_markers; + tl::Color m_cursor_color; + int m_cursor_line_style; + bool m_cursor_enabled; }; } diff --git a/src/laybasic/laybasic/layMove.h b/src/laybasic/laybasic/layMove.h index a51884d6c..bed2a18cb 100644 --- a/src/laybasic/laybasic/layMove.h +++ b/src/laybasic/laybasic/layMove.h @@ -41,7 +41,7 @@ public: MoveService (lay::LayoutViewBase *view); ~MoveService (); - virtual bool configure (const std::string &name, const std::string &value); + bool configure (const std::string &name, const std::string &value); bool begin_move (db::Transaction *transaction = 0, bool transient_selection = false); private: diff --git a/src/laybasic/laybasic/laybasicConfig.h b/src/laybasic/laybasic/laybasicConfig.h index 5731b82be..ba148ee60 100644 --- a/src/laybasic/laybasic/laybasicConfig.h +++ b/src/laybasic/laybasic/laybasicConfig.h @@ -77,6 +77,9 @@ static const std::string cfg_sel_inside_pcells_mode ("sel-inside-pcells-mode"); static const std::string cfg_tracking_cursor_color ("tracking-cursor-color"); static const std::string cfg_tracking_cursor_enabled ("tracking-cursor-enabled"); +static const std::string cfg_crosshair_cursor_color ("crosshair-cursor-color"); +static const std::string cfg_crosshair_cursor_line_style ("crosshair-cursor-line-style"); +static const std::string cfg_crosshair_cursor_enabled ("crosshair-cursor-enabled"); static const std::string cfg_markers_visible ("markers-visible"); diff --git a/src/layui/layui/LayoutViewConfigPage2d.ui b/src/layui/layui/LayoutViewConfigPage2d.ui index 0a9fc17f5..ad779f091 100644 --- a/src/layui/layui/LayoutViewConfigPage2d.ui +++ b/src/layui/layui/LayoutViewConfigPage2d.ui @@ -6,8 +6,8 @@ 0 0 - 608 - 318 + 696 + 420 @@ -120,6 +120,62 @@ + + + + Crosshair cursor + + + true + + + + + + Cursor color + + + + + + + Qt::Horizontal + + + + 508 + 31 + + + + + + + + The color in which the rulers are drawn + + + + + + + + + + Line style + + + + + + + + + + + + + @@ -142,6 +198,11 @@ QPushButton
layWidgets.h
+ + lay::LineStyleSelectionButton + QPushButton +
layWidgets.h
+
color_pb diff --git a/src/layui/layui/layLayoutViewConfigPages.cc b/src/layui/layui/layLayoutViewConfigPages.cc index d8e2ccb4e..ac7070ca5 100644 --- a/src/layui/layui/layLayoutViewConfigPages.cc +++ b/src/layui/layui/layLayoutViewConfigPages.cc @@ -424,9 +424,21 @@ LayoutViewConfigPage2d::setup (lay::Dispatcher *root) root->config_get (cfg_tracking_cursor_color, color, lay::ColorConverter ()); mp_ui->color_pb->set_color (color); - bool enabled = 0; + bool enabled = false; root->config_get (cfg_tracking_cursor_enabled, enabled); mp_ui->tracking_cb->setChecked (enabled); + + color = QColor (); + root->config_get (cfg_crosshair_cursor_color, color, lay::ColorConverter ()); + mp_ui->color_chc->set_color (color); + + int line_style = 0; + root->config_get (cfg_crosshair_cursor_line_style, line_style); + mp_ui->line_style_chc->set_line_style (line_style); + + enabled = false; + root->config_get (cfg_crosshair_cursor_enabled, enabled); + mp_ui->crosshair_cursor_cb->setChecked (enabled); } void @@ -435,6 +447,9 @@ LayoutViewConfigPage2d::commit (lay::Dispatcher *root) lay::ColorConverter cc; root->config_set (cfg_tracking_cursor_color, mp_ui->color_pb->get_color (), cc); root->config_set (cfg_tracking_cursor_enabled, mp_ui->tracking_cb->isChecked ()); + root->config_set (cfg_crosshair_cursor_color, mp_ui->color_chc->get_color (), cc); + root->config_set (cfg_crosshair_cursor_line_style, mp_ui->line_style_chc->line_style ()); + root->config_set (cfg_crosshair_cursor_enabled, mp_ui->crosshair_cursor_cb->isChecked ()); } // ------------------------------------------------------------