Merge pull request #370 from andreasb242/master

fixes #335
presentation
andreasb242 7 years ago committed by GitHub
commit 7182d5e21f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      src/control/settings/Settings.cpp
  2. 8
      src/control/settings/Settings.h
  3. 37
      src/gui/Layout.cpp
  4. 10
      src/gui/Layout.h
  5. 13
      src/gui/XournalView.cpp
  6. 13
      src/gui/dialog/SettingsDialog.cpp
  7. 86
      src/gui/widgets/XournalWidget.cpp
  8. 81
      ui/settings.glade

@ -107,6 +107,8 @@ void Settings::loadDefault()
this->selectionColor = 0xff0000;
this->backgroundColor = 0xDCDAD5;
this->eventCompression = true;
this->pageTemplate = "xoj/template\ncopyLastPageSettings=true\nsize=595.275591x841.889764\nbackgroundType=lined\nbackgroundColor=#ffffff\n";
@ -372,6 +374,10 @@ void Settings::parseItem(xmlDocPtr doc, xmlNodePtr cur)
{
this->selectionColor = g_ascii_strtoll((const char*) value, NULL, 10);
}
else if (xmlStrcmp(name, (const xmlChar*) "backgroundColor") == 0)
{
this->backgroundColor = 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;
@ -723,6 +729,7 @@ void Settings::save()
"If you have input problems, you can turn it of with false.");
WRITE_INT_PROP(selectionColor);
WRITE_INT_PROP(backgroundColor);
WRITE_INT_PROP(pdfPageCacheSize);
WRITE_COMMENT("The count of rendered PDF pages which will be cached.");
@ -1500,13 +1507,6 @@ void Settings::setPresentationHideElements(string elements)
save();
}
int Settings::getSelectionColor()
{
XOJ_CHECK_TYPE(Settings);
return this->selectionColor;
}
int Settings::getPdfPageCacheSize()
{
XOJ_CHECK_TYPE(Settings);
@ -1526,6 +1526,13 @@ void Settings::setPdfPageCacheSize(int size)
save();
}
int Settings::getSelectionColor()
{
XOJ_CHECK_TYPE(Settings);
return this->selectionColor;
}
void Settings::setSelectionColor(int color)
{
XOJ_CHECK_TYPE(Settings);
@ -1538,6 +1545,25 @@ void Settings::setSelectionColor(int color)
save();
}
int Settings::getBackgroundColor()
{
XOJ_CHECK_TYPE(Settings);
return this->backgroundColor;
}
void Settings::setBackgroundColor(int color)
{
XOJ_CHECK_TYPE(Settings);
if (this->backgroundColor == color)
{
return;
}
this->backgroundColor = color;
save();
}
XojFont& Settings::getFont()
{
XOJ_CHECK_TYPE(Settings);

@ -256,6 +256,9 @@ public:
int getSelectionColor();
void setSelectionColor(int color);
int getBackgroundColor();
void setBackgroundColor(int color);
int getPdfPageCacheSize();
void setPdfPageCacheSize(int size);
@ -491,6 +494,11 @@ private:
*/
int selectionColor;
/**
* The color for Xournal page background
*/
int backgroundColor;
/**
* Whether event compression should be enabled
*/

@ -8,19 +8,18 @@
Layout::Layout(XournalView* _view,
GtkAdjustment* _adjHorizontal,
GtkAdjustment* _adjVertical)
: view(_view),
adjHorizontal(_adjHorizontal),
adjVertical(_adjVertical),
lastWidgetWidth(0),
layoutWidth(0),
layoutHeight(0)
GtkAdjustment* adjHorizontal,
GtkAdjustment* adjVertical)
: view(_view),
adjHorizontal(adjHorizontal),
adjVertical(adjVertical),
lastWidgetWidth(0),
layoutWidth(0),
layoutHeight(0)
{
XOJ_INIT_TYPE(Layout);
g_signal_connect(adjHorizontal, "value-changed", G_CALLBACK(adjustmentValueChanged), this);
g_signal_connect(adjVertical, "value-changed", G_CALLBACK(adjustmentValueChanged), this);
}
@ -131,6 +130,22 @@ Rectangle Layout::getVisibleRect()
gtk_adjustment_get_page_size(adjVertical));
}
/**
* Returns the height of the entire Layout
*/
double Layout::getLayoutHeight()
{
return layoutHeight;
}
/**
* Returns the width of the entire Layout
*/
double Layout::getLayoutWidth()
{
return layoutWidth;
}
/**
* Padding outside the pages, including shadow
*/
@ -150,8 +165,8 @@ void Layout::layoutPages()
int len = this->view->viewPagesLen;
Settings* settings = this->view->getControl()->getSettings();
bool verticalSpace = settings->getAddVerticalSpace(),
horizontalSpace = settings->getAddHorizontalSpace();
bool verticalSpace = settings->getAddVerticalSpace();
bool horizontalSpace = settings->getAddHorizontalSpace();
bool dualPage = settings->isShowTwoPages();
int size[2] = { 0, 0 };

