Преглед на файлове

add fullscreen mode (F11) closes #17

Nicolas Winkler преди 4 години
родител
ревизия
97adb8880a
променени са 9 файла, в които са добавени 20 реда и са изтрити 564 реда
  1. 2 11
      Almond.pro
  2. 1 4
      include/Almond.h
  3. 1 1
      include/FractalZoomWidget.h
  4. 7 5
      src/Almond.cpp
  5. 4 13
      src/EscapeTimeVisualWidget.cpp
  6. 5 2
      src/FractalZoomWidget.cpp
  7. 0 151
      ui/exportimagedialog.ui
  8. 0 301
      ui/exportvideodialog.ui
  9. 0 76
      ui/gradientchooser.ui

+ 2 - 11
Almond.pro

@@ -39,11 +39,8 @@ SOURCES += \
         src/FractalZoomWidget.cpp \
         src/GradientMenu.cpp \
         src/GradientWidget.cpp \
-        src/MandelWidget.cpp \
         src/choosegenerators.cpp \
         src/customgenerator.cpp \
-        src/exportdialogs.cpp \
-        src/gradientchoosedialog.cpp \
         src/GridFlowLayout.cpp \
         src/main.cpp
 
@@ -60,12 +57,9 @@ HEADERS += \
         include/FractalZoomWidget.h \
         include/GradientMenu.h \
         include/GradientWidget.h \
-        include/MandelWidget.h \
         include/choosegenerators.h \
         include/customgenerator.h \
-        include/exportdialogs.h \
-        include/GridFlowLayout.h \
-        include/gradientchoosedialog.h
+        include/GridFlowLayout.h
 
 FORMS += \
         ui/Almond.ui \
@@ -73,10 +67,7 @@ FORMS += \
         ui/ExportVideoMenu.ui \
         ui/GradientMenu.ui \
         ui/choosegenerators.ui \
-        ui/customgenerator.ui \
-        ui/exportimagedialog.ui \
-        ui/exportvideodialog.ui \
-        ui/gradientchooser.ui
+        ui/customgenerator.ui
 
 INCLUDEPATH += include
 

+ 1 - 4
include/Almond.h

@@ -6,10 +6,7 @@
 #include "ui_Almond.h"
 
 #include <Mandel.h>
-#include "MandelWidget.h"
 #include "BackgroundTask.h"
-#include "exportdialogs.h"
-#include "gradientchoosedialog.h"
 #include "choosegenerators.h"
 #include "customgenerator.h"
 
@@ -52,13 +49,13 @@ private:
     GradientMenu* gradientMenu;
 
     bool fullscreenMode = false;
+    bool maximizedBeforeFullscreen = true;
     QWidget* cw;
 public:
     FractalWidget* fractalWidget;
 private:
     //std::unique_ptr<BenchmarkDialog> benchmarkDialog;
     std::unique_ptr<CustomGenerator> customGeneratorDialog;
-    GradientChooseDialog gcd;
 
     std::vector<std::unique_ptr<FractalDef>> customGenerators;
     FractalDef* currentCustom;

+ 1 - 1
include/FractalZoomWidget.h

@@ -97,7 +97,7 @@ class FractalZoomWidget :
     mnd::MandelGenerator* generator;
     Calcer calcer;
 
-    ETVImage* emptyImage;
+    std::unique_ptr<ETVImage> emptyImage;
 
     const bool useUploadThread = false;
     TextureUploader* uploader;

+ 7 - 5
src/Almond.cpp

@@ -6,7 +6,7 @@
 #include <QStatusBar>
 #include <QGradient>
 #include <QWindow>
-#include "gradientchoosedialog.h"
+#include <QKeyEvent>
 
 #include "GridFlowLayout.h"
 
@@ -212,21 +212,23 @@ void Almond::gradientEditOk(void)
 
 void Almond::toggleFullscreen(void)
 {
-    /*
     if (fullscreenMode) {
         auto* m = this->takeCentralWidget();
         ui.mandel_container->addWidget(m);
         this->setCentralWidget(cw);
-        emit this->showNormal();
+        if (maximizedBeforeFullscreen)
+            this->showMaximized();
+        else
+            this->showNormal();
         fullscreenMode = false;
     }
     else {
         cw = this->takeCentralWidget();
-        this->setCentralWidget(mw.get());
+        this->setCentralWidget(fractalWidget);
+        maximizedBeforeFullscreen = this->isMaximized();
         emit this->showFullScreen();
         fullscreenMode = true;
     }
-    */
 }
 
 

+ 4 - 13
src/EscapeTimeVisualWidget.cpp

@@ -388,19 +388,7 @@ void EscapeTimeVisualWidget::initializeGL(void)
 
     unsigned char pix[] = { 255, 0, 0, 0, 255, 0, 0, 0, 255 };
 
-    GLuint id;
-    gl.glEnable(GL_TEXTURE_2D);
-    gl.glGenTextures(1, &id);
-    gl.glBindTexture(GL_TEXTURE_2D, id);
-
-    gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 3, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<char*> (pix));
-    gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-    gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-    gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    gl.glBindTexture(GL_TEXTURE_2D, 0);
-
-    gradientTextureId = id;
+    updateGradient();
 
     gl.glDisable(GL_DEPTH_TEST);
     //gl3.glBindSampler(0, id);
@@ -536,6 +524,9 @@ void EscapeTimeVisualWidget::updateGradient(void)
     }
 
     gl.glEnable(GL_TEXTURE_2D);
+    if (gradientTextureId == 0)
+        gl.glGenTextures(1, &gradientTextureId);
+
     gl.glBindTexture(GL_TEXTURE_2D, gradientTextureId);
 
     gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, len, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<unsigned char*> (pixels.get()));

+ 5 - 2
src/FractalZoomWidget.cpp

@@ -178,7 +178,8 @@ const int FractalZoomWidget::chunkSize = 256;
 
 FractalZoomWidget::FractalZoomWidget(QWidget* parent) :
     EscapeTimeVisualWidget{ parent },
-    calcer{ *this }
+    calcer{ *this },
+    emptyImage{ nullptr }
 {
     qMetaTypeId<GridIndex>();
     setMaxIterations(250);
@@ -416,9 +417,11 @@ void FractalZoomWidget::initializeGL(void)
     EscapeTimeVisualWidget::initializeGL();
     Bitmap<float> empty{ 1, 1 };
     empty.get(0, 0) = 0.0f;
-    emptyImage = new ETVImage(*this, empty);
+    emptyImage = std::make_unique<ETVImage>(*this, empty);
 
 
+    // disconnect calcer from everything and reconnect
+    disconnect(&calcer, &Calcer::done, nullptr, nullptr);
     if (useUploadThread) {
         uploader = new TextureUploader(*this);
         uploadeThread = new QThread(this);

+ 0 - 151
ui/exportimagedialog.ui

@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ExportImageDialog</class>
- <widget class="QDialog" name="ExportImageDialog">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>712</width>
-    <height>227</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Export Image</string>
-  </property>
-  <property name="sizeGripEnabled">
-   <bool>false</bool>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <layout class="QFormLayout" name="formLayout">
-     <property name="sizeConstraint">
-      <enum>QLayout::SetDefaultConstraint</enum>
-     </property>
-     <property name="rowWrapPolicy">
-      <enum>QFormLayout::DontWrapRows</enum>
-     </property>
-     <item row="0" column="0">
-      <widget class="QLabel" name="label">
-       <property name="text">
-        <string>Maximum iterations</string>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="1">
-      <widget class="QLineEdit" name="maxIterations">
-       <property name="minimumSize">
-        <size>
-         <width>200</width>
-         <height>0</height>
-        </size>
-       </property>
-       <property name="text">
-        <string>5000</string>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="label_2">
-       <property name="text">
-        <string>Image Width</string>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="1">
-      <widget class="QLineEdit" name="imgWidth">
-       <property name="text">
-        <string>1920</string>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="0">
-      <widget class="QLabel" name="label_3">
-       <property name="text">
-        <string>Image Height</string>
-       </property>
-      </widget>
-     </item>
-     <item row="2" column="1">
-      <widget class="QLineEdit" name="imgHeight">
-       <property name="text">
-        <string>1080</string>
-       </property>
-      </widget>
-     </item>
-     <item row="3" column="0">
-      <widget class="QPushButton" name="pushButton">
-       <property name="text">
-        <string>Save As</string>
-       </property>
-      </widget>
-     </item>
-     <item row="3" column="1">
-      <widget class="QLineEdit" name="savePath">
-       <property name="minimumSize">
-        <size>
-         <width>500</width>
-         <height>0</height>
-        </size>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="enabled">
-      <bool>true</bool>
-     </property>
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>ExportImageDialog</receiver>
-   <slot>accept()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>248</x>
-     <y>254</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>rejected()</signal>
-   <receiver>ExportImageDialog</receiver>
-   <slot>reject()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>286</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>

+ 0 - 301
ui/exportvideodialog.ui

@@ -1,301 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ExportVideoDialog</class>
- <widget class="QDialog" name="ExportVideoDialog">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>1215</width>
-    <height>437</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Export Video</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_3">
-     <item>
-      <layout class="QFormLayout" name="formLayout">
-       <property name="sizeConstraint">
-        <enum>QLayout::SetMinimumSize</enum>
-       </property>
-       <item row="0" column="0">
-        <widget class="QLabel" name="label">
-         <property name="text">
-          <string>Maximum iterations</string>
-         </property>
-        </widget>
-       </item>
-       <item row="0" column="1">
-        <widget class="QLineEdit" name="maxIterations">
-         <property name="minimumSize">
-          <size>
-           <width>130</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="text">
-          <string>5000</string>
-         </property>
-        </widget>
-       </item>
-       <item row="1" column="0">
-        <widget class="QLabel" name="label_2">
-         <property name="text">
-          <string>Video Width</string>
-         </property>
-        </widget>
-       </item>
-       <item row="1" column="1">
-        <widget class="QLineEdit" name="vidWidth">
-         <property name="minimumSize">
-          <size>
-           <width>130</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="text">
-          <string>1920</string>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="0">
-        <widget class="QLabel" name="label_3">
-         <property name="text">
-          <string>Video Height</string>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="1">
-        <widget class="QLineEdit" name="vidHeight">
-         <property name="minimumSize">
-          <size>
-           <width>130</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="text">
-          <string>1080</string>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="0">
-        <widget class="QLabel" name="label_4">
-         <property name="text">
-          <string>Start View</string>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="1">
-        <layout class="QHBoxLayout" name="horizontalLayout">
-         <item>
-          <widget class="QLineEdit" name="startX">
-           <property name="minimumSize">
-            <size>
-             <width>80</width>
-             <height>0</height>
-            </size>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QLineEdit" name="startY">
-           <property name="minimumSize">
-            <size>
-             <width>80</width>
-             <height>0</height>
-            </size>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QLineEdit" name="startW">
-           <property name="minimumSize">
-            <size>
-             <width>80</width>
-             <height>0</height>
-            </size>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QLineEdit" name="startH">
-           <property name="minimumSize">
-            <size>
-             <width>80</width>
-             <height>0</height>
-            </size>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </item>
-       <item row="4" column="0">
-        <widget class="QLabel" name="label_5">
-         <property name="text">
-          <string>End View</string>
-         </property>
-        </widget>
-       </item>
-       <item row="4" column="1">
-        <layout class="QHBoxLayout" name="horizontalLayout_2">
-         <item>
-          <widget class="QLineEdit" name="endX"/>
-         </item>
-         <item>
-          <widget class="QLineEdit" name="endY"/>
-         </item>
-         <item>
-          <widget class="QLineEdit" name="endW"/>
-         </item>
-         <item>
-          <widget class="QLineEdit" name="endH"/>
-         </item>
-        </layout>
-       </item>
-       <item row="5" column="0">
-        <widget class="QPushButton" name="pushButton">
-         <property name="text">
-          <string>Save As</string>
-         </property>
-        </widget>
-       </item>
-       <item row="5" column="1">
-        <widget class="QLineEdit" name="savePath">
-         <property name="minimumSize">
-          <size>
-           <width>400</width>
-           <height>0</height>
-          </size>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <layout class="QFormLayout" name="formLayout_2">
-       <item row="0" column="0">
-        <widget class="QLabel" name="label_6">
-         <property name="text">
-          <string>Bitrate [kbps]</string>
-         </property>
-        </widget>
-       </item>
-       <item row="0" column="1">
-        <widget class="QLineEdit" name="bitrate">
-         <property name="minimumSize">
-          <size>
-           <width>130</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="text">
-          <string>5000</string>
-         </property>
-        </widget>
-       </item>
-       <item row="1" column="0">
-        <widget class="QLabel" name="label_7">
-         <property name="text">
-          <string>Encoding preset</string>
-         </property>
-        </widget>
-       </item>
-       <item row="1" column="1">
-        <widget class="QComboBox" name="encodingPresetBox">
-         <property name="editable">
-          <bool>false</bool>
-         </property>
-         <property name="currentText">
-          <string/>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="0">
-        <widget class="QLabel" name="label_8">
-         <property name="text">
-          <string>Fps</string>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="1">
-        <widget class="QLineEdit" name="fps">
-         <property name="text">
-          <string>60</string>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="0">
-        <widget class="QLabel" name="label_9">
-         <property name="text">
-          <string>Zoom Speed</string>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="1">
-        <widget class="QLineEdit" name="zoomSpeed">
-         <property name="text">
-          <string>1</string>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>ExportVideoDialog</receiver>
-   <slot>accept()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>248</x>
-     <y>254</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>rejected()</signal>
-   <receiver>ExportVideoDialog</receiver>
-   <slot>reject()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>286</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>

+ 0 - 76
ui/gradientchooser.ui

@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>GradientChooser</class>
- <widget class="QDialog" name="GradientChooser">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>457</width>
-    <height>313</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Dialog</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
-   <item>
-    <widget class="QComboBox" name="presets"/>
-   </item>
-   <item>
-    <widget class="QPlainTextEdit" name="plainTextEdit">
-     <property name="font">
-      <font>
-       <pointsize>10</pointsize>
-      </font>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>rejected()</signal>
-   <receiver>GradientChooser</receiver>
-   <slot>reject()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>286</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>GradientChooser</receiver>
-   <slot>accept()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>248</x>
-     <y>254</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>