Fast panning with Shift pressed.

This commit is contained in:
Matthias Koefferlein 2017-09-06 23:38:46 +02:00
parent 41e8c58869
commit e52c96b0bc
4 changed files with 60 additions and 9 deletions

View File

@ -378,8 +378,9 @@ LayoutCanvas::~LayoutCanvas ()
} }
void void
LayoutCanvas::key_event (unsigned int key, unsigned int /*buttons*/) LayoutCanvas::key_event (unsigned int key, unsigned int buttons)
{ {
if (! (buttons & lay::ShiftButton)) {
if (int (key) == Qt::Key_Down) { if (int (key) == Qt::Key_Down) {
emit down_arrow_key_pressed (); emit down_arrow_key_pressed ();
} else if (int (key) == Qt::Key_Up) { } else if (int (key) == Qt::Key_Up) {
@ -389,6 +390,17 @@ LayoutCanvas::key_event (unsigned int key, unsigned int /*buttons*/)
} else if (int (key) == Qt::Key_Right) { } else if (int (key) == Qt::Key_Right) {
emit right_arrow_key_pressed (); emit right_arrow_key_pressed ();
} }
} else {
if (int (key) == Qt::Key_Down) {
emit down_arrow_key_pressed_with_shift ();
} else if (int (key) == Qt::Key_Up) {
emit up_arrow_key_pressed_with_shift ();
} else if (int (key) == Qt::Key_Left) {
emit left_arrow_key_pressed_with_shift ();
} else if (int (key) == Qt::Key_Right) {
emit right_arrow_key_pressed_with_shift ();
}
}
} }
void void

View File

@ -348,6 +348,10 @@ signals:
void up_arrow_key_pressed (); void up_arrow_key_pressed ();
void right_arrow_key_pressed (); void right_arrow_key_pressed ();
void down_arrow_key_pressed (); void down_arrow_key_pressed ();
void left_arrow_key_pressed_with_shift ();
void up_arrow_key_pressed_with_shift ();
void right_arrow_key_pressed_with_shift ();
void down_arrow_key_pressed_with_shift ();
private: private:
lay::LayoutView *mp_view; lay::LayoutView *mp_view;

View File

@ -83,6 +83,9 @@ namespace lay
// factor for "zoom in & out" // factor for "zoom in & out"
const double zoom_factor = 0.7; const double zoom_factor = 0.7;
// factor by which panning is faster in "fast" (+Shift) mode
const double fast_factor = 3.0;
// ------------------------------------------------------------- // -------------------------------------------------------------
struct OpHideShowCell struct OpHideShowCell
@ -482,6 +485,10 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/)
connect (mp_canvas, SIGNAL (up_arrow_key_pressed ()), this, SLOT (pan_up ())); connect (mp_canvas, SIGNAL (up_arrow_key_pressed ()), this, SLOT (pan_up ()));
connect (mp_canvas, SIGNAL (right_arrow_key_pressed ()), this, SLOT (pan_right ())); connect (mp_canvas, SIGNAL (right_arrow_key_pressed ()), this, SLOT (pan_right ()));
connect (mp_canvas, SIGNAL (down_arrow_key_pressed ()), this, SLOT (pan_down ())); connect (mp_canvas, SIGNAL (down_arrow_key_pressed ()), this, SLOT (pan_down ()));
connect (mp_canvas, SIGNAL (left_arrow_key_pressed_with_shift ()), this, SLOT (pan_left_fast ()));
connect (mp_canvas, SIGNAL (up_arrow_key_pressed_with_shift ()), this, SLOT (pan_up_fast ()));
connect (mp_canvas, SIGNAL (right_arrow_key_pressed_with_shift ()), this, SLOT (pan_right_fast ()));
connect (mp_canvas, SIGNAL (down_arrow_key_pressed_with_shift ()), this, SLOT (pan_down_fast ()));
// occupy services and editables: // occupy services and editables:
// these services get deleted by the canvas destructor automatically: // these services get deleted by the canvas destructor automatically:
@ -3509,6 +3516,30 @@ LayoutView::pan_down ()
shift_window (1.0, 0.0, -m_pan_distance); shift_window (1.0, 0.0, -m_pan_distance);
} }
void
LayoutView::pan_left_fast ()
{
shift_window (1.0, -m_pan_distance * fast_factor, 0.0);
}
void
LayoutView::pan_right_fast ()
{
shift_window (1.0, m_pan_distance * fast_factor, 0.0);
}
void
LayoutView::pan_up_fast ()
{
shift_window (1.0, 0.0, m_pan_distance * fast_factor);
}
void
LayoutView::pan_down_fast ()
{
shift_window (1.0, 0.0, -m_pan_distance * fast_factor);
}
void void
LayoutView::pan_center (const db::DPoint &p) LayoutView::pan_center (const db::DPoint &p)
{ {

View File

@ -2425,6 +2425,10 @@ public slots:
void pan_up (); void pan_up ();
void pan_right (); void pan_right ();
void pan_down (); void pan_down ();
void pan_left_fast ();
void pan_up_fast ();
void pan_right_fast ();
void pan_down_fast ();
// menu callbacks // menu callbacks
void cm_new_layer (); void cm_new_layer ();