From 3f539f5313e06960eb626c53e1027ffd2f4dda29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Sat, 14 Apr 2012 13:05:03 +0000 Subject: [PATCH] paysages: Made colorgradation dialog sizable and take less space initially. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@294 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 18 ++++++++- gui_qt/dialogcolorgradation.cpp | 66 +++++++++++++++++++++++++-------- gui_qt/widgetcurveeditor.cpp | 32 +++++++++------- i18n/paysages_fr.ts | 18 ++++----- 4 files changed, 95 insertions(+), 39 deletions(-) diff --git a/TODO b/TODO index ef4630d..258cd7b 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,23 @@ -- Make colorgradation dialog sizable (and reduce minimum size). +Technology Preview 1 : - Make all UI more sizable. - Implement scrolling on previews. +- Find a licence and apply it. + +Technology Preview 2 : - Add a material editor dialog. +- Add a zone editor dialog for localized textures. +- Add a terrain modifier dialog with zones. +- Improve curve editor. - Replace FILE* by a custom type for Save and Load. - Water and terrain LOD moves with the camera, fix it like in the wanderer. - Implement a file header/versioning. + +Technology Preview 3 : - Restore render progress. -- Find a licence and apply it. +- Add basic vegetation system (not sure). +- Improve sky rendering (colors and light halo). +- Add rendering steps in small previews (not sure). + +Release Candidate : +- Polish all features and UI. +- More translations. diff --git a/gui_qt/dialogcolorgradation.cpp b/gui_qt/dialogcolorgradation.cpp index c1b443f..eb9a694 100644 --- a/gui_qt/dialogcolorgradation.cpp +++ b/gui_qt/dialogcolorgradation.cpp @@ -21,6 +21,7 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad QWidget* buttons; QWidget* form; QGridLayout* form_layout; + QLabel* label; _base = gradation; _current = colorGradationCreate(); @@ -33,33 +34,67 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad form->setLayout(form_layout); layout()->addWidget(form); - form_layout->addWidget(new QLabel(tr("This is the curve editor for color components.\nClick on a component preview below to edit it.\nClick on points and drag them to move them.\nDouble click to add a new point.\nRight click on a point to delete it."), form), 0, 0); + label = new QLabel(tr("This is the curve editor for color components.\nClick on a component preview below to edit it.\nClick on points and drag them to move them.\nDouble click to add a new point.\nRight click on a point to delete it."), form); + label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); + label->setMinimumWidth(150); + label->setMaximumWidth(200); + label->setWordWrap(true); + form_layout->addWidget(label, 0, 1); _curve_editor = new WidgetCurveEditor(form); - form_layout->addWidget(_curve_editor, 0, 1); + _curve_editor->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + form_layout->addWidget(_curve_editor, 0, 0); connect(_curve_editor, SIGNAL(liveChanged()), this, SLOT(updateColors())); - - form_layout->addWidget(new QLabel(tr("Red preview, click to edit"), form), 1, 0); + + label = new QLabel(tr("Red preview, click to edit"), form); + label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); + label->setMinimumWidth(150); + label->setMaximumWidth(200); + label->setWordWrap(true); + form_layout->addWidget(label, 1, 1); _preview_red = new PreviewColorGradation(form, _current, COLORGRADATIONBAND_RED); - _preview_red->setMinimumHeight(50); + _preview_red->setMinimumHeight(30); + _preview_red->setMaximumHeight(60); + _preview_red->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); connect(_preview_red, SIGNAL(clicked()), this, SLOT(selectRed())); - form_layout->addWidget(_preview_red, 1, 1); + form_layout->addWidget(_preview_red, 1, 0); - form_layout->addWidget(new QLabel(tr("Green preview, click to edit"), form), 2, 0); + label = new QLabel(tr("Green preview, click to edit"), form); + label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); + label->setMinimumWidth(150); + label->setMaximumWidth(200); + label->setWordWrap(true); + form_layout->addWidget(label, 2, 1); _preview_green = new PreviewColorGradation(form, _current, COLORGRADATIONBAND_GREEN); - _preview_green->setMinimumHeight(50); + _preview_green->setMinimumHeight(30); + _preview_green->setMaximumHeight(60); + _preview_green->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); connect(_preview_green, SIGNAL(clicked()), this, SLOT(selectGreen())); - form_layout->addWidget(_preview_green, 2, 1); + form_layout->addWidget(_preview_green, 2, 0); - form_layout->addWidget(new QLabel(tr("Blue preview, click to edit"), form), 3, 0); + label = new QLabel(tr("Blue preview, click to edit"), form); + label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); + label->setMinimumWidth(150); + label->setMaximumWidth(200); + label->setWordWrap(true); + form_layout->addWidget(label, 3, 1); _preview_blue = new PreviewColorGradation(form, _current, COLORGRADATIONBAND_BLUE); - _preview_blue->setMinimumHeight(50); + _preview_blue->setMinimumHeight(30); + _preview_blue->setMaximumHeight(60); + _preview_blue->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); connect(_preview_blue, SIGNAL(clicked()), this, SLOT(selectBlue())); - form_layout->addWidget(_preview_blue, 3, 1); + form_layout->addWidget(_preview_blue, 3, 0); - form_layout->addWidget(new QLabel(tr("Final preview"), form), 4, 0); + label = new QLabel(tr("Final preview"), form); + label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); + label->setMinimumWidth(150); + label->setMaximumWidth(200); + label->setWordWrap(true); + form_layout->addWidget(label, 4, 1); _preview_final = new PreviewColorGradation(form, _current, COLORGRADATIONBAND_FINAL); - _preview_final->setMinimumHeight(50); - form_layout->addWidget(_preview_final, 4, 1); + _preview_final->setMinimumHeight(30); + _preview_final->setMaximumHeight(60); + _preview_final->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + form_layout->addWidget(_preview_final, 4, 0); buttons = new QWidget(this); layout()->addWidget(buttons); @@ -80,6 +115,7 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad _curve = curveCreate(); setWindowTitle(tr("Paysages 3D - Color gradation editor")); + resize(900, 600); revert(); } diff --git a/gui_qt/widgetcurveeditor.cpp b/gui_qt/widgetcurveeditor.cpp index 31b1242..958ddf9 100644 --- a/gui_qt/widgetcurveeditor.cpp +++ b/gui_qt/widgetcurveeditor.cpp @@ -10,8 +10,7 @@ WidgetCurveEditor::WidgetCurveEditor(QWidget *parent) : QWidget(parent) _dragged = -1; _pen = QColor(0, 0, 0); - setMinimumSize(500, 500); - setMaximumSize(500, 500); + setMinimumSize(300, 300); } WidgetCurveEditor::~WidgetCurveEditor() @@ -39,25 +38,32 @@ void WidgetCurveEditor::setPenColor(QColor color) void WidgetCurveEditor::paintEvent(QPaintEvent* event) { int i, n; + int width, height; + double dwidth, dheight; CurvePoint point; double position, value; + width = this->width(); + height = this->height(); + dheight = (double)(height - 1); + dwidth = (double)(width - 1); + QPainter painter(this); - painter.fillRect(0, 0, 500, 500, QColor(255, 255, 255)); + painter.fillRect(0, 0, width, height, QColor(255, 255, 255)); painter.setPen(_pen); - for (int x = 0; x < 500; x++) + for (int x = 0; x < width; x++) { - position = ((double)x) / 499.0; + position = ((double)x) / dwidth; value = curveGetValue(_curve, position); - painter.drawPoint(x, 499 - (int)(value * 499.0)); + painter.drawPoint(x, height - 1 - (int)(value * dheight)); } n = curveGetPointCount(_curve); for (i = 0; i < n; i++) { curveGetPoint(_curve, i, &point); - painter.drawEllipse(QPointF((int)(point.position * 499.0), 499 - (int)(point.value * 499.0)), 4.0, 4.0); + painter.drawEllipse(QPointF((int)(point.position * dwidth), height - 1 - (int)(point.value * dheight)), 4.0, 4.0); } } @@ -77,8 +83,8 @@ void WidgetCurveEditor::mouseMoveEvent(QMouseEvent* event) if (_dragged >= 0 && (event->buttons() & Qt::LeftButton)) { - point.position = ((double)event->x()) / 499.0; - point.value = 1.0 - ((double)event->y()) / 499.0; + point.position = ((double)event->x()) / (double)(width() - 1); + point.value = 1.0 - ((double)event->y()) / (double)(height() - 1); point.position = (point.position < 0.0) ? 0.0 : point.position; point.position = (point.position > 1.0) ? 1.0 : point.position; @@ -127,8 +133,8 @@ void WidgetCurveEditor::mouseDoubleClickEvent(QMouseEvent* event) { if (getPointAt(event->x(), event->y()) < 0) { - point.position = ((double)event->x()) / 499.0; - point.value = 1.0 - ((double)event->y()) / 499.0; + point.position = ((double)event->x()) / (double)(width() - 1); + point.value = 1.0 - ((double)event->y()) / (double)(height() - 1); curveAddPoint(_curve, &point); curveValidate(_curve); @@ -144,8 +150,8 @@ int WidgetCurveEditor::getPointAt(int x, int y) int nearest; double distance, ndistance; CurvePoint point; - double dx = ((double)x) / 499.0; - double dy = 1.0 - ((double)y) / 499.0; + double dx = ((double)x) / (double)(width() - 1); + double dy = 1.0 - ((double)y) / (double)(height() - 1); n = curveGetPointCount(_curve); if (n < 1) diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index b45dab0..fb388e0 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -37,7 +37,7 @@ DialogColorGradation - + This is the curve editor for color components. Click on a component preview below to edit it. Click on points and drag them to move them. @@ -50,42 +50,42 @@ Double cliquez sur le fond pour ajouter un point. Cliquez avec le bouton droit sur un point pour le supprimer. - + Red preview, click to edit Aperçu du rouge, cliquer pour éditer - + Green preview, click to edit Aperçu du vert, cliquer pour éditer - + Blue preview, click to edit Aperçu du bleu, cliquez pour éditer - + Final preview Aperçu du gradient final - + Validate Valider - + Revert Recommencer - + Cancel Annuler - + Paysages 3D - Color gradation editor Paysages 3D - Editeur de gradients de couleur