Merge pull request #1041 from JJones780/UserSetMargins

fixes #1005 Prefs setting for AddVertical/Horizontal space
presentation
JJones780 7 years ago committed by GitHub
commit a8fd9e57a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/control/Control.cpp
  2. 61
      src/control/settings/Settings.cpp
  3. 17
      src/control/settings/Settings.h
  4. 4
      src/gui/Layout.cpp
  5. 16
      src/gui/dialog/SettingsDialog.cpp

@ -2107,21 +2107,26 @@ void Control::showSettings()
{
XOJ_CHECK_TYPE(Control);
// take note of some settings before to compare with after
int selectionColor = settings->getBorderColor();
bool verticalSpace = settings->getAddVerticalSpace();
int verticalSpaceAmount = settings->getAddVerticalSpaceAmount();
bool horizontalSpace = settings->getAddHorizontalSpace();
int horizontalSpaceAmount = settings->getAddHorizontalSpaceAmount();
bool bigCursor = settings->isShowBigCursor();
bool highlightPosition = settings->isHighlightPosition();
SettingsDialog* dlg = new SettingsDialog(this->gladeSearchPath, settings, this);
dlg->show(GTK_WINDOW(this->win->getWindow()));
// note which settings have changed and act accordingly
if (selectionColor != settings->getBorderColor())
{
win->getXournal()->forceUpdatePagenumbers();
}
if (verticalSpace != settings->getAddVerticalSpace() || horizontalSpace != settings->getAddHorizontalSpace())
if (verticalSpace != settings->getAddVerticalSpace() || horizontalSpace != settings->getAddHorizontalSpace()
|| verticalSpaceAmount != settings->getAddVerticalSpaceAmount() || horizontalSpaceAmount != settings->getAddHorizontalSpaceAmount() )
{
int currentPage = getCurrentPageNo();
win->getXournal()->layoutPages();

@ -89,7 +89,9 @@ void Settings::loadDefault()
this->autosaveEnabled = true;
this->addHorizontalSpace = false;
this->addHorizontalSpaceAmount = 150;
this->addVerticalSpace = false;
this->addVerticalSpaceAmount = 150;
this->snapRotation = true;
this->snapRotationTolerance = 0.20;
@ -453,10 +455,22 @@ void Settings::parseItem(xmlDocPtr doc, xmlNodePtr cur)
{
this->backgroundColor = g_ascii_strtoll((const char*) value, NULL, 10);
}
else if (xmlStrcmp(name, (const xmlChar*) "addHorizontalSpace") == 0)
{
this->addHorizontalSpace = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "addHorizontalSpaceAmount") == 0)
{
this->addHorizontalSpaceAmount = g_ascii_strtoll((const char*) value, NULL, 10);
}
else if (xmlStrcmp(name, (const xmlChar*) "addVerticalSpace") == 0)
{
this->addVerticalSpace = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "addVerticalSpaceAmount") == 0)
{
this->addVerticalSpaceAmount = g_ascii_strtoll((const char*) value, NULL, 10);
}
else if (xmlStrcmp(name, (const xmlChar*) "snapRotation") == 0)
{
this->snapRotation = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
@ -481,10 +495,6 @@ void Settings::parseItem(xmlDocPtr doc, xmlNodePtr cur)
{
this->touchWorkaround = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "addHorizontalSpace") == 0)
{
this->addHorizontalSpace = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "scrollbarHideType") == 0)
{
if (xmlStrcmp(value, (const xmlChar*) "both") == 0)
@ -846,7 +856,9 @@ void Settings::save()
WRITE_INT_PROP(autosaveTimeout);
WRITE_BOOL_PROP(addHorizontalSpace);
WRITE_INT_PROP(addHorizontalSpaceAmount);
WRITE_BOOL_PROP(addVerticalSpace);
WRITE_INT_PROP(addVerticalSpaceAmount);
WRITE_BOOL_PROP(snapRotation);
WRITE_DOUBLE_PROP(snapRotationTolerance);
@ -1118,6 +1130,27 @@ void Settings::setAddVerticalSpace(bool space)
this->addVerticalSpace = space;
}
int Settings::getAddVerticalSpaceAmount()
{
XOJ_CHECK_TYPE(Settings);
return this->addVerticalSpaceAmount;
}
void Settings::setAddVerticalSpaceAmount(int pixels)
{
XOJ_CHECK_TYPE(Settings);
if (this->addVerticalSpaceAmount == pixels)
{
return;
}
this->addVerticalSpaceAmount = pixels;
save();
}
bool Settings::getAddHorizontalSpace()
{
XOJ_CHECK_TYPE(Settings);
@ -1132,6 +1165,26 @@ void Settings::setAddHorizontalSpace(bool space)
this->addHorizontalSpace = space;
}
int Settings::getAddHorizontalSpaceAmount()
{
XOJ_CHECK_TYPE(Settings);
return this->addHorizontalSpaceAmount;
}
void Settings::setAddHorizontalSpaceAmount(int pixels)
{
XOJ_CHECK_TYPE(Settings);
if (this->addHorizontalSpaceAmount == pixels)
{
return;
}
this->addHorizontalSpaceAmount = pixels;
save();
}
bool Settings::isShowBigCursor()
{
XOJ_CHECK_TYPE(Settings);

@ -266,9 +266,13 @@ public:
bool getAddVerticalSpace();
void setAddVerticalSpace(bool space);
int getAddVerticalSpaceAmount();
void setAddVerticalSpaceAmount(int pixels);
bool getAddHorizontalSpace();
void setAddHorizontalSpace(bool space);
int getAddHorizontalSpaceAmount();
void setAddHorizontalSpaceAmount(int pixels);
bool isTouchWorkaround();
void setTouchWorkaround(bool b);
@ -584,15 +588,24 @@ private:
bool autosaveEnabled;
/**
* Allow scroll outside the page (horizontal)
* Allow scroll outside the page display area (horizontal)
*/
bool addHorizontalSpace;
/**
* Allow scroll outside the page (vertical)
* How much allowance to scroll outside the page display area (either side of )
*/
int addHorizontalSpaceAmount;
/**
* Allow scroll outside the page display area (vertical)
*/
bool addVerticalSpace;
/** How much allowance to scroll outside the page display area (above and below)
*/
int addVerticalSpaceAmount;
/**
* Rotation snapping enabled by default
*/

@ -218,13 +218,13 @@ void Layout::layoutPages()
int borderPrefX = XOURNAL_PADDING;
if (settings->getAddHorizontalSpace() )
{
borderPrefX += XOURNAL_PADDING_FREE_SPACE; // this adds extra space to the left and right
borderPrefX += settings->getAddHorizontalSpaceAmount(); // this adds extra space to the left and right
}
int borderPrefY = XOURNAL_PADDING;
if (settings->getAddVerticalSpace() )
{
borderPrefY += XOURNAL_PADDING_FREE_SPACE; // this adds space to the top and bottom
borderPrefY += settings->getAddVerticalSpaceAmount(); // this adds space to the top and bottom
}

@ -233,6 +233,12 @@ void SettingsDialog::load()
GtkWidget* spZoomStepScroll = get("spZoomStepScroll");
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(spZoomStepScroll), settings->getZoomStepScroll());
GtkWidget* spAddHorizontalSpace = get("spAddHorizontalSpace");
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spAddHorizontalSpace), settings->getAddHorizontalSpaceAmount());
GtkWidget* spAddVerticalSpace = get("spAddVerticalSpace");
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spAddVerticalSpace), settings->getAddVerticalSpaceAmount());
GtkWidget* slider = get("zoomCallibSlider");
@ -509,6 +515,16 @@ void SettingsDialog::save()
double zoomStepScroll = gtk_spin_button_get_value(
GTK_SPIN_BUTTON(spZoomStepScroll));
settings->setZoomStepScroll(zoomStepScroll);
GtkWidget* spAddHorizontalSpace = get("spAddHorizontalSpace");
int addHorizontalSpaceAmount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spAddHorizontalSpace));
settings->setAddHorizontalSpaceAmount(addHorizontalSpaceAmount);
GtkWidget* spAddVerticalSpace = get("spAddVerticalSpace");
int addVerticalSpaceAmount = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spAddVerticalSpace));
settings->setAddVerticalSpaceAmount(addVerticalSpaceAmount);
settings->setDisplayDpi(dpi);

Loading…
Cancel
Save