Browse Source

Add error message if window doesn't open, refactor SVGPanel

tags/v0.3.2
Andrew Belt 7 years ago
parent
commit
98987a2ef9
6 changed files with 27 additions and 29 deletions
  1. +1
    -1
      ext/osdialog
  2. +1
    -5
      include/app.hpp
  3. +0
    -20
      src/app/PanelBorder.cpp
  4. +18
    -2
      src/app/SVGPanel.cpp
  5. +6
    -1
      src/gui.cpp
  6. +1
    -0
      src/widgets/FramebufferWidget.cpp

+ 1
- 1
ext/osdialog

@@ -1 +1 @@
Subproject commit e66caf0f9d3266a79c513dcc73b57b6b3eb38120
Subproject commit 952d72f925ea5e9086067d47a9d31516878fcaac

+ 1
- 5
include/app.hpp View File

@@ -121,12 +121,8 @@ struct Panel : TransparentWidget {
void draw(NVGcontext *vg); void draw(NVGcontext *vg);
}; };


struct PanelBorder : TransparentWidget {
void draw(NVGcontext *vg);
};

struct SVGPanel : FramebufferWidget { struct SVGPanel : FramebufferWidget {
void addBackground(std::shared_ptr<SVG> svg);
void setBackground(std::shared_ptr<SVG> svg);
}; };


//////////////////// ////////////////////


+ 0
- 20
src/app/PanelBorder.cpp View File

@@ -1,20 +0,0 @@
#include "app.hpp"


namespace rack {

void PanelBorder::draw(NVGcontext *vg) {
nvgBeginPath(vg);
nvgRect(vg, 0.0, 0.0, box.size.x, box.size.y);

NVGcolor borderColor = nvgRGB(0xac, 0xac, 0xac);

// Border
nvgBeginPath(vg);
nvgRect(vg, 0.5, 0.5, box.size.x - 1, box.size.y - 1);
nvgStrokeColor(vg, borderColor);
nvgStrokeWidth(vg, 1.0);
nvgStroke(vg);
}

} // namespace rack

+ 18
- 2
src/app/SVGPanel.cpp View File

@@ -4,14 +4,30 @@
namespace rack { namespace rack {




void SVGPanel::addBackground(std::shared_ptr<SVG> svg) {
struct PanelBorder : TransparentWidget {
void draw(NVGcontext *vg) {
nvgBeginPath(vg);
nvgRect(vg, 0.0, 0.0, box.size.x, box.size.y);

NVGcolor borderColor = nvgRGBAf(0.5, 0.5, 0.5, 0.5);

nvgBeginPath(vg);
nvgRect(vg, 0.5, 0.5, box.size.x - 1.0, box.size.y - 1.0);
nvgStrokeColor(vg, borderColor);
nvgStrokeWidth(vg, 1.0);
nvgStroke(vg);
}
};


void SVGPanel::setBackground(std::shared_ptr<SVG> svg) {
SVGWidget *sw = new SVGWidget(); SVGWidget *sw = new SVGWidget();
sw->wrap(); sw->wrap();
sw->svg = svg; sw->svg = svg;
addChild(sw); addChild(sw);


PanelBorder *pb = new PanelBorder(); PanelBorder *pb = new PanelBorder();
sw->box.size = box.size;
pb->box.size = box.size;
addChild(pb); addChild(pb);
} }




+ 6
- 1
src/gui.cpp View File

@@ -3,6 +3,7 @@
#include "gui.hpp" #include "gui.hpp"
#include "app.hpp" #include "app.hpp"
#include "settings.hpp" #include "settings.hpp"
#include "../ext/osdialog/osdialog.h"


#define NANOVG_GL2_IMPLEMENTATION #define NANOVG_GL2_IMPLEMENTATION
// #define NANOVG_GL3_IMPLEMENTATION // #define NANOVG_GL3_IMPLEMENTATION
@@ -216,7 +217,11 @@ void guiInit() {
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
std::string title = gApplicationName + " " + gApplicationVersion; std::string title = gApplicationName + " " + gApplicationVersion;
gWindow = glfwCreateWindow(1000, 750, title.c_str(), NULL, NULL); gWindow = glfwCreateWindow(1000, 750, title.c_str(), NULL, NULL);
assert(gWindow);
if (!gWindow) {
osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Cannot open window with OpenGL 2.0 renderer. Does your graphics card support OpenGL 2.0? If so, are the latest drivers installed?");
exit(1);
}

glfwMakeContextCurrent(gWindow); glfwMakeContextCurrent(gWindow);


glfwSwapInterval(1); glfwSwapInterval(1);


+ 1
- 0
src/widgets/FramebufferWidget.cpp View File

@@ -42,6 +42,7 @@ void FramebufferWidget::step() {
Vec fbSize = internal->box.size.mult(gPixelRatio * oversample); Vec fbSize = internal->box.size.mult(gPixelRatio * oversample);
// assert(fbSize.isFinite()); // assert(fbSize.isFinite());


// Delete old one first to free up GPU memory
internal->setFramebuffer(NULL); internal->setFramebuffer(NULL);
NVGLUframebuffer *fb = nvgluCreateFramebuffer(gVg, fbSize.x, fbSize.y, NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); NVGLUframebuffer *fb = nvgluCreateFramebuffer(gVg, fbSize.x, fbSize.y, NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY);
if (!fb) if (!fb)


Loading…
Cancel
Save