Store ToolBox ObjectDetails fields as members.
This commit is contained in:
		
							parent
							
								
									dc94d0a130
								
							
						
					
					
						commit
						034d0a8b4e
					
				@ -16,7 +16,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using namespace Qtk;
 | 
					using namespace Qtk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ToolBox::ToolBox(QWidget * parent) : QDockWidget(parent), ui(new Ui::ToolBox)
 | 
					ToolBox::ToolBox(QWidget * parent) :
 | 
				
			||||||
 | 
					    QDockWidget(parent), objectDetails_(this), ui(new Ui::ToolBox)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ui->setupUi(this);
 | 
					  ui->setupUi(this);
 | 
				
			||||||
  setMinimumWidth(350);
 | 
					  setMinimumWidth(350);
 | 
				
			||||||
@ -81,25 +82,27 @@ void ToolBox::createTransformPanel(const Object * object)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    rowLayout->addWidget(spinBox);
 | 
					    rowLayout->addWidget(spinBox);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Add the layout for this panel to the layout for the primary widget.
 | 
				
			||||||
 | 
					  formLayout_->addRow(transformPanel_.layout);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ToolBox::createPageProperties(const Object * object)
 | 
					void ToolBox::createPageProperties(const Object * object)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  auto transform = object->getTransform();
 | 
					  auto transform = object->getTransform();
 | 
				
			||||||
  auto type = object->getType();
 | 
					 | 
				
			||||||
  auto * widget = new QWidget;
 | 
					  auto * widget = new QWidget;
 | 
				
			||||||
 | 
					  formLayout_ = new QFormLayout;
 | 
				
			||||||
 | 
					  widget->setLayout(formLayout_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui->toolBox->addItem(widget, "Properties");
 | 
					  ui->toolBox->addItem(widget, "Properties");
 | 
				
			||||||
  ui->toolBox->setCurrentWidget(widget);
 | 
					  ui->toolBox->setCurrentWidget(widget);
 | 
				
			||||||
 | 
					  objectDetails_.setDetails(object);
 | 
				
			||||||
  formLayout_ = new QFormLayout;
 | 
					  // TODO: Do this in ToolBox ctor after initializing the form.
 | 
				
			||||||
  formLayout_->addRow(new QLabel(tr("Name:")), new QLabel(object->getName()));
 | 
					  formLayout_->addRow(objectDetails_.name.label, objectDetails_.name.value);
 | 
				
			||||||
 | 
					  formLayout_->addRow(objectDetails_.objectType.label,
 | 
				
			||||||
  formLayout_->addRow(
 | 
					                      objectDetails_.objectType.value);
 | 
				
			||||||
      new QLabel(tr("Type:")),
 | 
					 | 
				
			||||||
      new QLabel(type == Object::Type::QTK_MESH ? "Mesh" : "Model"));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  createTransformPanel(object);
 | 
					  createTransformPanel(object);
 | 
				
			||||||
  formLayout_->addRow(transformPanel_.layout);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int minWidth = 75;
 | 
					  int minWidth = 75;
 | 
				
			||||||
  auto rowLayout = new QHBoxLayout;
 | 
					  auto rowLayout = new QHBoxLayout;
 | 
				
			||||||
@ -124,7 +127,6 @@ void ToolBox::createPageProperties(const Object * object)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  formLayout_->addRow(rowLayout);
 | 
					  formLayout_->addRow(rowLayout);
 | 
				
			||||||
  widget->setLayout(formLayout_);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ToolBox::createPageShader(const Object * object)
 | 
					void ToolBox::createPageShader(const Object * object)
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,6 @@
 | 
				
			|||||||
#include <QDockWidget>
 | 
					#include <QDockWidget>
 | 
				
			||||||
#include <QDoubleSpinBox>
 | 
					#include <QDoubleSpinBox>
 | 
				
			||||||
#include <QFormLayout>
 | 
					#include <QFormLayout>
 | 
				
			||||||
#include <QGroupBox>
 | 
					 | 
				
			||||||
#include <QHBoxLayout>
 | 
					#include <QHBoxLayout>
 | 
				
			||||||
#include <QLabel>
 | 
					#include <QLabel>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -62,6 +61,43 @@ namespace Qtk
 | 
				
			|||||||
       * Private Members
 | 
					       * Private Members
 | 
				
			||||||
       ************************************************************************/
 | 
					       ************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /// Displays details on the object.
 | 
				
			||||||
 | 
					      struct ObjectDetails {
 | 
				
			||||||
 | 
					          /// Single item containing a label and value.
 | 
				
			||||||
 | 
					          struct Item {
 | 
				
			||||||
 | 
					              explicit Item(QWidget * parent) :
 | 
				
			||||||
 | 
					                  label(new QLabel(parent)), value(new QLabel(parent))
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              void setItem(const QString & l, const QString & v)
 | 
				
			||||||
 | 
					              {
 | 
				
			||||||
 | 
					                label->setText(l);
 | 
				
			||||||
 | 
					                value->setText(v);
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					              QLabel * label;
 | 
				
			||||||
 | 
					              QLabel * value;
 | 
				
			||||||
 | 
					          };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          /// We pass the parent widget so that Qt handles releasing memory.
 | 
				
			||||||
 | 
					          explicit ObjectDetails(QWidget * parent) :
 | 
				
			||||||
 | 
					              name(parent), objectType(parent)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          void setDetails(const Qtk::Object * object)
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            name.setItem(tr("Name:"), object->getName());
 | 
				
			||||||
 | 
					            objectType.setItem(
 | 
				
			||||||
 | 
					                tr("Type:"),
 | 
				
			||||||
 | 
					                object->getType() == Object::QTK_MESH ? "Mesh" : "Model");
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          Item name, objectType;
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
 | 
					      ObjectDetails objectDetails_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /// Spinbox with 3 fields and label.
 | 
					      /// Spinbox with 3 fields and label.
 | 
				
			||||||
      struct SpinBox3D {
 | 
					      struct SpinBox3D {
 | 
				
			||||||
          QLabel * label;
 | 
					          QLabel * label;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user