Fill implementation

presentation
Andreas Butti 7 years ago
parent 1a2784a60c
commit 8cd2fdb850
  1. 9
      src/control/Actions.h
  2. 49
      src/control/Control.cpp
  3. 2
      src/control/Control.h
  4. 50
      src/control/Tool.cpp
  5. 32
      src/control/Tool.h
  6. 140
      src/control/ToolHandler.cpp
  7. 19
      src/control/ToolHandler.h
  8. 1
      src/control/tools/InputHandler.cpp
  9. 3
      src/gui/dialog/AboutDialog.cpp
  10. 2
      src/gui/dialog/AboutDialog.h
  11. 2
      src/gui/dialog/ButtonConfigGui.h
  12. 1
      src/gui/dialog/ExportDialog.h
  13. 85
      src/gui/dialog/FillTransparencyDialog.cpp
  14. 34
      src/gui/dialog/FillTransparencyDialog.h
  15. 2
      src/gui/dialog/FormatDialog.h
  16. 1
      src/gui/dialog/GotoDialog.h
  17. 2
      src/gui/dialog/LatexDialog.h
  18. 2
      src/gui/dialog/PageTemplateDialog.h
  19. 2
      src/gui/dialog/SettingsDialog.h
  20. 4
      src/gui/dialog/ToolbarManageDialog.cpp
  21. 2
      src/gui/dialog/ToolbarManageDialog.h
  22. 6
      src/gui/toolbarMenubar/ToolMenuHandler.cpp
  23. 1
      src/util/XournalTypeList.h
  24. 139
      ui/fillTransparency.glade
  25. 48
      ui/main.glade

@ -107,9 +107,16 @@ enum ActionType
ACTION_TOOL_PEN_SIZE_THICK,
ACTION_TOOL_PEN_SIZE_VERY_THICK,
ACTION_TOOL_PEN_FILL,
ACTION_TOOL_PEN_FILL_TRANSPARENCY,
ACTION_TOOL_HILIGHTER_SIZE_FINE,
ACTION_TOOL_HILIGHTER_SIZE_MEDIUM,
ACTION_TOOL_HILIGHTER_SIZE_THICK,
ACTION_TOOL_HILIGHTER_FILL,
ACTION_TOOL_HILIGHTER_FILL_TRANSPARENCY,
ACTION_ROTATION_SNAPPING,
ACTION_GRID_SNAPPING,
@ -155,7 +162,9 @@ enum ActionGroup
GROUP_ERASER_MODE,
GROUP_ERASER_SIZE,
GROUP_PEN_SIZE,
GROUP_PEN_FILL,
GROUP_HILIGHTER_SIZE,
GROUP_HILIGHTER_FILL,
// Need group for toggle button, this is the first Toggle Group
GROUP_TOGGLE_GROUP,

