Nicolas Winkler 5 years ago
parent
commit
b43feb8d6d
10 changed files with 60 additions and 23 deletions
  1. 2 3
      Almond.pro
  2. 1 0
      Almond.qrc
  3. 9 7
      Gradient.cpp
  4. 10 8
      MandelWidget.cpp
  5. 4 2
      VideoStream.cpp
  6. 1 1
      exportdialogs.cpp
  7. 0 2
      fdgsdfg.qrc
  8. 26 0
      gradientchoosedialog.cpp
  9. 4 0
      gradientchoosedialog.h
  10. 3 0
      gradientchooser.ui

+ 2 - 3
Almond.pro

@@ -10,7 +10,6 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
 TARGET = Almond
 TEMPLATE = app
-
 # The following define makes your compiler emit warnings if you use
 # any feature of Qt which has been marked as deprecated (the exact warnings
 # depend on your compiler). Please consult the documentation of the
@@ -57,6 +56,7 @@ FORMS += \
         gradientchooser.ui
 
 
+
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin
 else: unix:!android: target.path = /opt/$${TARGET}/bin
@@ -114,8 +114,7 @@ unix|win32: LIBS += -L$$PWD/../libs/ffmpeg-4.1.1-win32-dev/lib/ -lswscale
 #INCLUDEPATH += $$PWD/../libs/ffmpeg-4.1.1-win32-dev/include
 #DEPENDPATH += $$PWD/../libs/ffmpeg-4.1.1-win32-dev/include
 
-RESOURCES += \
-    Almond.qrc
+RESOURCES += Almond.qrc
 
 unix|win32: LIBS += -L$$PWD/libmandel/ -lmandel
 

+ 1 - 0
Almond.qrc

@@ -1,4 +1,5 @@
 <RCC>
     <qresource prefix="Almond">
+        <file alias="clouds">gradients/clouds.xml</file>
     </qresource>
 </RCC>

+ 9 - 7
Gradient.cpp

@@ -159,14 +159,16 @@ Gradient Gradient::defaultGradient(void)
     std::vector<std::pair<RGBColor, float>> colors = {
         { RGBColor{0, 0, 0}, 0 },
         { RGBColor{ 250, 70, 24 }, 40 },
-        { RGBColor{ 200, 230, 30 }, 104 },
-        { RGBColor{ 70, 223, 30 }, 190 },
-        { RGBColor{ 14, 20, 150 }, 295 },
-        { RGBColor{ 36, 155, 169 }, 418 },
-        { RGBColor{ 233, 33, 79 }, 558 },
+        { RGBColor{ 200, 230, 30 }, 80 },
+        { RGBColor{ 70, 223, 30 }, 105 },
+        { RGBColor{ 40, 190, 240 }, 140 },
+        { RGBColor{ 120, 60, 160 }, 230 },
+        { RGBColor{ 14, 20, 180 }, 300 },
+        { RGBColor{ 240, 240, 240 }, 418 },
+        { RGBColor{ 243, 20, 20 }, 558 },
         { RGBColor{ 254, 169, 63 }, 714 },
-        { RGBColor{ 227, 93, 201 }, 885 },
-        { RGBColor{ 188, 24, 161 }, 1071 },
+        { RGBColor{ 8, 50, 8 }, 885 },
+        { RGBColor{ 188, 5, 161 }, 1071 },
         { RGBColor{ 45, 225, 44 }, 1271 },
         { RGBColor{ 52, 58, 250 }, 1485 },
         { RGBColor{ 87, 93, 241 }, 1712 },

+ 10 - 8
MandelWidget.cpp

@@ -757,14 +757,16 @@ void MandelWidget::mouseReleaseEvent(QMouseEvent* me)
     QOpenGLWidget::mouseReleaseEvent(me);
     if (rubberbanding) {
         QRect rect = rubberband.toRect();
-        QRect full = this->geometry();
-
-        targetViewport.x += double(rect.left()) * targetViewport.width / full.width();
-        targetViewport.y += double(rect.top()) * targetViewport.height / full.height();
-        targetViewport.width *= double(rect.width()) / full.width();
-        targetViewport.height *= double(rect.height()) / full.height();
-        targetViewport.normalize();
-        currentViewport = targetViewport;
+        if(rect.width() != 0 && rect.height() != 0) {
+            QRect full = this->geometry();
+
+            targetViewport.x += double(rect.left()) * targetViewport.width / full.width();
+            targetViewport.y += double(rect.top()) * targetViewport.height / full.height();
+            targetViewport.width *= double(rect.width()) / full.width();
+            targetViewport.height *= double(rect.height()) / full.height();
+            targetViewport.normalize();
+            currentViewport = targetViewport;
+        }
         requestRecalc();
         rubberbanding = false;
     }

+ 4 - 2
VideoStream.cpp

@@ -27,7 +27,9 @@ VideoStream::VideoStream(int width, int height, const std::string& filename, int
         exit(1);
     }
 
-    AVOutputFormat* oformat = av_guess_format("mp4", NULL, NULL);
+    AVOutputFormat* oformat = av_guess_format(nullptr, filename.c_str(), nullptr);
+    if (!oformat)
+        oformat = av_guess_format("mp4", nullptr, nullptr);
     if (oformat == nullptr)
         throw "invalid format";
 
@@ -130,7 +132,7 @@ void VideoStream::encode(AVFrame* frame)
         //fwrite(pkt->data, 1, pkt->size, outfile);
         //av_interleaved_write_frame(formatContext, pkt);
 
-        av_packet_rescale_ts(pkt, (AVRational){1, 25}, stream->time_base);
+        av_packet_rescale_ts(pkt, AVRational{1, 60}, stream->time_base);
         pkt->stream_index = stream->index;
 
         av_write_frame(formatContext, pkt);

+ 1 - 1
exportdialogs.cpp

@@ -151,7 +151,7 @@ void ExportVideoDialog::on_pushButton_clicked()
 {
     QString saveAs = QFileDialog::getSaveFileName(this,
             tr("Save exported image"), "",
-            tr("MP4 video (*.mp4);;All Files (*)"));
+            tr("AVI video (*.avi);;MP4 video (*.mp4);;All Files (*)"));
     evd.savePath->setText(saveAs);
     this->repaint();
 }

+ 0 - 2
fdgsdfg.qrc

@@ -1,2 +0,0 @@
-<!DOCTYPE RCC>
-<RCC version="1.0"/>

+ 26 - 0
gradientchoosedialog.cpp

@@ -1,6 +1,18 @@
 #include "gradientchoosedialog.h"
 
 #include <QtXml/QDomDocument>
+#include <QFile>
+#include <QResource>
+#include <QDir>
+
+
+//resource hacks
+static const std::string clouds_xml = "";
+
+std::map<std::string, std::string> GradientChooseDialog::presets {
+    { "clouds", clouds_xml }
+};
+
 
 GradientChooseDialog::GradientChooseDialog()
 {
@@ -8,6 +20,13 @@ GradientChooseDialog::GradientChooseDialog()
     QFont f("unexistent");
     f.setStyleHint(QFont::Monospace);
     gcd.plainTextEdit->setFont(f);
+
+
+    QFile qf(":/Almond/clouds");
+    QString str = QString::fromUtf8(qf.readAll());
+    printf("%s\n", str.toStdString().c_str());
+    gcd.presets->addItem("clouds");
+    gcd.presets->addItem("none");
 }
 
 #if 0
@@ -49,3 +68,10 @@ void GradientChooseDialog::on_buttonBox_clicked(QAbstractButton *button)
 {
 
 }
+
+void GradientChooseDialog::on_presets_currentIndexChanged(const QString& index)
+{
+    QResource gr(":/gradients/clouds.xml");
+    QString str = QString::fromUtf8(reinterpret_cast<const char*>(gr.data()));
+    emit gcd.plainTextEdit->setPlainText(str);
+}

+ 4 - 0
gradientchoosedialog.h

@@ -6,6 +6,7 @@
 #include "Gradient.h"
 
 #include <memory>
+#include <map>
 
 class GradientChooseDialog : public QDialog
 {
@@ -13,12 +14,15 @@ class GradientChooseDialog : public QDialog
 private:
     Ui::GradientChooser gcd;
     std::unique_ptr<Gradient> chosenGradient = nullptr;
+    static std::map<std::string, std::string> presets;
 public:
     GradientChooseDialog();
 private slots:
     void on_buttonBox_accepted();
     void on_buttonBox_clicked(QAbstractButton *button);
 
+    void on_presets_currentIndexChanged(const QString &arg1);
+
 public:
     inline std::unique_ptr<Gradient> getGradient(void) { return std::move(chosenGradient); }
 };

+ 3 - 0
gradientchooser.ui

@@ -15,6 +15,9 @@
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
+    <widget class="QComboBox" name="presets"/>
+   </item>
+   <item>
     <widget class="QPlainTextEdit" name="plainTextEdit">
      <property name="font">
       <font>