@ -60,18 +60,12 @@ public:
/**
* Returns the height of the entire Layout
*/
double getLayoutHeight()
{
return layoutHeight;
}
double getLayoutHeight();
/**
* Returns the width of the entire Layout
*/
double getLayoutWidth()
{
return layoutWidth;
}
double getLayoutWidth();
/**
* Returns the Rectangle which is currently visible

@ -866,18 +866,7 @@ void XournalView::repaintSelection(bool evenWithoutSelection)
return;
}
// Redrawable * red = selection->getView();
// double zoom = getZoom();
// int x0 = red->getX();
// int y0 = red->getY();
// int x = selection->getX() * zoom;
// int y = selection->getY() * zoom;
// int w = selection->getWidth() * zoom;
// int h = selection->getHeight() * zoom;
//
// gtk_xournal_repaint_area(this->widget, x0 + x - 10, y0 + y - 10, w + 20, h + 20);
// TODO OPTIMIZE ?
// repaint always the whole widget
gtk_widget_queue_draw(this->widget);
}

@ -169,6 +169,9 @@ void SettingsDialog::load()
GdkRGBA color;
Util::apply_rgb_togdkrgba(color, settings->getSelectionColor());
gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(get("colorBorder")), &color);
Util::apply_rgb_togdkrgba(color, settings->getBackgroundColor());
gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(get("colorBackground")), &color);
bool hideFullscreenMenubar = false;
bool hideFullscreenSidebar = false;
@ -308,13 +311,13 @@ void SettingsDialog::save()
}
settings->setScrollbarHideType((ScrollbarHideType)scrollbarHideType);
GtkWidget* colorBorder = get("colorBorder");
GdkRGBA color;
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(colorBorder), &color);
int selectionColor = Util::gdkrgba_to_hex(color);
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(get("colorBorder")), &color);
settings->setSelectionColor(Util::gdkrgba_to_hex(color));
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(get("colorBackground")), &color);
settings->setBackgroundColor(Util::gdkrgba_to_hex(color));
settings->setSelectionColor(selectionColor);
bool hideFullscreenMenubar = getCheckbox("cbHideFullscreenMenubar");
bool hideFullscreenSidebar = getCheckbox("cbHideFullscreenSidebar");

@ -358,12 +358,12 @@ gboolean gtk_xournal_button_press_event(GtkWidget* widget, GdkEventButton* event
{
GtkXournal* xournal = GTK_XOURNAL(widget);
Settings* settings = xournal->view->getControl()->getSettings();
//gtk_gesture_is_recognized is always false (bug, programming error?)
//workaround with additional variable zoom_gesture_active
if (xournal->view->zoom_gesture_active)
{
return TRUE;
}
//gtk_gesture_is_recognized is always false (bug, programming error?)
//workaround with additional variable zoom_gesture_active
if (xournal->view->zoom_gesture_active)
{
return TRUE;
}
if (event->type != GDK_BUTTON_PRESS)
{
return FALSE; // this event is not handled here
@ -380,16 +380,17 @@ gboolean gtk_xournal_button_press_event(GtkWidget* widget, GdkEventButton* event
if (xournal->currentInputPage)
{
GdkEventButton ev = *event;
xournal->currentInputPage->translateEvent((GdkEvent*) &ev, xournal->x,
xournal->y);
xournal->currentInputPage->translateEvent((GdkEvent*) &ev, xournal->x, xournal->y);
xournal->currentInputPage->onButtonReleaseEvent(widget, &ev);
}
ToolHandler* h = xournal->view->getControl()->getToolHandler();
// Change the tool depending on the key or device
if(change_tool(settings, event, xournal))
if (change_tool(settings, event, xournal))
{
return TRUE;
}
// hand tool don't change the selection, so you can scroll e.g.
// with your touchscreen without remove the selection
@ -398,9 +399,9 @@ gboolean gtk_xournal_button_press_event(GtkWidget* widget, GdkEventButton* event
Cursor* cursor = xournal->view->getCursor();
cursor->setMouseDown(true);
xournal->inScrolling = true;
//set reference
xournal->lastMousePositionX=event->x_root;
xournal->lastMousePositionY=event->y_root;
//set reference
xournal->lastMousePositionX = event->x_root;
xournal->lastMousePositionY = event->y_root;
return TRUE;
}
@ -411,12 +412,11 @@ gboolean gtk_xournal_button_press_event(GtkWidget* widget, GdkEventButton* event
XojPageView* view = selection->getView();
GdkEventButton ev = *event;
view->translateEvent((GdkEvent*) &ev, xournal->x, xournal->y);
CursorSelectionType selType = selection->getSelectionTypeForPos(ev.x, ev.y,
xournal->view->getZoom());
CursorSelectionType selType = selection->getSelectionTypeForPos(ev.x, ev.y, xournal->view->getZoom());
if (selType)
{
if(selType == CURSOR_SELECTION_MOVE && event->button == 3)
if (selType == CURSOR_SELECTION_MOVE && event->button == 3)
{
selection->copySelection();
}
@ -428,13 +428,14 @@ gboolean gtk_xournal_button_press_event(GtkWidget* widget, GdkEventButton* event
else
{
xournal->view->clearSelection();
if(change_tool(settings, event, xournal))
if (change_tool(settings, event, xournal))
{
return TRUE;
}
}
}
XojPageView* pv = gtk_xournal_get_page_view_for_pos_cached(xournal, event->x,
event->y);
XojPageView* pv = gtk_xournal_get_page_view_for_pos_cached(xournal, event->x, event->y);
current_view = pv;
@ -450,8 +451,7 @@ gboolean gtk_xournal_button_press_event(GtkWidget* widget, GdkEventButton* event
return FALSE; // not handled
}
gboolean gtk_xournal_button_release_event(GtkWidget* widget,
GdkEventButton* event)
gboolean gtk_xournal_button_release_event(GtkWidget* widget, GdkEventButton* event)
{
if (event->button > 3) // scroll wheel events
{
@ -464,10 +464,10 @@ gboolean gtk_xournal_button_release_event(GtkWidget* widget,
Cursor* cursor = xournal->view->getCursor();
ToolHandler* h = xournal->view->getControl()->getToolHandler();
if (xournal->view->zoom_gesture_active)
{
return TRUE;
}
if (xournal->view->zoom_gesture_active)
{
return TRUE;
}
cursor->setMouseDown(false);
@ -482,8 +482,7 @@ gboolean gtk_xournal_button_release_event(GtkWidget* widget,
bool res = false;
if (xournal->currentInputPage)
{
xournal->currentInputPage->translateEvent((GdkEvent*) event, xournal->x,
xournal->y);
xournal->currentInputPage->translateEvent((GdkEvent*) event, xournal->x, xournal->y);
res = xournal->currentInputPage->onButtonReleaseEvent(widget, event);
xournal->currentInputPage = NULL;
}
@ -657,12 +656,7 @@ static void gtk_xournal_realize(GtkWidget* widget)
attributes_mask = GDK_WA_X | GDK_WA_Y;
gtk_widget_set_window(widget, gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask));
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gtk_widget_get_style(widget)->dark[GTK_STATE_NORMAL]);
gdk_window_set_user_data(gtk_widget_get_window(widget), widget);
gtk_widget_style_attach(widget);
gtk_style_set_background(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL);
}
static void gtk_xournal_draw_shadow(GtkXournal* xournal, cairo_t* cr, int left,
@ -736,10 +730,13 @@ static gboolean gtk_xournal_draw(GtkWidget* widget, cairo_t* cr)
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
Rectangle clippingRect(x1 - 10,
y1 - 10,
x2 - x1 + 20,
y2 - y1 + 20);
// Draw background
Settings* settings = xournal->view->getControl()->getSettings();
Util::cairo_set_source_rgbi(cr, settings->getBackgroundColor());
cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
cairo_fill(cr);
Rectangle clippingRect(x1 - 10, y1 - 10, x2 - x1 + 20, y2 - y1 + 20);
while (it.hasNext())
{
@ -750,14 +747,12 @@ static gboolean gtk_xournal_draw(GtkWidget* widget, cairo_t* cr)
int pw = pv->getDisplayWidth();
int ph = pv->getDisplayHeight();
if(!clippingRect.intersects(pv->getRect()))
if (!clippingRect.intersects(pv->getRect()))
{
continue;
}
gtk_xournal_draw_shadow(xournal, cr,
px, py, pw, ph,
pv->isSelected());
gtk_xournal_draw_shadow(xournal, cr, px, py, pw, ph, pv->isSelected());
cairo_save(cr);
cairo_translate(cr, px, py);
@ -766,7 +761,7 @@ static gboolean gtk_xournal_draw(GtkWidget* widget, cairo_t* cr)
cairo_restore(cr);
}
if(xournal->selection)
if (xournal->selection)
{
double zoom = xournal->view->getZoom();
@ -793,16 +788,5 @@ static void gtk_xournal_destroy(GtkWidget* object)
delete xournal->layout;
xournal->layout = NULL;
/*
* TODO: Do we need this?
GtkXournalClass* klass = (GtkXournalClass*) gtk_type_class(
gtk_widget_get_type());
if (GTK_OBJECT_CLASS(klass)->destroy)
{
(*GTK_OBJECT_CLASS(klass)->destroy)(object);
}
*/
}

@ -1122,7 +1122,7 @@ Here you can disable your touchscreen.&lt;/i&gt;</property>
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Selection Border&lt;/b&gt;</property>
<property name="label" translatable="yes">&lt;b&gt;Colors&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
@ -1145,55 +1145,62 @@ Here you can disable your touchscreen.&lt;/i&gt;</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="vbox8">
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box5">
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Border color for current page and other selections:</property>
<property name="justify">right</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkColorButton" id="colorBorder">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="title" translatable="yes">Border color</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Border color for current page and other selections:</property>
<property name="justify">right</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkColorButton" id="colorBorder">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="title" translatable="yes">Border color</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label44">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Background color for window Background</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkColorButton" id="colorBackground">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>

Loading…
Cancel
Save