Skip to content

Commit

Permalink
Move gradient widgets to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Apr 8, 2024
1 parent 947fe9e commit 18dd3d6
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 41 deletions.
14 changes: 0 additions & 14 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,9 @@ set(
GUI/ColorWidgets/colorsettingswidget.cpp
GUI/ColorWidgets/colorvaluerect.cpp
GUI/ColorWidgets/colorwidget.cpp
GUI/ColorWidgets/h_wheel_sv_triangle.cpp
GUI/ColorWidgets/colorpickingwidget.cpp
GUI/ColorWidgets/savedcolorbutton.cpp
GUI/ColorWidgets/savedcolorswidget.cpp
GUI/GradientWidgets/gradientwidget.cpp
GUI/ColorWidgets/glwidget.cpp
GUI/window.cpp
effectsloader.cpp
eimporters.cpp
Expand All @@ -197,9 +194,6 @@ set(
memoryhandler.cpp
GUI/RenderWidgets/renderwidget.cpp
GUI/RenderWidgets/renderinstancewidget.cpp
GUI/GradientWidgets/gradientslistwidget.cpp
GUI/GradientWidgets/displayedgradientswidget.cpp
GUI/GradientWidgets/currentgradientwidget.cpp
GUI/RenderWidgets/closablecontainer.cpp
GUI/BoxesList/boxtargetwidget.cpp
GUI/BoxesList/boxscrollarea.cpp
Expand All @@ -213,7 +207,6 @@ set(
GUI/qrealanimatorvalueslider.cpp
GUI/fontswidget.cpp
GUI/fillstrokesettings.cpp
GUI/ColorWidgets/colorwidgetshaders.cpp
GUI/toolbox.cpp
)

Expand Down Expand Up @@ -246,12 +239,9 @@ set(
GUI/ColorWidgets/colorsettingswidget.h
GUI/ColorWidgets/colorvaluerect.h
GUI/ColorWidgets/colorwidget.h
GUI/ColorWidgets/h_wheel_sv_triangle.h
GUI/ColorWidgets/colorpickingwidget.h
GUI/ColorWidgets/savedcolorbutton.h
GUI/ColorWidgets/savedcolorswidget.h
GUI/GradientWidgets/gradientwidget.h
GUI/ColorWidgets/glwidget.h
effectsloader.h
eimporters.h
iconloader.h
Expand All @@ -263,9 +253,6 @@ set(
memoryhandler.h
GUI/RenderWidgets/renderwidget.h
GUI/RenderWidgets/renderinstancewidget.h
GUI/GradientWidgets/gradientslistwidget.h
GUI/GradientWidgets/displayedgradientswidget.h
GUI/GradientWidgets/currentgradientwidget.h
GUI/RenderWidgets/closablecontainer.h
GUI/BoxesList/boxtargetwidget.h
GUI/BoxesList/boxscrollarea.h
Expand All @@ -279,7 +266,6 @@ set(
GUI/mainwindow.h
GUI/window.h
GUI/qrealanimatorvalueslider.h
GUI/ColorWidgets/colorwidgetshaders.h
)

set(
Expand Down
2 changes: 1 addition & 1 deletion src/app/GUI/ColorWidgets/colorlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <QWidget>
#include <QMenu>
#include "Private/document.h"
#include "colorwidgetshaders.h"
#include "widgets/colorwidgetshaders.h"

ColorLabel::ColorLabel(QWidget *parent) : ColorWidget(parent) {
//setMinimumSize(80, 20);
Expand Down
2 changes: 1 addition & 1 deletion src/app/GUI/ColorWidgets/colorvaluerect.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#ifndef COLORVALUERECT_H
#define COLORVALUERECT_H
#include "colorwidget.h"
#include "colorwidgetshaders.h"
#include "widgets/colorwidgetshaders.h"

class ColorValueRect : public ColorWidget {
Q_OBJECT
Expand Down
3 changes: 2 additions & 1 deletion src/app/GUI/ColorWidgets/colorwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

#ifndef COLORWIDGET_H
#define COLORWIDGET_H
#include "glwidget.h"

#include "widgets/glwidget.h"
#include "colorhelpers.h"

class ColorWidget : public GLWidget {
Expand Down
2 changes: 1 addition & 1 deletion src/app/GUI/fillstrokesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// Fork of enve - Copyright (C) 2016-2020 Maurycy Liebner

#include "fillstrokesettings.h"
#include "GUI/GradientWidgets/gradientwidget.h"
#include "gradientwidgets/gradientwidget.h"
#include "canvas.h"
#include "qrealanimatorvalueslider.h"
#include "GUI/ColorWidgets/colorsettingswidget.h"
Expand Down
2 changes: 1 addition & 1 deletion src/app/effectsloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <QFileSystemModel>
#include <iostream>

#include "GUI/ColorWidgets/colorwidgetshaders.h"
#include "widgets/colorwidgetshaders.h"
#include "ShaderEffects/shadereffectcreator.h"
#include "PathEffects/custompatheffect.h"
#include "PathEffects/custompatheffectcreator.h"
Expand Down
2 changes: 1 addition & 1 deletion src/app/evfileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include "Animators/qrealkey.h"
#include "GUI/mainwindow.h"
#include "GUI/canvaswindow.h"
#include "GUI/GradientWidgets/gradientwidget.h"
#include "gradientwidgets/gradientwidget.h"
#include <QMessageBox>
#include "PathEffects/patheffectsinclude.h"
#include "ReadWrite/basicreadwrite.h"
Expand Down
12 changes: 12 additions & 0 deletions src/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ set(
dialogs/qrealpointvaluedialog.cpp
dialogs/renderoutputwidget.cpp
dialogs/scenesettingsdialog.cpp
gradientwidgets/currentgradientwidget.cpp
gradientwidgets/displayedgradientswidget.cpp
gradientwidgets/gradientslistwidget.cpp
gradientwidgets/gradientwidget.cpp
misc/noshortcutaction.cpp
misc/keyfocustarget.cpp
optimalscrollarena/minimalscrollwidget.cpp
Expand All @@ -66,10 +70,12 @@ set(
widgets/buttonslist.cpp
widgets/canvassettingswidget.cpp
widgets/changewidthwidget.cpp
widgets/colorwidgetshaders.cpp
widgets/ecombobox.cpp
widgets/editablecombobox.cpp
widgets/fakemenubar.cpp
widgets/flowlayout.cpp
widgets/glwidget.cpp
widgets/glwindow.cpp
widgets/labeledslider.cpp
widgets/performancesettingswidget.cpp
Expand All @@ -94,6 +100,10 @@ set(
dialogs/qrealpointvaluedialog.h
dialogs/renderoutputwidget.h
dialogs/scenesettingsdialog.h
gradientwidgets/currentgradientwidget.h
gradientwidgets/displayedgradientswidget.h
gradientwidgets/gradientslistwidget.h
gradientwidgets/gradientwidget.h
misc/noshortcutaction.h
misc/keyfocustarget.h
optimalscrollarena/minimalscrollwidget.h
Expand All @@ -112,10 +122,12 @@ set(
widgets/buttonslist.h
widgets/canvassettingswidget.h
widgets/changewidthwidget.h
widgets/colorwidgetshaders.h
widgets/ecombobox.h
widgets/editablecombobox.h
widgets/fakemenubar.h
widgets/flowlayout.h
widgets/glwidget.h
widgets/glwindow.h
widgets/labeledslider.h
widgets/performancesettingswidget.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
// Fork of enve - Copyright (C) 2016-2020 Maurycy Liebner

#include "currentgradientwidget.h"
#include "GUI/GradientWidgets/gradientwidget.h"
#include "GUI/global.h"
#include "GUI/ColorWidgets/colorwidgetshaders.h"
#include "widgets/colorwidgetshaders.h"
#include "Animators/gradient.h"
#include "Private/document.h"

#include <QMouseEvent>

CurrentGradientWidget::CurrentGradientWidget(QWidget *parent) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@
#ifndef CURRENTGRADIENTWIDGET_H
#define CURRENTGRADIENTWIDGET_H

#include "GUI/ColorWidgets/glwidget.h"
#include "ui_global.h"

#include "widgets/glwidget.h"
#include "conncontextptr.h"

class GradientWidget;
class ColorAnimator;
class Gradient;

class CurrentGradientWidget : public GLWidget {
class UI_EXPORT CurrentGradientWidget : public GLWidget
{
Q_OBJECT

public:
explicit CurrentGradientWidget(QWidget *parent = nullptr);

Expand All @@ -43,15 +48,18 @@ class CurrentGradientWidget : public GLWidget {
void setCurrentColorId(const int id);

ColorAnimator *getColorAnimator();

protected:
void paintGL();

void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void leaveEvent(QEvent *);

signals:
void selectedColorChanged(ColorAnimator*);

private:
void updateCurrentColor();
int getColorIdAtX(const int x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
// Fork of enve - Copyright (C) 2016-2020 Maurycy Liebner

#include "displayedgradientswidget.h"

#include <QPainter>
#include "GUI/GradientWidgets/gradientwidget.h"

#include "Animators/gradient.h"
#include "Private/document.h"
#include "canvas.h"
Expand Down Expand Up @@ -84,7 +85,7 @@ void DisplayedGradientsWidget::updateHeight() {
setFixedHeight(qMax(minimumHeight(), (mGradients.count() + 1)*eSizesUI::widget));
}

#include "GUI/ColorWidgets/colorwidgetshaders.h"
#include "widgets/colorwidgetshaders.h"
void DisplayedGradientsWidget::paintGL() {
qreal pixelRatio = devicePixelRatioF();
const int nVisible = qMin(mGradients.count() - mTopGradientId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@
#ifndef DISPLACYEDGRADIENTSWIDGET_H
#define DISPLACYEDGRADIENTSWIDGET_H

#include "GUI/ColorWidgets/glwidget.h"
#include "ui_global.h"

#include "widgets/glwidget.h"
#include "GUI/global.h"
#include "conncontextobjlist.h"
#include "conncontextptr.h"

class Gradient;
class GradientWidget;
class Canvas;

class DisplayedGradientsWidget : public GLWidget {
class UI_EXPORT DisplayedGradientsWidget : public GLWidget
{
Q_OBJECT

public:
explicit DisplayedGradientsWidget(QWidget *parent = nullptr);

Expand All @@ -50,15 +55,18 @@ class DisplayedGradientsWidget : public GLWidget {
void removeGradient(Gradient* const gradient);

void updateHeight();

signals:
void selectionChanged(Gradient*);
void triggered(Gradient*);

protected:
void paintGL();

void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void leaveEvent(QEvent *);

private:
void updateTopGradientId();
void gradientContextMenuReq(const int gradId, const QPoint &globalPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
#ifndef GRADIENTSLISTWIDGET_H
#define GRADIENTSLISTWIDGET_H

#include "ui_global.h"

#include "optimalscrollarena/scrollarea.h"

class GradientWidget;
class DisplayedGradientsWidget;

class GradientsListWidget : public ScrollArea
class UI_EXPORT GradientsListWidget : public ScrollArea
{
public:
explicit GradientsListWidget(QWidget *parent = nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <QMenu>
#include <QAction>

#include "GUI/GradientWidgets/displayedgradientswidget.h"
#include "gradientwidgets/displayedgradientswidget.h"
#include "Animators/gradient.h"

GradientWidget::GradientWidget(QWidget * const parent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
#ifndef GRADIENTWIDGET_H
#define GRADIENTWIDGET_H

#include "ui_global.h"

#include <QComboBox>
#include <QScrollArea>
#include <QVBoxLayout>

#include "GUI/GradientWidgets/gradientslistwidget.h"
#include "GUI/GradientWidgets/currentgradientwidget.h"
#include "gradientwidgets/gradientslistwidget.h"
#include "gradientwidgets/currentgradientwidget.h"

class GradientWidget : public QWidget
class UI_EXPORT GradientWidget : public QWidget
{
Q_OBJECT

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,27 @@
// Fork of enve - Copyright (C) 2016-2020 Maurycy Liebner

#include "glwidget.h"

#include "colorhelpers.h"
#include "GUI/global.h"
#include "Animators/paintsettingsanimator.h"

GLWidget::GLWidget(QWidget *parent) : QOpenGLWidget(parent) {
GLWidget::GLWidget(QWidget *parent) : QOpenGLWidget(parent)
{
// setFormat(QSurfaceFormat::defaultFormat());
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setMinimumSize(eSizesUI::widget, eSizesUI::widget);
}

void GLWidget::initializeGL() {
if(!initializeOpenGLFunctions())
RuntimeThrow("Initializing OpenGL 3.3 functions failed. "
"Make sure your GPU supports OpenGL 3.3.");
void GLWidget::initializeGL()
{
if (!initializeOpenGLFunctions()) {
RuntimeThrow(tr("Initializing OpenGL 3.3 failed."));
}

glClearColor(0, 0, 0, 1);
//Set blending

// Set blending
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Expand Down
12 changes: 10 additions & 2 deletions src/app/GUI/ColorWidgets/glwidget.h → src/ui/widgets/glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,32 @@

#ifndef GLWIDGET_H
#define GLWIDGET_H

#include "ui_global.h"

#include <QOpenGLWidget>

#include "colorhelpers.h"
#include "skia/skiaincludes.h"
#include "glhelpers.h"

class SceneBoundGradient;

class GLWidget : public QOpenGLWidget, protected QGL33 {
class UI_EXPORT GLWidget : public QOpenGLWidget, protected QGL33
{
public:
GLWidget(QWidget *parent);
~GLWidget() {
if(mPlainSquareVAO) {
if (mPlainSquareVAO) {
makeCurrent();
glDeleteVertexArrays(1, &mPlainSquareVAO);
doneCurrent();
}
}

private:
void initializeGL();

protected:
GLuint mPlainSquareVAO = 0;
};
Expand Down

0 comments on commit 18dd3d6

Please sign in to comment.