Sfoglia il codice sorgente

better gradient editor

Nicolas Winkler 4 anni fa
parent
commit
fcc93bc836
5 ha cambiato i file con 82 aggiunte e 63 eliminazioni
  1. 1 0
      resources/Almond.qrc
  2. 34 0
      resources/icons/cancel.svg
  3. 0 21
      src/GradientWidget.cpp
  4. 3 3
      ui/Almond.ui
  5. 44 39
      ui/GradientMenu.ui

+ 1 - 0
resources/Almond.qrc

@@ -5,6 +5,7 @@
         <file alias="zoom_in">icons/zoom_in.svg</file>
         <file alias="zoom_out">icons/zoom_out.svg</file>
         <file alias="zoom_zero">icons/zoom_zero.svg</file>
+        <file alias="cancel">icons/cancel.svg</file>
     </qresource>
     <qresource prefix="/gradients">
         <file alias="oldschool">gradients/oldschool.xml</file>

+ 34 - 0
resources/icons/cancel.svg

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   id="svg8"
+   version="1.1"
+   viewBox="0 0 210 297"
+   height="297mm"
+   width="210mm">
+  <defs
+     id="defs2" />
+  <metadata
+     id="metadata5">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1">
+    <path
+       id="path832"
+       d="m 27.854233,223.32152 c -5.883202,-6.26321 -5.275239,-7.12501 29.66983,-42.05665 17.74761,-17.74081 32.2684,-32.80134 32.2684,-33.4679 0,-0.66653 -14.52079,-15.72707 -32.2684,-33.46788 C 29.249776,86.065646 25.255669,81.617004 25.255669,78.388467 c 0,-4.920247 4.276916,-8.882457 9.587959,-8.882457 3.713063,0 6.813285,2.751136 36.683505,32.55286 l 32.627687,32.55285 32.56476,-32.55285 c 29.23171,-29.221038 32.96149,-32.55286 36.44091,-32.55286 5.28047,0 8.65664,3.595229 8.65664,9.218288 0,4.211257 -1.64139,6.081976 -32.24511,36.749912 l -32.24515,32.31277 32.24515,32.32769 c 30.01558,30.09242 32.24511,32.61973 32.24511,36.55155 0,5.21525 -4.03264,9.42173 -9.03245,9.42173 -2.98751,0 -8.26987,-4.76779 -36.05527,-32.54304 l -32.55492,-32.54302 -32.678497,32.54302 c -30.293713,30.16814 -32.983692,32.54304 -36.860829,32.54304 -2.826495,0 -5.024765,-0.89685 -6.780931,-2.76643 z"
+       style="fill:none;stroke:#ec2900;stroke-width:45.17306137;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" />
+  </g>
+</svg>

+ 0 - 21
src/GradientWidget.cpp

@@ -53,27 +53,6 @@ QColor GradientWidget::colorAtY(float y)
 {
     float v = handleYToGradVal(y);
     return fromRGB(gradient.get(v));
-    /*float v = handleYToGradVal(y);
-    QColor up = QColor(QColor::Invalid);
-    QColor down = QColor(QColor::Invalid);
-    float upv = 0;
-    float downv = 1;
-    for (const auto& [color, val] : points) {
-        if (val >= upv && val < v) {
-            upv = val;
-            up = QColor(color.r, color.g, color.b);
-        }
-        if (val <= downv && val > v) {
-            downv = val;
-            down = QColor(color.r, color.g, color.b);
-        }
-    }
-
-    if (!up.isValid())
-        return down;
-    if (!down.isValid())
-        return up;
-    return lerp(up, down, (v - upv) / (downv - upv));*/
 }
 
 

+ 3 - 3
ui/Almond.ui

@@ -64,7 +64,7 @@
          <rect>
           <x>0</x>
           <y>0</y>
-          <width>381</width>
+          <width>271</width>
           <height>661</height>
          </rect>
         </property>
@@ -382,8 +382,8 @@
                  <string/>
                 </property>
                 <property name="icon">
-                 <iconset theme="cancel">
-                  <normaloff>.</normaloff>.</iconset>
+                 <iconset resource="../resources/Almond.qrc">
+                  <normaloff>:/icons/icons/cancel.svg</normaloff>:/icons/icons/cancel.svg</iconset>
                 </property>
                </widget>
               </item>

+ 44 - 39
ui/GradientMenu.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>427</width>
-    <height>508</height>
+    <width>323</width>
+    <height>501</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -69,10 +69,33 @@
     </layout>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0">
+    <layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,2">
      <item>
       <layout class="QVBoxLayout" name="verticalLayout_2">
        <item>
+        <widget class="QLabel" name="maxValLbl">
+         <property name="text">
+          <string>Max. Value</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QDoubleSpinBox" name="maxValSpb">
+         <property name="decimals">
+          <number>0</number>
+         </property>
+         <property name="maximum">
+          <double>100000.000000000000000</double>
+         </property>
+         <property name="singleStep">
+          <double>10.000000000000000</double>
+         </property>
+         <property name="stepType">
+          <enum>QAbstractSpinBox::AdaptiveDecimalStepType</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
         <spacer name="verticalSpacer">
          <property name="orientation">
           <enum>Qt::Vertical</enum>
@@ -140,6 +163,20 @@
          </property>
         </spacer>
        </item>
+       <item>
+        <widget class="QPushButton" name="removeBtn">
+         <property name="icon">
+          <iconset resource="../resources/Almond.qrc">
+           <normaloff>:/icons/cancel</normaloff>:/icons/cancel</iconset>
+         </property>
+         <property name="iconSize">
+          <size>
+           <width>32</width>
+           <height>32</height>
+          </size>
+         </property>
+        </widget>
+       </item>
       </layout>
      </item>
      <item>
@@ -158,8 +195,8 @@
          <rect>
           <x>0</x>
           <y>0</y>
-          <width>361</width>
-          <height>213</height>
+          <width>210</width>
+          <height>397</height>
          </rect>
         </property>
         <layout class="QGridLayout" name="gridLayout_2">
@@ -173,42 +210,10 @@
     </layout>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
-      <widget class="QLabel" name="maxValLbl">
-       <property name="text">
-        <string>Max. Value</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QDoubleSpinBox" name="maxValSpb">
-       <property name="decimals">
-        <number>0</number>
-       </property>
-       <property name="maximum">
-        <double>100000.000000000000000</double>
-       </property>
-       <property name="singleStep">
-        <double>10.000000000000000</double>
-       </property>
-       <property name="stepType">
-        <enum>QAbstractSpinBox::AdaptiveDecimalStepType</enum>
-       </property>
-      </widget>
-     </item>
-    </layout>
+    <layout class="QHBoxLayout" name="horizontalLayout_2"/>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <widget class="QPushButton" name="removeBtn">
-       <property name="text">
-        <string>Remove</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
+    <layout class="QHBoxLayout" name="horizontalLayout"/>
    </item>
   </layout>
  </widget>