From 309a533b7c5eab79addfc2b1733d39c1b48d9aae Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Fri, 13 Jul 2018 11:38:49 +0100 Subject: [PATCH] Style. --- gui/fpgaviewwidget.cc | 57 +++++++++++++++---------------------------- gui/fpgaviewwidget.h | 29 +++++++++++----------- 2 files changed, 35 insertions(+), 51 deletions(-) diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 263e0e60..6b6a2617 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -242,22 +242,13 @@ void LineShader::draw(const LineShaderData &line, const QMatrix4x4 &projection) FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr) { - /* - backgroundColor = QColor("#ffffff"); - gridColor = QColor("#ddd"); - gFrameColor = QColor("#303030"); - gHiddenColor = QColor("#a0a0a0"); - gInactiveColor = QColor("#d0d0d0"); - gActiveColor = QColor("#101010"); - frameColor = QColor("#0066ba"); - */ - backgroundColor = QColor("#000000"); - gridColor = QColor("#333"); - gFrameColor = QColor("#d0d0d0"); - gHiddenColor = QColor("#606060"); - gInactiveColor = QColor("#303030"); - gActiveColor = QColor("#f0f0f0"); - frameColor = QColor("#0066ba"); + backgroundColor_ = QColor("#000000"); + gridColor_ = QColor("#333"); + gFrameColor_ = QColor("#d0d0d0"); + gHiddenColor_ = QColor("#606060"); + gInactiveColor_ = QColor("#303030"); + gActiveColor_ = QColor("#f0f0f0"); + frameColor_ = QColor("#0066ba"); auto fmt = format(); fmt.setMajorVersion(3); @@ -293,7 +284,7 @@ void FPGAViewWidget::initializeGL() log_error("Could not compile shader.\n"); } initializeOpenGLFunctions(); - glClearColor(backgroundColor.red() / 255, backgroundColor.green() / 255, backgroundColor.blue() / 255, 0.0); + glClearColor(backgroundColor_.red() / 255, backgroundColor_.green() / 255, backgroundColor_.blue() / 255, 0.0); } void FPGAViewWidget::drawDecal(LineShaderData &out, const DecalXY &decal) @@ -338,15 +329,11 @@ void FPGAViewWidget::drawDecal(LineShaderData out[], const DecalXY &decal) line.point(offsetX + scale * el.x1, offsetY + scale * el.y2); switch (el.style) { case GraphicElement::G_FRAME: - line.build(out[0]); - break; - case GraphicElement::G_HIDDEN: - break; case GraphicElement::G_INACTIVE: - line.build(out[2]); - break; case GraphicElement::G_ACTIVE: - line.build(out[3]); + line.build(out[el.style]); + break; + default: break; } } @@ -356,15 +343,11 @@ void FPGAViewWidget::drawDecal(LineShaderData out[], const DecalXY &decal) offsetY + scale * el.y2); switch (el.style) { case GraphicElement::G_FRAME: - line.build(out[0]); - break; - case GraphicElement::G_HIDDEN: - break; case GraphicElement::G_INACTIVE: - line.build(out[2]); - break; case GraphicElement::G_ACTIVE: - line.build(out[3]); + line.build(out[el.style]); + break; + default: break; } } @@ -397,17 +380,17 @@ void FPGAViewWidget::paintGL() float thick11Px = mouseToWorldCoordinates(1.1, 0).x(); // Draw grid. - auto grid = LineShaderData(thick1Px, gridColor); + auto grid = LineShaderData(thick1Px, gridColor_); for (float i = -100.0f; i < 100.0f; i += 1.0f) { PolyLine(-100.0f, i, 100.0f, i).build(grid); PolyLine(i, -100.0f, i, 100.0f).build(grid); } lineShader_.draw(grid, matrix); - LineShaderData shaders[4] = {LineShaderData(thick11Px, gFrameColor), // GraphicElement::G_FRAME - LineShaderData(thick11Px, gHiddenColor), // GraphicElement::G_HIDDEN - LineShaderData(thick11Px, gInactiveColor), // GraphicElement::G_INACTIVE - LineShaderData(thick11Px, gActiveColor)}; // GraphicElement::G_ACTIVE + LineShaderData shaders[4] = {[GraphicElement::G_FRAME] = LineShaderData(thick11Px, gFrameColor_), + [GraphicElement::G_HIDDEN] = LineShaderData(thick11Px, gHiddenColor_), + [GraphicElement::G_INACTIVE] = LineShaderData(thick11Px, gInactiveColor_), + [GraphicElement::G_ACTIVE] = LineShaderData(thick11Px, gActiveColor_)}; if (ctx_) { // Draw Bels. @@ -433,7 +416,7 @@ void FPGAViewWidget::paintGL() lineShader_.draw(shaders[3], matrix); // Draw Frame Graphics. - auto frames = LineShaderData(thick11Px, frameColor); + auto frames = LineShaderData(thick11Px, frameColor_); if (ctx_) { drawDecal(frames, ctx_->getFrameDecal()); lineShader_.draw(frames, matrix); diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h index 8d91224e..410b0582 100644 --- a/gui/fpgaviewwidget.h +++ b/gui/fpgaviewwidget.h @@ -216,13 +216,13 @@ class LineShader class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions { Q_OBJECT - Q_PROPERTY(QColor backgroundColor MEMBER backgroundColor DESIGNABLE true) - Q_PROPERTY(QColor gridColor MEMBER gridColor DESIGNABLE true) - Q_PROPERTY(QColor gFrameColor MEMBER gFrameColor DESIGNABLE true) - Q_PROPERTY(QColor gHiddenColor MEMBER gHiddenColor DESIGNABLE true) - Q_PROPERTY(QColor gInactiveColor MEMBER gInactiveColor DESIGNABLE true) - Q_PROPERTY(QColor gActiveColor MEMBER gActiveColor DESIGNABLE true) - Q_PROPERTY(QColor frameColor MEMBER frameColor DESIGNABLE true) + Q_PROPERTY(QColor backgroundColor MEMBER backgroundColor_ DESIGNABLE true) + Q_PROPERTY(QColor gridColor MEMBER gridColor_ DESIGNABLE true) + Q_PROPERTY(QColor gFrameColor MEMBER gFrameColor_ DESIGNABLE true) + Q_PROPERTY(QColor gHiddenColor MEMBER gHiddenColor_ DESIGNABLE true) + Q_PROPERTY(QColor gInactiveColor MEMBER gInactiveColor_ DESIGNABLE true) + Q_PROPERTY(QColor gActiveColor MEMBER gActiveColor_ DESIGNABLE true) + Q_PROPERTY(QColor frameColor MEMBER frameColor_ DESIGNABLE true) public: FPGAViewWidget(QWidget *parent = 0); @@ -266,13 +266,14 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions const float zoomLvl2_ = 50.0f; Context *ctx_; - QColor backgroundColor; - QColor gridColor; - QColor gFrameColor; - QColor gHiddenColor; - QColor gInactiveColor; - QColor gActiveColor; - QColor frameColor; + + QColor backgroundColor_; + QColor gridColor_; + QColor gFrameColor_; + QColor gHiddenColor_; + QColor gInactiveColor_; + QColor gActiveColor_; + QColor frameColor_; }; NEXTPNR_NAMESPACE_END