Skip to content
Snippets Groups Projects
Commit c9c0ff5a authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

cleanup and adjust colors

parent 64d4e367
No related branches found
No related tags found
1 merge request!2741GUI sample builder supports periodic stacks (#20)
......@@ -33,6 +33,7 @@ LayerStackItem::LayerStackItem(const MaterialsSet* materials, uint n_periods)
, m_materials(materials)
{
ASSERT(materials);
m_color = QColor(220, 220, 220, 255);
}
std::vector<LayerItem*> LayerStackItem::uniqueLayerItems()
......
......@@ -39,6 +39,8 @@ SampleItem::SampleItem()
, m_outer_stack(std::make_unique<LayerStackItem>(&m_materials))
{
m_external_field.init("External field", "External field (A/m)", "extField");
// the outer stack has the same color as sample form itself
m_outer_stack->setColor(QColor(Qt::white));
}
SampleItem::~SampleItem() = default;
......
......@@ -16,6 +16,7 @@
#include "Base/Util/Assert.h"
#include "Base/Util/Vec.h"
#include "GUI/Model/Sample/ItemWithLayers.h"
#include "GUI/Model/Sample/LayerStackItem.h"
#include "GUI/Model/Sample/SampleItem.h"
#include "GUI/Model/Type/PredefinedColors.h"
#include "GUI/View/Base/ActionFactory.h"
......@@ -95,6 +96,12 @@ void LayerContainerForm::expand()
setExpanded(true);
}
void LayerContainerForm::updatePositionDependentElements()
{
LayerStackItem* parentStack = m_ec->sampleItem()->parentOfComponent(m_item);
m_move_button->setVisible(parentStack && parentStack->componentItems().size() > 1);
}
void LayerContainerForm::updateColor()
{
QColor bckgrCol = m_item->color();
......
......@@ -32,7 +32,7 @@ public:
ItemWithLayers* item() const { return m_item; }
void expand();
virtual void updatePositionDependentElements() = 0;
virtual void updatePositionDependentElements();
protected:
void updateColor();
......
......@@ -94,6 +94,8 @@ void LayerForm::updateTitle()
void LayerForm::updatePositionDependentElements()
{
LayerContainerForm::updatePositionDependentElements();
if (m_roughness_row == -1)
return;
......@@ -129,8 +131,6 @@ void LayerForm::updatePositionDependentElements()
m_layout->removeRow(m_thickness_row);
m_layout->insertValue(m_thickness_row, layerItem()->thickness());
}
m_move_button->setVisible(m_ec->sampleItem()->uniqueLayerItems().size() > 1);
}
void LayerForm::onLayoutAdded(ParticleLayoutItem* t)
......
......@@ -61,7 +61,6 @@ LayerStackForm::LayerStackForm(QWidget* parent, LayerStackItem* stack, SampleEdi
: LayerContainerForm(parent, stack, ec, "stack")
, m_stack_layout(new QVBoxLayout)
{
ASSERT(stack);
m_layout->addRow(m_stack_layout);
for (auto* item : stack->componentItems()) {
......@@ -76,15 +75,10 @@ LayerStackForm::LayerStackForm(QWidget* parent, LayerStackItem* stack, SampleEdi
m_stack_layout->addWidget(new AddLayerContainerWidget(this, nullptr, m_ec), 0, Qt::AlignTop);
m_stack_layout->setSizeConstraint(QLayout::SetMinimumSize);
if (isOuterStack()) {
setStyleSheet("LayerStackForm {background-color: light grey}");
m_title_widget->hide();
} else {
// Unlike layers, all stacks have fixed color
setStyleSheet("LayerStackForm {background-color: grey}");
}
updatePositionDependentElements();
updateTitle();
if (isOuterStack())
m_title_widget->hide();
}
LayerStackItem& LayerStackForm::stackItem() const
......@@ -164,6 +158,7 @@ void LayerStackForm::removeComponentForm(ItemWithLayers* componentItem)
void LayerStackForm::updatePositionDependentElements()
{
LayerContainerForm::updatePositionDependentElements();
updateTitle();
}
......
......@@ -81,40 +81,6 @@ SampleForm::SampleForm(SampleItem* sampleItem, SampleEditorController* ec)
m_layout->addWidget(new LayerStackForm(this, &m_sample_item->outerStackItem(), m_ec), 0,
Qt::AlignTop);
// for (auto* item : sampleItem->componentItems()) {
// m_layout->addWidget(
// new AddLayerContainerWidget(this, item, m_ec), 0,
// Qt::AlignTop);
// if (auto* layer = dynamic_cast<LayerItem*>(item))
// m_layout->addWidget(new LayerForm(this, layer, m_ec), 0, Qt::AlignTop);
// else if (auto* stack = dynamic_cast<LayerStackItem*>(item))
// m_layout->addWidget(new LayerStackForm(this, stack, m_ec), 0, Qt::AlignTop);
// else
// ASSERT_NEVER;
// }
// m_layout->addWidget(
// new AddLayerContainerWidget(this, nullptr, m_ec), 0,
// Qt::AlignTop);
// m_layout->setSizeConstraint(QLayout::SetMinimumSize);
}
void SampleForm::onLayerAdded(LayerItem* layerItem)
{
// const int rowInMultiLayer = Vec::indexOfPtr(layerItem, m_sample_item->uniqueLayerItems());
// const int rowInLayout = rowInMultiLayer * 2 + 1;
// m_layout->insertWidget(rowInLayout, new LayerForm(this, layerItem, m_ec), 0,
// Qt::AlignTop);
// // same row => button is above!
// m_layout->insertWidget(
// rowInLayout,
// new AddLayerContainerWidget(this, layerItem, m_ec), 0,
// Qt::AlignTop);
// updateRowVisibilities();
}
void SampleForm::onLayerMoved(ItemWithLayers* item)
......@@ -151,32 +117,6 @@ void SampleForm::onLayerMoved(ItemWithLayers* item)
// updateRowVisibilities();
}
void SampleForm::onAboutToRemoveLayerContainer(ItemWithLayers* itemWithLayers)
{
// LayerContainerForm* layerContainerForm = nullptr;
// AddLayerContainerWidget* addLayerWidget = nullptr;
// for (auto* c : findChildren<QWidget*>()) {
// if (auto* w = dynamic_cast<AddLayerContainerWidget*>(c))
// if (w->m_item == itemWithLayers)
// addLayerWidget = w;
// if (auto* w = dynamic_cast<LayerContainerForm*>(c)) {
// if (w->item() == itemWithLayers)
// layerContainerForm = w;
// }
// }
// if (layerContainerForm) {
// // delete editors which are subscribed to SessionItems
// GUI::Util::Layout::clearLayout(layerContainerForm->layout());
// layerContainerForm->hide();
// layerContainerForm->setParent(nullptr); // so it is not findable in update routines
// layerContainerForm->deleteLater(); // delete later (this is the sender)
// }
// delete addLayerWidget;
}
void SampleForm::updateRowVisibilities()
{
for (auto* c : findChildren<LayerContainerForm*>())
......
......@@ -34,19 +34,11 @@ class SampleForm : public QWidget {
public:
SampleForm(SampleItem* sampleItem, SampleEditorController* ec);
//! Create widgets for the new layer.
void onLayerAdded(LayerItem* layerItem);
//! Call this when an ItemWithLayers has been moved to a different position.
//!
//! This updates the item's position in the layout.
void onLayerMoved(ItemWithLayers* layerItem);
//! Call this before removing (deleting) a ItemWithLayers.
//!
//! Any widgets related to the item will be deleted or scheduled for later deletion.
void onAboutToRemoveLayerContainer(ItemWithLayers* itemWithLayers);
void updateRowVisibilities();
LayerStackForm* formOfStackItem(const LayerStackItem* searchedStackItem);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment