Skip to content
Snippets Groups Projects
Commit fea30e55 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

mv predefined colors to GUI/Support

(cloned GUI/View/Sample/LayerEditorUtil -> GUI/Support/Style/PredefinedColors)
parent a2d0039b
No related branches found
No related tags found
1 merge request!2387unify code for list views
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Support/Style/PredefinedColors.cpp
//! @brief Implements namespace GUI::Colors.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2021
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/Support/Style/PredefinedColors.h"
const QVector<QColor>& GUI::Colors::layerDefaults()
{
static QVector<QColor> colors = {QColor(230, 255, 213), QColor(194, 252, 240),
QColor(239, 228, 176), QColor(200, 191, 231),
QColor(253, 205, 193), QColor(224, 193, 253)};
return colors;
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Support/Style/PredefinedColors.h
//! @brief Defines namespace GUI::Colors.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2021
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_SUPPORT_STYLE_PREDEFINEDCOLORS_H
#define BORNAGAIN_GUI_SUPPORT_STYLE_PREDEFINEDCOLORS_H
#include <QColor>
#include <QVector>
//! Utility functions to support layer oriented sample editor
namespace GUI::Colors {
const QVector<QColor>& layerDefaults();
} // namespace GUI::Colors
#endif // BORNAGAIN_GUI_SUPPORT_STYLE_PREDEFINEDCOLORS_H
......@@ -19,6 +19,7 @@
#include "GUI/Model/Material/MaterialsSet.h"
#include "GUI/Model/Sample/LayerItem.h"
#include "GUI/Model/Sample/SampleItem.h"
#include "GUI/Support/Style/PredefinedColors.h"
#include "GUI/View/Numeric/NumWidgetUtil.h"
#include "GUI/View/Sample/HeinzFormLayout.h"
#include "GUI/View/Sample/MaterialInplaceForm.h"
......@@ -52,7 +53,7 @@ LayerForm::LayerForm(QWidget* parent, LayerItem* layerItem, SampleEditorControll
chooseColorAction->setMenu(menu);
addTitleAction(chooseColorAction);
for (const auto& col : GUI::Util::Layer::predefinedLayerColors()) {
for (const auto& col : GUI::Colors::layerDefaults()) {
QPixmap p(64, 64);
p.fill(col);
auto* ca = menu->addAction(QIcon(p), "");
......
......@@ -16,8 +16,8 @@
#include "GUI/Model/Project/ProjectDocument.h"
#include "GUI/Model/Sample/LayerItem.h"
#include "GUI/Model/Sample/SampleItem.h"
#include "GUI/Support/Style/PredefinedColors.h"
#include "GUI/View/Layout/ApplicationSettings.h"
#include "GUI/View/Sample/LayerEditorUtil.h"
#include "GUI/View/Sample/SampleEditorController.h"
#include "GUI/View/Sample/SampleForm.h"
#include "GUI/View/Widget/StyledToolbar.h"
......@@ -72,14 +72,12 @@ void SampleEditor::createLayerColors() // #baLayerEditor move to better place
if (!m_current_sample)
return;
const auto& colors = GUI::Colors::layerDefaults();
int col = 0;
for (auto* l : m_current_sample->layerItems()) {
if (l->color().isValid())
continue;
l->setColor(GUI::Util::Layer::predefinedLayerColors()[col]);
col++;
if (col == GUI::Util::Layer::predefinedLayerColors().size())
col = 0;
if (!l->color().isValid())
l->setColor(colors[col]);
col = (col + 1) % colors.size();
}
}
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