Add widgets to object editor

Wed, 22 Jun 2022 23:51:06 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Wed, 22 Jun 2022 23:51:06 +0300
changeset 258
fe094d0687ad
parent 257
afdab56e8210
child 259
c27612f0eac0

Add widgets to object editor

src/ui/objecteditor.cpp file | annotate | diff | comparison | revisions
src/ui/objecteditor.ui file | annotate | diff | comparison | revisions
src/widgets/colorindexinput.cpp file | annotate | diff | comparison | revisions
src/widgets/colorindexinput.h file | annotate | diff | comparison | revisions
src/widgets/colorindexinput.ui file | annotate | diff | comparison | revisions
src/widgets/colorselectdialog.ui file | annotate | diff | comparison | revisions
--- a/src/ui/objecteditor.cpp	Wed Jun 22 23:32:34 2022 +0300
+++ b/src/ui/objecteditor.cpp	Wed Jun 22 23:51:06 2022 +0300
@@ -119,14 +119,4 @@
 	QWidget{parent}
 {
 	this->ui.setupUi(this);
-	this->editorwidgets.resize(NUM_PROPERTIES);
-	QFormLayout* layout = new QFormLayout{this};
-	for (std::size_t i = 0; i < NUM_PROPERTIES; ++i) {
-		const auto key = static_cast<PropertyKey>(i);
-		QLabel* const label = new QLabel{propertyName(key), this};
-		QWidget* const field = new QWidget{this};
-		this->editorwidgets[i] = field;
-		layout->addRow(label, field);
-	}
-	this->ui.properties->setLayout(layout);
 }
--- a/src/ui/objecteditor.ui	Wed Jun 22 23:32:34 2022 +0300
+++ b/src/ui/objecteditor.ui	Wed Jun 22 23:51:06 2022 +0300
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>492</width>
-    <height>336</height>
+    <width>941</width>
+    <height>400</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -24,42 +24,183 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>472</width>
-        <height>316</height>
+        <width>908</width>
+        <height>857</height>
        </rect>
       </property>
       <layout class="QHBoxLayout" name="horizontalLayout_2">
        <item>
-        <layout class="QVBoxLayout" name="verticalLayout">
+        <layout class="QVBoxLayout" name="verticalLayout_3">
          <item>
-          <layout class="QHBoxLayout" name="horizontalLayout">
+          <layout class="QVBoxLayout" name="verticalLayout">
            <item>
-            <widget class="QLabel" name="typeIconLabel">
-             <property name="text">
-              <string>&lt;icon&gt;</string>
-             </property>
-            </widget>
+            <layout class="QHBoxLayout" name="horizontalLayout">
+             <item>
+              <widget class="QLabel" name="typeIconLabel">
+               <property name="text">
+                <string>&lt;icon&gt;</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QLabel" name="typeNameLabel">
+               <property name="styleSheet">
+                <string notr="true">font-weight: bold</string>
+               </property>
+               <property name="text">
+                <string>Object</string>
+               </property>
+              </widget>
+             </item>
+            </layout>
            </item>
            <item>
-            <widget class="QLabel" name="typeNameLabel">
-             <property name="styleSheet">
-              <string notr="true">font-weight: bold</string>
+            <widget class="QGroupBox" name="properties">
+             <property name="title">
+              <string>Properties</string>
              </property>
-             <property name="text">
-              <string>Object</string>
-             </property>
+             <layout class="QFormLayout" name="formLayout">
+              <item row="1" column="0">
+               <widget class="QLabel" name="point1Label">
+                <property name="text">
+                 <string>Point 1</string>
+                </property>
+                <property name="buddy">
+                 <cstring>point1Label</cstring>
+                </property>
+               </widget>
+              </item>
+              <item row="1" column="1">
+               <widget class="VectorInput" name="point1"/>
+              </item>
+              <item row="2" column="0">
+               <widget class="QLabel" name="point2Label">
+                <property name="text">
+                 <string>Point 2</string>
+                </property>
+                <property name="buddy">
+                 <cstring>point2Label</cstring>
+                </property>
+               </widget>
+              </item>
+              <item row="2" column="1">
+               <widget class="VectorInput" name="point2"/>
+              </item>
+              <item row="3" column="0">
+               <widget class="QLabel" name="point3Label">
+                <property name="text">
+                 <string>Point 3</string>
+                </property>
+               </widget>
+              </item>
+              <item row="3" column="1">
+               <widget class="VectorInput" name="point3"/>
+              </item>
+              <item row="4" column="0">
+               <widget class="QLabel" name="point4Label">
+                <property name="text">
+                 <string>Point 4</string>
+                </property>
+               </widget>
+              </item>
+              <item row="4" column="1">
+               <widget class="VectorInput" name="point4"/>
+              </item>
+              <item row="5" column="0">
+               <widget class="QLabel" name="control1Label">
+                <property name="text">
+                 <string>Control 1</string>
+                </property>
+               </widget>
+              </item>
+              <item row="5" column="1">
+               <widget class="VectorInput" name="control1"/>
+              </item>
+              <item row="6" column="0">
+               <widget class="QLabel" name="control2Label">
+                <property name="text">
+                 <string>Control 2</string>
+                </property>
+               </widget>
+              </item>
+              <item row="6" column="1">
+               <widget class="VectorInput" name="control2"/>
+              </item>
+              <item row="8" column="0">
+               <widget class="QLabel" name="transformLabel">
+                <property name="text">
+                 <string>Transform</string>
+                </property>
+               </widget>
+              </item>
+              <item row="8" column="1">
+               <widget class="MatrixEditor" name="transformation"/>
+              </item>
+              <item row="9" column="0">
+               <widget class="QLabel" name="nameLabel">
+                <property name="text">
+                 <string>Name</string>
+                </property>
+                <property name="buddy">
+                 <cstring>name</cstring>
+                </property>
+               </widget>
+              </item>
+              <item row="10" column="0">
+               <widget class="QLabel" name="textLabel">
+                <property name="text">
+                 <string>Text</string>
+                </property>
+                <property name="buddy">
+                 <cstring>text</cstring>
+                </property>
+               </widget>
+              </item>
+              <item row="11" column="0">
+               <widget class="QLabel" name="codeLabel">
+                <property name="text">
+                 <string>Code</string>
+                </property>
+                <property name="buddy">
+                 <cstring>code</cstring>
+                </property>
+               </widget>
+              </item>
+              <item row="12" column="0">
+               <widget class="QLabel" name="fractionLabel">
+                <property name="text">
+                 <string>Fraction</string>
+                </property>
+               </widget>
+              </item>
+              <item row="9" column="1">
+               <widget class="QLineEdit" name="name"/>
+              </item>
+              <item row="10" column="1">
+               <widget class="QLineEdit" name="text"/>
+              </item>
+              <item row="11" column="1">
+               <widget class="QLineEdit" name="code"/>
+              </item>
+              <item row="0" column="0">
+               <widget class="QLabel" name="colorLabel">
+                <property name="text">
+                 <string>Colour</string>
+                </property>
+                <property name="buddy">
+                 <cstring>color</cstring>
+                </property>
+               </widget>
+              </item>
+              <item row="0" column="1">
+               <widget class="ColorIndexInput" name="color" native="true"/>
+              </item>
+             </layout>
             </widget>
            </item>
           </layout>
          </item>
          <item>
