mirror of https://github.com/KLayout/klayout.git
Fixed issue #1510 (cross hair cursor, with options to enable from menu, color and line style can be configured)
This commit is contained in:
parent
67d934194f
commit
45f3216530
|
|
@ -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"))));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -72,11 +72,15 @@ public:
|
|||
options.push_back (std::pair<std::string, std::string> (cfg_sel_line_width, "1"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_sel_vertex_size, "3"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_sel_dither_pattern, "1"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_sel_line_style, "0"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_sel_halo, "true"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_sel_transient_mode, "true"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_sel_inside_pcells_mode, "false"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_tracking_cursor_enabled, "true"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_tracking_cursor_color, cc.to_string (tl::Color ())));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_crosshair_cursor_color, cc.to_string (tl::Color ())));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_crosshair_cursor_line_style, "0"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_crosshair_cursor_enabled, "false"));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_background_color, cc.to_string (tl::Color ())));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_ctx_color, cc.to_string (tl::Color ())));
|
||||
options.push_back (std::pair<std::string, std::string> (cfg_ctx_dimming, "50"));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<lay::DMarker> mp_markers;
|
||||
tl::Color m_cursor_color;
|
||||
int m_cursor_line_style;
|
||||
bool m_cursor_enabled;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>608</width>
|
||||
<height>318</height>
|
||||
<width>696</width>
|
||||
<height>420</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -120,6 +120,62 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="crosshair_cursor_cb">
|
||||
<property name="title">
|
||||
<string>Crosshair cursor</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel3_3">
|
||||
<property name="text">
|
||||
<string>Cursor color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>508</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="lay::ColorButton" name="color_chc">
|
||||
<property name="toolTip">
|
||||
<string>The color in which the rulers are drawn</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Line style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="lay::LineStyleSelectionButton" name="line_style_chc">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
|
@ -142,6 +198,11 @@
|
|||
<extends>QPushButton</extends>
|
||||
<header>layWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>lay::LineStyleSelectionButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>layWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>color_pb</tabstop>
|
||||
|
|
|
|||
|
|
@ -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 ());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue