Added background override.

This commit is contained in:
Leonardo Zide 2021-01-07 17:04:19 -08:00
parent 5058455666
commit e6397a98ac
3 changed files with 30 additions and 4 deletions

View file

@ -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<QImage> 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);

View file

@ -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)

View file

@ -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<lcFramebuffer, lcFramebuffer> mRenderFramebuffer;
#endif
bool mOverrideBackgroundColor = false;
quint32 mBackgroundColor = 0;
std::unique_ptr<lcScene> mScene;
std::unique_ptr<lcViewSphere> mViewSphere;