Skip to content

Commit

Permalink
Brush dock UI redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
callaa committed Apr 8, 2017
1 parent 1ce4b1f commit 45d7b03
Show file tree
Hide file tree
Showing 36 changed files with 1,876 additions and 3,401 deletions.
13 changes: 13 additions & 0 deletions desktop/theme/dark/configure-shortcuts.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions desktop/theme/dark/input-tablet.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions desktop/theme/light/configure-shortcuts.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions desktop/theme/light/input-tablet.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/client/tools/brushes.cpp
@@ -1,7 +1,7 @@
/*
Drawpile - a collaborative drawing program.
Copyright (C) 2006-2015 Calle Laakkonen
Copyright (C) 2006-2017 Calle Laakkonen
Drawpile is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,12 +31,12 @@

namespace tools {

BrushBase::BrushBase(ToolController &owner, Type type)
: Tool(owner, type, Qt::CrossCursor)
Freehand::Freehand(ToolController &owner)
: Tool(owner, FREEHAND, Qt::CrossCursor)
{
}

void BrushBase::begin(const paintcore::Point& point, float zoom)
void Freehand::begin(const paintcore::Point& point, float zoom)
{
Q_UNUSED(zoom);

Expand All @@ -50,7 +50,7 @@ void BrushBase::begin(const paintcore::Point& point, float zoom)
owner.client()->sendMessages(msgs);
}

void BrushBase::motion(const paintcore::Point& point, bool constrain, bool center)
void Freehand::motion(const paintcore::Point& point, bool constrain, bool center)
{
Q_UNUSED(constrain);
Q_UNUSED(center);
Expand All @@ -60,7 +60,7 @@ void BrushBase::motion(const paintcore::Point& point, bool constrain, bool cente
owner.client()->sendMessage(protocol::MessagePtr(new protocol::PenMove(owner.client()->myId(), v)));
}

void BrushBase::end()
void Freehand::end()
{
owner.client()->sendMessage(protocol::MessagePtr(new protocol::PenUp(owner.client()->myId())));
}
Expand Down
49 changes: 4 additions & 45 deletions src/client/tools/brushes.h
@@ -1,7 +1,7 @@
/*
Drawpile - a collaborative drawing program.
Copyright (C) 2006-2015 Calle Laakkonen
Copyright (C) 2006-2017 Calle Laakkonen
Drawpile is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -23,11 +23,11 @@

namespace tools {

//! Base class for brush type tools
class BrushBase : public Tool
//! Freehand brush tool
class Freehand : public Tool
{
public:
BrushBase(ToolController &owner, Type type);
Freehand(ToolController &owner);

void begin(const paintcore::Point& point, float zoom);
void motion(const paintcore::Point& point, bool constrain, bool center);
Expand All @@ -36,47 +36,6 @@ class BrushBase : public Tool
bool allowSmoothing() const { return true; }
};

/**
* \brief Pen tool
*
* The pen tool draws non-antialiased strokes and full hardness.
*/
class Pen : public BrushBase {
public:
Pen(ToolController &owner) : BrushBase(owner, PEN) {}
};

/**
* \brief Regular brush tool
*
* The normal brush draws antialised strokes.
*/
class Brush : public BrushBase {
public:
Brush(ToolController &owner) : BrushBase(owner, BRUSH) {}
};

/**
* \brief Smudge brush tool
*
* Smudge brush works like a normal brush, but it also picks up color from the layer
*/
class Smudge : public BrushBase {
public:
Smudge(ToolController &owner) : BrushBase(owner, SMUDGE) { }
};

