Skip to content
Snippets Groups Projects
Commit 09bc6d88 authored by BATON Theau's avatar BATON Theau
Browse files

Modification Pixelpainter en Brush, Pixeleraiser en Eraiser

parent 521a87b4
No related branches found
No related tags found
No related merge requests found
Showing
with 518 additions and 77 deletions
...@@ -12,6 +12,7 @@ SOURCES += \ ...@@ -12,6 +12,7 @@ SOURCES += \
colorpickerwidget.cpp \ colorpickerwidget.cpp \
dialog/rescaledialog.cpp \ dialog/rescaledialog.cpp \
dialog/resizedialog.cpp \ dialog/resizedialog.cpp \
dialog/sizedialog.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
tools/editable.cpp \ tools/editable.cpp \
...@@ -35,6 +36,7 @@ SOURCES += \ ...@@ -35,6 +36,7 @@ SOURCES += \
ui/menu/filemenulambda.cpp \ ui/menu/filemenulambda.cpp \
ui/menu/imagemenulambda.cpp \ ui/menu/imagemenulambda.cpp \
ui/menu/menubarmanager.cpp \ ui/menu/menubarmanager.cpp \
ui/menu/selectionmenulambda.cpp \
ui/toolbox/toolRegister.cpp \ ui/toolbox/toolRegister.cpp \
ui/view/imagearea.cpp \ ui/view/imagearea.cpp \
ui/view/multyimagemodifier.cpp \ ui/view/multyimagemodifier.cpp \
...@@ -48,6 +50,7 @@ HEADERS += \ ...@@ -48,6 +50,7 @@ HEADERS += \
colorpickerwidget.h \ colorpickerwidget.h \
dialog/rescaledialog.h \ dialog/rescaledialog.h \
dialog/resizedialog.h \ dialog/resizedialog.h \
dialog/sizedialog.h \
mainwindow.h \ mainwindow.h \
tools/editable.h \ tools/editable.h \
tools/editable/bucket.h \ tools/editable/bucket.h \
...@@ -71,6 +74,7 @@ HEADERS += \ ...@@ -71,6 +74,7 @@ HEADERS += \
ui/menu/filemenulambda.h \ ui/menu/filemenulambda.h \
ui/menu/imagemenulambda.h \ ui/menu/imagemenulambda.h \
ui/menu/menubarmanager.h \ ui/menu/menubarmanager.h \
ui/menu/selectionmenulambda.h \
ui/toolbox/toolRegister.h \ ui/toolbox/toolRegister.h \
ui/view/imagearea.h \ ui/view/imagearea.h \
ui/view/multyimagemodifier.h \ ui/view/multyimagemodifier.h \
...@@ -84,6 +88,7 @@ HEADERS += \ ...@@ -84,6 +88,7 @@ HEADERS += \
FORMS += \ FORMS += \
dialog/rescaledialog.ui \ dialog/rescaledialog.ui \
dialog/resizedialog.ui \ dialog/resizedialog.ui \
dialog/sizedialog.ui \
mainwindow.ui mainwindow.ui
# Default rules for deployment. # Default rules for deployment.
......
...@@ -15,7 +15,7 @@ ColorPickerWidget::ColorPickerWidget(QWidget *parent) ...@@ -15,7 +15,7 @@ ColorPickerWidget::ColorPickerWidget(QWidget *parent)
this->_colorListWidget = new QListWidget(this); this->_colorListWidget = new QListWidget(this);
this->_mainLayout->addWidget(this->_colorListWidget); this->_mainLayout->addWidget(this->_colorListWidget);
this->_currentColorLayout = new QHBoxLayout(this); this->_currentColorLayout = new QHBoxLayout();
this->_currentColorLabel = new QLabel("Couleur courrante :", this); this->_currentColorLabel = new QLabel("Couleur courrante :", this);
this->_currentColorLayout->addWidget(this->_currentColorLabel); this->_currentColorLayout->addWidget(this->_currentColorLabel);
...@@ -58,7 +58,6 @@ ColorPickerWidget::ColorPickerWidget(QWidget *parent) ...@@ -58,7 +58,6 @@ ColorPickerWidget::ColorPickerWidget(QWidget *parent)
} }
ColorPickerWidget::~ColorPickerWidget() { ColorPickerWidget::~ColorPickerWidget() {
delete this->_mainLayout;
delete this->_colorListWidget; delete this->_colorListWidget;
delete this->_currentColorLayout; delete this->_currentColorLayout;
delete this->_currentColorLabel; delete this->_currentColorLabel;
...@@ -67,6 +66,7 @@ ColorPickerWidget::~ColorPickerWidget() { ...@@ -67,6 +66,7 @@ ColorPickerWidget::~ColorPickerWidget() {
delete this->_modifyColorButton; delete this->_modifyColorButton;
delete this->_chooseColorButton; delete this->_chooseColorButton;
delete this->_duplicateColorButton; delete this->_duplicateColorButton;
delete this->_mainLayout;
} }
void ColorPickerWidget::setCurrentColor(const QColor & color) { void ColorPickerWidget::setCurrentColor(const QColor & color) {
...@@ -124,11 +124,12 @@ void ColorPickerWidget::modifyColor() { ...@@ -124,11 +124,12 @@ void ColorPickerWidget::modifyColor() {
void ColorPickerWidget::modifyColor(QListWidgetItem* item) { void ColorPickerWidget::modifyColor(QListWidgetItem* item) {
QListWidgetItem * selectedItem = item; QListWidgetItem * selectedItem = item;
if(selectedItem) { if(selectedItem) {
QColor color = QColorDialog::getColor(selectedItem->background().color(), this, "Modification de l'iamge"); QColor color = QColorDialog::getColor(selectedItem->background().color(), this, "Modification de l'image");
if (color.isValid()) { if (color.isValid()) {
selectedItem->setBackground(QBrush(color)); selectedItem->setBackground(QBrush(color));
this->_currentColor = color; this->_currentColor = color;
this->setFrameColor(color); this->setFrameColor(color);
emit this->currentColorChange(this->_currentColor);
} }
} }
} }
...@@ -136,12 +137,15 @@ void ColorPickerWidget::modifyColor(QListWidgetItem* item) { ...@@ -136,12 +137,15 @@ void ColorPickerWidget::modifyColor(QListWidgetItem* item) {
void ColorPickerWidget::chooseColor() { void ColorPickerWidget::chooseColor() {
this->_currentColor = this->_colorListWidget->currentItem()->background().color(); this->_currentColor = this->_colorListWidget->currentItem()->background().color();
this->setFrameColor(this->_currentColor); this->setFrameColor(this->_currentColor);
emit this->currentColorChange(this->_currentColor);
this->close(); this->close();
} }
void ColorPickerWidget::chooseColor(QListWidgetItem * item) { void ColorPickerWidget::chooseColor(QListWidgetItem * item) {
this->_currentColor = item->background().color(); this->_currentColor = item->background().color();
this->setFrameColor(this->_currentColor); this->setFrameColor(this->_currentColor);
emit this->currentColorChange(this->_currentColor);
qDebug() << "Color Selected !" << this->_currentColor;
} }
void ColorPickerWidget::duplicateCurrent() { void ColorPickerWidget::duplicateCurrent() {
......
...@@ -33,7 +33,7 @@ class ColorPickerWidget : public QWidget { ...@@ -33,7 +33,7 @@ class ColorPickerWidget : public QWidget {
ColorPickerWidget(QWidget *parent = nullptr); ColorPickerWidget(QWidget *parent = nullptr);
~ColorPickerWidget(); ~ColorPickerWidget();
inline const QColor & currentColor() const {return this->_currentColor;} inline QColor currentColor() const {return this->_currentColor;}
void setCurrentColor(const QColor &); void setCurrentColor(const QColor &);
...@@ -49,4 +49,7 @@ class ColorPickerWidget : public QWidget { ...@@ -49,4 +49,7 @@ class ColorPickerWidget : public QWidget {
void chooseColor(QListWidgetItem*); void chooseColor(QListWidgetItem*);
void duplicateCurrent(); void duplicateCurrent();
signals:
void currentColorChange(const QColor &);
}; };
#include "sizedialog.h"
namespace dialog {
SizeDialog::SizeDialog(QString title, QString titleLabel , int min, int max, int def, QWidget *parent)
: QDialog(parent) {
this->setupUi(this);
this->_titleLabel->setText(titleLabel);
this->_sizeLabel->setText(QString::number(def));
this->_sizeSlidder->setMinimum(min);
this->_sizeSlidder->setMaximum(max);
this->_sizeSlidder->setValue(def);
this->setWindowTitle(title);
QObject::connect(this->_sizeSlidder, SIGNAL(valueChanged(int)), this, SLOT(updateSizeLabel(int)));
}
void SizeDialog::setValue(int value) {
this->_sizeSlidder->setValue(value);
this->_sizeLabel->setText(QString::number(value));
}
void SizeDialog::updateSizeLabel(int value) {
this->_sizeLabel->setText(QString::number(value));
}
}
#pragma once
#include <QDialog>
#include <ui_sizedialog.h>
namespace dialog {
class SizeDialog : public QDialog, public Ui::SizeDialog {
Q_OBJECT
public:
explicit SizeDialog(QString title, QString titleLabel, int min, int max, int def = 0, QWidget *parent = nullptr);
inline int min() const {return this->_sizeSlidder->minimum();}
inline int max() const {return this->_sizeSlidder->maximum();}
inline int value() const {return this->_sizeSlidder->value();}
inline void setTitleLabelText(const QString & text) {this->_titleLabel->setText(text);}
inline void setSlitderLabelText(const QString & text) {this->_sizeLabel->setText(text);}
inline void setMax(int max) {this->_sizeSlidder->setMaximum(max);}
inline void setMin(int min) {this->_sizeSlidder->setMaximum(min);}
void setValue(int);
protected slots:
void updateSizeLabel(int);
};
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SizeDialog</class>
<widget class="QDialog" name="SizeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>98</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="../ressource.qrc">
<normaloff>:/icon/ressource/image/icon/icon.png</normaloff>:/icon/ressource/image/icon/icon.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="_titleLabel">
<property name="text">
<string>Current Size :</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="_sizeArea">
<item>
<spacer name="_sizeLeftSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSlider" name="_sizeSlidder">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="_sizeLabel">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item>
<spacer name="_sizeRightSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_exitArea">
<item>
<spacer name="_exitSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="_exitButton">
<property name="text">
<string>Fermer</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../ressource.qrc"/>
</resources>
<connections>
<connection>
<sender>_exitButton</sender>
<signal>released()</signal>
<receiver>SizeDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>357</x>
<y>83</y>
</hint>
<hint type="destinationlabel">
<x>300</x>
<y>90</y>
</hint>
</hints>
</connection>
</connections>
</ui>
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <ui/menu/filemenulambda.h> #include <ui/menu/filemenulambda.h>
#include <ui/menu/displaymenulambda.h> #include <ui/menu/displaymenulambda.h>
#include <ui/menu/imagemenulambda.h> #include <ui/menu/imagemenulambda.h>
#include <ui/menu/selectionmenulambda.h>
#include <ui/files/treefileselector.h> #include <ui/files/treefileselector.h>
...@@ -79,20 +80,26 @@ MainWindow::MainWindow(QWidget * parent) ...@@ -79,20 +80,26 @@ MainWindow::MainWindow(QWidget * parent)
qDebug() << "Mark_6"; qDebug() << "Mark_6";
this->_toolRegister = new ui::ToolboxRegister(this->_toolConfigButton, this->_toolbox, this->_viewManager); this->_toolRegister = new ui::ToolboxRegister(this->_selectionToolbox, this->_editToolbox, this->_viewManager, this->_toolConfigButton);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Hand(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Hand(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Picker(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Picker(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::EDIT);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Rectangle(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Rectangle(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::RectangleTriangle(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::RectangleTriangle(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Triangle(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Triangle(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Ellipse(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Ellipse(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Polygone(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Polygone(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Pixelpainter(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Pixelpainter(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::EDIT);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Pixeleraiser(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Pixeleraiser(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::EDIT);
this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Bucket(this->colorPickerWidget))); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Bucket(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::EDIT);
qDebug() << "Mark_6.1";
qDebug() << "Mark_6.2";
this->_toolRegister->update(); this->_toolRegister->update();
...@@ -101,10 +108,11 @@ MainWindow::MainWindow(QWidget * parent) ...@@ -101,10 +108,11 @@ MainWindow::MainWindow(QWidget * parent)
this->_menubarManager.insert(this->_menuFile, QSharedPointer<ui::MenuLambda>(new ui::FilemenuLambda(this->_fileselectorManager, this->_viewManager))); this->_menubarManager.insert(this->_menuFile, QSharedPointer<ui::MenuLambda>(new ui::FilemenuLambda(this->_fileselectorManager, this->_viewManager)));
this->_menubarManager.insert(this->_menuAffichage, QSharedPointer<ui::MenuLambda>(new ui::DisplayMenuLambda(this->_viewManager))); this->_menubarManager.insert(this->_menuAffichage, QSharedPointer<ui::MenuLambda>(new ui::DisplayMenuLambda(this->_viewManager)));
this->_menubarManager.insert(this->_menuImage, QSharedPointer<ui::MenuLambda>(new ui::imagemenulambda(this->_rescaleDialog, this->_resizeDialog, this->_viewManager))); this->_menubarManager.insert(this->_menuImage, QSharedPointer<ui::MenuLambda>(new ui::imagemenulambda(this->_rescaleDialog, this->_resizeDialog, this->_viewManager)));
this->_menubarManager.insert(this->_menuSelection, QSharedPointer<ui::MenuLambda>(new ui::SelectionMenuLambda(this->_viewManager)));
this->_menubarManager.update(); this->_menubarManager.update();
qDebug() << "Mark_7"; qDebug() << "Mark_8";
_actionNoirEtBlanc = new QAction(QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/color-picker-black.png"), "Convertir en Noir et Blanc", this); _actionNoirEtBlanc = new QAction(QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/color-picker-black.png"), "Convertir en Noir et Blanc", this);
toolBarLeft->addAction(_actionNoirEtBlanc); toolBarLeft->addAction(_actionNoirEtBlanc);
...@@ -115,6 +123,7 @@ MainWindow::MainWindow(QWidget * parent) ...@@ -115,6 +123,7 @@ MainWindow::MainWindow(QWidget * parent)
toolBarLeft->addAction(_actionAdjustBrightnessContrast); toolBarLeft->addAction(_actionAdjustBrightnessContrast);
connect(_actionAdjustBrightnessContrast, &QAction::triggered, this, &MainWindow::adjustBrightnessContrastActionTriggered); connect(_actionAdjustBrightnessContrast, &QAction::triggered, this, &MainWindow::adjustBrightnessContrastActionTriggered);
qDebug() << "Mark_9";
_actionAdjustBrightness = new QAction("Augmenter la luminosité", this); _actionAdjustBrightness = new QAction("Augmenter la luminosité", this);
toolBarLeft->addAction(_actionAdjustBrightness); toolBarLeft->addAction(_actionAdjustBrightness);
...@@ -126,6 +135,8 @@ MainWindow::MainWindow(QWidget * parent) ...@@ -126,6 +135,8 @@ MainWindow::MainWindow(QWidget * parent)
_actionDecreaseBrightness->setVisible(false); _actionDecreaseBrightness->setVisible(false);
connect(_actionDecreaseBrightness, &QAction::triggered, this, &MainWindow::decreaseBrightnessActionTriggered); connect(_actionDecreaseBrightness, &QAction::triggered, this, &MainWindow::decreaseBrightnessActionTriggered);
qDebug() << "Mark_10";
_actionIncreaseContrast = new QAction("Augmenter le contraste", this); _actionIncreaseContrast = new QAction("Augmenter le contraste", this);
toolBarLeft->addAction(_actionIncreaseContrast); toolBarLeft->addAction(_actionIncreaseContrast);
_actionIncreaseContrast->setVisible(false); _actionIncreaseContrast->setVisible(false);
...@@ -136,7 +147,7 @@ MainWindow::MainWindow(QWidget * parent) ...@@ -136,7 +147,7 @@ MainWindow::MainWindow(QWidget * parent)
_actionDecreaseContrast->setVisible(false); _actionDecreaseContrast->setVisible(false);
connect(_actionDecreaseContrast, &QAction::triggered, this, &MainWindow::decreaseContrastActionTriggered); connect(_actionDecreaseContrast, &QAction::triggered, this, &MainWindow::decreaseContrastActionTriggered);
qDebug() << "Mark_8"; qDebug() << "Mark_11";
} }
void MainWindow::dragEnterEvent(QDragEnterEvent *e) { void MainWindow::dragEnterEvent(QDragEnterEvent *e) {
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>998</width> <width>983</width>
<height>698</height> <height>882</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
<item> <item>
<widget class="QLabel" name="_cuurentFilesLabel"> <widget class="QLabel" name="_cuurentFilesLabel">
<property name="text"> <property name="text">
<string>Fichiers Courrant :</string> <string>Fichiers Courant :</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -470,14 +470,14 @@ ...@@ -470,14 +470,14 @@
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="_toolLabel"> <widget class="QLabel" name="_selectionToolLabel">
<property name="text"> <property name="text">
<string>Outils :</string> <string>Outils de selection :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QListWidget" name="_toolbox"> <widget class="QListWidget" name="_selectionToolbox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -513,6 +513,32 @@ ...@@ -513,6 +513,32 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="_editLabel">
<property name="text">
<string>Outils d'édition :</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="_editToolbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="tabKeyNavigation">
<bool>true</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="_toolConfigButton"> <widget class="QPushButton" name="_toolConfigButton">
<property name="statusTip"> <property name="statusTip">
...@@ -622,7 +648,7 @@ ...@@ -622,7 +648,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>998</width> <width>983</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>
...@@ -695,6 +721,7 @@ ...@@ -695,6 +721,7 @@
<string>Selection</string> <string>Selection</string>
</property> </property>
<addaction name="_action_del"/> <addaction name="_action_del"/>
<addaction name="_action_unselect"/>
</widget> </widget>
<addaction name="_menuFile"/> <addaction name="_menuFile"/>
<addaction name="_menuSelection"/> <addaction name="_menuSelection"/>
...@@ -731,17 +758,6 @@ ...@@ -731,17 +758,6 @@
<addaction name="_action_turn_verticaly"/> <addaction name="_action_turn_verticaly"/>
<addaction name="_action_turn_horizonaly"/> <addaction name="_action_turn_horizonaly"/>
</widget> </widget>
<widget class="QToolBar" name="toolBarRight">
<property name="windowTitle">
<string>toolBar_2</string>
</property>
<attribute name="toolBarArea">
<enum>RightToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="_action_new"> <action name="_action_new">
<property name="icon"> <property name="icon">
<iconset resource="ressource.qrc"> <iconset resource="ressource.qrc">
...@@ -1049,7 +1065,7 @@ ...@@ -1049,7 +1065,7 @@
<string>Redimensionne l'image.</string> <string>Redimensionne l'image.</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+R</string> <string>Ctrl+Shift+R</string>
</property> </property>
</action> </action>
<action name="_action_rezise_draw_area"> <action name="_action_rezise_draw_area">
...@@ -1102,9 +1118,6 @@ ...@@ -1102,9 +1118,6 @@
<property name="statusTip"> <property name="statusTip">
<string>Effectue une rotation, vers la gauche, de l'image à 90 degrées.</string> <string>Effectue une rotation, vers la gauche, de l'image à 90 degrées.</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+G</string>
</property>
</action> </action>
<action name="_action_rotate_right_90"> <action name="_action_rotate_right_90">
<property name="icon"> <property name="icon">
...@@ -1117,9 +1130,6 @@ ...@@ -1117,9 +1130,6 @@
<property name="statusTip"> <property name="statusTip">
<string>Effectue une rotation, vers la droite, de l'image à 90 degrées.</string> <string>Effectue une rotation, vers la droite, de l'image à 90 degrées.</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+H</string>
</property>
</action> </action>
<action name="_action_rotate_180"> <action name="_action_rotate_180">
<property name="icon"> <property name="icon">
...@@ -1148,6 +1158,21 @@ ...@@ -1148,6 +1158,21 @@
<string>Ctrl+Shift+O</string> <string>Ctrl+Shift+O</string>
</property> </property>
</action> </action>
<action name="_action_unselect">
<property name="icon">
<iconset resource="ressource.qrc">
<normaloff>:/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-unselect.png</normaloff>:/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-unselect.png</iconset>
</property>
<property name="text">
<string>Déselectionner</string>
</property>
<property name="statusTip">
<string>Déselectionne la selection courrante</string>
</property>
<property name="shortcut">
<string>Ctrl+D</string>
</property>
</action>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>_filesSelector</tabstop> <tabstop>_filesSelector</tabstop>
...@@ -1157,7 +1182,7 @@ ...@@ -1157,7 +1182,7 @@
<tabstop>_colorPicker</tabstop> <tabstop>_colorPicker</tabstop>
<tabstop>_rescaleButton</tabstop> <tabstop>_rescaleButton</tabstop>
<tabstop>_resizeButton</tabstop> <tabstop>_resizeButton</tabstop>
<tabstop>_toolbox</tabstop> <tabstop>_selectionToolbox</tabstop>
<tabstop>_toolConfigButton</tabstop> <tabstop>_toolConfigButton</tabstop>
<tabstop>_emitDrawCheckbox</tabstop> <tabstop>_emitDrawCheckbox</tabstop>
<tabstop>_receiveDrawCheckbox</tabstop> <tabstop>_receiveDrawCheckbox</tabstop>
......
...@@ -416,6 +416,7 @@ ...@@ -416,6 +416,7 @@
<file>ressource/image/oxygen/icons/16x16/zoom-select.png</file> <file>ressource/image/oxygen/icons/16x16/zoom-select.png</file>
<file>ressource/image/oxygen/icons/16x16/align-none.png</file> <file>ressource/image/oxygen/icons/16x16/align-none.png</file>
<file>ressource/image/oxygen/icons/16x16/actions-fill-color-icon.png</file> <file>ressource/image/oxygen/icons/16x16/actions-fill-color-icon.png</file>
<file>ressource/image/oxygen/icons/16x16/draw-unselect.png</file>
</qresource> </qresource>
<qresource prefix="/stylesheet"/> <qresource prefix="/stylesheet"/>
<qresource prefix="/oxygen/64x64"> <qresource prefix="/oxygen/64x64">
......
IHM_Retouche_Photo/ressource/image/oxygen/icons/16x16/draw-unselect.png

492 B

#include "Brush.h"
#include "../../dialog/sizedialog.h"
namespace tool {
Brush::Brush(const ColorPickerWidget & cp)
: Editable(cp, "Brosse", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/document-sign.png")),
_config(new dialog::SizeDialog("Paramètre de la Brosse", "Taille de la brosse", 1, 255, 4)) {
this->setCongigurationDialog(this->_config.get());
QObject::connect(&cp, SIGNAL(currentColorChange(QColor)), this, SLOT(changeColor(QColor)));
}
void Brush::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget & cp) {
if(e.button() == Qt::LeftButton) {
this->_leftButton = true;
}
}
void Brush::onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) {
if(e.button() == Qt::LeftButton) {
this->_leftButton = false;
}
}
void Brush::onMouseMoved(ui::ImageArea & area, QImage & img, const QPoint & c, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) {
if(this->_leftButton && hold) {
int cx = c.x();
int cy = c.y();
int size = this->_config->value();
QColor color = cp.currentColor();
if(color.isValid()) {
for(int i = 0; i < size; i++) {
int dx = i - size / 2;
int x = cx + dx;
int h = qRound(size * qSqrt(size * size / 4.0 - dx * dx) /size);
for(int dy = 1; dy < h; dy++) {
QPoint p(x, cy + dy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
area.setColor(p, color);
}
else {
area.setColor(p, color);
}
}
p = QPoint(x, cy - dy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
area.setColor(p, color);
}
else {
area.setColor(p, color);
}
}
}
if(h >= 0) {
QPoint p(x, cy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
area.setColor(p, color);
}
else {
area.setColor(p, color);
}
}
}
}
}
}
}
}
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
namespace tool { namespace tool {
Pixeleraiser::Pixeleraiser(const ColorPickerWidget & cp) Pixeleraiser::Pixeleraiser(const ColorPickerWidget & cp)
: Editable(cp, "Gomme Pixel", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-eraser.png")), _leftButton(false), _rightButton(false) {} : Editable(cp, "Gomme", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-eraser.png")),
_config(new dialog::SizeDialog("Paramètre du crayon", "Taille du crayon", 1, 255, 4)), _leftButton(false), _rightButton(false) {
this->setCongigurationDialog(this->_config.get());
}
void Pixeleraiser::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { void Pixeleraiser::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) {
if(e.button() == Qt::LeftButton) { if(e.button() == Qt::LeftButton) {
...@@ -24,21 +27,81 @@ namespace tool { ...@@ -24,21 +27,81 @@ namespace tool {
} }
} }
void Pixeleraiser::onMouseMoved(ui::ImageArea & a, QImage &, const QPoint & p, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget &, bool hold) { void Pixeleraiser::onMouseMoved(ui::ImageArea & area, QImage & img, const QPoint & c, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) {
if(hold && this->_leftButton) { if(hold) {
if(s.empty()) { int cx = c.x();
a.setColor(p, QColor(0, 0, 0, 0)); int cy = c.y();
int size = this->_config->value();
for(int i = 0; i < size; i++) {
int dx = i - size / 2;
int x = cx + dx;
int h = qRound(size * qSqrt(size * size / 4.0 - dx * dx) /size);
for(int dy = 1; dy < h; dy++) {
QPoint p(x, cy + dy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
if(this->_leftButton) {
area.setColor(p, QColor(0, 0, 0, 0));
}
else if(this->_rightButton) {
area.setColor(p ,QColorConstants::White);
}
}
else {
if(this->_leftButton) {
area.setColor(p, QColor(0, 0, 0, 0));
}
else if(this->_rightButton) {
area.setColor(p ,QColorConstants::White);
}
}
}
p = QPoint(x, cy - dy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
if(this->_leftButton) {
area.setColor(p, QColor(0, 0, 0, 0));
}
else if(this->_rightButton) {
area.setColor(p ,QColorConstants::White);
}
}
else {
if(this->_leftButton) {
area.setColor(p, QColor(0, 0, 0, 0));
}
else if(this->_rightButton) {
area.setColor(p ,QColorConstants::White);
}
}
}
}
if(h >= 0) {
QPoint p(x, cy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
if(this->_leftButton) {
area.setColor(p, QColor(0, 0, 0, 0));
}
else if(this->_rightButton) {
area.setColor(p ,QColorConstants::White);
}
}
else {
if(this->_leftButton) {
area.setColor(p, QColor(0, 0, 0, 0));
}
else if(this->_rightButton) {
area.setColor(p ,QColorConstants::White);
} }
else if(s.contain(p)) {
a.setColor(p, QColor(0, 0, 0, 0));
} }
} }
else if(hold && this->_rightButton) {
if(s.empty()) {
a.setColor(p, QColorConstants::White);
} }
else if(s.contain(p)) {
a.setColor(p, QColorConstants::White);
} }
} }
} }
......
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
#include "../editable.h" #include "../editable.h"
#include <dialog/sizedialog.h>
namespace tool { namespace tool {
class Pixeleraiser : public Editable { class Pixeleraiser : public Editable {
private: private:
QSharedPointer<dialog::SizeDialog> _config;
bool _leftButton; bool _leftButton;
bool _rightButton; bool _rightButton;
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
namespace tool { namespace tool {
Pixelpainter::Pixelpainter(const ColorPickerWidget & cp) Pixelpainter::Pixelpainter(const ColorPickerWidget & cp)
: Editable(cp, "Crayon Pixel", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-freehand.png")), _leftButton(false) {} : Editable(cp, "Crayon", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-freehand.png")),
_config(new dialog::SizeDialog("Paramètre du crayon", "Taille du crayon", 1, 255, 4)), _leftButton(false) {
this->setCongigurationDialog(this->_config.get());
}
void Pixelpainter::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { void Pixelpainter::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) {
if(e.button() == Qt::LeftButton) { if(e.button() == Qt::LeftButton) {
...@@ -16,13 +19,55 @@ namespace tool { ...@@ -16,13 +19,55 @@ namespace tool {
} }
} }
void Pixelpainter::onMouseMoved(ui::ImageArea & a, QImage &, const QPoint & p, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) { void Pixelpainter::onMouseMoved(ui::ImageArea & area, QImage & img, const QPoint & c, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) {
if(hold && this->_leftButton) { if(this->_leftButton && hold) {
if(s.empty()) { int cx = c.x();
a.setColor(p, cp.currentColor()); int cy = c.y();
int size = this->_config->value();
QColor color = cp.currentColor();
if(color.isValid()) {
for(int i = 0; i < size; i++) {
int dx = i - size / 2;
int x = cx + dx;
int h = qRound(size * qSqrt(size * size / 4.0 - dx * dx) /size);
for(int dy = 1; dy < h; dy++) {
QPoint p(x, cy + dy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
area.setColor(p, color);
}
else {
area.setColor(p, color);
}
}
p = QPoint(x, cy - dy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
area.setColor(p, color);
}
else {
area.setColor(p, color);
}
}
}
if(h >= 0) {
QPoint p(x, cy);
if(img.rect().contains(p)) {
if(!s.empty() && s.contain(p)) {
area.setColor(p, color);
}
else {
area.setColor(p, color);
}
}
}
} }
else if(s.contain(p)) {
a.setColor(p, cp.currentColor());
} }
} }
} }
......
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
#include "../editable.h" #include "../editable.h"
#include <dialog/sizedialog.h>
namespace tool { namespace tool {
class Pixelpainter : public Editable { class Pixelpainter : public Editable {
private: private:
QSharedPointer<dialog::SizeDialog> _config;
bool _leftButton; bool _leftButton;
public: public:
......
#include "tool.h" #include "tool.h"
namespace tool { namespace tool {
Tool::Tool(const QString & name, const QIcon & icon, QSharedPointer<QDialog> configDialog) Tool::Tool(const QString & name, const QIcon & icon)
: QListWidgetItem(), _configurationDialog(configDialog) { : QListWidgetItem(), _configurationDialog(nullptr) {
this->setText(name); this->setText(name);
this->setIcon(icon); this->setIcon(icon);
} }
void Tool::showConfiguration() { void Tool::showConfiguration() {
if(!this->_configurationDialog.isNull()) { if(this->_configurationDialog != nullptr) {
this->_configurationDialog.get()->exec(); this->_configurationDialog->exec();
} }
} }
} }
...@@ -11,15 +11,17 @@ namespace tool { ...@@ -11,15 +11,17 @@ namespace tool {
class Tool : public QObject, public QListWidgetItem { class Tool : public QObject, public QListWidgetItem {
Q_OBJECT Q_OBJECT
private: private:
QSharedPointer<QDialog> _configurationDialog; QDialog * _configurationDialog;
public: public:
Tool(const QString &, const QIcon &, QSharedPointer<QDialog> = nullptr); Tool(const QString &, const QIcon &);
virtual inline Qt::CursorShape shape() const {return Qt::CursorShape::ArrowCursor;} virtual inline Qt::CursorShape shape() const {return Qt::CursorShape::ArrowCursor;}
inline bool HaveConfigurationDialog() const {return !this->_configurationDialog.isNull();} inline bool HaveConfigurationDialog() const {return this->_configurationDialog != nullptr;}
inline QDialog * configurationDialog() const {return this->_configurationDialog.get();} inline QDialog * configurationDialog() const {return this->_configurationDialog;}
inline void setCongigurationDialog(QDialog * dial) {this->_configurationDialog = dial;}
public slots: public slots:
virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) = 0; virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) = 0;
......
...@@ -17,5 +17,7 @@ namespace ui { ...@@ -17,5 +17,7 @@ namespace ui {
QObject::connect(menu->actions().at(Actions::SAVE), SIGNAL(triggered()), this->_viewManager, SLOT(saveCurrentView())); QObject::connect(menu->actions().at(Actions::SAVE), SIGNAL(triggered()), this->_viewManager, SLOT(saveCurrentView()));
QObject::connect(menu->actions().at(Actions::SAVE_AS), SIGNAL(triggered()), this->_viewManager, SLOT(saveAsCurrentView())); QObject::connect(menu->actions().at(Actions::SAVE_AS), SIGNAL(triggered()), this->_viewManager, SLOT(saveAsCurrentView()));
QObject::connect(menu->actions().at(Actions::NEW), SIGNAL(triggered()), this->_viewManager, SLOT(newView())); QObject::connect(menu->actions().at(Actions::NEW), SIGNAL(triggered()), this->_viewManager, SLOT(newView()));
QObject::connect(menu->actions().at(Actions::CLOSE), SIGNAL(triggered()), this->_viewManager, SLOT(deleteCurrentView()));
} }
} }
#include "selectionmenulambda.h"
namespace ui {
SelectionMenuLambda::SelectionMenuLambda(ViewManager * manager)
: _menu(nullptr), _manager(manager) {
}
void SelectionMenuLambda::initializeMenu(const QMenu * menu) {
this->_menu = menu;
QObject::connect(this->_manager, SIGNAL(changedView(ImageArea*)), this, SLOT(viewChanged(ImageArea*)));
}
void SelectionMenuLambda::viewChanged(ImageArea * area) {
if(area != nullptr && this->_menu != nullptr) {
QObject::connect(this->_menu->actions().at(Actions::SUPPR), SIGNAL(triggered()), area, SLOT(deleteCurrentSelection()));
QObject::connect(this->_menu->actions().at(Actions::UNSELECT), SIGNAL(triggered()), &area->selection(), SLOT(clear()));
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment