diff --git a/src/control/settings/Settings.cpp b/src/control/settings/Settings.cpp index 20af3658..6aa6b1e0 100644 --- a/src/control/settings/Settings.cpp +++ b/src/control/settings/Settings.cpp @@ -54,6 +54,9 @@ void Settings::loadDefault() { this->numPairsOffset = 1; + this->edgePanSpeed = 20.0; + this->edgePanMaxMult = 5.0; + this->zoomStep = 10.0; this->zoomStepScroll = 2.0; @@ -334,6 +337,10 @@ void Settings::parseItem(xmlDocPtr doc, xmlNodePtr cur) { this->lastOpenPath = fs::u8path(reinterpret_cast(value)); } else if (xmlStrcmp(name, reinterpret_cast("lastImagePath")) == 0) { this->lastImagePath = fs::u8path(reinterpret_cast(value)); + } else if (xmlStrcmp(name, reinterpret_cast("edgePanSpeed")) == 0) { + this->edgePanSpeed = tempg_ascii_strtod(reinterpret_cast(value), nullptr); + } else if (xmlStrcmp(name, reinterpret_cast("edgePanMaxMult")) == 0) { + this->edgePanMaxMult = tempg_ascii_strtod(reinterpret_cast(value), nullptr); } else if (xmlStrcmp(name, reinterpret_cast("zoomStep")) == 0) { this->zoomStep = tempg_ascii_strtod(reinterpret_cast(value), nullptr); } else if (xmlStrcmp(name, reinterpret_cast("zoomStepScroll")) == 0) { @@ -803,6 +810,8 @@ void Settings::save() { SAVE_STRING_PROP(lastOpenPath); SAVE_STRING_PROP(lastImagePath); + SAVE_DOUBLE_PROP(edgePanSpeed); + SAVE_DOUBLE_PROP(edgePanMaxMult); SAVE_DOUBLE_PROP(zoomStep); SAVE_DOUBLE_PROP(zoomStepScroll); SAVE_INT_PROP(displayDpi); @@ -1551,6 +1560,26 @@ void Settings::setZoomStepScroll(double zoomStepScroll) { auto Settings::getZoomStepScroll() const -> double { return this->zoomStepScroll; } +void Settings::setEdgePanSpeed(double speed) { + if (this->edgePanSpeed == speed) { + return; + } + this->edgePanSpeed = speed; + save(); +} + +auto Settings::getEdgePanSpeed() const -> double { return this->edgePanSpeed; } + +void Settings::setEdgePanMaxMult(double maxMult) { + if (this->edgePanMaxMult == maxMult) { + return; + } + this->edgePanMaxMult = maxMult; + save(); +} + +auto Settings::getEdgePanMaxMult() const -> double { return this->edgePanMaxMult; } + void Settings::setDisplayDpi(int dpi) { if (this->displayDpi == dpi) { return; diff --git a/src/control/settings/Settings.h b/src/control/settings/Settings.h index dcc38ab7..478d164d 100644 --- a/src/control/settings/Settings.h +++ b/src/control/settings/Settings.h @@ -142,6 +142,12 @@ public: void setSelectedToolbar(const std::string& name); std::string const& getSelectedToolbar() const; + void setEdgePanSpeed(double speed); + double getEdgePanSpeed() const; + + void setEdgePanMaxMult(double mult); + double getEdgePanMaxMult() const; + /** * Set the Zoomstep for one step in percent */ @@ -658,6 +664,18 @@ private: */ XojFont font; + /** + * Base speed (as a percentage of visible canvas) of edge pan per + * second + */ + double edgePanSpeed{}; + + /** + * Maximum multiplier of edge pan speed due to proportion of selection out + * of view + */ + double edgePanMaxMult{}; + /** * Zoomstep for one step */ diff --git a/src/control/tools/EditSelection.cpp b/src/control/tools/EditSelection.cpp index 59b6ea59..d3e3e67d 100644 --- a/src/control/tools/EditSelection.cpp +++ b/src/control/tools/EditSelection.cpp @@ -740,6 +740,7 @@ bool EditSelection::handleEdgePan(EditSelection* self) { Layout* layout = gtk_xournal_get_layout(self->view->getXournal()->getWidget()); + const Settings* const settings = self->getView()->getXournal()->getControl()->getSettings(); const double zoom = self->view->getXournal()->getZoom(); // Helper function to compute scroll amount for a single dimension, based on visible region and selection bbox @@ -754,7 +755,7 @@ bool EditSelection::handleEdgePan(EditSelection* self) { double mult = 0.0; // Calculate bonus scroll amount due to proportion of selection out of view. - const double maxMult = 5.0; + const double maxMult = settings->getEdgePanMaxMult(); int panDir = 0; if (aboveMax) { panDir = 1; @@ -765,7 +766,7 @@ bool EditSelection::handleEdgePan(EditSelection* self) { } // Base amount to translate selection (in document coordinates) per timer tick - const double panSpeed = 20.0; + const double panSpeed = settings->getEdgePanSpeed(); const double translateAmt = visLen * panSpeed / (100.0 * PAN_TIMER_RATE); // Amount to scroll the visible area by (in layout coordinates), accounting for multiplier diff --git a/src/gui/dialog/SettingsDialog.cpp b/src/gui/dialog/SettingsDialog.cpp index aae4053d..038c0f85 100644 --- a/src/gui/dialog/SettingsDialog.cpp +++ b/src/gui/dialog/SettingsDialog.cpp @@ -416,6 +416,9 @@ void SettingsDialog::load() { GtkWidget* spSnapGridSize = get("spSnapGridSize"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spSnapGridSize), settings->getSnapGridSize() / DEFAULT_GRID_SIZE); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(get("edgePanSpeed")), settings->getEdgePanSpeed()); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(get("edgePanMaxMult")), settings->getEdgePanMaxMult()); + GtkWidget* spZoomStep = get("spZoomStep"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spZoomStep), settings->getZoomStep()); @@ -786,6 +789,9 @@ void SettingsDialog::save() { int numPairsOffset = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spPairsOffset)); settings->setPairsOffset(numPairsOffset); + settings->setEdgePanSpeed(gtk_spin_button_get_value(GTK_SPIN_BUTTON(get("edgePanSpeed")))); + settings->setEdgePanMaxMult(gtk_spin_button_get_value(GTK_SPIN_BUTTON(get("edgePanMaxMult")))); + GtkWidget* spZoomStep = get("spZoomStep"); double zoomStep = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spZoomStep)); settings->setZoomStep(zoomStep); diff --git a/ui/settings.glade b/ui/settings.glade index e7ffb987..dba5c862 100644 --- a/ui/settings.glade +++ b/ui/settings.glade @@ -25,6 +25,16 @@ 1 10 + + 10 + 1 + 10 + + + 100 + 1 + 10 + 1000 150 @@ -3323,6 +3333,93 @@ This setting can make it easier to draw with touch. 3 + + + True + False + 0 + none + + + True + False + 12 + 12 + + + + True + False + + + True + True + number + adjustmentEdgePanSpeed + True + + + 1 + 0 + + + + + True + True + number + adjustmentEdgePanMaxMult + True + + + 1 + 1 + + + + + True + False + When an element is selected and moved past the visible portion of the canvas, pan the screen by an amount equal to this percentage of the visible part of the canvas. + start + Base speed + + + 0 + 0 + + + + + True + False + Multiply the panning speed by up to this amount, based on how much of the selected element is out of view. + start + Max multiplier + + + 0 + 1 + + + + + + + + + True + False + Selection Edge Panning + + + + + False + True + 4 + + True @@ -3387,7 +3484,7 @@ This setting can make it easier to draw with touch. False True - 4 + 5 @@ -3488,7 +3585,7 @@ This setting can make it easier to draw with touch. False True - 5 + 6 @@ -3597,7 +3694,7 @@ This setting can make it easier to draw with touch. False True - 6 + 7