@ -8,6 +8,7 @@
#include "gui/dialog/AboutDialog.h"
#include "gui/dialog/GotoDialog.h"
#include "gui/dialog/FillTransparencyDialog.h"
#include "gui/dialog/FormatDialog.h"
#include "gui/dialog/PageTemplateDialog.h"
#include "gui/dialog/SettingsDialog.h"
@ -745,6 +746,14 @@ void Control::actionPerformed(ActionType type, ActionGroup group, GdkEvent* even
penSizeChanged();
}
break;
case ACTION_TOOL_PEN_FILL:
this->toolHandler->setPenFillEnabled(enabled);
break;
case ACTION_TOOL_PEN_FILL_TRANSPARENCY:
selectFillAlpha(true);
break;
case ACTION_TOOL_HILIGHTER_SIZE_FINE:
if (enabled)
{
@ -766,6 +775,12 @@ void Control::actionPerformed(ActionType type, ActionGroup group, GdkEvent* even
hilighterSizeChanged();
}
break;
case ACTION_TOOL_HILIGHTER_FILL:
this->toolHandler->setHilighterFillEnabled(enabled);
break;
case ACTION_TOOL_HILIGHTER_FILL_TRANSPARENCY:
selectFillAlpha(false);
break;
case ACTION_FONT_BUTTON_CHANGED:
fontChanged();
@ -905,6 +920,40 @@ bool Control::paste()
return this->clipboardHandler->paste();
}
void Control::selectFillAlpha(bool pen)
{
XOJ_CHECK_TYPE(Control);
int alpha = 0;
if (pen)
{
alpha = toolHandler->getPenFill();
}
else
{
alpha = toolHandler->getHilighterFill();
}
FillTransparencyDialog dlg(gladeSearchPath, alpha);
dlg.show(getGtkWindow());
if (dlg.getResultAlpha() == -1)
{
return;
}
if (pen)
{
toolHandler->setPenFill(dlg.getResultAlpha());
}
else
{
toolHandler->setHilighterFill(dlg.getResultAlpha());
}
}
void Control::clearSelectionEndText()
{
XOJ_CHECK_TYPE(Control);

@ -218,6 +218,8 @@ public:
void help();
void selectFillAlpha(bool pen);
public:
// UndoRedoListener interface
void undoRedoChanged();

@ -1,8 +1,6 @@
#include "Tool.h"
Tool::Tool(string name, ToolType type, int color, bool enableColor, bool enableSize, bool enableRuler,
bool enableRectangle, bool enableCircle, bool enableArrow, bool enableShapreRecognizer,
double* thickness)
Tool::Tool(string name, ToolType type, int color, int capabilities, double* thickness)
{
XOJ_INIT_TYPE(Tool);
@ -10,18 +8,15 @@ Tool::Tool(string name, ToolType type, int color, bool enableColor, bool enableS
this->type = type;
this->thickness = thickness;
this->enableColor = enableColor;
this->enableSize = enableSize;
this->enableShapeRecognizer = enableShapreRecognizer;
this->enableRuler = enableRuler;
this->enableRectangle = enableRectangle;
this->enableCircle = enableCircle;
this->enableArrow = enableArrow;
this->capabilities = capabilities;
this->drawingType = DRAWING_TYPE_DEFAULT;
this->color = color;
this->size = TOOL_SIZE_MEDIUM;
this->fill = false;
this->fillAlpha = 128;
}
Tool::~Tool()
@ -69,53 +64,74 @@ void Tool::setSize(ToolSize size)
this->size = size;
}
void Tool::setCapability(int capability, bool enabled)
{
XOJ_CHECK_TYPE(Tool);
if (enabled)
{
this->capabilities |= capability;
}
else
{
this->capabilities &= ~capability;
}
}
bool Tool::isEnableColor()
{
XOJ_CHECK_TYPE(Tool);
return this->enableColor;
return this->capabilities & TOOL_CAP_COLOR != 0;
}
bool Tool::isEnableSize()
{
XOJ_CHECK_TYPE(Tool);
return this->enableSize;
return this->capabilities & TOOL_CAP_SIZE != 0;
}
bool Tool::isEnableRuler()
{
XOJ_CHECK_TYPE(Tool);
return this->enableRuler;
return this->capabilities & TOOL_CAP_RULER != 0;
}
bool Tool::isEnableRectangle()
{
XOJ_CHECK_TYPE(Tool);
return this->enableRectangle;
return this->capabilities & TOOL_CAP_RECTANGLE != 0;
}
bool Tool::isEnableCircle()
{
XOJ_CHECK_TYPE(Tool);
return this->enableCircle;
return this->capabilities & TOOL_CAP_CIRCLE != 0;
}
bool Tool::isEnableArrow()
{
XOJ_CHECK_TYPE(Tool);
return this->enableArrow;
return this->capabilities & TOOL_CAP_ARROW != 0;
}
bool Tool::isEnableShapeRecognizer()
{
XOJ_CHECK_TYPE(Tool);
return this->enableShapeRecognizer;
return this->capabilities & TOOL_CAP_RECOGNIZER != 0;
}
bool Tool::isEnableFill()
{
XOJ_CHECK_TYPE(Tool);
return this->capabilities & TOOL_CAP_FILL != 0;
}
DrawingType Tool::getDrawingType()

@ -89,12 +89,23 @@ enum DrawingType
string drawingTypeToString(DrawingType type);
DrawingType drawingTypeFromString(string type);
enum ToolCapabilities
{
TOOL_CAP_NONE = 0,
TOOL_CAP_COLOR = 1 << 0,
TOOL_CAP_SIZE = 1 << 1,
TOOL_CAP_RULER = 1 << 2,
TOOL_CAP_RECTANGLE = 1 << 3,
TOOL_CAP_CIRCLE = 1 << 4,
TOOL_CAP_ARROW = 1 << 5,
TOOL_CAP_RECOGNIZER = 1 << 6,
TOOL_CAP_FILL = 1 << 7
};
class Tool
{
public:
Tool(string name, ToolType tool, int color, bool enableColor, bool enableSize,
bool enableRuler, bool enableRectangle, bool enableCircle, bool enableArrow,
bool enableShapreRecognizer, double* thickness);
Tool(string name, ToolType tool, int color, int capabilities, double* thickness);
virtual ~Tool();
string getName();
@ -115,9 +126,13 @@ public:
bool isEnableCircle();
bool isEnableArrow();
bool isEnableShapeRecognizer();
bool isEnableFill();
double getThickness(ToolSize size);
protected:
void setCapability(int capability, bool enabled);
private:
Tool(const Tool& t);
void operator=(const Tool& t);
@ -132,15 +147,12 @@ private:
ToolSize size;
double* thickness;
bool fill;
int fillAlpha;
DrawingType drawingType;
bool enableColor;
bool enableSize;
bool enableRuler;
bool enableRectangle;
bool enableCircle;
bool enableArrow;
bool enableShapeRecognizer;
int capabilities;
friend class ToolHandler;
};

@ -43,7 +43,10 @@ void ToolHandler::initTools()
thickness[TOOL_SIZE_MEDIUM] = 1.41;
thickness[TOOL_SIZE_THICK] = 2.26;
thickness[TOOL_SIZE_VERY_THICK] = 5.67;
t = new Tool("pen", TOOL_PEN, 0x3333CC, true, true, true, true, true, true, true, thickness);
t = new Tool("pen", TOOL_PEN, 0x3333CC,
TOOL_CAP_COLOR | TOOL_CAP_SIZE | TOOL_CAP_RULER | TOOL_CAP_RECTANGLE |
TOOL_CAP_CIRCLE | TOOL_CAP_ARROW | TOOL_CAP_RECOGNIZER | TOOL_CAP_FILL,
thickness);
tools[TOOL_PEN - TOOL_PEN] = t;
thickness = new double[5];
@ -52,7 +55,7 @@ void ToolHandler::initTools()
thickness[TOOL_SIZE_MEDIUM] = 8.50;
thickness[TOOL_SIZE_THICK] = 19.84;
thickness[TOOL_SIZE_VERY_THICK] = 19.84;
t = new Tool("eraser", TOOL_ERASER, 0x000000, false, true, false, false, false, false, false, thickness);
t = new Tool("eraser", TOOL_ERASER, 0x000000, TOOL_CAP_SIZE, thickness);
tools[TOOL_ERASER - TOOL_PEN] = t;
// highlighter thicknesses = 1, 3, 7 mm
@ -62,40 +65,43 @@ void ToolHandler::initTools()
thickness[TOOL_SIZE_MEDIUM] = 8.50;
thickness[TOOL_SIZE_THICK] = 19.84;
thickness[TOOL_SIZE_VERY_THICK] = 19.84;
t = new Tool("hilighter", TOOL_HILIGHTER, 0xFFFF00, true, true, true, true, true, true, true, thickness);
t = new Tool("hilighter", TOOL_HILIGHTER, 0xFFFF00,
TOOL_CAP_COLOR | TOOL_CAP_SIZE | TOOL_CAP_RULER | TOOL_CAP_RECTANGLE |
TOOL_CAP_CIRCLE | TOOL_CAP_ARROW | TOOL_CAP_RECOGNIZER | TOOL_CAP_FILL,
thickness);
tools[TOOL_HILIGHTER - TOOL_PEN] = t;
t = new Tool("text", TOOL_TEXT, 0x000000, true, false, false, false, false, false, false, NULL);
t = new Tool("text", TOOL_TEXT, 0x000000, TOOL_CAP_COLOR, NULL);
tools[TOOL_TEXT - TOOL_PEN] = t;
t = new Tool("image", TOOL_IMAGE, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("image", TOOL_IMAGE, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_IMAGE - TOOL_PEN] = t;
t = new Tool("selectRect", TOOL_SELECT_RECT, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("selectRect", TOOL_SELECT_RECT, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_SELECT_RECT - TOOL_PEN] = t;
t = new Tool("selectRegion", TOOL_SELECT_REGION, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("selectRegion", TOOL_SELECT_REGION, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_SELECT_REGION - TOOL_PEN] = t;
t = new Tool("selectObject", TOOL_SELECT_OBJECT, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("selectObject", TOOL_SELECT_OBJECT, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_SELECT_OBJECT - TOOL_PEN] = t;
t = new Tool("verticalSpace", TOOL_VERTICAL_SPACE, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("verticalSpace", TOOL_VERTICAL_SPACE, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_VERTICAL_SPACE - TOOL_PEN] = t;
t = new Tool("hand", TOOL_HAND, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("hand", TOOL_HAND, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_HAND - TOOL_PEN] = t;
t = new Tool("playObject", TOOL_PLAY_OBJECT, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("playObject", TOOL_PLAY_OBJECT, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_PLAY_OBJECT - TOOL_PEN] = t;
t = new Tool("drawRect", TOOL_DRAW_RECT, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("drawRect", TOOL_DRAW_RECT, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_DRAW_RECT - TOOL_PEN] = t;
t = new Tool("drawCircle", TOOL_DRAW_CIRCLE, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("drawCircle", TOOL_DRAW_CIRCLE, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_DRAW_CIRCLE - TOOL_PEN] = t;
t = new Tool("drawArrow", TOOL_DRAW_ARROW, 0x000000, false, false, false, false, false, false, false, NULL);
t = new Tool("drawArrow", TOOL_DRAW_ARROW, 0x000000, TOOL_CAP_NONE, NULL);
tools[TOOL_DRAW_ARROW - TOOL_PEN] = t;
selectTool(TOOL_PEN);
@ -185,7 +191,7 @@ void ToolHandler::fireToolChanged()
}
}
Tool &ToolHandler::getTool(ToolType type)
Tool& ToolHandler::getTool(ToolType type)
{
return *(this->tools[type - TOOL_PEN]);
}
@ -201,49 +207,49 @@ bool ToolHandler::isEnableColor()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableColor;
return current->capabilities & TOOL_CAP_COLOR != 0;
}
bool ToolHandler::isEnableSize()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableSize;
return current->capabilities & TOOL_CAP_SIZE != 0;
}
bool ToolHandler::isEnableRuler()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableRuler;
return current->capabilities & TOOL_CAP_RULER != 0;
}
bool ToolHandler::isEnableRectangle()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableRectangle;
return current->capabilities & TOOL_CAP_RECTANGLE != 0;
}
bool ToolHandler::isEnableCircle()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableCircle;
return current->capabilities & TOOL_CAP_CIRCLE != 0;
}
bool ToolHandler::isEnableArrow()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableArrow;
return current->capabilities & TOOL_CAP_ARROW != 0;
}
bool ToolHandler::isEnableShapreRecognizer()
{
XOJ_CHECK_TYPE(ToolHandler);
return current->enableShapeRecognizer;
return current->capabilities & TOOL_CAP_RECOGNIZER != 0;
}
ToolSize ToolHandler::getSize()
@ -310,6 +316,74 @@ void ToolHandler::setHilighterSize(ToolSize size)
}
}
void ToolHandler::setPenFillEnabled(bool fill)
{
XOJ_CHECK_TYPE(ToolHandler);
this->tools[TOOL_PEN - TOOL_PEN]->fill = fill;
// TODO: Currently no toolbar event to send, but if there is a toolbar, here the event should be sent
// if (this->current->type == TOOL_PEN)
// {
// this->listener->toolSizeChanged();
// }
}
bool ToolHandler::getPenFillEnabled()
{
XOJ_CHECK_TYPE(ToolHandler);
return this->tools[TOOL_PEN - TOOL_PEN]->fill;
}
void ToolHandler::setPenFill(int alpha)
{
XOJ_CHECK_TYPE(ToolHandler);
this->tools[TOOL_PEN - TOOL_PEN]->fillAlpha = alpha;
}
int ToolHandler::getPenFill()
{
XOJ_CHECK_TYPE(ToolHandler);
return this->tools[TOOL_PEN - TOOL_PEN]->fillAlpha;
}
void ToolHandler::setHilighterFillEnabled(bool fill)
{
XOJ_CHECK_TYPE(ToolHandler);
this->tools[TOOL_HILIGHTER - TOOL_PEN]->fill = fill;
// TODO: Currently no toolbar event to send, but if there is a toolbar, here the event should be sent
// if (this->current->type == TOOL_HILIGHTER)
// {
// this->listener->toolSizeChanged();
// }
}
bool ToolHandler::getHilighterFillEnabled()
{
XOJ_CHECK_TYPE(ToolHandler);
return this->tools[TOOL_HILIGHTER - TOOL_PEN]->fill;
}
void ToolHandler::setHilighterFill(int alpha)
{
XOJ_CHECK_TYPE(ToolHandler);
this->tools[TOOL_HILIGHTER - TOOL_PEN]->fillAlpha = alpha;
}
int ToolHandler::getHilighterFill()
{
XOJ_CHECK_TYPE(ToolHandler);
return this->tools[TOOL_HILIGHTER - TOOL_PEN]->fillAlpha;
}
double ToolHandler::getThickness()
{
XOJ_CHECK_TYPE(ToolHandler);
@ -370,6 +444,21 @@ int ToolHandler::getColor()
return current->color;
}
/**
* @return -1 if fill is disabled, else the fill alpha value
*/
int ToolHandler::getFill()
{
XOJ_CHECK_TYPE(ToolHandler);
if (!current->fill)
{
return -1;
}
return current->fillAlpha;
}
DrawingType ToolHandler::getDrawingType()
{
XOJ_CHECK_TYPE(ToolHandler);
@ -565,6 +654,9 @@ const double* ToolHandler::getToolThickness(ToolType type)
return this->tools[type - TOOL_PEN]->thickness;
}
/**
* Change the selection tools capabilities, depending on the selected elements
*/
void ToolHandler::setSelectionEditTools(bool setColor, bool setSize)
{
XOJ_CHECK_TYPE(ToolHandler);
@ -572,8 +664,8 @@ void ToolHandler::setSelectionEditTools(bool setColor, bool setSize)
for (int i = TOOL_SELECT_RECT - TOOL_PEN; i <= TOOL_SELECT_OBJECT - TOOL_PEN; i++)
{
Tool* t = tools[i];
t->enableColor = setColor;
t->enableSize = setSize;
t->setCapability(TOOL_CAP_COLOR, setColor);
t->setCapability(TOOL_CAP_SIZE, setSize);
t->size = TOOL_SIZE_NONE;
t->color = -1;
}

@ -50,6 +50,11 @@ public:
void setColor(int color, bool userSelection);
int getColor();
/**
* @return -1 if fill is disabled, else the fill alpha value
*/
int getFill();
DrawingType getDrawingType();
void setDrawingType(DrawingType drawingType);
@ -66,12 +71,21 @@ public:
void setEraserSize(ToolSize size);
void setHilighterSize(ToolSize size);
void setPenFillEnabled(bool fill);
bool getPenFillEnabled();
void setPenFill(int alpha);
int getPenFill();
void setHilighterFillEnabled(bool fill);
bool getHilighterFillEnabled();
void setHilighterFill(int alpha);
int getHilighterFill();
void selectTool(ToolType type, bool fireToolChanged = true);
ToolType getToolType();
void fireToolChanged();
Tool &getTool(ToolType type);
Tool& getTool(ToolType type);
void setEraserType(EraserType eraserType);
EraserType getEraserType();
@ -93,6 +107,9 @@ public:
ArrayIterator<Tool*> iterator();
/**
* Change the selection tools capabilities, depending on the selected elements
*/
void setSelectionEditTools(bool setColor, bool setSize);
const double* getToolThickness(ToolType type);

@ -57,6 +57,7 @@ void InputHandler::createStroke(Point p)
stroke = new Stroke();
stroke->setWidth(h->getThickness());
stroke->setColor(h->getColor());
stroke->setFill(h->getFill());
if (h->getToolType() == TOOL_PEN)
{

@ -3,7 +3,8 @@
#include <config.h>
#include <StringUtils.h>
AboutDialog::AboutDialog(GladeSearchpath* gladeSearchPath) : GladeGui(gladeSearchPath, "about.glade", "aboutDialog")
AboutDialog::AboutDialog(GladeSearchpath* gladeSearchPath)
: GladeGui(gladeSearchPath, "about.glade", "aboutDialog")
{
XOJ_INIT_TYPE(AboutDialog);

@ -13,8 +13,6 @@
#include "gui/GladeGui.h"
#include <XournalType.h>
class AboutDialog : public GladeGui
{
public:

@ -14,8 +14,6 @@
#include "control/Actions.h"
#include "gui/GladeGui.h"
#include <XournalType.h>
#include <gdk/gdk.h>
class Settings;

@ -15,7 +15,6 @@
#include "gui/GladeGui.h"
#include <PageRange.h>
#include <XournalType.h>
#include <boost/filesystem/path.hpp>
using boost::filesystem::path;

@ -0,0 +1,85 @@
#include "FillTransparencyDialog.h"
FillTransparencyDialog::FillTransparencyDialog(GladeSearchpath* gladeSearchPath, int alpha)
: GladeGui(gladeSearchPath, "fillTransparency.glade", "fillTransparencyDialog"),
resultAlpha(-1)
{
XOJ_INIT_TYPE(FillTransparencyDialog);
GtkWidget* scaleAlpha = get("scaleAlpha");
gtk_range_set_value(GTK_RANGE(scaleAlpha), alpha / 255.0 * 100);
setPreviewImage(alpha);
g_signal_connect(scaleAlpha, "change-value", G_CALLBACK(
+[](GtkRange* range, GtkScrollType scroll, gdouble value, FillTransparencyDialog* self)
{
XOJ_CHECK_TYPE_OBJ(self, FillTransparencyDialog);
self->setPreviewImage((int)(value / 100 * 255));
}), this);
}
FillTransparencyDialog::~FillTransparencyDialog()
{
XOJ_RELEASE_TYPE(FillTransparencyDialog);
}
const int PREVIEW_WIDTH = 70;
const int PREVIEW_HEIGTH = 50;
const int PREVIEW_BORDER = 10;
void FillTransparencyDialog::setPreviewImage(int alpha)
{
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PREVIEW_WIDTH, PREVIEW_HEIGTH);
cairo_t* cr = cairo_create(surface);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgb(cr, 255, 255, 255);
cairo_rectangle(cr, 0, 0, PREVIEW_WIDTH, PREVIEW_WIDTH);
cairo_fill(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_set_source_rgba(cr, 0, 0x80 / 255.0, 0, alpha / 255.0);
cairo_rectangle(cr, PREVIEW_BORDER, PREVIEW_BORDER, PREVIEW_WIDTH - PREVIEW_BORDER * 2, PREVIEW_HEIGTH - PREVIEW_BORDER * 2);
cairo_fill(cr);
cairo_set_line_width(cr, 5);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgb(cr, 0, 0x80 / 255.0, 0);
cairo_rectangle(cr, PREVIEW_BORDER, PREVIEW_BORDER, PREVIEW_WIDTH - PREVIEW_BORDER * 2, PREVIEW_HEIGTH - PREVIEW_BORDER * 2);
cairo_stroke(cr);
cairo_destroy(cr);
GtkWidget* preview = get("imgPreview");
gtk_image_set_from_surface(GTK_IMAGE(preview), surface);
}
int FillTransparencyDialog::getResultAlpha()
{
XOJ_CHECK_TYPE(FillTransparencyDialog);
return resultAlpha;
}
void FillTransparencyDialog::show(GtkWindow* parent)
{
XOJ_CHECK_TYPE(FillTransparencyDialog);
gtk_window_set_transient_for(GTK_WINDOW(this->window), parent);
int result = gtk_dialog_run(GTK_DIALOG(this->window));
gtk_widget_hide(this->window);
// OK Button
if (result == 1)
{
GtkWidget* scaleAlpha = get("scaleAlpha");
resultAlpha = gtk_range_get_value(GTK_RANGE(scaleAlpha));
}
else
{
resultAlpha = -1;
}
}

@ -0,0 +1,34 @@
/*
* Xournal++
*
* The about dialog
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include "gui/GladeGui.h"
class FillTransparencyDialog : public GladeGui
{
public:
FillTransparencyDialog(GladeSearchpath* gladeSearchPath, int alpha);
virtual ~FillTransparencyDialog();
public:
virtual void show(GtkWindow* parent);
int getResultAlpha();
private:
void setPreviewImage(int alpha);
private:
XOJ_TYPE_ATTRIB;
int resultAlpha;
};

@ -14,8 +14,6 @@
#include "control/settings/Settings.h"
#include "gui/GladeGui.h"
#include <XournalType.h>
enum Orientation
{
ORIENTATION_NOT_DEFINED, ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT

@ -12,7 +12,6 @@
#pragma once
#include "gui/GladeGui.h"
#include <XournalType.h>
class GotoDialog : public GladeGui
{

@ -17,8 +17,6 @@
#include "model/TexImage.h"
#include <XournalType.h>
class LatexDialog : public GladeGui
{
public:

@ -16,8 +16,6 @@
#include "control/pagetype/PageTypeMenu.h"
#include "control/settings/PageTemplateSettings.h"
#include <XournalType.h>
class PageTypeHandler;
class PageTypeMenu;
class PageTypeInfo;

@ -14,8 +14,6 @@
#include "control/settings/Settings.h"
#include "gui/GladeGui.h"
#include <XournalType.h>
class ButtonConfigGui;
class SettingsDialog : public GladeGui

@ -11,8 +11,8 @@ enum
COLUMN_STRING, COLUMN_BOLD, COLUMN_POINTER, COLUMN_EDITABLE, N_COLUMNS
};
ToolbarManageDialog::ToolbarManageDialog(GladeSearchpath* gladeSearchPath, ToolbarModel* model) :
GladeGui(gladeSearchPath, "toolbarManageDialog.glade", "DialogManageToolbar")
ToolbarManageDialog::ToolbarManageDialog(GladeSearchpath* gladeSearchPath, ToolbarModel* model)
: GladeGui(gladeSearchPath, "toolbarManageDialog.glade", "DialogManageToolbar")
{
XOJ_INIT_TYPE(ToolbarManageDialog);

@ -13,8 +13,6 @@
#include "gui/GladeGui.h"
#include <XournalType.h>
class ToolbarData;
class ToolbarModel;

@ -495,10 +495,16 @@ void ToolMenuHandler::initToolItems()
registerMenupoint(gui->get("penthicknessThick"), ACTION_TOOL_PEN_SIZE_THICK, GROUP_PEN_SIZE);
registerMenupoint(gui->get("penthicknessVeryThick"), ACTION_TOOL_PEN_SIZE_VERY_THICK, GROUP_PEN_SIZE);
registerMenupoint(gui->get("penFill"), ACTION_TOOL_PEN_FILL, GROUP_PEN_FILL);
registerMenupoint(gui->get("penFillTransparency"), ACTION_TOOL_PEN_FILL_TRANSPARENCY);
registerMenupoint(gui->get("highlighterFine"), ACTION_TOOL_HILIGHTER_SIZE_FINE, GROUP_HILIGHTER_SIZE);
registerMenupoint(gui->get("highlighterMedium"), ACTION_TOOL_HILIGHTER_SIZE_MEDIUM, GROUP_HILIGHTER_SIZE);
registerMenupoint(gui->get("highlighterThick"), ACTION_TOOL_HILIGHTER_SIZE_THICK, GROUP_HILIGHTER_SIZE);
registerMenupoint(gui->get("highlighterFill"), ACTION_TOOL_HILIGHTER_FILL, GROUP_HILIGHTER_FILL);
registerMenupoint(gui->get("highlighterFillTransparency"), ACTION_TOOL_HILIGHTER_FILL_TRANSPARENCY);
registerMenupoint(gui->get("menuToolsTextFont"), ACTION_SELECT_FONT);
#ifdef ENABLE_MATHTEX

@ -249,4 +249,5 @@ XOJ_DECLARE_TYPE(NewGtkInputDevice, 238);
XOJ_DECLARE_TYPE(InputSequence, 239);
XOJ_DECLARE_TYPE(ZoomGesture, 240);
XOJ_DECLARE_TYPE(GroupUndoAction, 241);
XOJ_DECLARE_TYPE(FillTransparencyDialog, 242);

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkDialog" id="fillTransparencyDialog">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Transparency settings</property>
<property name="window_position">center</property>
<property name="icon">pixmaps/xournalpp.svg</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="btCancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btOk">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Fill transparency settings&lt;/b&gt;
Select transparency for fill color</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage" id="imgPreview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="scaleAlpha">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="show_fill_level">True</property>
<property name="fill_level">100</property>
<property name="round_digits">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="2">btCancel</action-widget>
<action-widget response="1">btOk</action-widget>
</action-widgets>
</object>
</interface>

@ -299,7 +299,7 @@
<property name="label" translatable="yes">Rec-Stop</property>
</object>
</child>
<child>
<child>
<object class="GtkCheckMenuItem" id="menuSnapRotation">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
@ -307,7 +307,7 @@
<property name="label" translatable="yes">Rotation Snapping</property>
</object>
</child>
<child>
<child>
<object class="GtkCheckMenuItem" id="menuSnapGrid">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
@ -884,6 +884,28 @@
<property name="draw_as_radio">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="penFill">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Fi_ll</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="penFillTransparency">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Fill transparency</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
</child>
</object>
@ -999,6 +1021,28 @@
<property name="draw_as_radio">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="highlighterFill">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Fi_ll</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="highlighterFillTransparency">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Fill transparency</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
</child>
</object>

Loading…
Cancel
Save