Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilayout - more columns, more arrangement of pages. #872

Merged
merged 17 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 162 additions & 1 deletion src/control/Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ void Control::initWindow(MainWindow* win)
// Disable undo buttons
undoRedoChanged();

setViewColumns(settings->getViewColumns());


setViewLayoutVert(settings->getViewLayoutVert());
setViewLayoutR2L(settings->getViewLayoutR2L());
setViewLayoutB2T(settings->getViewLayoutB2T());



setViewTwoPages(settings->isShowTwoPages());
setViewPresentationMode(settings->isPresentationMode());

Expand Down Expand Up @@ -832,7 +841,7 @@ void Control::actionPerformed(ActionType type, ActionGroup group, GdkEvent* even
case ACTION_VIEW_TWO_PAGES:
setViewTwoPages(enabled);
break;

case ACTION_VIEW_PRESENTATION_MODE:
setViewPresentationMode(enabled);
break;
Expand All @@ -848,6 +857,63 @@ void Control::actionPerformed(ActionType type, ActionGroup group, GdkEvent* even
enableFullscreen(enabled);
break;

case ACTION_SET_COLUMNS_1:
setViewColumns(1);
break;

case ACTION_SET_COLUMNS_2:
setViewColumns(2);
break;

case ACTION_SET_COLUMNS_3:
setViewColumns(3);
break;

case ACTION_SET_COLUMNS_4:
setViewColumns(4);
break;

case ACTION_SET_COLUMNS_5:
setViewColumns(5);
break;

case ACTION_SET_COLUMNS_6:
setViewColumns(6);
break;

case ACTION_SET_COLUMNS_7:
setViewColumns(7);
break;

case ACTION_SET_COLUMNS_8:
setViewColumns(8);
break;

case ACTION_SET_LAYOUT_HORIZONTAL:
setViewLayoutVert(false);
break;

case ACTION_SET_LAYOUT_VERTICAL:
setViewLayoutVert(true);
break;

case ACTION_SET_LAYOUT_L2R:
setViewLayoutR2L(false);
break;

case ACTION_SET_LAYOUT_R2L:
setViewLayoutR2L(true);
break;

case ACTION_SET_LAYOUT_T2B:
setViewLayoutB2T(false);
break;

case ACTION_SET_LAYOUT_B2T:
setViewLayoutB2T(true);
break;


case ACTION_RECSTOP:
{
bool result;
Expand Down Expand Up @@ -1457,6 +1523,101 @@ void Control::setViewPresentationMode(bool presentationMode)
scrollHandler->scrollToPage(currentPage);
}

void Control::setPairsOffset(int numOffset)
{
XOJ_CHECK_TYPE(Control);

settings->setPairsOffset(numOffset);
fireActionSelected(GROUP_TWOPAGES, numOffset ? ACTION_SET_PAIRS_OFFSET: ACTION_NOT_SELECTED);
int currentPage = getCurrentPageNo();
win->getXournal()->layoutPages();
scrollHandler->scrollToPage(currentPage);
}

void Control::setViewColumns(int numColumns)
{
XOJ_CHECK_TYPE(Control);

settings->setViewColumns(numColumns);

ActionType action;

switch(numColumns){
case 1: action = ACTION_SET_COLUMNS_1; break;
case 2: action = ACTION_SET_COLUMNS_2; break;
case 3: action = ACTION_SET_COLUMNS_3; break;
case 4: action = ACTION_SET_COLUMNS_4; break;
case 5: action = ACTION_SET_COLUMNS_5; break;
case 6: action = ACTION_SET_COLUMNS_6; break;
case 7: action = ACTION_SET_COLUMNS_7; break;
case 8: action = ACTION_SET_COLUMNS_8; break;
default: action = ACTION_SET_COLUMNS;
}

fireActionSelected(GROUP_COLUMNS, action);

int currentPage = getCurrentPageNo();
win->getXournal()->layoutPages();
scrollHandler->scrollToPage(currentPage);
}

void Control::setViewLayoutVert(bool vert)
{
XOJ_CHECK_TYPE(Control);

settings->setViewLayoutVert(vert);

ActionType action;

if(vert){ action = ACTION_SET_LAYOUT_VERTICAL;}
else {action = ACTION_SET_LAYOUT_HORIZONTAL;}

fireActionSelected(GROUP_LAYOUT_HORIZONTAL, action);

int currentPage = getCurrentPageNo();
win->getXournal()->layoutPages();
scrollHandler->scrollToPage(currentPage);
}

void Control::setViewLayoutR2L(bool r2l)
{
XOJ_CHECK_TYPE(Control);

settings->setViewLayoutR2L(r2l);

ActionType action;

if(r2l){ action = ACTION_SET_LAYOUT_R2L;}
else {action = ACTION_SET_LAYOUT_L2R;}


fireActionSelected(GROUP_LAYOUT_LR, action);

int currentPage = getCurrentPageNo();
win->getXournal()->layoutPages();
scrollHandler->scrollToPage(currentPage);
}

void Control::setViewLayoutB2T(bool b2t)
{
XOJ_CHECK_TYPE(Control);

settings->setViewLayoutB2T(b2t);

ActionType action;

if(b2t){ action = ACTION_SET_LAYOUT_B2T;}
else {action = ACTION_SET_LAYOUT_T2B;}


fireActionSelected(GROUP_LAYOUT_TB, action);

int currentPage = getCurrentPageNo();
win->getXournal()->layoutPages();
scrollHandler->scrollToPage(currentPage);
}


/**
* This callback is used by used to be called later in the UI Thread
* On slower machine this feels more fluent, therefore this will not
Expand Down
6 changes: 6 additions & 0 deletions src/control/Control.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class Control :
void calcZoomFitSize();
void setViewTwoPages(bool continous);
void setViewPresentationMode(bool continous);
void setPairsOffset(int numOffset);
void setViewColumns(int numColumns);
void setViewLayoutVert(bool vert);
void setViewLayoutR2L(bool r2l);
void setViewLayoutB2T(bool b2t);

void manageToolbars();
void customizeToolbars();
void enableFullscreen(bool enabled, bool presentation = false);
Expand Down
140 changes: 140 additions & 0 deletions src/control/settings/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ void Settings::loadDefault()
this->showTwoPages = false;
JJones780 marked this conversation as resolved.
Show resolved Hide resolved
this->presentationMode = false;

this->numColumns = 1;

this->layoutVertical = false;
this->layoutRightToLeft = false;
this->layoutBottomToTop = false;

this->numPairsOffset = 0;

this->displayDpi = 72;

this->font.setName(DEFAULT_FONT);
Expand Down Expand Up @@ -326,10 +334,30 @@ void Settings::parseItem(xmlDocPtr doc, xmlNodePtr cur)
{
this->scrollbarOnLeft = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "numColumns") == 0)
{
this->numColumns = g_ascii_strtoll((const char*) value, NULL, 10);
}
else if (xmlStrcmp(name, (const xmlChar*) "layoutVertical") == 0)
{
this->layoutVertical = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "layoutRightToLeft") == 0)
{
this->layoutRightToLeft = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "layoutBottomToTop") == 0)
{
this->layoutBottomToTop = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "showTwoPages") == 0)
{
this->showTwoPages = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
}
else if (xmlStrcmp(name, (const xmlChar*) "numPairsOffset") == 0)
{
this->numPairsOffset = g_ascii_strtoll((const char*) value, NULL, 10);
}
else if (xmlStrcmp(name, (const xmlChar*) "presentationMode") == 0)
{
this->presentationMode = xmlStrcmp(value, (const xmlChar*) "true") ? false : true;
Expand Down Expand Up @@ -741,7 +769,12 @@ void Settings::save()

WRITE_BOOL_PROP(sidebarOnRight);
WRITE_BOOL_PROP(scrollbarOnLeft);
WRITE_INT_PROP(numColumns);
WRITE_BOOL_PROP(showTwoPages);
WRITE_BOOL_PROP(layoutVertical);
WRITE_BOOL_PROP(layoutRightToLeft);
WRITE_BOOL_PROP(layoutBottomToTop);
WRITE_INT_PROP(numPairsOffset);
WRITE_BOOL_PROP(presentationMode);

WRITE_STRING_PROP(fullscreenHideElements);
Expand Down Expand Up @@ -1396,6 +1429,113 @@ void Settings::setPresureSensitivity(gboolean presureSensitivity)
save();
}

void Settings::setPairsOffset(int numOffset)
{
XOJ_CHECK_TYPE(Settings);

if (this->numPairsOffset == numOffset)
{
return;
}

this->numPairsOffset = numOffset;
save();
}

int Settings::getPairsOffset()
{
XOJ_CHECK_TYPE(Settings);

return this->numPairsOffset;
}

void Settings::setViewColumns(int numColumns)
{
XOJ_CHECK_TYPE(Settings);

if (this->numColumns == numColumns)
{
return;
}

this->numColumns = numColumns;
save();
}

int Settings::getViewColumns()
{
XOJ_CHECK_TYPE(Settings);

return this->numColumns;
}


void Settings::setViewLayoutVert(bool vert)
{
XOJ_CHECK_TYPE(Settings);

if (this->layoutVertical == vert)
{
return;
}

this->layoutVertical = vert;
save();
}

bool Settings::getViewLayoutVert()
{
XOJ_CHECK_TYPE(Settings);

return this->layoutVertical;
}


void Settings::setViewLayoutR2L(bool r2l)
{
XOJ_CHECK_TYPE(Settings);

if (this->layoutRightToLeft == r2l)
{
return;
}

this->layoutRightToLeft = r2l;
save();
}

bool Settings::getViewLayoutR2L()
{
XOJ_CHECK_TYPE(Settings);

return this->layoutRightToLeft;
}


void Settings::setViewLayoutB2T(bool b2t)
{
XOJ_CHECK_TYPE(Settings);

if (this->layoutBottomToTop == b2t)
{
return;
}

this->layoutBottomToTop = b2t;
save();

}

bool Settings::getViewLayoutB2T()
{
XOJ_CHECK_TYPE(Settings);

return this->layoutBottomToTop;
}




void Settings::setLastSavePath(Path p)
{
XOJ_CHECK_TYPE(Settings);
Expand Down
Loading