colordialog: began widgets and dialogs for a managed color picker
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
add_subdirectory(about)
|
||||
add_subdirectory(actionsearch)
|
||||
add_subdirectory(color)
|
||||
add_subdirectory(export)
|
||||
add_subdirectory(footageproperties)
|
||||
add_subdirectory(keyframeproperties)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
dialog/color/colordialog.h
|
||||
dialog/color/colordialog.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "colordialog.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "widget/colorwheel/colorwheelwidget.h"
|
||||
|
||||
ColorDialog::ColorDialog(ColorManager* color_manager, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
color_manager_(color_manager)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
QSplitter* splitter = new QSplitter(Qt::Horizontal);
|
||||
layout->addWidget(splitter);
|
||||
|
||||
ColorWheelWidget* cww1 = new ColorWheelWidget();
|
||||
ColorWheelWidget* cww2 = new ColorWheelWidget();
|
||||
|
||||
splitter->addWidget(cww1);
|
||||
splitter->addWidget(cww2);
|
||||
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
layout->addWidget(buttons);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef COLORDIALOG_H
|
||||
#define COLORDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "render/color.h"
|
||||
#include "render/colormanager.h"
|
||||
|
||||
class ColorDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
ColorDialog(ColorManager* color_manager, QWidget* parent = nullptr);
|
||||
|
||||
private:
|
||||
ColorManager* color_manager_;
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORDIALOG_H
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
add_subdirectory(audiomonitor)
|
||||
add_subdirectory(clickablelabel)
|
||||
add_subdirectory(colorbutton)
|
||||
add_subdirectory(colorwheel)
|
||||
add_subdirectory(columnedgridlayout)
|
||||
add_subdirectory(curvewidget)
|
||||
add_subdirectory(flowlayout)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/colorbutton/colorbutton.h
|
||||
widget/colorbutton/colorbutton.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "colorbutton.h"
|
||||
|
||||
#include "dialog/color/colordialog.h"
|
||||
|
||||
ColorButton::ColorButton(QWidget *parent) :
|
||||
QPushButton(parent)
|
||||
{
|
||||
connect(this, &ColorButton::clicked, this, &ColorButton::ShowColorDialog);
|
||||
}
|
||||
|
||||
void ColorButton::ShowColorDialog()
|
||||
{
|
||||
ColorDialog cd(nullptr);
|
||||
cd.exec();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef COLORBUTTON_H
|
||||
#define COLORBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
class ColorButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorButton(QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void ColorChanged();
|
||||
|
||||
private slots:
|
||||
void ShowColorDialog();
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORBUTTON_H
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/colorwheel/colorwheelwidget.h
|
||||
widget/colorwheel/colorwheelwidget.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "colorwheelwidget.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QtMath>
|
||||
|
||||
#define RADIAN_TO_0_1_RANGE 0.15915494309188486110703542313983
|
||||
|
||||
ColorWheelWidget::ColorWheelWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ColorWheelWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
QPainter p(this);
|
||||
|
||||
qreal radius = qMin(width(), height()) / 2;
|
||||
QPoint center = rect().center();
|
||||
|
||||
p.setPen(Qt::red);
|
||||
|
||||
int x_start = center.x() - radius;
|
||||
int x_end= center.x() + radius;
|
||||
int y_start = center.y() - radius;
|
||||
int y_end= center.y() + radius;
|
||||
|
||||
for (int i=x_start;i<x_end;i++) {
|
||||
for (int j=y_start;j<y_end;j++) {
|
||||
qreal opposite = j - center.y();
|
||||
qreal adjacent = i - center.x();
|
||||
qreal pix_len = qSqrt(qPow(adjacent, 2) + qPow(opposite, 2));
|
||||
|
||||
if (pix_len <= radius) {
|
||||
qreal hue = qAtan2(opposite, adjacent) * RADIAN_TO_0_1_RANGE + 0.5;
|
||||
qreal sat = (pix_len / radius);
|
||||
qreal value = 1.0;
|
||||
|
||||
QColor c;
|
||||
c.setHsvF(hue, sat, value);
|
||||
p.setPen(c);
|
||||
|
||||
p.drawPoint(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef COLORWHEELWIDGET_H
|
||||
#define COLORWHEELWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ColorWheelWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
ColorWheelWidget(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORWHEELWIDGET_H
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "nodeparamviewundo.h"
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "undo/undostack.h"
|
||||
#include "widget/colorbutton/colorbutton.h"
|
||||
#include "widget/footagecombobox/footagecombobox.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
#include "widget/slider/integerslider.h"
|
||||
@@ -92,8 +93,12 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
// FIXME: File selector
|
||||
break;
|
||||
case NodeParam::kColor:
|
||||
// FIXME: Color selector
|
||||
{
|
||||
ColorButton* color_button = new ColorButton();
|
||||
widgets_.append(color_button);
|
||||
connect(color_button, &ColorButton::ColorChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
|
||||
break;
|
||||
}
|
||||
case NodeParam::kText:
|
||||
{
|
||||
QLineEdit* line_edit = new QLineEdit();
|
||||
|
||||
Reference in New Issue
Block a user