/**
* \brief Eraser tool
*
* The eraser too draws only using the eraser blending mode.
* Eraser can draw either antialiased soft strokes or hard strokes.
*/
class Eraser : public BrushBase {
public:
Eraser(ToolController &owner) : BrushBase(owner, ERASER) {}
};

}

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/client/tools/tool.h
Expand Up @@ -41,7 +41,7 @@ class ToolController;
class Tool
{
public:
enum Type {PEN, BRUSH, SMUDGE, ERASER, LINE, RECTANGLE, ELLIPSE, FLOODFILL, ANNOTATION, PICKER, LASERPOINTER, SELECTION, POLYGONSELECTION, _LASTTOOL};
enum Type {FREEHAND, LINE, RECTANGLE, ELLIPSE, FLOODFILL, ANNOTATION, PICKER, LASERPOINTER, SELECTION, POLYGONSELECTION, _LASTTOOL};

Tool(ToolController &owner, Type type, const QCursor &cursor)
: owner(owner), m_type(type), m_cursor(cursor)
Expand Down
7 changes: 2 additions & 5 deletions src/client/tools/toolcontroller.cpp
Expand Up @@ -45,10 +45,7 @@ ToolController::ToolController(net::Client *client, QObject *parent)
{
Q_ASSERT(client);

registerTool(new Pen(*this));
registerTool(new Brush(*this));
registerTool(new Smudge(*this));
registerTool(new Eraser(*this));
registerTool(new Freehand(*this));
registerTool(new ColorPicker(*this));
registerTool(new Line(*this));
registerTool(new Rectangle(*this));
Expand All @@ -59,7 +56,7 @@ ToolController::ToolController(net::Client *client, QObject *parent)
registerTool(new RectangleSelection(*this));
registerTool(new PolygonSelection(*this));

m_activeTool = m_toolbox[Tool::PEN];
m_activeTool = m_toolbox[Tool::FREEHAND];
m_activeLayer = 0;
m_activeAnnotation = 0;
}
Expand Down
8 changes: 2 additions & 6 deletions src/client/tools/toolproperties.cpp
Expand Up @@ -58,16 +58,12 @@ void ToolProperties::save(QSettings &cfg) const
i.next();
cfg.setValue(i.key(), i.value());
}
cfg.setValue("tooltype", m_tool);
cfg.setValue("tooltype", m_type);
}

ToolProperties ToolProperties::load(const QSettings &cfg)
{
bool ok;
ToolProperties tp(cfg.value("tooltype", -1).toInt(&ok));
if(!ok)
tp.m_tool = -1;

ToolProperties tp(cfg.value("tooltype").toString());
for(const QString &key : cfg.allKeys()) {
tp.m_props[key] = cfg.value(key);
}
Expand Down
30 changes: 25 additions & 5 deletions src/client/tools/toolproperties.h
Expand Up @@ -33,11 +33,17 @@ namespace tools {
class ToolProperties
{
public:
ToolProperties() : m_tool(-1) { }
ToolProperties(int tool) : m_tool(tool) { }
ToolProperties() { }
ToolProperties(const QString &type)
: m_type(type) { }

//! Get the type of the tool
int toolType() const { return m_tool; }
/**
* @brief Get the type of the tool
*
* E.g. Freehand and Line tools are both "brush" type tools,
* as they share their settings.
*/
QString toolType() const { return m_type; }

/**
* @brief Set a value
Expand Down Expand Up @@ -71,6 +77,9 @@ class ToolProperties
*/
bool boolValue(const QString &key, bool defaultValue) const;

//! Are there any stored properties?
bool isEmpty() const { return m_props.isEmpty(); }

/**
* @brief Save tool properties
*
Expand All @@ -88,11 +97,22 @@ class ToolProperties
*/
static ToolProperties load(const QSettings &cfg);

QVariantHash asVariant() const { return m_props; }

static ToolProperties fromVariant(const QVariantHash &h, const QString &type=QString())
{
ToolProperties tp(type);
tp.m_props = h;
return tp;
}

private:
QVariantHash m_props;
int m_tool;
QString m_type;
};

}

Q_DECLARE_METATYPE(tools::ToolProperties)

#endif
6 changes: 1 addition & 5 deletions src/desktop/CMakeLists.txt
Expand Up @@ -12,7 +12,6 @@ set (
notifications.cpp
toolwidgets/toolsettings.cpp
toolwidgets/brushsettings.cpp
toolwidgets/shapetoolsettings.cpp
toolwidgets/colorpickersettings.cpp
toolwidgets/selectionsettings.cpp
toolwidgets/annotationsettings.cpp
Expand Down Expand Up @@ -91,16 +90,13 @@ endif()

set (
UIs
ui/brushdock.ui
ui/brushsettings.ui
ui/simplesettings.ui
ui/smudgesettings.ui
ui/certificateview.ui
ui/hostdialog.ui
ui/joindialog.ui
ui/settings.ui
ui/textsettings.ui
ui/pensettings.ui
ui/erasersettings.ui
ui/selectsettings.ui
ui/fillsettings.ui
ui/lasersettings.ui
Expand Down

0 comments on commit 45d7b03

Please sign in to comment.