Add preference settings for edge panning

In particular, this adds two options:

* Edge pan speed (as % of viewport dimension per second)
* Maximum edge pan multiplier resulting from proportion of selection out of view
upstream-master
Bryan Tan 5 years ago committed by Bryan Tan
parent a10353dabe
commit c09e9e389a
  1. 29
      src/control/settings/Settings.cpp
  2. 18
      src/control/settings/Settings.h
  3. 5
      src/control/tools/EditSelection.cpp
  4. 6
      src/gui/dialog/SettingsDialog.cpp
  5. 103
      ui/settings.glade

@ -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<const char*>(value));
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("lastImagePath")) == 0) {
this->lastImagePath = fs::u8path(reinterpret_cast<const char*>(value));
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("edgePanSpeed")) == 0) {
this->edgePanSpeed = tempg_ascii_strtod(reinterpret_cast<const char*>(value), nullptr);
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("edgePanMaxMult")) == 0) {
this->edgePanMaxMult = tempg_ascii_strtod(reinterpret_cast<const char*>(value), nullptr);
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("zoomStep")) == 0) {
this->zoomStep = tempg_ascii_strtod(reinterpret_cast<const char*>(value), nullptr);
} else if (xmlStrcmp(name, reinterpret_cast<const xmlChar*>("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;

@ -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
*/

@ -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

@ -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);

@ -25,6 +25,16 @@
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentEdgePanMaxMult">
<property name="upper">10</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentEdgePanSpeed">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentHorizontalSpace">
<property name="upper">1000</property>
<property name="value">150</property>
@ -3323,6 +3333,93 @@ This setting can make it easier to draw with touch. </property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="left-padding">12</property>
<property name="right-padding">12</property>
<child>
<!-- n-columns=2 n-rows=2 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkSpinButton" id="edgePanSpeed">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="input-purpose">number</property>
<property name="adjustment">adjustmentEdgePanSpeed</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="edgePanMaxMult">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="input-purpose">number</property>
<property name="adjustment">adjustmentEdgePanMaxMult</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">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. </property>
<property name="halign">start</property>
<property name="label" translatable="yes">Base speed</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Multiply the panning speed by up to this amount, based on how much of the selected element is out of view.</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Max multiplier</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Selection Edge Panning</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="sid114">
<property name="visible">True</property>
@ -3387,7 +3484,7 @@ This setting can make it easier to draw with touch. </property>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child>
@ -3488,7 +3585,7 @@ This setting can make it easier to draw with touch. </property>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
<child>
@ -3597,7 +3694,7 @@ This setting can make it easier to draw with touch. </property>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
</object>

Loading…
Cancel
Save