├── .gitignore ├── Draftoola.pro ├── LICENSE ├── README.md ├── assets_raw └── icons │ └── gradient.xcf ├── skia.pri └── src ├── common ├── skia_includes.h └── utilities.h ├── designer ├── canvasscene.cpp ├── canvasscene.h ├── canvasview.cpp ├── canvasview.h ├── handleframe.cpp ├── handleframe.h ├── ruler.cpp └── ruler.h ├── gui ├── colordialog │ ├── QtColorWidgets │ │ ├── color_2d_slider.cpp │ │ ├── color_2d_slider.hpp │ │ ├── color_line_edit.cpp │ │ ├── color_line_edit.hpp │ │ ├── color_names.cpp │ │ ├── color_names.hpp │ │ ├── color_preview.cpp │ │ ├── color_preview.hpp │ │ ├── color_utils.hpp │ │ ├── colorwidgets_global.hpp │ │ ├── gradient_editor.cpp │ │ ├── gradient_editor.hpp │ │ ├── gradient_helper.hpp │ │ ├── gradient_slider.cpp │ │ ├── gradient_slider.hpp │ │ ├── hue_slider.cpp │ │ └── hue_slider.hpp │ ├── colordialog.cpp │ ├── colordialog.h │ ├── colordialog.ui │ ├── colorinput.cpp │ ├── colorinput.h │ ├── colorinput.ui │ ├── tabcolors.cpp │ ├── tabcolors.h │ ├── tabcolors.ui │ ├── tabimage.cpp │ ├── tabimage.h │ └── tabimage.ui ├── tool_itemproperties.cpp ├── tool_itemproperties.h ├── tool_itemproperties.ui ├── tool_itemproperties │ ├── ip_exportlevel.cpp │ ├── ip_exportlevel.h │ ├── ip_exportlevel.ui │ ├── ip_fills.cpp │ ├── ip_fills.h │ ├── ip_fills.ui │ ├── ip_geometry.cpp │ ├── ip_geometry.h │ ├── ip_geometry.ui │ ├── ip_innershadows.cpp │ ├── ip_innershadows.h │ ├── ip_shadows.cpp │ ├── ip_shadows.h │ ├── ip_shadows.ui │ ├── ip_strokes.cpp │ ├── ip_strokes.h │ ├── ip_strokes.ui │ ├── propertyexportlevel.cpp │ ├── propertyexportlevel.h │ ├── propertyexportlevel.ui │ ├── propertyfill.cpp │ ├── propertyfill.h │ ├── propertyfill.ui │ ├── propertyshadow.cpp │ ├── propertyshadow.h │ ├── propertyshadow.ui │ ├── propertystroke.cpp │ ├── propertystroke.h │ └── propertystroke.ui ├── tool_outliner.cpp ├── tool_outliner.h ├── tool_outliner.ui └── widgets │ ├── buttongroup.cpp │ ├── buttongroup.h │ ├── colorbutton.cpp │ ├── colorbutton.h │ ├── flowlayout.cpp │ ├── flowlayout.h │ ├── intelligentspinbox.cpp │ ├── intelligentspinbox.h │ ├── layoutsection.cpp │ ├── layoutsection.h │ ├── layoutsegment.h │ ├── popupmenu.cpp │ └── popupmenu.h ├── item ├── abstractitembase.cpp ├── abstractitembase.h ├── artboard.cpp ├── artboard.h ├── itembase.cpp ├── itembase.h ├── itemgroup.cpp ├── itemgroup.h ├── itemoval.cpp ├── itemoval.h ├── itempolygon.cpp ├── itempolygon.h ├── itemrect.cpp ├── itemrect.h ├── itemtext.cpp ├── itemtext.h └── members │ ├── abstractitemproperty.cpp │ ├── abstractitemproperty.h │ ├── abstractproperty.cpp │ ├── abstractproperty.h │ ├── color.cpp │ ├── color.h │ ├── exportlevel.cpp │ ├── exportlevel.h │ ├── fills.cpp │ ├── fills.h │ ├── gradient.cpp │ ├── gradient.h │ ├── pathprocessor.cpp │ ├── pathprocessor.h │ ├── shadow.cpp │ ├── shadow.h │ ├── stroke.cpp │ └── stroke.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── manager ├── qt2skia.cpp ├── qt2skia.h ├── skia2qt.cpp ├── skia2qt.h ├── stylefactory.cpp └── stylefactory.h └── resources └── icons ├── dark ├── chevron-down.svg ├── chevron-right.svg ├── close.svg ├── colordialog │ ├── color.svg │ ├── conical_gradient.png │ ├── image.svg │ ├── linear_gradient.png │ ├── radial_gradient.png │ └── radial_gradient_alt.png ├── delete-24px.svg ├── eye-off.svg ├── eye.svg ├── folder-open.svg ├── frame-all-lock.svg ├── frame-free.svg ├── frame-horizontal-lock.svg ├── frame-vertical-lock.svg ├── plus.svg ├── settings.svg └── tools │ ├── ellipse.svg │ ├── format-text-variant.svg │ ├── format-textbox.svg │ ├── fountain-pen-tip.svg │ ├── image.svg │ ├── line.svg │ ├── pentagon.svg │ ├── presentation.svg │ ├── rectangle.svg │ ├── star.svg │ └── triangle.svg └── icons.qrc /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | moc_*.h 24 | qrc_*.cpp 25 | ui_*.h 26 | Makefile* 27 | *build-* 28 | 29 | # QtCreator 30 | 31 | *.autosave 32 | 33 | # QtCtreator Qml 34 | *.qmlproject.user 35 | *.qmlproject.user.* 36 | 37 | # QtCtreator CMake 38 | CMakeLists.txt.user* 39 | 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Draftoola 2 | Open Source UI and UX prototyping tool for designing static and animated layouts. 3 | 4 | *Draftoola* is a combination out of "draft" and "tool". 5 | 6 | **Note: it is an early development state and not ready to use!** 7 | 8 | ## Development State 9 | ![Bildschirmfoto von 2019-05-05 12-56-01](https://user-images.githubusercontent.com/15112256/71785561-5b1dc680-3001-11ea-818f-7623ac3dc898.png) 10 | 11 | ## Dependencies 12 | Draftoola requires minimum Qt 5.14 - https://www.qt.io/download \ 13 | Draftoola requires Skia - https://skia.org/ 14 | 15 | ## Prepare Skia library 16 | 17 | ### Download Skia 18 | Download Skia somewhere on your local machine by following instructions. \ 19 | Draftoola code is tested with "chrome/m81" branch from Skia library. You can use a later one, but it is not tested. \ 20 | Open your terminal and navigate to your preferred folder where Skia should be downloaded. 21 | 22 | ``` 23 | git clone -b chrome/m81 --single-branch https://github.com/google/skia.git 24 | ``` 25 | 26 | ### Install dependencies 27 | 28 | Install 3rd party libs and other dependencies for Skia. 29 | ``` 30 | cd skia 31 | python2 tools/git-sync-deps 32 | ``` 33 | 34 | Install missing dependencies 35 | ``` 36 | tools/install_dependencies.sh 37 | ``` 38 | 39 | ### Precompile Skia 40 | 41 | Now Skia have to precompiled as a static library. You can follow the official instructions on https://skia.org/user/build. 42 | 43 | #### Example for Ubuntu 44 | 45 | Create output folder and setup instructions for compiler. 46 | ``` 47 | bin/gn gen out/Release --args='is_debug=false' 48 | ``` 49 | 50 | Compile via ninja. Depending on processing power of your machine it takes a while. 51 | ``` 52 | ninja -C out/Release 53 | ``` 54 | 55 | ### Add environment variable in QtCreator 56 | Now we have to tell Draftoola where Skia is located. Add a new environment variable in QtCreator. \ 57 | Variable: SKIA_DIR \ 58 | Value: %your-path-to-skia-folder%/skia 59 | 60 | 61 | ## Development Notes 62 | Every vector-based path processing program needs good path operations, such as Boolean path operation, expanding and shrinking paths, etc. In the best case, the Bezier paths are retained in these operations. Qt SVG ist not the best library to render and work with SVG's. Target is to implement a powerful library. 63 | \ 64 | \ 65 | The following libraries can be used. 66 | * [Skia Graphics Library (Google Chrome)](https://skia.org/) - currently in use for path processing 67 | * [lib2geom (Inkscape)](http://lib2geom.sourceforge.net/) 68 | * [resvg](https://github.com/RazrFalcon/resvg) 69 | -------------------------------------------------------------------------------- /assets_raw/icons/gradient.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nitramr/Draftoola/7ab179cc0f6ca3f2e9b4fc2ca5346fb5bae01384/assets_raw/icons/gradient.xcf -------------------------------------------------------------------------------- /skia.pri: -------------------------------------------------------------------------------- 1 | DISTFILES += skia.pri 2 | 3 | QMAKE_SKIA_DIR = $$(SKIA_DIR) 4 | 5 | exists ($$QMAKE_SKIA_DIR) { 6 | INCLUDEPATH += $$QMAKE_SKIA_DIR 7 | INCLUDEPATH += $$QMAKE_SKIA_DIR/include/pathops/ 8 | INCLUDEPATH += $$QMAKE_SKIA_DIR/include/core/ 9 | INCLUDEPATH += $$QMAKE_SKIA_DIR/include/config/ 10 | INCLUDEPATH += $$QMAKE_SKIA_DIR/include/effects/ 11 | Release { 12 | QMAKE_LIBDIR += $$QMAKE_SKIA_DIR/out/Release 13 | } 14 | Debug { 15 | QMAKE_LIBDIR += $$QMAKE_SKIA_DIR/out/Debug 16 | } 17 | 18 | } else { 19 | message ("Please, specify skia dir using environment variable SKIA_DIR") 20 | } 21 | 22 | 23 | LIBS += -L$$QMAKE_SKIA_DIR/out/Release 24 | INCLUDEPATH += $$QMAKE_SKIA_DIR/out/Release 25 | DEPENDPATH += $$QMAKE_SKIA_DIR/out/Release 26 | 27 | win32:*msvc* { 28 | LIBS *= skia.lib 29 | } 30 | 31 | *g++* | *clang* { 32 | LIBS *= -lskia 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/common/skia_includes.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2020 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef SKIAINCLUDES_H 24 | #define SKIAINCLUDES_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #endif // SKIAINCLUDES_H 33 | -------------------------------------------------------------------------------- /src/common/utilities.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ITEMSTRUCT_H 24 | #define ITEMSTRUCT_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #define MINIMAL_FOR_COMPARISON 1e-6 33 | 34 | static inline bool are_equal (double first, double second) 35 | { 36 | return 3 * fabs (first - second) < (first + second + 1.0) * MINIMAL_FOR_COMPARISON; 37 | } 38 | 39 | static inline double cubed (double x) { return x * x * x; } 40 | static inline double squared (double x) { return x * x; } 41 | 42 | static inline QPixmap paintGrid(int blockSize = 6){ 43 | 44 | QPixmap pixmap(blockSize*2,blockSize*2); 45 | QPainter painter(&pixmap); 46 | painter.fillRect(pixmap.rect(), Qt::white); 47 | 48 | painter.fillRect(QRect(blockSize,0,blockSize,blockSize), Qt::lightGray); 49 | painter.fillRect(QRect(0,blockSize,blockSize,blockSize), Qt::lightGray); 50 | 51 | return pixmap; 52 | } 53 | 54 | 55 | 56 | enum class FillType { 57 | Color = 0, 58 | Image = 1, 59 | LinearGradient = 2, 60 | RadialGradient = 3, 61 | ConicalGradient = 4, 62 | Pattern = 5 63 | 64 | }; 65 | Q_DECLARE_METATYPE(FillType) 66 | 67 | 68 | #endif // ITEMSTRUCT_H 69 | -------------------------------------------------------------------------------- /src/designer/canvasscene.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef CANVASSCENE_H 24 | #define CANVASSCENE_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | class CanvasScene : public QGraphicsScene 34 | { 35 | Q_OBJECT 36 | public: 37 | CanvasScene(QObject *parent = nullptr); 38 | 39 | HandleFrame *handleFrame(); 40 | 41 | qreal scaleFactor() const; 42 | void setScaleFactor(qreal factor); 43 | 44 | public slots: 45 | void exportItems(); 46 | void exportItem(AbstractItemBase *item); 47 | 48 | private slots: 49 | void updateLabels(); 50 | 51 | private: 52 | HandleFrame *m_handleFrame; 53 | qreal m_scaleFactor; 54 | int m_grid; 55 | QPainterPath m_hoverPath; 56 | QPointF m_hoverPoint; 57 | QTransform m_hoverTransform; 58 | qreal m_hoverRotation; 59 | QColor m_color; 60 | 61 | void saveImage(AbstractItemBase *bi, qreal multiplier, const QString outputPath, QColor bgColor = Qt::transparent); 62 | void saveSVG(AbstractItemBase *bi, const QString outputPath); 63 | void savePDF(AbstractItemBase *bi, const QString outputPath); 64 | 65 | protected: 66 | void keyPressEvent(QKeyEvent *event); 67 | void keyReleaseEvent(QKeyEvent * event); 68 | void drawBackground(QPainter *painter, const QRectF &rect); 69 | void drawForeground(QPainter *painter, const QRectF &rect); 70 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 71 | 72 | }; 73 | 74 | #endif // CANVASSCENE_H 75 | -------------------------------------------------------------------------------- /src/designer/canvasview.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef CANVASVIEW_H 24 | #define CANVASVIEW_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | class CanvasView : public QGraphicsView 37 | { 38 | Q_OBJECT 39 | public: 40 | CanvasView(QWidget * parent = nullptr); 41 | HandleFrame *handleFrame(); 42 | 43 | void addItem(AbstractItemBase *item, qreal x = 0, qreal y = 0, AbstractItemBase *parent = nullptr); 44 | 45 | AbstractItemBase::RenderQuality renderQuality() const; 46 | void setRenderQuality(AbstractItemBase::RenderQuality renderQuality); 47 | 48 | AbstractItemBase *itemByName(const QString name); 49 | QList artboardList(); 50 | 51 | 52 | 53 | protected: 54 | void wheelEvent(QWheelEvent *event); 55 | void keyPressEvent(QKeyEvent *event); 56 | void keyReleaseEvent(QKeyEvent * event); 57 | void mouseMoveEvent(QMouseEvent *event); 58 | void mousePressEvent(QMouseEvent *event); 59 | void mouseReleaseEvent(QMouseEvent *event); 60 | 61 | private: 62 | CanvasScene *m_scene; 63 | QTimer *timer; 64 | Artboard *m_activeArtboard; 65 | QDRuler *m_HRuler; 66 | QDRuler *m_VRuler; 67 | 68 | AbstractItemBase::RenderQuality m_renderQuality; 69 | 70 | void applyScaleFactor(); 71 | qreal scaleFactor() const; 72 | 73 | ItemGroup *createItemGroup(const QList &items); 74 | QList m_copyCache; 75 | 76 | Artboard *getTopLevelArtboard(QGraphicsItem *item); 77 | 78 | 79 | signals: 80 | void signalViewIsDragged(bool); 81 | void itemsChanged(); 82 | void zoomChanged(qreal); 83 | 84 | public slots: 85 | void groupItems(); 86 | void ungroupItems(); 87 | void deleteItems(); 88 | void copyItems(bool asDuplicate); 89 | void pasteItems(); 90 | 91 | private slots: 92 | void resetItemCache(); 93 | void updateVRulerPosition(); 94 | void updateHRulerPosition(); 95 | void setRulerToSelection(); 96 | void filterSelection(QRect viewportRect, QPointF fromScenePoint, QPointF toScenePoint); 97 | 98 | 99 | }; 100 | 101 | #endif // CANVASVIEW_H 102 | -------------------------------------------------------------------------------- /src/designer/ruler.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2010 Shahazan Ali 6 | Copyright (C) 2019 Martin Reininger 7 | 8 | Widget based on code from https://kernelcoder.wordpress.com/2010/08/25/how-to-insert-ruler-scale-type-widget-into-a-qabstractscrollarea-type-widget/ 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | **************************************************************************************/ 25 | 26 | #ifndef RULER_H 27 | #define RULER_H 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #define RULER_SIZE 20 34 | 35 | class QDRuler : public QWidget 36 | { 37 | Q_OBJECT 38 | Q_ENUMS(RulerType) 39 | Q_PROPERTY(qreal origin READ origin WRITE setOrigin) 40 | Q_PROPERTY(qreal scaleFactor READ scaleFactor WRITE setScaleFactor) 41 | public: 42 | enum RulerType { Horizontal, Vertical }; 43 | 44 | QDRuler(QDRuler::RulerType rulerType, QWidget* parent); 45 | 46 | QSize minimumSizeHint() const; 47 | 48 | QDRuler::RulerType rulerType() const; 49 | 50 | qreal origin() const; 51 | qreal scaleFactor() const; 52 | QColor markerColor() const; 53 | 54 | public slots: 55 | 56 | void setOrigin(const qreal origin); 57 | void setCursorPos(const QPoint cursorPos); 58 | void setMouseTrack(const bool track); 59 | void setScaleFactor(qreal scaleFactor); 60 | void setMarkerColor(const QColor color); 61 | void setMarkerRange(qreal start, qreal stop); 62 | 63 | protected: 64 | void mouseMoveEvent(QMouseEvent* event); 65 | void paintEvent(QPaintEvent*); 66 | 67 | private: 68 | void drawAScaleMeter(QPainter* painter, QRectF rulerRect, qreal scaleMeter, qreal startPositionLine, bool drawNumber = false); 69 | void drawFromOriginTo(QPainter* painter, QRectF rulerRect, qreal startMark, qreal endMark, int startTickNo, qreal step, qreal startPositionLine, bool drawNumber); 70 | void drawMousePosTick(QPainter* painter); 71 | void drawMarkerRange(QPainter* painter); 72 | 73 | RulerType m_RulerType; 74 | qreal m_Origin; 75 | QPoint m_CursorPos; 76 | bool m_MouseTracking; 77 | qreal m_scaleFactor; 78 | QColor m_color; 79 | qreal m_markerStart; 80 | qreal m_markerStop; 81 | }; 82 | 83 | #endif // RULER_H 84 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/color_line_edit.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_WIDGETS_COLOR_LINE_EDIT_HPP 23 | #define COLOR_WIDGETS_COLOR_LINE_EDIT_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | #include 27 | #include 28 | 29 | namespace color_widgets { 30 | 31 | /** 32 | * \brief A line edit used to define a color name 33 | * 34 | * Supported string formats: 35 | * * Short hex strings #f00 36 | * * Long hex strings #ff0000 37 | * * Color names red 38 | * * Function-like rgb(255,0,0) 39 | * 40 | * Additional string formats supported when showAlpha is true: 41 | * * Long hex strings #ff0000ff 42 | * * Function like rgba(255,0,0,255) 43 | */ 44 | class QCP_EXPORT ColorLineEdit : public QLineEdit 45 | { 46 | Q_OBJECT 47 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) 48 | /** 49 | * \brief Whether the widget displays and edits the alpha channel 50 | */ 51 | Q_PROPERTY(bool showAlpha READ showAlpha WRITE setShowAlpha NOTIFY showAlphaChanged) 52 | /** 53 | * \brief If \b true, the background of the widget is changed to show the color 54 | */ 55 | Q_PROPERTY(bool previewColor READ previewColor WRITE setPreviewColor NOTIFY previewColorChanged) 56 | 57 | public: 58 | explicit ColorLineEdit(QWidget* parent = nullptr); 59 | ~ColorLineEdit(); 60 | 61 | QColor color() const; 62 | bool showAlpha() const; 63 | bool previewColor() const; 64 | 65 | public Q_SLOTS: 66 | void setColor(const QColor& color); 67 | void setShowAlpha(bool showAlpha); 68 | void setPreviewColor(bool previewColor); 69 | 70 | Q_SIGNALS: 71 | /** 72 | * \brief Emitted when the color is changed by any means 73 | */ 74 | void colorChanged(const QColor& color); 75 | /** 76 | * \brief Emitted when the user is typing a color but has not finished yet 77 | */ 78 | void colorEdited(const QColor& color); 79 | /** 80 | * \brief Emitted when the user finished to edit a string 81 | */ 82 | void colorEditingFinished(const QColor& color); 83 | 84 | void showAlphaChanged(bool showAlpha); 85 | void previewColorChanged(bool previewColor); 86 | 87 | protected: 88 | void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE; 89 | void dropEvent(QDropEvent * event) Q_DECL_OVERRIDE; 90 | void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; 91 | 92 | private: 93 | class Private; 94 | Private* p; 95 | }; 96 | 97 | } // namespace color_widgets 98 | #endif // COLOR_WIDGETS_COLOR_LINE_EDIT_HPP 99 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/color_names.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #include "QtColorWidgets/color_names.hpp" 23 | #include 24 | 25 | static QRegularExpression regex_qcolor (QStringLiteral("^(?:(?:#[[:xdigit:]]{3})|(?:#[[:xdigit:]]{6})|(?:[[:alpha:]]+))$")); 26 | static QRegularExpression regex_func_rgb (QStringLiteral(R"(^rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)$)")); 27 | static QRegularExpression regex_hex_rgba (QStringLiteral("^#[[:xdigit:]]{8}$")); 28 | static QRegularExpression regex_func_rgba (QStringLiteral(R"(^rgba?\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)$)")); 29 | 30 | namespace color_widgets { 31 | 32 | 33 | QString stringFromColor(const QColor& color, bool alpha) 34 | { 35 | if ( !alpha || color.alpha() == 255 ) 36 | return color.name(); 37 | return color.name()+QStringLiteral("%1").arg(color.alpha(), 2, 16, QChar('0')); 38 | } 39 | 40 | QColor colorFromString(const QString& string, bool alpha) 41 | { 42 | QString xs = string.trimmed(); 43 | QRegularExpressionMatch match; 44 | 45 | match = regex_qcolor.match(xs); 46 | if ( match.hasMatch() ) 47 | { 48 | return QColor(xs); 49 | } 50 | 51 | match = regex_func_rgb.match(xs); 52 | if ( match.hasMatch() ) 53 | { 54 | return QColor( 55 | match.captured(1).toInt(), 56 | match.captured(2).toInt(), 57 | match.captured(3).toInt() 58 | ); 59 | } 60 | 61 | if ( alpha ) 62 | { 63 | match = regex_hex_rgba.match(xs); 64 | if ( match.hasMatch() ) 65 | { 66 | return QColor( 67 | xs.mid(1,2).toInt(nullptr,16), 68 | xs.mid(3,2).toInt(nullptr,16), 69 | xs.mid(5,2).toInt(nullptr,16), 70 | xs.mid(7,2).toInt(nullptr,16) 71 | ); 72 | } 73 | 74 | match = regex_func_rgba.match(xs); 75 | if ( match.hasMatch() ) 76 | { 77 | return QColor( 78 | match.captured(1).toInt(), 79 | match.captured(2).toInt(), 80 | match.captured(3).toInt(), 81 | match.captured(4).toInt() 82 | ); 83 | } 84 | } 85 | 86 | return QColor(); 87 | } 88 | 89 | } // namespace color_widgets 90 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/color_names.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_WIDGETS_COLOR_NAMES_HPP 23 | #define COLOR_WIDGETS_COLOR_NAMES_HPP 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | namespace color_widgets { 31 | 32 | /** 33 | * \brief Convert a string into a color 34 | * 35 | * Supported string formats: 36 | * * Short hex strings #f00 37 | * * Long hex strings #ff0000 38 | * * Color names red 39 | * * Function-like rgb(255,0,0) 40 | * 41 | * Additional string formats supported only when \p alpha is true: 42 | * * Long hex strings #ff0000ff 43 | * * Function like rgba(255,0,0,255) 44 | */ 45 | QCP_EXPORT QColor colorFromString(const QString& string, bool alpha = true); 46 | 47 | /** 48 | * \brief Convert a color into a string 49 | * 50 | * Format: 51 | * * If the color has full alpha: #ff0000 52 | * * If alpha is true and the color has non-full alpha: #ff000088 53 | */ 54 | QCP_EXPORT QString stringFromColor(const QColor& color, bool alpha = true); 55 | 56 | } // namespace color_widgets 57 | #endif // COLOR_WIDGETS_COLOR_NAMES_HPP 58 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/color_preview.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 7 | * \copyright Copyright (C) 2014 Calle Laakkonen 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | #ifndef COLOR_PREVIEW_HPP 24 | #define COLOR_PREVIEW_HPP 25 | 26 | #include "colorwidgets_global.hpp" 27 | 28 | #include 29 | 30 | namespace color_widgets { 31 | 32 | /** 33 | * Simple widget that shows a preview of a color 34 | */ 35 | class QCP_EXPORT ColorPreview : public QWidget 36 | { 37 | Q_OBJECT 38 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged DESIGNABLE true) 39 | Q_PROPERTY(QColor comparisonColor READ comparisonColor WRITE setComparisonColor NOTIFY comparisonColorChanged DESIGNABLE true) 40 | Q_PROPERTY(DisplayMode display_mode READ displayMode WRITE setDisplayMode NOTIFY displayModeChanged DESIGNABLE true) 41 | Q_PROPERTY(QBrush background READ background WRITE setBackground NOTIFY backgroundChanged DESIGNABLE true) 42 | Q_ENUMS(DisplayMode) 43 | public: 44 | enum DisplayMode 45 | { 46 | NoAlpha, ///< Show current color with no transparency 47 | AllAlpha, ///< show current color with transparency 48 | SplitAlpha, ///< Show both solid and transparent side by side 49 | SplitColor ///< Show current and comparison colors side by side 50 | }; 51 | Q_ENUMS(DisplayMode) 52 | 53 | explicit ColorPreview(QWidget *parent = 0); 54 | ~ColorPreview(); 55 | 56 | /// Get the background visible under transparent colors 57 | QBrush background() const; 58 | 59 | /// Change the background visible under transparent colors 60 | void setBackground(const QBrush &bk); 61 | 62 | /// Get color display mode 63 | DisplayMode displayMode() const; 64 | 65 | /// Set how transparent colors are handled 66 | void setDisplayMode(DisplayMode dm); 67 | 68 | /// Get current color 69 | QColor color() const; 70 | 71 | /// Get the comparison color 72 | QColor comparisonColor() const; 73 | 74 | QSize sizeHint () const; 75 | 76 | void paint(QPainter &painter, QRect rect) const; 77 | 78 | void setOrientation(Qt::Orientation orientation); 79 | 80 | public Q_SLOTS: 81 | /// Set current color 82 | void setColor(const QColor &c); 83 | 84 | /// Set the comparison color 85 | void setComparisonColor(const QColor &c); 86 | 87 | Q_SIGNALS: 88 | /// Emitted when the user clicks on the widget 89 | void clicked(); 90 | 91 | /// Emitted on setColor 92 | void colorChanged(QColor); 93 | 94 | void comparisonColorChanged(QColor); 95 | void displayModeChanged(DisplayMode); 96 | void backgroundChanged(const QBrush&); 97 | 98 | protected: 99 | void paintEvent(QPaintEvent *); 100 | void resizeEvent(QResizeEvent *); 101 | void mouseReleaseEvent(QMouseEvent *ev); 102 | void mouseMoveEvent(QMouseEvent *ev); 103 | 104 | private: 105 | class Private; 106 | Private * const p; 107 | }; 108 | 109 | } // namespace color_widgets 110 | Q_DECLARE_METATYPE(color_widgets::ColorPreview::DisplayMode) 111 | 112 | #endif // COLOR_PREVIEW_HPP 113 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/color_utils.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef COLOR_UTILS_HPP 23 | #define COLOR_UTILS_HPP 24 | 25 | #include 26 | #include 27 | 28 | #include "QtColorWidgets/colorwidgets_global.hpp" 29 | 30 | namespace color_widgets { 31 | namespace detail { 32 | 33 | 34 | inline qreal color_chromaF(const QColor& c) 35 | { 36 | qreal max = qMax(c.redF(), qMax(c.greenF(), c.blueF())); 37 | qreal min = qMin(c.redF(), qMin(c.greenF(), c.blueF())); 38 | return max - min; 39 | } 40 | 41 | inline qreal color_lumaF(const QColor& c) 42 | { 43 | return 0.30 * c.redF() + 0.59 * c.greenF() + 0.11 * c.blueF(); 44 | } 45 | QColor color_from_lch(qreal hue, qreal chroma, qreal luma, qreal alpha = 1 ); 46 | 47 | inline QColor rainbow_lch(qreal hue) 48 | { 49 | return color_from_lch(hue,1,1); 50 | } 51 | 52 | inline QColor rainbow_hsv(qreal hue) 53 | { 54 | return QColor::fromHsvF(hue,1,1); 55 | } 56 | 57 | inline qreal color_lightnessF(const QColor& c) 58 | { 59 | return ( qMax(c.redF(),qMax(c.greenF(),c.blueF())) + 60 | qMin(c.redF(),qMin(c.greenF(),c.blueF())) ) / 2; 61 | } 62 | 63 | inline qreal color_HSL_saturationF(const QColor& col) 64 | { 65 | qreal c = color_chromaF(col); 66 | qreal l = color_lightnessF(col); 67 | if ( qFuzzyCompare(l+1,1) || qFuzzyCompare(l+1,2) ) 68 | return 0; 69 | return c / (1-qAbs(2*l-1)); 70 | } 71 | 72 | QCP_EXPORT QColor color_from_hsl(qreal hue, qreal sat, qreal lig, qreal alpha = 1 ); 73 | 74 | } // namespace detail 75 | } // namespace color_widgets 76 | 77 | #endif // COLOR_UTILS_HPP 78 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/colorwidgets_global.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QT_COLOR_WIDGETS_GLOBAL_H 2 | #define QT_COLOR_WIDGETS_GLOBAL_H 3 | 4 | #include 5 | 6 | #if defined(QTCOLORWIDGETS_STATICALLY_LINKED) 7 | # define QCP_EXPORT 8 | #elif defined(QTCOLORWIDGETS_LIBRARY) 9 | # define QCP_EXPORT Q_DECL_EXPORT 10 | #else 11 | # define QCP_EXPORT Q_DECL_IMPORT 12 | #endif 13 | 14 | #endif // QT_COLOR_WIDGETS_GLOBAL_H 15 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/gradient_editor.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file gradient_editor.hpp 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef GRADIENT_EDITOR_HPP 23 | #define GRADIENT_EDITOR_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | 27 | #include 28 | #include 29 | 30 | namespace color_widgets { 31 | 32 | /** 33 | * \brief A slider that moves on top of a gradient 34 | */ 35 | class QCP_EXPORT GradientEditor : public QWidget 36 | { 37 | Q_OBJECT 38 | Q_PROPERTY(QBrush background READ background WRITE setBackground NOTIFY backgroundChanged) 39 | Q_PROPERTY(QGradientStops stops READ stops WRITE setStops NOTIFY stopsChanged) 40 | Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient) 41 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) 42 | Q_PROPERTY(int selectedStop READ selectedStop WRITE setSelectedStop NOTIFY selectedStopChanged) 43 | Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor) 44 | 45 | public: 46 | explicit GradientEditor(QWidget *parent = 0); 47 | explicit GradientEditor(Qt::Orientation orientation, QWidget *parent = 0); 48 | ~GradientEditor(); 49 | 50 | QSize sizeHint() const override; 51 | 52 | /// Get the background, it's visible for transparent gradient stops 53 | QBrush background() const; 54 | /// Set the background, it's visible for transparent gradient stops 55 | void setBackground(const QBrush &bg); 56 | 57 | /// Get the colors that make up the gradient 58 | QGradientStops stops() const; 59 | /// Set the colors that make up the gradient 60 | void setStops(const QGradientStops &colors); 61 | 62 | /// Get the gradient 63 | QLinearGradient gradient() const; 64 | /// Set the gradient 65 | void setGradient(const QLinearGradient &gradient); 66 | 67 | Qt::Orientation orientation() const; 68 | 69 | /** 70 | * \brief Index of the currently selected gradient stop (or -1 if there is no selection) 71 | */ 72 | int selectedStop() const; 73 | 74 | /** 75 | * \brief Color of the selected stop 76 | */ 77 | QColor selectedColor() const; 78 | 79 | public Q_SLOTS: 80 | void setOrientation(Qt::Orientation); 81 | void setSelectedStop(int stop); 82 | void setSelectedColor(const QColor& color); 83 | void addStop(); 84 | void removeStop(); 85 | 86 | Q_SIGNALS: 87 | void backgroundChanged(const QBrush&); 88 | void stopsChanged(const QGradientStops&); 89 | void selectedStopChanged(int); 90 | 91 | protected: 92 | void paintEvent(QPaintEvent *ev) override; 93 | 94 | void mousePressEvent(QMouseEvent *ev) override; 95 | void mouseMoveEvent(QMouseEvent *ev) override; 96 | void mouseReleaseEvent(QMouseEvent *ev) override; 97 | void leaveEvent(QEvent * event) override; 98 | void mouseDoubleClickEvent(QMouseEvent *event) override; 99 | 100 | void dragEnterEvent(QDragEnterEvent *event) override; 101 | void dragMoveEvent(QDragMoveEvent* event) override; 102 | void dragLeaveEvent(QDragLeaveEvent *event) override; 103 | void dropEvent(QDropEvent* event) override; 104 | 105 | private: 106 | class Private; 107 | Private * const p; 108 | }; 109 | 110 | } // namespace color_widgets 111 | 112 | #endif // GRADIENT_EDITOR_HPP 113 | 114 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/gradient_helper.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | * 21 | */ 22 | #ifndef GRADIENT_HELPER_HPP 23 | #define GRADIENT_HELPER_HPP 24 | 25 | #include "colorwidgets_global.hpp" 26 | 27 | #include 28 | 29 | namespace color_widgets { 30 | 31 | inline QColor blendColors(const QColor& a, const QColor& b, qreal ratio) 32 | { 33 | return QColor::fromRgbF( 34 | a.redF() * (1-ratio) + b.redF() * ratio, 35 | a.greenF() * (1-ratio) + b.greenF() * ratio, 36 | a.blueF() * (1-ratio) + b.blueF() * ratio, 37 | a.alphaF() * (1-ratio) + b.alphaF() * ratio 38 | ); 39 | } 40 | 41 | 42 | /** 43 | * \brief Get an insertion point in the gradient 44 | * \param gradient Gradient stops to look into (must be properly set up) 45 | * \param factor Value in [0, 1] to get the color for 46 | * \return A pair whose first element is the index to insert the new value at, and a GradientStop 47 | */ 48 | inline QPair Q_DECL_EXPORT gradientBlendedColorInsert(const QGradientStops& gradient, qreal factor) 49 | { 50 | if ( gradient.empty() ) 51 | return {0, {0, QColor()}}; 52 | 53 | if ( gradient.size() == 1 || factor <= 0 ) 54 | return {0, gradient.front()}; 55 | 56 | int i = 0; 57 | QGradientStop s1; 58 | for ( auto s2 : gradient ) 59 | { 60 | if ( factor < s2.first ) 61 | { 62 | qreal ratio = (factor - s1.first) / (s2.first - s1.first); 63 | return {i, {factor, blendColors(s1.second, s2.second, ratio)}}; 64 | } 65 | s1 = s2; 66 | ++i; 67 | } 68 | 69 | return {gradient.size(), gradient.back()}; 70 | } 71 | 72 | /** 73 | * \brief Returns a color in the gradient 74 | * \param gradient Gradient stops to look into (must be properly set up) 75 | * \param factor Value in [0, 1] to get the color for 76 | */ 77 | inline QColor Q_DECL_EXPORT gradientBlendedColor(const QGradientStops& gradient, qreal factor) 78 | { 79 | return gradientBlendedColorInsert(gradient, factor).second.second; 80 | } 81 | 82 | /** 83 | * \brief Returns a color in the gradient 84 | * \param gradient Gradient to look into 85 | * \param factor Value in [0, 1] to get the color for 86 | */ 87 | inline QColor Q_DECL_EXPORT gradientBlendedColor(const QGradient& gradient, qreal factor) 88 | { 89 | return gradientBlendedColor(gradient.stops(), factor); 90 | } 91 | 92 | } // namespace color_widgets 93 | 94 | 95 | 96 | 97 | #endif // GRADIENT_HELPER_HPP 98 | 99 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/gradient_slider.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file gradient_slider.hpp 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 7 | * \copyright Copyright (C) 2014 Calle Laakkonen 8 | * \copyright Copyright (C) 2017 caryoscelus 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation, either version 3 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program. If not, see . 22 | * 23 | */ 24 | #ifndef GRADIENT_SLIDER_HPP 25 | #define GRADIENT_SLIDER_HPP 26 | 27 | #include "colorwidgets_global.hpp" 28 | 29 | #include 30 | #include 31 | 32 | namespace color_widgets { 33 | 34 | /** 35 | * \brief A slider that moves on top of a gradient 36 | */ 37 | class QCP_EXPORT GradientSlider : public QSlider 38 | { 39 | Q_OBJECT 40 | Q_PROPERTY(QBrush background READ background WRITE setBackground NOTIFY backgroundChanged) 41 | Q_PROPERTY(QGradientStops colors READ colors WRITE setColors DESIGNABLE false) 42 | Q_PROPERTY(QColor firstColor READ firstColor WRITE setFirstColor STORED false) 43 | Q_PROPERTY(QColor lastColor READ lastColor WRITE setLastColor STORED false) 44 | Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient) 45 | 46 | public: 47 | explicit GradientSlider(QWidget *parent = 0); 48 | explicit GradientSlider(Qt::Orientation orientation, QWidget *parent = 0); 49 | ~GradientSlider(); 50 | 51 | /// Get the background, it's visible for transparent gradient stops 52 | QBrush background() const; 53 | /// Set the background, it's visible for transparent gradient stops 54 | void setBackground(const QBrush &bg); 55 | 56 | /// Get the colors that make up the gradient 57 | QGradientStops colors() const; 58 | /// Set the colors that make up the gradient 59 | void setColors(const QGradientStops &colors); 60 | 61 | /// Get the gradient 62 | QLinearGradient gradient() const; 63 | /// Set the gradient 64 | void setGradient(const QLinearGradient &gradient); 65 | 66 | /** 67 | * Overload: create an evenly distributed gradient of the given colors 68 | */ 69 | void setColors(const QVector &colors); 70 | 71 | /** 72 | * \brief Set the first color of the gradient 73 | * 74 | * If the gradient is currently empty it will create a stop with the given color 75 | */ 76 | void setFirstColor(const QColor &c); 77 | 78 | /** 79 | * \brief Set the last color of the gradient 80 | * 81 | * If the gradient is has less than two colors, 82 | * it will create a stop with the given color 83 | */ 84 | void setLastColor(const QColor &c); 85 | 86 | /** 87 | * \brief Get the first color 88 | * 89 | * \returns QColor() con empty gradient 90 | */ 91 | QColor firstColor() const; 92 | 93 | /** 94 | * \brief Get the last color 95 | * 96 | * \returns QColor() con empty gradient 97 | */ 98 | QColor lastColor() const; 99 | 100 | Q_SIGNALS: 101 | void backgroundChanged(const QBrush&); 102 | 103 | protected: 104 | void paintEvent(QPaintEvent *ev) override; 105 | 106 | void mousePressEvent(QMouseEvent *ev) override; 107 | void mouseMoveEvent(QMouseEvent *ev) override; 108 | void mouseReleaseEvent(QMouseEvent *ev) override; 109 | 110 | private: 111 | class Private; 112 | Private * const p; 113 | }; 114 | 115 | } // namespace color_widgets 116 | 117 | #endif // GRADIENT_SLIDER_HPP 118 | -------------------------------------------------------------------------------- /src/gui/colordialog/QtColorWidgets/hue_slider.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \author Mattia Basaglia 5 | * 6 | * \copyright Copyright (C) 2014 Calle Laakkonen 7 | * \copyright Copyright (C) 2013-2019 Mattia Basaglia 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program. If not, see . 21 | * 22 | */ 23 | #ifndef HUE_SLIDER_HPP 24 | #define HUE_SLIDER_HPP 25 | 26 | #include "gradient_slider.hpp" 27 | 28 | namespace color_widgets { 29 | 30 | /** 31 | * \brief A slider for selecting a hue value 32 | */ 33 | class QCP_EXPORT HueSlider : public GradientSlider 34 | { 35 | Q_OBJECT 36 | /** 37 | * \brief Saturation used in the rainbow gradient, as a [0-1] float 38 | */ 39 | Q_PROPERTY(qreal colorSaturation READ colorSaturation WRITE setColorSaturation NOTIFY colorSaturationChanged) 40 | /** 41 | * \brief Value used in the rainbow gradient, as a [0-1] float 42 | */ 43 | Q_PROPERTY(qreal colorValue READ colorValue WRITE setColorValue NOTIFY colorValueChanged) 44 | /** 45 | * \brief Alpha used in the rainbow gradient, as a [0-1] float 46 | */ 47 | Q_PROPERTY(qreal colorAlpha READ colorAlpha WRITE setColorAlpha NOTIFY colorAlphaChanged) 48 | 49 | /** 50 | * \brief Color with corresponding color* components 51 | */ 52 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) 53 | 54 | /** 55 | * \brief Normalized Hue, as indicated from the slider 56 | */ 57 | Q_PROPERTY(qreal colorHue READ colorHue WRITE setColorHue NOTIFY colorHueChanged) 58 | 59 | 60 | public: 61 | explicit HueSlider(QWidget *parent = nullptr); 62 | explicit HueSlider(Qt::Orientation orientation, QWidget *parent = nullptr); 63 | ~HueSlider(); 64 | 65 | qreal colorSaturation() const; 66 | qreal colorValue() const; 67 | qreal colorAlpha() const; 68 | QColor color() const; 69 | qreal colorHue() const; 70 | 71 | public Q_SLOTS: 72 | void setColorValue(qreal value); 73 | void setColorSaturation(qreal value); 74 | void setColorAlpha(qreal alpha); 75 | void setColorHue(qreal colorHue); 76 | /** 77 | * \brief Set Hue Saturation and ColorValue, ignoring alpha 78 | */ 79 | void setColor(const QColor& color); 80 | /** 81 | * \brief Set Hue Saturation, ColorValue and Alpha 82 | */ 83 | void setFullColor(const QColor& color); 84 | 85 | Q_SIGNALS: 86 | void colorHueChanged(qreal colorHue); 87 | void colorChanged(QColor); 88 | void colorAlphaChanged(qreal v); 89 | void colorSaturationChanged(qreal v); 90 | void colorValueChanged(qreal v); 91 | 92 | private: 93 | class Private; 94 | Private * const p; 95 | }; 96 | 97 | } // namespace color_widgets 98 | 99 | #endif // HUE_SLIDER_HPP 100 | 101 | -------------------------------------------------------------------------------- /src/gui/colordialog/colordialog.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2020 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef COLORDIALOG_H 24 | #define COLORDIALOG_H 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace Ui { 35 | class ColorDialog; 36 | } 37 | 38 | class ColorDialog : public QWidget 39 | { 40 | Q_OBJECT 41 | 42 | enum Mode { 43 | FillLayout = 0, 44 | StrokeLayout = 1, 45 | ShadowLayout = 2 46 | }; 47 | 48 | 49 | public: 50 | explicit ColorDialog(QWidget *parent = nullptr); 51 | ~ColorDialog(); 52 | 53 | void setProperty(AbstractItemProperty *property); 54 | 55 | Gradient gradient() const; 56 | Color color() const; 57 | QString imagePath() const; 58 | qreal opacity() const; 59 | FillType fillType() const; 60 | Fills::FillMode fillMode() const; 61 | 62 | Mode mode() const; 63 | 64 | private: 65 | Ui::ColorDialog *ui; 66 | 67 | Mode m_mode; 68 | FillType m_fillType; 69 | Fills::FillMode m_fillMode; 70 | Color m_color; 71 | Gradient m_gradient; 72 | QString m_imagePath; 73 | qreal m_opacity; 74 | QTabBar *m_tabBar; 75 | 76 | void configurateDialog(); 77 | void selectTab(); 78 | 79 | 80 | signals: 81 | 82 | void propertyChanged(); 83 | 84 | public slots: 85 | void updateProperty(); 86 | 87 | private slots: 88 | void changeTabs(int index); 89 | 90 | }; 91 | 92 | #endif // COLORDIALOG_H 93 | -------------------------------------------------------------------------------- /src/gui/colordialog/colordialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ColorDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 300 10 | 328 11 | 12 | 13 | 14 | 15 | 300 16 | 16777215 17 | 18 | 19 | 20 | Form 21 | 22 | 23 | 24 | 4 25 | 26 | 27 | 4 28 | 29 | 30 | 4 31 | 32 | 33 | 4 34 | 35 | 36 | 37 | 38 | 0 39 | 40 | 41 | 42 | 43 | 4 44 | 45 | 46 | 4 47 | 48 | 49 | 4 50 | 51 | 52 | 4 53 | 54 | 55 | 4 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 4 66 | 67 | 68 | 4 69 | 70 | 71 | 4 72 | 73 | 74 | 4 75 | 76 | 77 | 4 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 4 88 | 89 | 90 | 4 91 | 92 | 93 | 4 94 | 95 | 96 | 4 97 | 98 | 99 | 4 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | TabImage 113 | QWidget 114 |
src/gui/colordialog/tabimage.h
115 | 1 116 |
117 | 118 | TabColors 119 | QWidget 120 |
src/gui/colordialog/tabcolors.h
121 | 1 122 |
123 |
124 | 125 | 126 |
127 | -------------------------------------------------------------------------------- /src/gui/colordialog/colorinput.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2020 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "colorinput.h" 24 | #include "ui_colorinput.h" 25 | #include 26 | 27 | #include 28 | 29 | ColorInput::ColorInput(QWidget *parent) : 30 | QWidget(parent), 31 | ui(new Ui::ColorInput) 32 | { 33 | ui->setupUi(this); 34 | connectSlots(); 35 | } 36 | 37 | ColorInput::~ColorInput() 38 | { 39 | delete ui; 40 | } 41 | 42 | void ColorInput::connectSlots() 43 | { 44 | connect(ui->sbRed, QOverload::of(&QSpinBox::valueChanged), this, &ColorInput::updateColor); 45 | connect(ui->sbGreen, QOverload::of(&QSpinBox::valueChanged), this, &ColorInput::updateColor); 46 | connect(ui->sbBlue, QOverload::of(&QSpinBox::valueChanged), this, &ColorInput::updateColor); 47 | connect(ui->sbAlpha, QOverload::of(&QSpinBox::valueChanged), this, &ColorInput::updateColor); 48 | connect(ui->txtHex, &color_widgets::ColorLineEdit::returnPressed, this, &ColorInput::updateColor); 49 | } 50 | 51 | void ColorInput::disconnectSlots() 52 | { 53 | disconnect(ui->sbRed, QOverload::of(&QSpinBox::valueChanged), this, &ColorInput::updateColor); 54 | disconnect(ui->sbGreen, QOverload::of(&QSpinBox::valueChanged), this, &ColorInput::updateColor); 55 | disconnect(ui->sbBlue, QOverload::of(&QSpinBox::valueChanged), this, &ColorInput::updateColor); 56 | disconnect(ui->sbAlpha, QOverload::of(&QSpinBox::valueChanged), this, &ColorInput::updateColor); 57 | disconnect(ui->txtHex, &color_widgets::ColorLineEdit::returnPressed, this, &ColorInput::updateColor); 58 | } 59 | 60 | void ColorInput::setColor(const Color color) 61 | { 62 | disconnectSlots(); 63 | 64 | m_color = color; 65 | ui->txtHex->setColor(m_color); 66 | ui->sbRed->setValue( color.red() ); 67 | ui->sbGreen->setValue( color.green() ); 68 | ui->sbBlue->setValue( color.blue() ); 69 | ui->sbAlpha->setValue( qRound(m_color.alphaF() * 100) ); 70 | 71 | connectSlots(); 72 | } 73 | 74 | 75 | /*! 76 | * \brief Update color that changed by input 77 | */ 78 | void ColorInput::updateColor() 79 | { 80 | color_widgets::ColorLineEdit *hexEdit = dynamic_cast(sender()); 81 | 82 | if(hexEdit){ 83 | m_color = ui->txtHex->color(); 84 | m_color.setAlphaF( ui->sbAlpha->value() / 100.0 ); 85 | }else{ 86 | m_color.setRgb(ui->sbRed->value(), ui->sbGreen->value(), ui->sbBlue->value() ); 87 | m_color.setAlphaF( ui->sbAlpha->value() / 100.0 ); 88 | } 89 | 90 | setColor( m_color); 91 | 92 | emit colorChanged( m_color); 93 | } 94 | 95 | //void ColorInput::updateAlpha() 96 | //{ 97 | // // setColor( m_color, ui->sbAlpha->value()); 98 | 99 | // emit alphaChanged( m_alpha); 100 | //} 101 | -------------------------------------------------------------------------------- /src/gui/colordialog/colorinput.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2020 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef COLORINPUT_H 24 | #define COLORINPUT_H 25 | 26 | #include 27 | #include 28 | 29 | namespace Ui { 30 | class ColorInput; 31 | } 32 | 33 | class ColorInput : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit ColorInput(QWidget *parent = nullptr); 39 | ~ColorInput(); 40 | 41 | private: 42 | Ui::ColorInput *ui; 43 | Color m_color; 44 | // int m_alpha; 45 | 46 | void connectSlots(); 47 | void disconnectSlots(); 48 | 49 | public slots: 50 | void setColor(const Color color); 51 | 52 | private slots: 53 | void updateColor(); 54 | // void updateAlpha(); 55 | 56 | signals: 57 | void colorChanged(Color color); 58 | // void alphaChanged(int alpha); 59 | 60 | }; 61 | 62 | #endif // COLORINPUT_H 63 | -------------------------------------------------------------------------------- /src/gui/colordialog/tabcolors.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2020 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef TABSOLID_H 24 | #define TABSOLID_H 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | namespace Ui { 33 | class TabColors; 34 | } 35 | 36 | class TabColors : public QWidget 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | explicit TabColors(QWidget *parent = nullptr); 42 | ~TabColors(); 43 | 44 | Color color() const; 45 | Gradient gradient() const; 46 | 47 | void enableGradientControls(bool enabled); 48 | 49 | private: 50 | Ui::TabColors *ui; 51 | 52 | color_widgets::Color2DSlider * m_colorMap2D; 53 | Color m_color; 54 | Gradient m_gradient; 55 | 56 | void connectSlots(); 57 | void disconnectSlots(); 58 | 59 | public slots: 60 | 61 | void setColor(Color color); 62 | void setGradient(Gradient gradient); 63 | 64 | private slots: 65 | void updateHue(qreal hue); 66 | void updateColor(Color color); 67 | void updateAlpha(int alpha); 68 | void updateGradient(QGradientStops stops); 69 | void updateGradientStop(int stop); 70 | 71 | signals: 72 | void colorChanged(); 73 | void gradientChanged(); 74 | 75 | }; 76 | 77 | #endif // TABSOLID_H 78 | -------------------------------------------------------------------------------- /src/gui/colordialog/tabcolors.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | TabColors 4 | 5 | 6 | 7 | 0 8 | 0 9 | 254 10 | 160 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 4 19 | 20 | 21 | 0 22 | 23 | 24 | 4 25 | 26 | 27 | 0 28 | 29 | 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 4 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 4 50 | 51 | 52 | 4 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | Qt::Vertical 74 | 75 | 76 | 77 | 20 78 | 40 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | ColorInput 88 | QWidget 89 |
src/gui/colordialog/colorinput.h
90 | 1 91 |
92 | 93 | LayoutSection 94 | QWidget 95 |
src/gui/widgets/layoutsection.h
96 | 1 97 |
98 | 99 | color_widgets::ColorPreview 100 | QWidget 101 |
src/gui/colordialog/QtColorWidgets/color_preview.hpp
102 | 1 103 |
104 | 105 | color_widgets::HueSlider 106 | QWidget 107 |
src/gui/colordialog/QtColorWidgets/hue_slider.hpp
108 | 1 109 |
110 | 111 | color_widgets::GradientSlider 112 | QWidget 113 |
src/gui/colordialog/QtColorWidgets/gradient_slider.hpp
114 | 1 115 |
116 | 117 | color_widgets::GradientEditor 118 | QWidget 119 |
src/gui/colordialog/QtColorWidgets/gradient_editor.hpp
120 | 1 121 |
122 |
123 | 124 | 125 |
126 | -------------------------------------------------------------------------------- /src/gui/colordialog/tabimage.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2020 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef TABIMAGE_H 24 | #define TABIMAGE_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace Ui { 32 | class TabImage; 33 | } 34 | 35 | class TabImage : public QWidget 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit TabImage(QWidget *parent = nullptr); 41 | ~TabImage(); 42 | 43 | QString imagePath() const; 44 | void setImagePath(const QString path); 45 | 46 | Fills::FillMode fillMode() const; 47 | void setFillMode(Fills::FillMode fillMode); 48 | 49 | private: 50 | Ui::TabImage *ui; 51 | 52 | QString m_imagePath; 53 | Fills::FillMode m_fillMode; 54 | QComboBox *m_comboFillMode; 55 | QLabel *m_labelFillMode; 56 | QLabel *m_preview; 57 | 58 | void connectSlots(); 59 | void disconnectSlots(); 60 | 61 | bool loadFile(const QString &fileName); 62 | 63 | public slots: 64 | 65 | void updateProperty(); 66 | 67 | private slots: 68 | void open(); 69 | 70 | 71 | signals: 72 | void imageChanged(); 73 | 74 | }; 75 | 76 | #endif // TABIMAGE_H 77 | -------------------------------------------------------------------------------- /src/gui/colordialog/tabimage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | TabImage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 300 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 4 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 10 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Qt::Vertical 39 | 40 | 41 | 42 | 20 43 | 40 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | LayoutSection 53 | QWidget 54 |
src/gui/widgets/layoutsection.h
55 | 1 56 |
57 |
58 | 59 | 60 |
61 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ITEMPROPERTIES_H 24 | #define ITEMPROPERTIES_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | namespace Ui { 39 | class ItemProperties; 40 | } 41 | 42 | class ItemProperties : public QWidget 43 | { 44 | Q_OBJECT 45 | 46 | public: 47 | explicit ItemProperties(QScrollArea * container, QWidget *parent = nullptr); 48 | ~ItemProperties(); 49 | 50 | public slots: 51 | void setActiveItems(QList items); 52 | 53 | signals: 54 | void exportItem(AbstractItemBase *item); 55 | void itemsChanged(); 56 | 57 | private: 58 | Ui::ItemProperties *ui; 59 | 60 | ipGeometry * itemGeometry; 61 | ipFills * itemFills; 62 | ipStrokes * itemStrokes; 63 | ipShadows * itemShadows; 64 | ipInnerShadows * itemInnerShadows; 65 | ipExportLevels * itemExportLevels; 66 | 67 | void setupGeometry(); 68 | void setupFills(); 69 | void setupStrokes(); 70 | void setupShadows(); 71 | void setupInnerShadows(); 72 | void setupExportLevel(); 73 | 74 | }; 75 | 76 | #endif // ITEMPROPERTIES_H 77 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ItemProperties 4 | 5 | 6 | 7 | 0 8 | 0 9 | 300 10 | 359 11 | 12 | 13 | 14 | Item Properties 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 4 22 | 23 | 24 | 4 25 | 26 | 27 | 4 28 | 29 | 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_exportlevel.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef IP_EXPORT_H 24 | #define IP_EXPORT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace Ui { 38 | class ipExportLevel; 39 | } 40 | 41 | class ipExportLevels : public QWidget 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | explicit ipExportLevels(QWidget *parent = nullptr); 47 | ~ipExportLevels(); 48 | 49 | void setActiveItem(AbstractItemBase *item); 50 | 51 | private: 52 | Ui::ipExportLevel *ui; 53 | 54 | AbstractItemBase *m_item; 55 | QList*m_propertyItemList; 56 | 57 | void loadProperties(); 58 | void resetItems(); 59 | void unloadItems(); 60 | void loadExportLevels(); 61 | void addExportLevel(PropertyExportLevel *propertyItem); 62 | void removeExportLevel(PropertyExportLevel *propertyItem); 63 | 64 | 65 | signals: 66 | void sendCollapse(bool); 67 | void exportItem(AbstractItemBase *item); 68 | void itemsChanged(); 69 | 70 | public slots: 71 | void newExportLevel(); 72 | 73 | private slots: 74 | void updateItem(); 75 | void doExport(); 76 | }; 77 | 78 | #endif // IP_EXPORT_H 79 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_exportlevel.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ipExportLevel 4 | 5 | 6 | 7 | 0 8 | 0 9 | 250 10 | 35 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | Form 21 | 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 0 34 | 35 | 36 | 0 37 | 38 | 39 | 40 | 41 | 0 42 | 43 | 44 | 45 | 46 | 47 | 48 | Qt::Vertical 49 | 50 | 51 | QSizePolicy::MinimumExpanding 52 | 53 | 54 | 55 | 20 56 | 8 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Export 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_fills.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef IP_FILLS_H 24 | #define IP_FILLS_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace Ui { 37 | class ipFills; 38 | } 39 | 40 | class ipFills : public QWidget 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | explicit ipFills(QWidget *parent = nullptr); 46 | ~ipFills(); 47 | 48 | void setActiveItem(AbstractItemBase *item); 49 | 50 | private: 51 | Ui::ipFills *ui; 52 | 53 | ItemBase *m_item; 54 | QList*m_propertyItemList; 55 | 56 | void loadProperties(); 57 | void resetItems(); 58 | void unloadItems(); 59 | void loadFills(); 60 | void addFill(PropertyFill *propertyItem); 61 | void removeFill(PropertyFill *propertyItem); 62 | 63 | signals: 64 | void sendCollapse(bool); 65 | void enabled(bool); 66 | void itemsChanged(); 67 | 68 | public slots: 69 | void newFill(); 70 | 71 | private slots: 72 | void updateItem(); 73 | }; 74 | 75 | #endif // IP_FILLS_H 76 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_fills.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ipFills 4 | 5 | 6 | 7 | 0 8 | 0 9 | 250 10 | 56 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | Form 21 | 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 0 34 | 35 | 36 | 0 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_geometry.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef IP_GEOMETRY_H 24 | #define IP_GEOMETRY_H 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace Ui { 37 | class ip_geometry; 38 | } 39 | 40 | class ipGeometry : public QWidget 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | explicit ipGeometry(QWidget *parent = nullptr); 46 | ~ipGeometry(); 47 | 48 | void setActiveItem(AbstractItemBase *item); 49 | 50 | private: 51 | Ui::ip_geometry *ui; 52 | 53 | AbstractItemBase *m_item; 54 | ButtonGroup *btnGroup; 55 | ButtonGroupButton *btnFree; 56 | ButtonGroupButton *btnFixedHeight; 57 | ButtonGroupButton *btnFixedWidth; 58 | ButtonGroupButton *btnFixedSize; 59 | 60 | void loadProperties(); 61 | void loadGeometry(); 62 | void resetItems(); 63 | void unloadItems(); 64 | void connectSlots(); 65 | void disconnectSlots(); 66 | void updateFrameState(AbstractItemBase::FrameType frameType); 67 | 68 | private slots: 69 | void updateItem(); 70 | 71 | signals: 72 | void itemsChanged(); 73 | }; 74 | 75 | #endif // IP_GEOMETRY_H 76 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_innershadows.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef IP_INNERSHADOWS_H 24 | #define IP_INNERSHADOWS_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace Ui { 37 | class ipShadows; 38 | } 39 | 40 | class ipInnerShadows : public QWidget 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | explicit ipInnerShadows(QWidget *parent = nullptr); 46 | ~ipInnerShadows(); 47 | 48 | void setActiveItem(AbstractItemBase *item); 49 | 50 | private: 51 | Ui::ipShadows *ui; 52 | 53 | ItemBase *m_item; 54 | QList*m_propertyItemList; 55 | 56 | void loadProperties(); 57 | void resetItems(); 58 | void unloadItems(); 59 | void loadShadows(); 60 | void addShadow(PropertyShadow *propertyItem); 61 | void removeShadow(PropertyShadow *propertyItem); 62 | 63 | signals: 64 | void sendCollapse(bool); 65 | void enabled(bool); 66 | void itemsChanged(); 67 | 68 | public slots: 69 | void newShadow(); 70 | 71 | private slots: 72 | void updateItem(); 73 | }; 74 | 75 | #endif // IP_INNERSHADOWS_H 76 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_shadows.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef IP_SHADOWS_H 24 | #define IP_SHADOWS_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace Ui { 37 | class ipShadows; 38 | } 39 | 40 | class ipShadows : public QWidget 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | explicit ipShadows(QWidget *parent = nullptr); 46 | ~ipShadows(); 47 | 48 | void setActiveItem(AbstractItemBase *item); 49 | 50 | private: 51 | Ui::ipShadows *ui; 52 | 53 | ItemBase *m_item; 54 | QList*m_propertyItemList; 55 | 56 | void loadProperties(); 57 | void resetItems(); 58 | void unloadItems(); 59 | void loadShadows(); 60 | void addShadow(PropertyShadow *propertyItem); 61 | void removeShadow(PropertyShadow *propertyItem); 62 | 63 | signals: 64 | void sendCollapse(bool); 65 | void enabled(bool); 66 | void itemsChanged(); 67 | 68 | public slots: 69 | void newShadow(); 70 | 71 | private slots: 72 | void updateItem(); 73 | }; 74 | 75 | #endif // IP_SHADOWS_H 76 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_shadows.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ipShadows 4 | 5 | 6 | 7 | 0 8 | 0 9 | 250 10 | 56 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | Form 21 | 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 0 34 | 35 | 36 | 0 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_strokes.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef IP_STROKES_H 24 | #define IP_STROKES_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace Ui { 37 | class ipStrokes; 38 | } 39 | 40 | class ipStrokes : public QWidget 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | explicit ipStrokes(QWidget *parent = nullptr); 46 | ~ipStrokes(); 47 | 48 | void setActiveItem(AbstractItemBase *item); 49 | 50 | private: 51 | Ui::ipStrokes *ui; 52 | 53 | ItemBase *m_item; 54 | QList*m_propertyItemList; 55 | 56 | void loadProperties(); 57 | void resetItems(); 58 | void unloadItems(); 59 | void loadStrokes(); 60 | void addStroke(PropertyStroke *propertyItem); 61 | void removeStroke(PropertyStroke *propertyItem); 62 | 63 | signals: 64 | void sendCollapse(bool); 65 | void enabled(bool); 66 | void itemsChanged(); 67 | 68 | public slots: 69 | void newStroke(); 70 | 71 | private slots: 72 | void updateItem(); 73 | }; 74 | 75 | #endif // IP_STROKES_H 76 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/ip_strokes.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ipStrokes 4 | 5 | 6 | 7 | 0 8 | 0 9 | 250 10 | 56 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | Form 21 | 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 0 34 | 35 | 36 | 0 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/propertyexportlevel.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef PROPERTYEXPORTLEVEL_H 24 | #define PROPERTYEXPORTLEVEL_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | namespace Ui { 32 | class propertyExportLevel; 33 | } 34 | 35 | class PropertyExportLevel : public QWidget 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit PropertyExportLevel(QWidget *parent = nullptr); 41 | explicit PropertyExportLevel(ExportLevel exportLevel, QWidget *parent = nullptr); 42 | ~PropertyExportLevel(); 43 | 44 | void setExportLevel(ExportLevel exportLevel); 45 | ExportLevel exportLevel() const; 46 | 47 | private: 48 | Ui::propertyExportLevel *ui; 49 | 50 | ExportLevel m_exportLevel; 51 | 52 | void drawFill(ExportLevel exportLevel); 53 | void connectSlots(); 54 | void disconnectSlots(); 55 | 56 | signals: 57 | void remove(PropertyExportLevel*); 58 | void hasChanged(bool); 59 | 60 | private slots: 61 | void removeClick(); 62 | void updateFill(); 63 | 64 | }; 65 | 66 | #endif // PROPERTYEXPORTLEVEL_H 67 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/propertyfill.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef PROPERTYFILL_H 24 | #define PROPERTYFILL_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace Ui { 33 | class propertyFill; 34 | } 35 | 36 | class PropertyFill : public QWidget 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | explicit PropertyFill(QWidget *parent = nullptr); 42 | explicit PropertyFill(Fills fill, QWidget *parent = nullptr); 43 | ~PropertyFill(); 44 | 45 | void setFill(Fills fill); 46 | Fills fill() const; 47 | 48 | private: 49 | Ui::propertyFill *ui; 50 | 51 | Fills m_property; 52 | 53 | ColorDialog * m_colorDialog; 54 | 55 | void drawFill(Fills property); 56 | void connectSlots(); 57 | void disconnectSlots(); 58 | 59 | private slots: 60 | void updateProperty(); 61 | void updateFill(); 62 | void updateOpacity(); 63 | 64 | signals: 65 | void hasChanged(bool); 66 | void remove(PropertyFill*); 67 | 68 | }; 69 | 70 | #endif // PROPERTYFILL_H 71 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/propertyshadow.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef PROPERTYSHADOW_H 24 | #define PROPERTYSHADOW_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | namespace Ui { 33 | class propertyShadow; 34 | } 35 | 36 | class PropertyShadow : public QWidget 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | explicit PropertyShadow(QWidget *parent = nullptr); 42 | explicit PropertyShadow(Shadow shadow, QWidget *parent = nullptr); 43 | ~PropertyShadow(); 44 | 45 | void setShadow(Shadow shadow); 46 | Shadow shadow() const; 47 | 48 | private: 49 | Ui::propertyShadow *ui; 50 | 51 | Shadow m_property; 52 | 53 | ColorDialog * m_colorDialog; 54 | 55 | void drawPreview(Shadow property); 56 | void connectSlots(); 57 | void disconnectSlots(); 58 | 59 | private slots: 60 | void updateProperty(); 61 | void updateFill(); 62 | 63 | signals: 64 | void hasChanged(bool); 65 | void remove(PropertyShadow*); 66 | }; 67 | 68 | #endif // PROPERTYSHADOW_H 69 | -------------------------------------------------------------------------------- /src/gui/tool_itemproperties/propertystroke.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef PROPERTYSTROKE_H 24 | #define PROPERTYSTROKE_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace Ui { 34 | class propertyStroke; 35 | } 36 | 37 | class PropertyStroke : public QWidget 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit PropertyStroke(QWidget *parent = nullptr); 43 | explicit PropertyStroke(Stroke stroke, QWidget *parent = nullptr); 44 | ~PropertyStroke(); 45 | 46 | void setStroke(Stroke stroke); 47 | Stroke stroke() const; 48 | 49 | private: 50 | Ui::propertyStroke *ui; 51 | 52 | Stroke m_property; 53 | ColorDialog * m_colorDialog; 54 | 55 | ButtonGroup *m_position; 56 | ButtonGroupButton * btn_center; 57 | ButtonGroupButton * btn_outer; 58 | ButtonGroupButton * btn_inner; 59 | 60 | void drawPreview(Stroke property); 61 | void connectSlots(); 62 | void disconnectSlots(); 63 | 64 | private slots: 65 | void updateProperty(); 66 | void updateFill(); 67 | 68 | signals: 69 | void hasChanged(bool); 70 | void remove(PropertyStroke*); 71 | }; 72 | 73 | #endif // PROPERTYSTROKE_H 74 | -------------------------------------------------------------------------------- /src/gui/tool_outliner.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "tool_outliner.h" 24 | #include "ui_tool_outliner.h" 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | Outliner::Outliner(QWidget *parent) : 32 | QWidget(parent), 33 | ui(new Ui::Outliner) 34 | { 35 | ui->setupUi(this); 36 | ui->treeWidget->setHeaderLabel("Artboards"); 37 | } 38 | 39 | Outliner::~Outliner() 40 | { 41 | delete ui; 42 | } 43 | 44 | /*************************************************** 45 | * 46 | * Members 47 | * 48 | ***************************************************/ 49 | 50 | void Outliner::updateList() 51 | { 52 | CanvasView *canvas = static_cast(sender()); 53 | 54 | if(canvas){ 55 | 56 | ui->treeWidget->clear(); 57 | 58 | foreach(Artboard* artboard, canvas->artboardList()){ 59 | QTreeWidgetItem * twi = new QTreeWidgetItem(); 60 | twi->setText(0, artboard->name()); 61 | 62 | foreach(AbstractItemBase *item, artboard->childItems()){ 63 | QTreeWidgetItem * twc = new QTreeWidgetItem(); 64 | twc->setText(0, item->name()); 65 | twi->addChild(twc); 66 | 67 | } 68 | ui->treeWidget->addTopLevelItem(twi); 69 | } 70 | 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/gui/tool_outliner.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef OUTLINER_H 24 | #define OUTLINER_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | namespace Ui { 34 | class Outliner; 35 | } 36 | 37 | class Outliner : public QWidget 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit Outliner(QWidget *parent = nullptr); 43 | ~Outliner(); 44 | 45 | public slots: 46 | void updateList(); 47 | 48 | private: 49 | Ui::Outliner *ui; 50 | }; 51 | 52 | #endif // OUTLINER_H 53 | -------------------------------------------------------------------------------- /src/gui/tool_outliner.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Outliner 4 | 5 | 6 | 7 | 0 8 | 0 9 | 267 10 | 415 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | 33 | 1 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/gui/widgets/buttongroup.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "buttongroup.h" 24 | 25 | #include 26 | #include 27 | 28 | /*************************************************** 29 | * 30 | * ButtonGroup Button 31 | * 32 | ***************************************************/ 33 | 34 | ButtonGroupButton::ButtonGroupButton(QWidget *parent) : QToolButton (parent) 35 | { 36 | setButtonType(ButtonGroupButton::Type::normal); 37 | } 38 | 39 | void ButtonGroupButton::setButtonType(ButtonGroupButton::Type type) 40 | { 41 | m_type = type; 42 | } 43 | 44 | ButtonGroupButton::Type ButtonGroupButton::buttonType() 45 | { 46 | return m_type; 47 | } 48 | 49 | void ButtonGroupButton::setData(QVariant data) 50 | { 51 | m_data = data; 52 | } 53 | 54 | QVariant ButtonGroupButton::data() 55 | { 56 | return m_data; 57 | } 58 | 59 | void ButtonGroupButton::paintEvent(QPaintEvent *event) 60 | { 61 | if(buttonType() == ButtonGroupButton::Type::normal){ 62 | QToolButton::paintEvent(event); 63 | }else{ 64 | // Should be change look of button based on type 65 | QToolButton::paintEvent(event); 66 | } 67 | 68 | // QStyleOptionButton option; 69 | // option.initFrom(this); 70 | // option.state = isDown() ? QStyle::State_Sunken : QStyle::State_Raised; 71 | // //if (isDefault()) 72 | // option.features |= QStyleOptionButton::DefaultButton; 73 | // option.text = text(); 74 | // option.icon = icon(); 75 | 76 | // QStylePainter painter(this); 77 | // painter.drawControl(QStyle::CE_PushButton, &option, &painter, this); 78 | 79 | 80 | } 81 | 82 | 83 | 84 | /*************************************************** 85 | * 86 | * ButtonGroup 87 | * 88 | ***************************************************/ 89 | 90 | ButtonGroup::ButtonGroup(QWidget *parent): QWidget(parent) 91 | { 92 | bg = new QButtonGroup; 93 | 94 | hl = new QHBoxLayout; 95 | hl->setContentsMargins(0, 0, 0, 0); 96 | hl->setMargin(0); 97 | hl->setSpacing(0); 98 | 99 | setLayout(hl); 100 | 101 | connect(bg, static_cast(&QButtonGroup::buttonPressed), 102 | [=](QAbstractButton *button){ emit buttonPressed(button); }); 103 | connect(bg, static_cast(&QButtonGroup::buttonClicked), 104 | [=](QAbstractButton *button){ emit buttonClicked(button); }); 105 | } 106 | 107 | void ButtonGroup::addButton(ButtonGroupButton *button, bool checked) 108 | { 109 | button->setCheckable(true); 110 | button->setChecked(checked); 111 | bg->addButton(button); 112 | hl->addWidget(button); 113 | } 114 | 115 | QAbstractButton *ButtonGroup::checkedButton() const 116 | { 117 | return bg->checkedButton(); 118 | } 119 | 120 | QList ButtonGroup::buttons() const 121 | { 122 | return bg->buttons(); 123 | } 124 | 125 | -------------------------------------------------------------------------------- /src/gui/widgets/buttongroup.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef BUTTONGROUP_H 24 | #define BUTTONGROUP_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class ButtonGroupButton : public QToolButton 35 | { 36 | Q_OBJECT 37 | public: 38 | 39 | enum Type{ 40 | normal = 0, 41 | left = 1, 42 | middle = 2, 43 | right = 3 44 | }; 45 | Q_ENUM(Type) 46 | 47 | ButtonGroupButton(QWidget *parent = nullptr); 48 | 49 | void setButtonType(ButtonGroupButton::Type type); 50 | ButtonGroupButton::Type buttonType(); 51 | 52 | void setData(QVariant data); 53 | QVariant data(); 54 | 55 | void paintEvent(QPaintEvent *event); 56 | 57 | protected: 58 | // void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget); 59 | 60 | private: 61 | ButtonGroupButton::Type m_type; 62 | QVariant m_data; 63 | 64 | }; 65 | 66 | 67 | class ButtonGroup : public QWidget 68 | { 69 | Q_OBJECT 70 | public: 71 | ButtonGroup(QWidget *parent = nullptr); 72 | 73 | QWidget *createButton(QString const& name,bool checked,QString const& sheet = QString()); 74 | 75 | void addButton(ButtonGroupButton *button, bool checked); 76 | 77 | QAbstractButton * checkedButton() const; 78 | QList buttons() const; 79 | 80 | signals: 81 | void buttonClicked(QAbstractButton * button); 82 | void buttonPressed(QAbstractButton * button); 83 | 84 | private: 85 | QButtonGroup *bg; 86 | QHBoxLayout *hl; 87 | }; 88 | 89 | #endif // BUTTONGROUP_H 90 | -------------------------------------------------------------------------------- /src/gui/widgets/colorbutton.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "colorbutton.h" 24 | #include 25 | #include 26 | #include 27 | 28 | ColorButton::ColorButton(QWidget *parent) : QToolButton(parent) 29 | { 30 | setPopupMode(QToolButton::InstantPopup); 31 | setStyleSheet("QToolButton::menu-indicator { image: none; }"); 32 | 33 | } 34 | 35 | void ColorButton::setIcon(const QPixmap &pixmap) 36 | { 37 | 38 | QPixmap iconPixmap(pixmap.size()); 39 | 40 | QPainter painter(&iconPixmap); 41 | 42 | QPainterPath path; 43 | path.addRect(iconPixmap.rect()); 44 | 45 | painter.fillRect(pixmap.rect(), QBrush(paintGrid()) ); 46 | painter.drawPixmap(pixmap.rect(), pixmap); 47 | 48 | QIcon icon(iconPixmap); 49 | QToolButton::setIcon(icon); 50 | } 51 | 52 | void ColorButton::setIcon(const QIcon &icon) 53 | { 54 | QToolButton::setIcon(icon); 55 | } 56 | 57 | void ColorButton::setMenu(QMenu *menu) 58 | { 59 | QToolButton::setMenu(menu); 60 | connect(this->menu(), &QMenu::aboutToShow, this, &ColorButton::openPopup); 61 | } 62 | -------------------------------------------------------------------------------- /src/gui/widgets/colorbutton.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef COLORBUTTON_H 24 | #define COLORBUTTON_H 25 | 26 | #include "popupmenu.h" 27 | 28 | #include 29 | 30 | class ColorButton : public QToolButton 31 | { 32 | 33 | Q_OBJECT 34 | 35 | public: 36 | ColorButton(QWidget *parent = nullptr); 37 | 38 | void setIcon(const QPixmap &pixmap); 39 | void setIcon(const QIcon &icon); 40 | void setMenu(QMenu *menu); 41 | 42 | private: 43 | PopupMenu * m_colorMenu; 44 | 45 | signals: 46 | void openPopup(); 47 | }; 48 | 49 | #endif // COLORBUTTON_H 50 | -------------------------------------------------------------------------------- /src/gui/widgets/flowlayout.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2016 The Qt Company Ltd. 4 | ** Contact: https://www.qt.io/licensing/ 5 | ** 6 | ** This file is part of the examples of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** Commercial License Usage 10 | ** Licensees holding valid commercial Qt licenses may use this file in 11 | ** accordance with the commercial license agreement provided with the 12 | ** Software or, alternatively, in accordance with the terms contained in 13 | ** a written agreement between you and The Qt Company. For licensing terms 14 | ** and conditions see https://www.qt.io/terms-conditions. For further 15 | ** information use the contact form at https://www.qt.io/contact-us. 16 | ** 17 | ** BSD License Usage 18 | ** Alternatively, you may use this file under the terms of the BSD license 19 | ** as follows: 20 | ** 21 | ** "Redistribution and use in source and binary forms, with or without 22 | ** modification, are permitted provided that the following conditions are 23 | ** met: 24 | ** * Redistributions of source code must retain the above copyright 25 | ** notice, this list of conditions and the following disclaimer. 26 | ** * Redistributions in binary form must reproduce the above copyright 27 | ** notice, this list of conditions and the following disclaimer in 28 | ** the documentation and/or other materials provided with the 29 | ** distribution. 30 | ** * Neither the name of The Qt Company Ltd nor the names of its 31 | ** contributors may be used to endorse or promote products derived 32 | ** from this software without specific prior written permission. 33 | ** 34 | ** 35 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 43 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 45 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 46 | ** 47 | ** $QT_END_LICENSE$ 48 | ** 49 | ****************************************************************************/ 50 | 51 | #ifndef FLOWLAYOUT_H 52 | #define FLOWLAYOUT_H 53 | 54 | #include 55 | #include 56 | #include 57 | //! [0] 58 | class FlowLayout : public QLayout 59 | { 60 | public: 61 | explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); 62 | explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); 63 | ~FlowLayout(); 64 | 65 | void addItem(QLayoutItem *item) override; 66 | int horizontalSpacing() const; 67 | int verticalSpacing() const; 68 | Qt::Orientations expandingDirections() const override; 69 | bool hasHeightForWidth() const override; 70 | int heightForWidth(int) const override; 71 | int count() const override; 72 | QLayoutItem *itemAt(int index) const override; 73 | QSize minimumSize() const override; 74 | void setGeometry(const QRect &rect) override; 75 | QSize sizeHint() const override; 76 | QLayoutItem *takeAt(int index) override; 77 | 78 | private: 79 | int doLayout(const QRect &rect, bool testOnly) const; 80 | int smartSpacing(QStyle::PixelMetric pm) const; 81 | 82 | QList itemList; 83 | int m_hSpace; 84 | int m_vSpace; 85 | }; 86 | //! [0] 87 | 88 | #endif // FLOWLAYOUT_H 89 | -------------------------------------------------------------------------------- /src/gui/widgets/intelligentspinbox.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "intelligentspinbox.h" 24 | #include 25 | #include 26 | 27 | IntelligentSpinBox::IntelligentSpinBox(QWidget *parent) : QDoubleSpinBox (parent) 28 | { 29 | /* 30 | 31 | Left part: match negative or positive number with optional comma 32 | -?\d+(?:(?:\,|\.)\d+(?:\d+)*)? 33 | 34 | Mid part: matches an arithmetic operator inclusive optional spaces 35 | (?:\s*[-+/\*]\s* 36 | 37 | Right part: match negative or positive number with optional comma 38 | -?\d+(?:(?:\,|\.)\d+(?:\d+)*)?)* 39 | 40 | Mid and right part are grouped so that they can be unlimited included in formula 41 | 42 | */ 43 | 44 | QRegExp rx("-?\\d+(?:(?:\\,|\\.)\\d+(?:\\d+)*)?(?:\\s*[-+\\/\\*]\\s*-?\\d+(?:(?:\\,|\\.)\\d+(?:\\d+)*)?)*"); 45 | validator = new QRegExpValidator(rx, this); 46 | 47 | setDecimals(1); 48 | setKeyboardTracking(false); // deactivate value change on each key press 49 | 50 | 51 | // don't support handling of suffix yet. 52 | // setSuffix("px"); 53 | 54 | 55 | } 56 | 57 | QValidator::State IntelligentSpinBox::validate(QString &text, int &pos) const 58 | { 59 | return validator->validate(text, pos); 60 | } 61 | 62 | double IntelligentSpinBox::valueFromText(const QString &text) const 63 | { 64 | QString expression_string(text); 65 | expression_string = expression_string.replace(",", "."); 66 | QScriptEngine expression; 67 | 68 | return expression.evaluate(expression_string).toNumber(); 69 | } 70 | -------------------------------------------------------------------------------- /src/gui/widgets/intelligentspinbox.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef INTELLIGENTSPINBOX_H 24 | #define INTELLIGENTSPINBOX_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class IntelligentSpinBox : public QDoubleSpinBox 31 | { 32 | public: 33 | IntelligentSpinBox(QWidget *parent = nullptr); 34 | 35 | private: 36 | // double dbl_value; 37 | // QString str_value; 38 | // QLineEdit *lineEdit; 39 | QRegExpValidator *validator; 40 | 41 | protected: 42 | QValidator::State validate(QString &text, int &pos) const; 43 | double valueFromText(const QString &text) const; 44 | }; 45 | 46 | #endif // INTELLIGENTSPINBOX_H 47 | -------------------------------------------------------------------------------- /src/gui/widgets/layoutsection.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef LAYOUTSECTION_H 24 | #define LAYOUTSECTION_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include "flowlayout.h" 30 | 31 | class LayoutSectionHeader : public QWidget 32 | { 33 | Q_OBJECT 34 | Q_CLASSINFO("Version", "1.0.0") 35 | 36 | 37 | friend class LayoutSection; 38 | 39 | public: 40 | LayoutSectionHeader(QString text, QWidget *menu = nullptr, bool toggle = false, QWidget *parent = nullptr); 41 | void addWidget(QWidget *widget); 42 | void removeWidget(QWidget *widget); 43 | 44 | private: 45 | void paintEvent(QPaintEvent *); 46 | QHBoxLayout *m_headerLayout; 47 | QLabel *m_caption; 48 | QToolButton *m_btnMenu; 49 | QToolButton *m_btnCollapse; 50 | bool m_collapsed; 51 | 52 | signals: 53 | void sendCollapsedState(bool); 54 | 55 | public slots: 56 | void setCollapsed(bool isCollapsed); 57 | 58 | private slots: 59 | void setCollapsedState(); 60 | }; 61 | 62 | 63 | class LayoutSection : public QWidget 64 | { 65 | Q_OBJECT 66 | Q_CLASSINFO("Version", "1.0.0") 67 | 68 | Q_PROPERTY(QString text READ text WRITE setText) 69 | 70 | public: 71 | LayoutSection(QWidget *parent = nullptr); 72 | LayoutSection(QString text, QWidget *menu = nullptr, bool toggle = false, QWidget *parent = nullptr); 73 | void addWidget(QWidget * item); 74 | void addHeaderWidget(QWidget *widget); 75 | void removeHeaderButton(QWidget *widget); 76 | 77 | void setText(QString text); 78 | QString text() const; 79 | 80 | private: 81 | QVBoxLayout *m_layout; 82 | LayoutSectionHeader * m_header; 83 | QWidget * m_drawer; 84 | 85 | signals: 86 | void collapsedState(bool); 87 | 88 | public slots: 89 | void setCollapsedState(bool); 90 | }; 91 | 92 | #endif // LAYOUTSECTION_H 93 | -------------------------------------------------------------------------------- /src/gui/widgets/layoutsegment.h: -------------------------------------------------------------------------------- 1 | #ifndef LAYOUTSEGMENT_H 2 | #define LAYOUTSEGMENT_H 3 | 4 | #include 5 | #include 6 | 7 | class LayoutSegment : public QWidget 8 | { 9 | private: 10 | QGridLayout * m_layout; 11 | 12 | public: 13 | LayoutSegment(QWidget *parent = nullptr); 14 | void addWidget(QWidget * item, int row, int column); 15 | void addGridLayout(QGridLayout*gridLayout); 16 | QGridLayout *getLayout(); 17 | }; 18 | 19 | #endif // LAYOUTSEGMENT_H 20 | -------------------------------------------------------------------------------- /src/gui/widgets/popupmenu.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "popupmenu.h" 24 | #include 25 | #include 26 | 27 | /*! 28 | * \brief [CTR] 29 | * \param widget 30 | */ 31 | PopupMenu::PopupMenu(QWidget *contentWidget) 32 | { 33 | if(contentWidget == nullptr) contentWidget = new QWidget(); 34 | 35 | QVBoxLayout *layout = new QVBoxLayout(); 36 | layout->addWidget(contentWidget); 37 | layout->setMargin(1); 38 | 39 | QWidget *panel = new QWidget(); 40 | panel->setMinimumSize(contentWidget->size()); 41 | panel->setLayout(layout); 42 | 43 | QWidgetAction * action = new QWidgetAction(this); 44 | action->setDefaultWidget(panel); 45 | 46 | contentWidget->installEventFilter(this); 47 | 48 | this->addAction(action); 49 | 50 | } 51 | 52 | bool PopupMenu::eventFilter(QObject *obj, QEvent *event) 53 | { 54 | 55 | // prevent that menu is close by interact with the background 56 | if (event->type() == QEvent::MouseButtonPress || 57 | event->type() == QEvent::MouseButtonDblClick || 58 | event->type() == QEvent::MouseMove) { 59 | 60 | return true; 61 | } 62 | 63 | return QObject::eventFilter(obj, event); 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/gui/widgets/popupmenu.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef POPUPMENU_H 24 | #define POPUPMENU_H 25 | 26 | #include 27 | #include 28 | 29 | class PopupMenu : public QMenu 30 | { 31 | public: 32 | PopupMenu(QWidget*contentWidget); 33 | protected: 34 | bool eventFilter(QObject *obj, QEvent *event); 35 | }; 36 | 37 | #endif // POPUPMENU_H 38 | -------------------------------------------------------------------------------- /src/item/itemgroup.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | ItemGroup::ItemGroup(QGraphicsItem *parent) : AbstractItemBase(QRectF(), parent){ 30 | // m_group = new QGraphicsItemGroup(); 31 | 32 | this->setFlag(QGraphicsItem::ItemIsSelectable, true); 33 | this->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); 34 | this->setFlag(QGraphicsItem::ItemContainsChildrenInShape, true); 35 | this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); 36 | } 37 | 38 | 39 | void ItemGroup::setRect(QRectF rect) 40 | { 41 | QPainterPath path; 42 | path.addRect(rect); 43 | setShape(path); 44 | } 45 | 46 | 47 | QRectF ItemGroup::renderRect() const 48 | { 49 | return m_renderRect; 50 | } 51 | 52 | QRectF ItemGroup::rect() const 53 | { 54 | return m_rect; 55 | } 56 | 57 | QRectF ItemGroup::boundingRect() const 58 | { 59 | return renderRect(); 60 | } 61 | 62 | void ItemGroup::addItem(AbstractItemBase *children) 63 | { 64 | QPointF itemPos = children->pos(); 65 | 66 | m_children.append(children); 67 | children->setParentItem(this); 68 | children->setVisible(false); 69 | 70 | if(m_children.isEmpty()) setPos(itemPos); 71 | 72 | QRectF rect = children->rect(); 73 | rect.moveTopLeft(itemPos); 74 | m_rect = m_rect.united(rect); 75 | 76 | QRectF renderRect = children->renderRect(); 77 | renderRect.moveTopLeft(itemPos); 78 | m_renderRect = m_renderRect.united(renderRect); 79 | 80 | 81 | 82 | qDebug() << "ItemGroup" << scenePos() << parentItem(); 83 | } 84 | 85 | QList ItemGroup::childItems() const 86 | { 87 | return m_children; 88 | } 89 | 90 | void ItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) 91 | { 92 | if(childItems().isEmpty()) return; 93 | 94 | // m_renderRect = rect(); 95 | 96 | foreach(QGraphicsItem* item, childItems()){ 97 | AbstractItemBase *abItem = dynamic_cast(item); 98 | 99 | if(abItem){ 100 | painter->translate(abItem->pos()); 101 | abItem->paint(painter,option,widget); 102 | painter->translate(-abItem->pos()); 103 | } 104 | } 105 | } 106 | 107 | void ItemGroup::render(QPainter *painter) 108 | { 109 | Q_UNUSED(painter) 110 | } 111 | -------------------------------------------------------------------------------- /src/item/itemgroup.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ITEMGROUP_H 24 | #define ITEMGROUP_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | class ItemGroup : public AbstractItemBase 31 | { 32 | 33 | public: 34 | explicit ItemGroup(QGraphicsItem *parent = nullptr); 35 | 36 | // Properties 37 | int type() const override { return Type::Group; } 38 | void setRect(QRectF rect) override; 39 | QRectF renderRect() const override; 40 | QRectF rect() const override; 41 | QRectF boundingRect() const override; 42 | 43 | 44 | // Member 45 | void addItem(AbstractItemBase *childItems) override; 46 | QList childItems() const override; 47 | 48 | 49 | // Events 50 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; 51 | void render(QPainter *painter) override; 52 | 53 | private: 54 | QList m_children; 55 | QRectF m_renderRect; 56 | QRectF m_rect; 57 | 58 | signals: 59 | 60 | public slots: 61 | }; 62 | 63 | #endif // WAGROUP_H 64 | -------------------------------------------------------------------------------- /src/item/itemoval.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include 24 | 25 | ItemOval::ItemOval(QGraphicsItem *parent) : ItemOval(0,0,80,80, parent){} 26 | ItemOval::ItemOval(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent) : ItemOval(QRectF(x,y,width,height), parent){} 27 | ItemOval::ItemOval(qreal width, qreal height, QGraphicsItem *parent) : ItemOval(QRectF(0,0,width,height), parent){} 28 | ItemOval::ItemOval(QRectF rect, QGraphicsItem *parent) : ItemBase(rect, parent){ 29 | 30 | this->setRect(rect); 31 | this->setName(tr("Oval")); 32 | 33 | } 34 | 35 | ItemOval::ItemOval(const ItemOval &other) : ItemBase(other){} 36 | 37 | bool ItemOval::operator==(const ItemOval &other) const 38 | { 39 | if(this == &other) return true; 40 | 41 | return ItemBase::operator==(other); 42 | } 43 | 44 | /*************************************************** 45 | * 46 | * Properties 47 | * 48 | ***************************************************/ 49 | 50 | void ItemOval::setRect(QRectF rect) 51 | { 52 | switch(frameType()){ 53 | case AbstractItemBase::FixedWidth: 54 | rect.setWidth(this->rect().width()); 55 | break; 56 | case AbstractItemBase::FixedHeight: 57 | rect.setHeight(this->rect().height()); 58 | break; 59 | case AbstractItemBase::FixedSize: 60 | rect = this->rect(); 61 | break; 62 | case AbstractItemBase::Free: 63 | break; 64 | } 65 | 66 | QPainterPath path; 67 | path.addEllipse(rect); 68 | ItemBase::setShape(path); 69 | calculateRenderRect(); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/item/itemoval.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ITEMOVAL_H 24 | #define ITEMOVAL_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | class ItemOval : public ItemBase 33 | { 34 | Q_CLASSINFO("Version", "1.0.0") 35 | 36 | Q_PROPERTY(QRect rect READ rect WRITE setRect) 37 | 38 | public: 39 | ItemOval(qreal x, qreal y, qreal width, qreal height, QGraphicsItem * parent = nullptr); 40 | ItemOval(qreal width, qreal height, QGraphicsItem * parent = nullptr); 41 | ItemOval(QRectF rect, QGraphicsItem * parent = nullptr); 42 | ItemOval(QGraphicsItem * parent = nullptr); 43 | ItemOval(const ItemOval &other); 44 | 45 | 46 | // operator 47 | bool operator==( const ItemOval & other ) const; 48 | inline bool operator!=(const ItemOval &itemBase) const; 49 | 50 | 51 | // Properties 52 | int type() const override { return Type::Oval; } 53 | void setRect(QRectF rect) override; 54 | 55 | }; 56 | 57 | #endif // ITEMOVAL_H 58 | -------------------------------------------------------------------------------- /src/item/itempolygon.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2020 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ITEMSTAR_H 24 | #define ITEMSTAR_H 25 | 26 | #include 27 | 28 | class ItemPolygon : public ItemBase 29 | { 30 | Q_CLASSINFO("Version", "1.0.0") 31 | 32 | Q_PROPERTY(QRect rect READ rect WRITE setRect) 33 | Q_PROPERTY(bool useInnerRadius READ useInnerRadius WRITE setUseInnerRadius) 34 | Q_PROPERTY(qreal innerRadius READ innerRadius WRITE setInnerRadius) 35 | Q_PROPERTY(int sides READ sides WRITE setSides) 36 | 37 | public: 38 | ItemPolygon(qreal x, qreal y, qreal width, qreal height, int sides = 10, bool useInnerRadius = false, QGraphicsItem * parent = nullptr); 39 | ItemPolygon(qreal width, qreal height, int sides = 10, bool useInnerRadius = false, QGraphicsItem * parent = nullptr); 40 | ItemPolygon(QRectF rect, int sides = 10, bool useInnerRadius = false, QGraphicsItem * parent = nullptr); 41 | ItemPolygon(QGraphicsItem * parent = nullptr); 42 | ItemPolygon(const ItemPolygon &other); 43 | 44 | 45 | // operator 46 | bool operator==( const ItemPolygon & other ) const; 47 | inline bool operator!=(const ItemPolygon &itemBase) const; 48 | 49 | 50 | // Properties 51 | int type() const override { return Type::Polygon; } 52 | void setSides(int count); 53 | int sides() const; 54 | void setInnerRadius(qreal length); 55 | qreal innerRadius() const; 56 | void setUseInnerRadius(bool allow); 57 | bool useInnerRadius() const; 58 | 59 | void setRect(QRectF rect) override; 60 | virtual QPainterPath shapeScaled(QRectF frame) const; 61 | 62 | private: 63 | int m_sides; 64 | qreal m_innerRadius; 65 | bool m_useInnerRadius; 66 | 67 | }; 68 | 69 | #endif // ITEMSTAR_H 70 | -------------------------------------------------------------------------------- /src/item/itemrect.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ITEMRECT_H 24 | #define ITEMRECT_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | class ItemRect : public ItemBase 33 | { 34 | 35 | Q_CLASSINFO("Version", "1.0.0") 36 | 37 | Q_PROPERTY(QRect rect READ rect WRITE setRect) 38 | Q_PROPERTY(qreal radius READ radius WRITE setRadius) 39 | 40 | public: 41 | ItemRect(qreal x, qreal y, qreal width, qreal height, QGraphicsItem * parent = nullptr); 42 | ItemRect(qreal width, qreal height, QGraphicsItem * parent = nullptr); 43 | ItemRect(QRectF rect, QGraphicsItem * parent = nullptr); 44 | ItemRect(QGraphicsItem * parent = nullptr); 45 | ItemRect(const ItemRect &other); 46 | 47 | 48 | // operator 49 | bool operator==( const ItemRect & other ) const; 50 | inline bool operator!=(const ItemRect &itemBase) const; 51 | 52 | 53 | // Properties 54 | int type() const override { return Type::Rect; } 55 | void setRadius(qreal radius); 56 | void setRadius(qreal topleft, qreal topright, qreal bottomright, qreal bottomleft); 57 | qreal radius() const; 58 | void setRect(QRectF rect) override; 59 | virtual QPainterPath shapeScaled(QRectF frame) const; 60 | // virtual QPainterPath shapeScaled2(QRectF frame, qreal scaleFactor, qreal offset = 0, Stroke stroke = Stroke("tmp",QBrush(Qt::transparent),0, StrokePosition::Center)) const; 61 | 62 | private: 63 | 64 | qreal m_radiusTL; 65 | qreal m_radiusTR; 66 | qreal m_radiusBR; 67 | qreal m_radiusBL; 68 | }; 69 | 70 | #endif // WARECT_H 71 | -------------------------------------------------------------------------------- /src/item/itemtext.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ITEMTEXT_H 24 | #define ITEMTEXT_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | 35 | 36 | class ItemText: public ItemBase 37 | { 38 | public: 39 | ItemText(const QString &text, QGraphicsItem * parent = nullptr); 40 | ItemText(const ItemText &other); 41 | 42 | 43 | // operator 44 | bool operator==( const ItemText & other ) const; 45 | inline bool operator!=(const ItemText &itemBase) const; 46 | 47 | 48 | // Properties 49 | int type() const override { return Type::Text; } 50 | 51 | void setRect(QRectF rect) override; 52 | 53 | void setText(const QString text); 54 | QString text() const; 55 | 56 | void setFont(const QFont font); 57 | QFont font() const; 58 | 59 | void setFontSize(int pixelSize); 60 | int fontSize() const; 61 | 62 | void setTextColor(const QColor color); 63 | QColor textColor() const; 64 | 65 | void setAlignment(Qt::Alignment alignment); 66 | Qt::Alignment alignment() const; 67 | 68 | void setLineHeight(qreal lineHeight); 69 | qreal lineHeight() const; 70 | 71 | // Events 72 | void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override; 73 | 74 | private: 75 | // QGraphicsTextItem *m_text; 76 | QTextDocument * m_text; 77 | QColor m_color; 78 | int m_lineHeight; 79 | 80 | void refreshFrame(); 81 | 82 | // QList layouts; 83 | // QStringList paragraphs; 84 | // QList > formats; 85 | 86 | protected: 87 | // virtual void focusOutEvent (QFocusEvent * event); 88 | // virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event); 89 | 90 | // QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); 91 | // void SetTextInteraction(bool on, bool selectAll = false); 92 | }; 93 | 94 | #endif // WATEXT_H 95 | -------------------------------------------------------------------------------- /src/item/members/abstractitemproperty.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ABSTRACTITEMPROPERTY_H 24 | #define ABSTRACTITEMPROPERTY_H 25 | 26 | #include 27 | #include 28 | 29 | class AbstractItemProperty 30 | { 31 | 32 | friend class Fills; 33 | friend class Stroke; 34 | friend class Gradient; 35 | friend class Shadow; 36 | friend class ExportLevel; 37 | 38 | Q_CLASSINFO("Version", "1.0.0") 39 | 40 | Q_PROPERTY(QString name READ name WRITE setName) 41 | Q_PROPERTY(bool isOn READ isOn WRITE setIsOn) 42 | Q_PROPERTY(QPainter::CompositionMode blendMode READ blendMode WRITE setBlendMode) 43 | 44 | public: 45 | 46 | enum Type { 47 | Fill = 0, 48 | Stroke = 1, 49 | Shadow = 2 50 | }; 51 | 52 | AbstractItemProperty(); 53 | AbstractItemProperty(const QString name, QPainter::CompositionMode compositionMode = QPainter::CompositionMode_SourceOver, bool isOn = true); 54 | // AbstractItemProperty(const AbstractItemProperty &other); 55 | AbstractItemProperty(const AbstractItemProperty &) = default; 56 | 57 | ~AbstractItemProperty() = default; 58 | 59 | // operator 60 | AbstractItemProperty &operator=(const AbstractItemProperty &) = default; 61 | bool operator==( const AbstractItemProperty & other ) const; 62 | inline bool operator!=(const AbstractItemProperty &other) const { return !(operator==(other)); } 63 | friend QDataStream &operator<<(QDataStream &out, const AbstractItemProperty &obj); 64 | friend QDataStream &operator>>(QDataStream &in, AbstractItemProperty &obj); 65 | 66 | 67 | // Properties 68 | void setID(const QString id); 69 | QString ID() const; 70 | 71 | void setName(const QString name); 72 | QString name() const; 73 | 74 | void setBlendMode(QPainter::CompositionMode compositionMode); 75 | QPainter::CompositionMode blendMode() const; 76 | 77 | void setIsOn(bool isOn); 78 | bool isOn() const; 79 | 80 | virtual Type type() const; 81 | 82 | 83 | private: 84 | QString m_id; 85 | QString m_name; 86 | QPainter::CompositionMode m_blendMode; 87 | bool m_isOn; 88 | Type m_type; 89 | 90 | 91 | 92 | }; 93 | Q_DECLARE_METATYPE(AbstractItemProperty) 94 | 95 | #ifndef QT_NO_DEBUG_STREAM 96 | QDebug operator<<(QDebug dbg, const AbstractItemProperty &obj); 97 | #endif 98 | 99 | //QDataStream &operator<<(QDataStream &out, const AbstractItemProperty &obj); 100 | //QDataStream &operator>>(QDataStream &in, AbstractItemProperty &obj); 101 | 102 | #endif // ABSTRACTITEMPROPERTY_H 103 | -------------------------------------------------------------------------------- /src/item/members/abstractproperty.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "abstractproperty.h" 24 | #include 25 | #include 26 | 27 | AbstractProperty::AbstractProperty() : AbstractProperty(QString()) {} 28 | AbstractProperty::AbstractProperty(const QString name) 29 | { 30 | QRandomGenerator *random = QRandomGenerator::global(); 31 | quint32 value32 = random->generate(); 32 | QString hexvalue = QString("0x%1").arg(value32, 8, 16, QLatin1Char( '0' )); 33 | 34 | m_id = hexvalue; //static_cast(value32); 35 | m_caption = name; 36 | } 37 | 38 | //AbstractProperty::AbstractProperty(const AbstractProperty &other) 39 | //{ 40 | // m_id = other.m_id; 41 | // m_caption = other.m_caption; 42 | //} 43 | 44 | /*************************************************** 45 | * 46 | * Properties 47 | * 48 | ***************************************************/ 49 | 50 | QString AbstractProperty::ID() const 51 | { 52 | return m_id; 53 | } 54 | 55 | void AbstractProperty::setCaption(const QString name) 56 | { 57 | m_caption = name; 58 | } 59 | 60 | QString AbstractProperty::caption() const{ 61 | return m_caption; 62 | } 63 | 64 | 65 | /*************************************************** 66 | * 67 | * Operator 68 | * 69 | ***************************************************/ 70 | 71 | bool AbstractProperty::operator==(const AbstractProperty &other) const 72 | { 73 | if(this == &other) return true; 74 | 75 | return m_id == other.m_id && 76 | m_caption == other.m_caption; 77 | } 78 | 79 | void AbstractProperty::setID(const QString id) 80 | { 81 | m_id = id; 82 | } 83 | 84 | QDebug operator<<(QDebug dbg, const AbstractProperty &obj) 85 | { 86 | dbg << obj.ID() << 87 | obj.caption(); 88 | return dbg.maybeSpace(); 89 | } 90 | 91 | 92 | QDataStream &operator<<(QDataStream &out, const AbstractProperty &obj) 93 | { 94 | out << obj.ID() 95 | << obj.caption(); 96 | 97 | return out; 98 | } 99 | 100 | QDataStream &operator>>(QDataStream &in, AbstractProperty &obj) 101 | { 102 | in >> obj.m_id; 103 | in >> obj.m_caption; 104 | 105 | return in; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /src/item/members/abstractproperty.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef ABSTRACTPROPERTY_H 24 | #define ABSTRACTPROPERTY_H 25 | 26 | #include 27 | #include 28 | 29 | class AbstractProperty 30 | { 31 | 32 | friend class Gradient; 33 | friend class ExportLevel; 34 | friend class Color; 35 | 36 | Q_CLASSINFO("Version", "1.0.0") 37 | 38 | Q_PROPERTY(QString caption READ caption WRITE setCaption) 39 | 40 | public: 41 | AbstractProperty(); 42 | AbstractProperty(const QString caption); 43 | // AbstractProperty(const AbstractProperty &other); 44 | AbstractProperty(const AbstractProperty &) = default; 45 | 46 | // operator 47 | AbstractProperty &operator=(const AbstractProperty &) = default; 48 | bool operator==( const AbstractProperty & other ) const; 49 | inline bool operator!=(const AbstractProperty &other) const { return !(operator==(other)); } 50 | friend QDataStream &operator<<(QDataStream &out, const AbstractProperty &obj); 51 | friend QDataStream &operator>>(QDataStream &in, AbstractProperty &obj); 52 | 53 | 54 | // Properties 55 | void setID(const QString id); 56 | QString ID() const; 57 | 58 | void setCaption(const QString caption); 59 | QString caption() const; 60 | 61 | private: 62 | QString m_id; 63 | QString m_caption; 64 | 65 | }; 66 | Q_DECLARE_METATYPE(AbstractProperty) 67 | 68 | #ifndef QT_NO_DEBUG_STREAM 69 | QDebug operator<<(QDebug dbg, const AbstractProperty &shadow); 70 | #endif 71 | 72 | #endif // ABSTRACTPROPERTY_H 73 | -------------------------------------------------------------------------------- /src/item/members/color.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "color.h" 24 | 25 | #include 26 | 27 | /*************************************************** 28 | * 29 | * Constructor 30 | * 31 | ***************************************************/ 32 | 33 | Color::Color() : Color(QColor(Qt::black)){} 34 | Color::Color(const QString name, QColor color) : AbstractProperty(name), QColor(color){} 35 | Color::Color(int r, int g, int b, int a) : Color(QColor(r,g,b,a)){} 36 | Color::Color(const QString name, int r, int g, int b, int a): Color(name, QColor(r,g,b,a)){} 37 | //Color::Color(const Color &other) : AbstractProperty(other), QColor(other){} 38 | Color::Color(const QColor &color) : Color(QString(),color) 39 | { 40 | m_caption = color.name(); 41 | } 42 | 43 | /*************************************************** 44 | * 45 | * Member 46 | * 47 | ***************************************************/ 48 | 49 | void Color::fromObject(AbstractProperty object) 50 | { 51 | m_id = object.m_id; 52 | m_caption = object.m_caption; 53 | } 54 | 55 | /*************************************************** 56 | * 57 | * Operator 58 | * 59 | ***************************************************/ 60 | 61 | bool Color::operator==(const Color &other) const 62 | { 63 | return AbstractProperty::operator==(other) && 64 | QColor::operator==(other); 65 | } 66 | 67 | 68 | QDebug operator<<(QDebug dbg, const Color &obj) 69 | { 70 | const AbstractProperty &aip = obj; 71 | const QColor &col = obj; 72 | 73 | dbg << "Color(" << 74 | aip << 75 | col << 76 | ")"; 77 | return dbg.maybeSpace(); 78 | } 79 | 80 | QDataStream &operator<<(QDataStream &out, const Color &obj) 81 | { 82 | const AbstractProperty &ap = obj; 83 | const QColor &col = obj; 84 | 85 | out << ap 86 | << col; 87 | 88 | return out; 89 | } 90 | 91 | QDataStream &operator>>(QDataStream &in, Color &obj) 92 | { 93 | AbstractProperty m_ap; 94 | QColor color; 95 | 96 | in >> m_ap >> color; 97 | 98 | obj.fromObject(m_ap); 99 | 100 | switch(color.spec()){ 101 | default: 102 | case QColor::Rgb: 103 | obj.setRgbF(color.redF(),color.greenF(),color.blueF(),color.alphaF()); 104 | break; 105 | case QColor::Hsv: 106 | obj.setHsvF(color.hueF(),color.saturationF(),color.valueF(),color.alphaF()); 107 | break; 108 | case QColor::Cmyk: 109 | obj.setCmykF(color.cyanF(),color.magentaF(),color.yellowF(),color.blackF()); 110 | break; 111 | case QColor::Hsl: 112 | obj.setHslF(color.hueF(),color.saturationF(),color.lightnessF(),color.alphaF()); 113 | break; 114 | case QColor::Invalid: 115 | obj.setRgb(Qt::black); 116 | break; 117 | } 118 | 119 | return in; 120 | } 121 | 122 | -------------------------------------------------------------------------------- /src/item/members/color.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef COLOR_H 24 | #define COLOR_H 25 | 26 | #include 27 | #include 28 | 29 | class Color : public AbstractProperty, public QColor 30 | { 31 | Q_CLASSINFO("Version", "1.0.0") 32 | 33 | 34 | public: 35 | // constructor 36 | Color(); 37 | Color(const QColor &color); 38 | Color(const QString caption, QColor color); 39 | Color(int r, int g, int b, int a=255); 40 | Color(const QString caption, int r, int g, int b, int a=255); 41 | Color(const Color &) = default; 42 | 43 | // operator 44 | Color &operator=(const Color &) = default; 45 | bool operator==( const Color & other ) const; 46 | inline bool operator!=(const Color &color) const { return !(operator==(color)); } 47 | friend QDataStream &operator<<(QDataStream &out, const Color &obj); 48 | friend QDataStream &operator>>(QDataStream &in, Color &obj); 49 | 50 | #ifndef QT_NO_DEBUG_STREAM 51 | friend QDebug operator<<(QDebug dbg, const Color &obj); 52 | #endif 53 | 54 | private: 55 | void fromObject(AbstractProperty object); 56 | 57 | }; 58 | 59 | #endif // COLOR_H 60 | -------------------------------------------------------------------------------- /src/item/members/exportlevel.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef EXPORTLEVEL_H 24 | #define EXPORTLEVEL_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | class ExportLevel 32 | { 33 | 34 | public: 35 | 36 | enum FileFormat{ 37 | JPG = 0, 38 | PNG = 1, 39 | SVG = 2, 40 | PDF = 3 41 | }; 42 | 43 | enum PathType{ 44 | prefix = 0, 45 | suffix = 1 46 | }; 47 | 48 | ExportLevel(); 49 | ExportLevel(int id, double level, FileFormat fileFormat = FileFormat::PNG, QString path = "", PathType pathType = PathType::suffix); 50 | ExportLevel(const ExportLevel &) = default; 51 | // virtual ~ExportLevel(){} 52 | 53 | ExportLevel &operator=(const ExportLevel &) = default; 54 | bool operator==( const ExportLevel & other ) const; 55 | inline bool operator!=(const ExportLevel &exportLevel) const { return !(operator==(exportLevel)); } 56 | friend QDataStream &operator<<(QDataStream &out, const ExportLevel &obj); 57 | friend QDataStream &operator>>(QDataStream &in, ExportLevel &obj); 58 | 59 | #ifndef QT_NO_DEBUG_STREAM 60 | friend QDebug operator<<(QDebug dbg, const ExportLevel &obj); 61 | #endif 62 | 63 | void setID(int id); 64 | int ID() const; 65 | 66 | void setRenderLevel(double level); 67 | double renderLevel () const; 68 | 69 | void setPath(QString path); 70 | QString path() const; 71 | 72 | void setFileFormat(FileFormat fileFormat); 73 | FileFormat fileFormat() const; 74 | 75 | void setPathType(PathType pathType); 76 | PathType pathType() const; 77 | 78 | 79 | private: 80 | int m_id; 81 | double m_renderLevel; 82 | QString m_path; 83 | FileFormat m_fileFormat; 84 | PathType m_pathType; 85 | 86 | }; 87 | 88 | Q_DECLARE_METATYPE(ExportLevel) 89 | Q_DECLARE_METATYPE(ExportLevel::FileFormat) 90 | Q_DECLARE_METATYPE(ExportLevel::PathType) 91 | 92 | 93 | #endif // EXPORTLEVEL_H 94 | -------------------------------------------------------------------------------- /src/item/members/fills.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef FILLS_H 24 | #define FILLS_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | class Fills : public AbstractItemProperty 38 | { 39 | 40 | Q_CLASSINFO("Version", "1.0.0") 41 | 42 | Q_PROPERTY(FillType fillType READ fillType WRITE setFillType) 43 | Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode) 44 | Q_PROPERTY(Gradient gradient READ gradient WRITE setGradient) 45 | Q_PROPERTY(Color color READ color WRITE setColor) 46 | Q_PROPERTY(QString path READ imagePath WRITE setImagePath) 47 | Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) 48 | 49 | 50 | public: 51 | 52 | enum FillMode { 53 | Fill = 0, 54 | Fit = 1, 55 | Stretch = 2, 56 | Tile = 3 57 | }; 58 | 59 | 60 | // Constructor 61 | Fills(); 62 | Fills(const QString name); 63 | Fills(const QString name, const Color & color); 64 | Fills(const QString name, const QString &path, const FillMode fillMode = FillMode::Fill); 65 | Fills(const QString name, const Gradient & gradient); 66 | Fills(const Fills &) = default; 67 | 68 | ~Fills() = default; 69 | 70 | 71 | // Properties 72 | 73 | Type type() const override{ 74 | return Type::Fill; 75 | }; 76 | 77 | void setFillType(FillType filltype); 78 | FillType fillType() const; 79 | 80 | void setFillMode(FillMode fillMode); 81 | FillMode fillMode() const; 82 | 83 | void setGradient(Gradient gradient); 84 | virtual Gradient gradient() const; 85 | 86 | void setColor(Color color); 87 | Color color() const; 88 | 89 | void setImagePath(const QString path); 90 | QString imagePath() const; 91 | 92 | QPixmap pixmap() const; 93 | 94 | void setOpacity(qreal opacity); 95 | qreal opacity() const; 96 | 97 | Fills &operator=(const Fills &) = default; 98 | bool operator==( const Fills & other ) const; 99 | inline bool operator!=(const Fills &fill) const { return !(operator==(fill)); } 100 | friend QDataStream &operator<<(QDataStream &out, const Fills &obj); 101 | friend QDataStream &operator>>(QDataStream &in, Fills &obj); 102 | 103 | #ifndef QT_NO_DEBUG_STREAM 104 | friend QDebug operator<<(QDebug dbg, const Fills &obj); 105 | #endif 106 | 107 | private: 108 | 109 | FillType m_fillType; 110 | FillMode m_fillMode; 111 | Gradient m_gradient; 112 | Color m_color; 113 | QPixmap m_pixmap; 114 | QString m_imagePath; 115 | qreal m_opacity; 116 | 117 | void fromObject(AbstractItemProperty object); 118 | 119 | }; 120 | Q_DECLARE_METATYPE(Fills) 121 | Q_DECLARE_METATYPE(Fills::FillMode) 122 | 123 | #endif // FILLS_H 124 | -------------------------------------------------------------------------------- /src/item/members/pathprocessor.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef PATHHANDLER_H 24 | #define PATHHANDLER_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class PathProcessor 31 | { 32 | public: 33 | enum class Booleans { 34 | Unite = 0, 35 | Subtract = 1, 36 | Intersect = 2, 37 | InvertIntersect = 3 38 | }; 39 | 40 | static QPainterPath combine(const QPainterPath &path1, const QPainterPath &path2, Booleans boolOperator = Booleans::Unite); 41 | static SkPath combine(const SkPath &path1, const SkPath &path2, Booleans boolOperator = Booleans::Unite); 42 | 43 | static QPainterPath scale( const QPainterPath &path, qreal amount); 44 | 45 | static QPainterPath simplify(QPainterPath path); 46 | static SkPath simplify(SkPath path); 47 | 48 | static QPainterPath map(QTransform transform, QPainterPath sourcePath); 49 | static SkPath map(SkMatrix matrix, SkPath sourcePath); 50 | 51 | }; 52 | 53 | #endif // PATHHANDLER_H 54 | -------------------------------------------------------------------------------- /src/item/members/shadow.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef SHADOW_H 24 | #define SHADOW_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class Shadow : public AbstractItemProperty 33 | { 34 | Q_CLASSINFO("Version", "1.0.0") 35 | 36 | Q_PROPERTY(qreal radius READ radius WRITE setRadius) 37 | Q_PROPERTY(Color color READ color WRITE setColor) 38 | Q_PROPERTY(QPointF offset READ offset WRITE setOffset) 39 | Q_PROPERTY(qreal spread READ spread WRITE setSpread) 40 | 41 | public: 42 | // Constructor 43 | Shadow(); 44 | Shadow(QString name, Color color= Color(0,0,0,128), qreal radius = 4, QPointF offset = QPointF(0,2), qreal spread = 0); 45 | Shadow(const Shadow &) = default; 46 | 47 | ~Shadow() = default; 48 | 49 | Shadow &operator=(const Shadow &) = default; 50 | bool operator==( const Shadow & other ) const; 51 | inline bool operator!=(const Shadow &shadow) const { return !(operator==(shadow)); } 52 | friend QDataStream &operator<<(QDataStream &out, const Shadow &obj); 53 | friend QDataStream &operator>>(QDataStream &in, Shadow &obj); 54 | 55 | #ifndef QT_NO_DEBUG_STREAM 56 | friend QDebug operator<<(QDebug dbg, const Shadow &obj); 57 | #endif 58 | 59 | // Properties 60 | Type type() const override{ 61 | return Type::Shadow; 62 | }; 63 | 64 | void setColor(Color color); 65 | Color color() const; 66 | 67 | void setRadius(qreal radius); 68 | qreal radius() const; 69 | 70 | void setOffset(QPointF offset); 71 | void setOffset(qreal x, qreal y); 72 | QPointF offset() const; 73 | 74 | void setSpread(qreal spread); 75 | qreal spread() const; 76 | 77 | 78 | private: 79 | Color m_color; 80 | qreal m_radius; 81 | QPointF m_offset; 82 | qreal m_spread; 83 | 84 | void fromObject(AbstractItemProperty object); 85 | 86 | }; 87 | Q_DECLARE_METATYPE(Shadow) 88 | 89 | 90 | #endif // SHADOW_H 91 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include "mainwindow.h" 24 | #include 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | QApplication a(argc, argv); 29 | 30 | QCoreApplication::setApplicationName("Draftoola Studio"); 31 | QCoreApplication::setApplicationVersion("0.1 alpha"); 32 | QCoreApplication::setOrganizationName("Draftoola Development Team"); 33 | 34 | qRegisterMetaType("AbstractItemProperty"); 35 | qRegisterMetaTypeStreamOperators("AbstractItemProperty"); 36 | 37 | qRegisterMetaType("Shadow"); 38 | qRegisterMetaTypeStreamOperators("Shadow"); 39 | 40 | qRegisterMetaType("ExportLevel"); 41 | qRegisterMetaType("Fills"); 42 | qRegisterMetaType("Stroke"); 43 | qRegisterMetaType("Gradient"); 44 | qRegisterMetaType("Color"); 45 | // qRegisterMetaType("AbstractItemBase"); 46 | 47 | MainWindow w; 48 | w.show(); 49 | 50 | return a.exec(); 51 | } 52 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef MAINWINDOW_H 24 | #define MAINWINDOW_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | //#include 32 | //#include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace Ui { 39 | class MainWindow; 40 | } 41 | 42 | class MainWindow : public QMainWindow 43 | { 44 | Q_OBJECT 45 | 46 | public: 47 | explicit MainWindow(QWidget *parent = nullptr); 48 | ~MainWindow(); 49 | 50 | 51 | private: 52 | Ui::MainWindow *ui; 53 | 54 | Outliner * m_outliner; 55 | ItemProperties * m_properties; 56 | CanvasView * m_canvas; 57 | CanvasScene * m_scene; 58 | QDockWidget * m_outlinerDock; 59 | QDockWidget * m_propertiesDock; 60 | 61 | // Tools 62 | QToolButton *m_toolRectangle; 63 | QToolButton *m_toolOval; 64 | QToolButton *m_toolText; 65 | QToolButton *m_toolLine; 66 | QToolButton *m_toolTriangle; 67 | QToolButton *m_toolStar; 68 | QToolButton *m_toolPolygon; 69 | QToolButton *m_toolPath; 70 | QToolButton *m_toolImage; 71 | QToolButton *m_toolArtboard; 72 | 73 | void setupWorkspace(); 74 | void setupToolbar(); 75 | 76 | void connectSlots(); 77 | 78 | void tmpSetup(int offsetX, int offsetY); 79 | 80 | 81 | public slots: 82 | void setActiveItems(QList items); 83 | void addNewItem(); 84 | void zoomHasChanged(qreal zoomFactor); 85 | 86 | }; 87 | 88 | #endif // MAINWINDOW_H 89 | -------------------------------------------------------------------------------- /src/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1200 10 | 800 11 | 12 | 13 | 14 | Draftoola Studio 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 0 22 | 1200 23 | 22 24 | 25 | 26 | 27 | false 28 | 29 | 30 | 31 | &File 32 | 33 | 34 | 35 | 36 | &Edit 37 | 38 | 39 | 40 | 41 | &Help 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 18 52 | 18 53 | 54 | 55 | 56 | TopToolBarArea 57 | 58 | 59 | false 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/manager/qt2skia.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2014 Alexey Telishev 6 | Copyright (C) 2020 Martin Reininger 7 | 8 | Base on https://github.com/telishev/sneakPic/blob/master/src/renderer/qt2skia.cpp 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | **************************************************************************************/ 25 | 26 | #include "qt2skia.h" 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | namespace skia{ 37 | 38 | SkMatrix skMatrix(const QTransform &tr) 39 | { 40 | SkMatrix matrix; 41 | // scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2 42 | // m11, m21, m31, m12, m22, m32, m13, m23, m33 43 | matrix.setAll(tr.m11(), tr.m21(), tr.m31(), tr.m12(), tr.m22(), tr.m32(), tr.m13(), tr.m23(), tr.m33()); 44 | return matrix; 45 | } 46 | 47 | SkPoint skPoint(const QPointF &point) 48 | { 49 | return SkPoint::Make(SkFloatToScalar(point.x()), SkFloatToScalar(point.y())); 50 | } 51 | 52 | int skFillRule(int rule) 53 | { 54 | switch(rule) 55 | { 56 | case Qt::FillRule::OddEvenFill: 57 | return (int)SkPathFillType::kEvenOdd; 58 | case Qt::FillRule::WindingFill: 59 | default: 60 | return (int)SkPathFillType::kWinding; 61 | } 62 | } 63 | 64 | SkPath skPath(const QPainterPath &qpath) 65 | { 66 | SkPath path; 67 | int count = qpath.elementCount(); 68 | for(int i = 0; i < count; i++) 69 | { 70 | QPainterPath::Element elem = qpath.elementAt(i); 71 | switch(elem.type) 72 | { 73 | case QPainterPath::MoveToElement: 74 | path.moveTo(skPoint(elem)); 75 | break; 76 | case QPainterPath::LineToElement: 77 | path.lineTo(skPoint(elem)); 78 | break; 79 | case QPainterPath::CurveToElement: 80 | { 81 | path.cubicTo(skPoint(elem), 82 | skPoint(qpath.elementAt(i+1)), 83 | skPoint(qpath.elementAt(i+2)) 84 | ); 85 | break; 86 | } 87 | default: 88 | break; 89 | } 90 | } 91 | 92 | if(count == 1) 93 | { 94 | path.lineTo( skPoint( qpath.elementAt(0) )); 95 | path.close(); 96 | } 97 | 98 | if(count > 3 99 | && are_equal( qpath.elementAt(count - 1).x, qpath.elementAt(0).x ) 100 | && are_equal( qpath.elementAt(count - 1).y, qpath.elementAt(0).y ) 101 | ) 102 | path.close(); 103 | // Qt doesn't have any special definition if path is closed expect that it's first and last points are equal 104 | 105 | path.setFillType( (SkPathFillType)skFillRule( qpath.fillRule() )); 106 | return path; 107 | } 108 | 109 | 110 | 111 | }; 112 | -------------------------------------------------------------------------------- /src/manager/qt2skia.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2014 Alexey Telishev 6 | Copyright (C) 2020 Martin Reininger 7 | 8 | Base on https://github.com/telishev/sneakPic/blob/master/src/renderer/qt2skia.h 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | **************************************************************************************/ 25 | 26 | #ifndef QT2SKIA_H 27 | #define QT2SKIA_H 28 | 29 | 30 | struct SkPoint; 31 | class SkPath; 32 | class SkMatrix; 33 | 34 | class QPointF; 35 | class QPainterPath; 36 | class QTransform; 37 | 38 | namespace skia{ 39 | 40 | SkMatrix skMatrix (const QTransform &tr); 41 | SkPoint skPoint (const QPointF &point); 42 | SkPath skPath (const QPainterPath &qpath); 43 | int skFillRule (int rule); 44 | }; 45 | 46 | #endif // QT2SKIA_H 47 | -------------------------------------------------------------------------------- /src/manager/skia2qt.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2014 Alexey Telishev 6 | Copyright (C) 2020 Martin Reininger 7 | 8 | Base on https://github.com/telishev/sneakPic/blob/master/src/renderer/qt2skia.cpp 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | **************************************************************************************/ 25 | 26 | #include "skia2qt.h" 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | namespace skia{ 38 | 39 | QTransform qtMatrix (const SkMatrix &tr) 40 | { 41 | QTransform matrix; 42 | // scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2 43 | // m11, m21, m31, m12, m22, m32, m13, m23, m33 44 | // matrix.setMatrix(tr.getScaleX(), tr.getSkewX(), tr.getTranslateX(), tr.getSkewY(), tr.getScaleY(), tr.getTranslateY(), tr.getPerspX(), tr.getPerspY(), tr.get(8)); 45 | matrix.setMatrix(tr.get(0), tr.get(1), tr.get(2), tr.get(3), tr.get(4), tr.get(5), tr.get(6), tr.get(7), tr.get(8)); 46 | return matrix; 47 | } 48 | 49 | 50 | int qtFillRule (int rule) 51 | { 52 | switch (SkPathFillType(rule)) 53 | { 54 | case SkPathFillType::kEvenOdd: 55 | return Qt::FillRule::OddEvenFill; 56 | case SkPathFillType::kWinding: 57 | default: 58 | return Qt::FillRule::WindingFill; 59 | } 60 | } 61 | 62 | QPointF qtPoint (const SkPoint &skpoint) 63 | { 64 | return QPointF(skpoint.x(), skpoint.y()); 65 | } 66 | 67 | QPainterPath qtPath(const SkPath &skpath) 68 | { 69 | QPainterPath path; 70 | int max = skpath.countVerbs(); 71 | uint8_t verbs[max]; 72 | skpath.getVerbs(verbs, max); 73 | 74 | int count = 0; 75 | 76 | for (int i = 0; i < max; ++i) { 77 | 78 | switch( verbs[i] ){ 79 | case 0: // move 80 | path.moveTo(qtPoint(skpath.getPoint(count))); 81 | count +=1; 82 | break; 83 | case 1: // line 84 | path.lineTo(qtPoint(skpath.getPoint(count))); 85 | count +=1; 86 | break; 87 | case 2: // quad 88 | path.quadTo( 89 | qtPoint(skpath.getPoint(count)), 90 | qtPoint(skpath.getPoint(count+1)) 91 | ); 92 | count +=2; 93 | break; 94 | case 3: // conic 95 | qDebug() << "conicTo"; 96 | count +=3; 97 | break; 98 | case 4: // cubic 99 | path.cubicTo( 100 | qtPoint(skpath.getPoint(count)), 101 | qtPoint(skpath.getPoint(count+1)), 102 | qtPoint(skpath.getPoint(count+2)) 103 | ); 104 | count +=3; 105 | break; 106 | case 5: // close 107 | case 6: // done 108 | break; 109 | } 110 | } 111 | 112 | path.setFillRule( (Qt::FillRule)qtFillRule((int)skpath.getFillType()) ); 113 | return path; 114 | } 115 | 116 | 117 | }; 118 | -------------------------------------------------------------------------------- /src/manager/skia2qt.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2014 Alexey Telishev 6 | Copyright (C) 2020 Martin Reininger 7 | 8 | Base on https://github.com/telishev/sneakPic/blob/master/src/renderer/qt2skia.h 9 | 10 | This program is free software; you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation; either version 2 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License along 21 | with this program; if not, write to the Free Software Foundation, Inc., 22 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | 24 | **************************************************************************************/ 25 | 26 | #ifndef SKIA2QT_H 27 | #define SKIA2QT_H 28 | 29 | struct SkPoint; 30 | class SkPath; 31 | class SkMatrix; 32 | 33 | class QPointF; 34 | class QPainterPath; 35 | class QTransform; 36 | 37 | namespace skia{ 38 | 39 | QTransform qtMatrix (const SkMatrix &tr); 40 | QPointF qtPoint (const SkPoint &skpoint); 41 | QPainterPath qtPath (const SkPath &skpath); 42 | int qtFillRule (int rule); 43 | 44 | }; 45 | 46 | #endif // SKIA2QT_H 47 | -------------------------------------------------------------------------------- /src/manager/stylefactory.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #include 24 | #include 25 | 26 | StyleFactory::StyleFactory(const QString name) : QProxyStyle(QStyleFactory::create(name)) 27 | { 28 | 29 | } 30 | 31 | void StyleFactory::drawControl(ControlElement control, const QStyleOption *option, QPainter *painter, const QWidget *widget) const 32 | { 33 | switch (control) { 34 | // case CE_PushButtonLabel: 35 | // { 36 | // QStyleOptionButton myButtonOption; 37 | // const QStyleOptionButton *buttonOption = qstyleoption_cast(option); 38 | // if (buttonOption) { 39 | // myButtonOption = *buttonOption; 40 | // if (myButtonOption.palette.currentColorGroup() 41 | // != QPalette::Disabled) { 42 | // if (myButtonOption.state & (State_Sunken | State_On)) { 43 | // myButtonOption.palette.setBrush(QPalette::ButtonText, 44 | // myButtonOption.palette.brightText()); 45 | // } 46 | // } 47 | // } 48 | // QProxyStyle::drawControl(control, &myButtonOption, painter, widget); 49 | // } 50 | // break; 51 | default: 52 | QProxyStyle::drawControl(control, option, painter, widget); 53 | } 54 | } 55 | 56 | void StyleFactory::drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const 57 | { 58 | switch (control) { 59 | case CC_ToolButton: 60 | { 61 | QStyleOptionToolButton myButtonOption; 62 | const QStyleOptionToolButton *buttonOption = qstyleoption_cast(option); 63 | if (buttonOption) { 64 | myButtonOption = *buttonOption; 65 | // if (myButtonOption.palette.currentColorGroup() != QPalette::Disabled) { 66 | // if (myButtonOption.state & (State_Sunken | State_On)) { 67 | // myButtonOption.palette.setBrush(QPalette::ButtonText, 68 | // myButtonOption.palette.brightText()); 69 | // } 70 | // } 71 | 72 | } 73 | 74 | QProxyStyle::drawComplexControl(control, &myButtonOption, painter, widget); 75 | } 76 | break; 77 | default: 78 | QProxyStyle::drawComplexControl(control, option, painter, widget); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/manager/stylefactory.h: -------------------------------------------------------------------------------- 1 | /************************************************************************************* 2 | 3 | Draftoola - UI and UX prototyping tool for designing static and animated layouts. 4 | 5 | Copyright (C) 2019 Martin Reininger 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License along 18 | with this program; if not, write to the Free Software Foundation, Inc., 19 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | **************************************************************************************/ 22 | 23 | #ifndef STYLEFACTORY_H 24 | #define STYLEFACTORY_H 25 | 26 | #include 27 | #include 28 | 29 | class StyleFactory : public QProxyStyle 30 | { 31 | Q_OBJECT 32 | public: 33 | StyleFactory(const QString name); 34 | 35 | void drawControl(ControlElement control, const QStyleOption *option, 36 | QPainter *painter, const QWidget *widget) const override; 37 | 38 | void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, 39 | QPainter *painter, const QWidget *widget = nullptr) const override; 40 | 41 | }; 42 | 43 | #endif // STYLEFACTORY_H 44 | -------------------------------------------------------------------------------- /src/resources/icons/dark/chevron-down.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/chevron-right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/close.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/colordialog/color.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/resources/icons/dark/colordialog/conical_gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nitramr/Draftoola/7ab179cc0f6ca3f2e9b4fc2ca5346fb5bae01384/src/resources/icons/dark/colordialog/conical_gradient.png -------------------------------------------------------------------------------- /src/resources/icons/dark/colordialog/image.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/colordialog/linear_gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nitramr/Draftoola/7ab179cc0f6ca3f2e9b4fc2ca5346fb5bae01384/src/resources/icons/dark/colordialog/linear_gradient.png -------------------------------------------------------------------------------- /src/resources/icons/dark/colordialog/radial_gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nitramr/Draftoola/7ab179cc0f6ca3f2e9b4fc2ca5346fb5bae01384/src/resources/icons/dark/colordialog/radial_gradient.png -------------------------------------------------------------------------------- /src/resources/icons/dark/colordialog/radial_gradient_alt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nitramr/Draftoola/7ab179cc0f6ca3f2e9b4fc2ca5346fb5bae01384/src/resources/icons/dark/colordialog/radial_gradient_alt.png -------------------------------------------------------------------------------- /src/resources/icons/dark/delete-24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/eye-off.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/eye.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/folder-open.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/frame-all-lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /src/resources/icons/dark/frame-free.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/frame-horizontal-lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /src/resources/icons/dark/frame-vertical-lock.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/resources/icons/dark/plus.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/settings.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/ellipse.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/format-text-variant.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/format-textbox.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/fountain-pen-tip.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/image.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/line.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/pentagon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/presentation.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/rectangle.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/star.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/dark/tools/triangle.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/resources/icons/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | dark/close.svg 4 | dark/plus.svg 5 | dark/eye-off.svg 6 | dark/eye.svg 7 | dark/settings.svg 8 | dark/chevron-right.svg 9 | dark/chevron-down.svg 10 | dark/delete-24px.svg 11 | dark/frame-all-lock.svg 12 | dark/frame-free.svg 13 | dark/frame-horizontal-lock.svg 14 | dark/frame-vertical-lock.svg 15 | dark/tools/ellipse.svg 16 | dark/tools/fountain-pen-tip.svg 17 | dark/tools/image.svg 18 | dark/tools/line.svg 19 | dark/tools/pentagon.svg 20 | dark/tools/presentation.svg 21 | dark/tools/rectangle.svg 22 | dark/tools/star.svg 23 | dark/tools/triangle.svg 24 | dark/tools/format-textbox.svg 25 | dark/tools/format-text-variant.svg 26 | dark/colordialog/color.svg 27 | dark/colordialog/conical_gradient.png 28 | dark/colordialog/image.svg 29 | dark/colordialog/linear_gradient.png 30 | dark/colordialog/radial_gradient.png 31 | dark/colordialog/radial_gradient_alt.png 32 | dark/folder-open.svg 33 | 34 | 35 | --------------------------------------------------------------------------------