-          <widget class="QGroupBox" name="properties">
-           <property name="title">
-            <string>Properties</string>
-           </property>
-          </widget>
-         </item>
-         <item>
           <spacer name="verticalSpacer">
            <property name="orientation">
             <enum>Qt::Vertical</enum>
@@ -93,6 +234,24 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>VectorInput</class>
+   <extends>QWidget</extends>
+   <header>vec3editor.h</header>
+  </customwidget>
+  <customwidget>
+   <class>MatrixEditor</class>
+   <extends>QWidget</extends>
+   <header>matrixeditor.h</header>
+  </customwidget>
+  <customwidget>
+   <class>ColorIndexInput</class>
+   <extends>QWidget</extends>
+   <header>widgets/colorindexinput.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>
--- a/src/widgets/colorindexinput.cpp	Wed Jun 22 23:32:34 2022 +0300
+++ b/src/widgets/colorindexinput.cpp	Wed Jun 22 23:51:06 2022 +0300
@@ -3,11 +3,12 @@
 #include "colorselectdialog.h"
 #include "uiutilities.h"
 
-ColorIndexInput::ColorIndexInput(ColorTable *colorTable, ColorIndex color, QWidget *parent) :
+ColorIndexInput::ColorIndexInput(QWidget *parent) :
 	QWidget{parent},
-	colorTable{colorTable},
 	ui{*new Ui_ColorIndexInput}
 {
+	static const ColorTable emptyColorTable;
+	this->colorTable = &emptyColorTable;
 	this->ui.setupUi(this);
 	connect(this->ui.button, &QPushButton::clicked, [this]()
 	{
@@ -28,7 +29,7 @@
 		}
 		Q_EMIT this->colorChanged({value});
 	});
-	this->ui.index->setValue(color.index);
+	this->ui.index->setValue(MAIN_COLOR.index);
 }
 
 ColorIndexInput::~ColorIndexInput()
--- a/src/widgets/colorindexinput.h	Wed Jun 22 23:32:34 2022 +0300
+++ b/src/widgets/colorindexinput.h	Wed Jun 22 23:51:06 2022 +0300
@@ -4,14 +4,14 @@
 class ColorIndexInput : public QWidget
 {
 	Q_OBJECT
+	const ColorTable* colorTable = nullptr;
+	class Ui_ColorIndexInput& ui;
 public:
-	ColorIndexInput(ColorTable *colorTable, ColorIndex color = MAIN_COLOR, QWidget *parent = nullptr);
+	ColorIndexInput(QWidget *parent = nullptr);
 	~ColorIndexInput();
 	ldraw::Color selectedColor() const;
 	void setSelectedColor(ldraw::Color color);
 Q_SIGNALS:
 	void colorChanged(ldraw::Color color);
 private:
-	ColorTable* const colorTable;
-	class Ui_ColorIndexInput& ui;
 };
--- a/src/widgets/colorindexinput.ui	Wed Jun 22 23:32:34 2022 +0300
+++ b/src/widgets/colorindexinput.ui	Wed Jun 22 23:51:06 2022 +0300
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>370</width>
-    <height>47</height>
+    <height>53</height>
    </rect>
   </property>
   <property name="windowTitle">
--- a/src/widgets/colorselectdialog.ui	Wed Jun 22 23:32:34 2022 +0300
+++ b/src/widgets/colorselectdialog.ui	Wed Jun 22 23:51:06 2022 +0300
@@ -33,8 +33,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>732</width>
-        <height>329</height>
+        <width>730</width>
+        <height>285</height>
        </rect>
       </property>
       <layout class="QGridLayout" name="gridLayout">

mercurial