Skip to content

Commit

Permalink
add FaceListPropertyWidget skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Bies committed Mar 11, 2022
1 parent fbc5d43 commit d7189e4
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/propertywidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_sources(libommpfritt PRIVATE
add_subdirectory(boolpropertywidget)
add_subdirectory(colorpropertywidget)
add_subdirectory(numericpropertywidget)
add_subdirectory(facelistpropertywidget)
add_subdirectory(floatpropertywidget)
add_subdirectory(floatvectorpropertywidget)
add_subdirectory(integerpropertywidget)
Expand Down
8 changes: 8 additions & 0 deletions src/propertywidgets/facelistpropertywidget/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
target_sources(libommpfritt PRIVATE
facelistwidget.cpp
facelistwidget.h
facelistpropertyconfigwidget.cpp
facelistpropertyconfigwidget.h
facelistpropertywidget.cpp
facelistpropertywidget.h
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "propertywidgets/facelistpropertywidget/facelistpropertyconfigwidget.h"


namespace omm
{

FaceListPropertyConfigWidget ::FaceListPropertyConfigWidget()
{
}

void FaceListPropertyConfigWidget::init(const PropertyConfiguration&)
{
}

void FaceListPropertyConfigWidget::update(PropertyConfiguration&) const
{

}

} // namespace omm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "properties/facelistproperty.h"
#include "propertywidgets/propertyconfigwidget.h"

class QListWidget;

namespace omm
{

class FaceListPropertyConfigWidget : public PropertyConfigWidget<FaceListProperty>
{
public:
FaceListPropertyConfigWidget();
void init(const PropertyConfiguration&) override;
void update(PropertyConfiguration&) const override;
};

} // namespace omm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "propertywidgets/facelistpropertywidget/facelistpropertywidget.h"
#include "properties/typedproperty.h"
#include "propertywidgets/facelistpropertywidget/facelistwidget.h"

#include <QLabel>
#include <QVBoxLayout>

namespace omm
{
FaceListPropertyWidget::FaceListPropertyWidget(Scene& scene, const std::set<Property*>& properties)
: PropertyWidget(scene, properties)
{
auto face_list_widget = std::make_unique<FaceListWidget>();
m_face_list_widget = face_list_widget.get();
set_widget(std::move(face_list_widget));
FaceListPropertyWidget::update_edit();
}

void FaceListPropertyWidget::update_edit()
{
QSignalBlocker blocker(m_face_list_widget);
m_face_list_widget->set_values(get_properties_values());
}

} // namespace omm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "properties/facelistproperty.h"
#include "propertywidgets/propertywidget.h"

namespace omm
{
class FaceListWidget;

class FaceListPropertyWidget : public PropertyWidget<FaceListProperty>
{
public:
explicit FaceListPropertyWidget(Scene& scene, const std::set<Property*>& properties);

protected:
void update_edit() override;

private:
FaceListWidget* m_face_list_widget;
};

} // namespace omm
44 changes: 44 additions & 0 deletions src/propertywidgets/facelistpropertywidget/facelistwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "propertywidgets/facelistpropertywidget/facelistwidget.h"

#include <QListWidget>
#include <QCheckBox>
#include <QPushButton>
#include <QGridLayout>

namespace omm
{

void FaceListWidget::set_value(const value_type& value)
{
Q_UNUSED(value)
}

void FaceListWidget::set_inconsistent_value()
{
set_value(FaceList{});
}

FaceListWidget::value_type FaceListWidget::value() const
{
return FaceList{};
}

FaceListWidget::FaceListWidget(QWidget* parent)
: QWidget(parent)
{
setFocusPolicy(Qt::StrongFocus);
auto layout = std::make_unique<QGridLayout>();

auto insert = [layout=layout.get()](auto&& widget, const int row, const int col, const int row_span = 1) -> auto& {
auto& ref = *widget;
layout->addWidget(widget.release(), row, col, row_span, Qt::AlignLeft);
return ref;
};

m_lw = &insert(std::make_unique<QListWidget>(), 0, 0, 2);
m_pb_clear = &insert(std::make_unique<QPushButton>(), 1, 0);
m_cb_invert = &insert(std::make_unique<QCheckBox>(), 1, 1);
setLayout(layout.release());
}

} // namespace omm
30 changes: 30 additions & 0 deletions src/propertywidgets/facelistpropertywidget/facelistwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include "propertywidgets/multivalueedit.h"
#include "facelist.h"
#include <QWidget>

class QCheckBox;
class QListWidget;
class QPushButton;

namespace omm
{

class FaceListWidget : public QWidget, public MultiValueEdit<FaceList>
{
public:
explicit FaceListWidget(QWidget* parent = nullptr);
void set_value(const value_type& value) override;
[[nodiscard]] value_type value() const override;

protected:
void set_inconsistent_value() override;

private:
QCheckBox* m_cb_invert;
QListWidget* m_lw;
QPushButton* m_pb_clear;
};

} // namespace omm

0 comments on commit d7189e4

Please sign in to comment.