From e6397a98ac2bc45999d3f4f03ba3669f2e3c2b9e Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Thu, 7 Jan 2021 17:04:19 -0800 Subject: [PATCH] Added background override. --- common/lc_instructionsdialog.cpp | 19 +++++++++++++++---- common/lc_view.cpp | 7 +++++++ common/lc_view.h | 8 ++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/common/lc_instructionsdialog.cpp b/common/lc_instructionsdialog.cpp index 1a7c1fc5..fe4495ae 100644 --- a/common/lc_instructionsdialog.cpp +++ b/common/lc_instructionsdialog.cpp @@ -1,10 +1,9 @@ #include "lc_global.h" #include "lc_instructionsdialog.h" -#include "lc_collapsiblewidget.h" +#include "lc_pagesetupdialog.h" #include "project.h" #include "lc_model.h" -#include "lc_qutils.h" -#include "lc_pagesetupdialog.h" +#include "lc_view.h" lcInstructionsPageWidget::lcInstructionsPageWidget(QWidget* Parent, lcInstructions* Instructions) : QGraphicsView(Parent), mInstructions(Instructions) @@ -32,7 +31,19 @@ void lcInstructionsPageWidget::SetCurrentPage(const lcInstructionsPage* Page) const float StepWidth = MarginsRect.width() * Step.Rect.width(); const float StepHeight = MarginsRect.height() * Step.Rect.height(); - QImage StepImage = Step.Model->GetStepImage(false, StepWidth, StepHeight, Step.Step); // todo: override background color and opacity + lcView View(lcViewType::View, Step.Model); + + View.SetOffscreenContext(); + View.MakeCurrent(); +// View.SetBackgroundColorOverride(LC_RGBA(255, 255, 0, 255)); + View.SetSize(StepWidth, StepHeight); + + std::vector Images = View.GetStepImages(Step.Step, Step.Step); + + if (Images.empty()) + continue; + + QImage& StepImage = Images.front(); QGraphicsPixmapItem* StepImageItem = new QGraphicsPixmapItem(QPixmap::fromImage(StepImage), PageItem); StepImageItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable); diff --git a/common/lc_view.cpp b/common/lc_view.cpp index 06dc961d..698ab78b 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -1028,6 +1028,13 @@ void lcView::OnDraw() void lcView::DrawBackground() const { + if (mOverrideBackgroundColor) + { + lcVector4 BackgroundColor(lcVector4FromColor(mBackgroundColor)); + mContext->ClearColorAndDepth(BackgroundColor); + return; + } + const lcPreferences& Preferences = lcGetPreferences(); if (!Preferences.mBackgroundGradient) diff --git a/common/lc_view.h b/common/lc_view.h index 0114f63e..304b3d50 100644 --- a/common/lc_view.h +++ b/common/lc_view.h @@ -168,6 +168,12 @@ public: return mMouseY; } + void SetBackgroundColorOverride(quint32 BackgroundColor) + { + mOverrideBackgroundColor = true; + mBackgroundColor = BackgroundColor; + } + static void UpdateProjectViews(const Project* Project); static void UpdateAllViews(); @@ -313,6 +319,8 @@ protected: #else std::pair mRenderFramebuffer; #endif + bool mOverrideBackgroundColor = false; + quint32 mBackgroundColor = 0; std::unique_ptr mScene; std::unique_ptr mViewSphere;