Initial background color support.

This commit is contained in:
Leonardo Zide
2021-01-14 18:19:58 -08:00
parent 449f405d17
commit 26c34e3609
7 changed files with 241 additions and 25 deletions
+37
View File
@@ -24,6 +24,28 @@ lcInstructions::lcInstructions(Project* Project)
CreatePages();
}
lcInstructionsStepProperties lcInstructions::GetStepProperties(lcModel* Model, lcStep Step) const
{
lcInstructionsStepProperties StepProperties = mStepProperties;
std::map<lcModel*, lcInstructionsModel>::const_iterator ModelIt = mModels.find(Model);
if (ModelIt == mModels.end())
return StepProperties;
const lcInstructionsModel& InstructionModel = ModelIt->second;
for (lcStep StepIndex = 0; StepIndex <= Step; StepIndex++)
{
const lcInstructionsStepProperties& Properties = InstructionModel.StepProperties[StepIndex];
if (Properties.BackgroundColorMode == lcInstructionsPropertyMode::Set || (Properties.BackgroundColorMode == lcInstructionsPropertyMode::StepOnly && Step == StepIndex))
StepProperties.BackgroundColor = Properties.BackgroundColor;
}
return StepProperties;
}
void lcInstructions::SetDefaultPageSettings(const lcInstructionsPageSettings& PageSettings)
{
mPageSettings = PageSettings;
@@ -31,6 +53,17 @@ void lcInstructions::SetDefaultPageSettings(const lcInstructionsPageSettings& Pa
CreatePages();
}
void lcInstructions::SetDefaultStepBackgroundColor(quint32 Color)
{
if (mStepProperties.BackgroundColor == Color)
return;
mStepProperties.BackgroundColor = Color;
for (size_t PageIndex = 0; PageIndex < mPages.size(); PageIndex++)
emit PageInvalid(static_cast<int>(PageIndex)); // todo: invalidate steps, not pages
}
void lcInstructions::CreatePages()
{
mPages.clear();
@@ -57,6 +90,10 @@ void lcInstructions::AddDefaultPages(lcModel* Model, std::vector<const lcModel*>
lcInstructionsPage Page;
int Row = 0, Column = 0;
lcInstructionsModel InstructionModel;
InstructionModel.StepProperties.resize(LastStep + 1);
mModels.emplace(Model, std::move(InstructionModel));
for (lcStep Step = 1; Step <= LastStep; Step++)
{
std::set<lcModel*> StepSubModels;