| @@ -1,30 +1,22 @@ | |||
| ARCH ?= linux | |||
| CFLAGS = -MMD -g -Wall -O2 | |||
| CXXFLAGS = -MMD -g -Wall -std=c++11 -O3 -msse -mfpmath=sse -ffast-math -fno-exceptions \ | |||
| ARCH ?= lin | |||
| FLAGS = -g -Wall -O3 -msse -mfpmath=sse -ffast-math \ | |||
| -I./ext -I./include | |||
| LDFLAGS = | |||
| CXXFLAGS = -fno-exceptions | |||
| SOURCES = $(wildcard src/*.cpp src/*/*.cpp) \ | |||
| ext/nanovg/src/nanovg.c | |||
| # Linux | |||
| ifeq ($(ARCH), linux) | |||
| CC = gcc | |||
| CXX = g++ | |||
| ifeq ($(ARCH), lin) | |||
| SOURCES += ext/noc/noc_file_dialog.c | |||
| CFLAGS += -DNOC_FILE_DIALOG_GTK $(shell pkg-config --cflags gtk+-2.0) | |||
| CXXFLAGS += -DLINUX | |||
| LDFLAGS += -rdynamic \ | |||
| -lpthread -lGL -lGLEW -lglfw -ldl -ljansson -lportaudio -lportmidi -lsamplerate \ | |||
| $(shell pkg-config --libs gtk+-2.0) | |||
| TARGET = Rack | |||
| endif | |||
| # Apple | |||
| ifeq ($(ARCH), apple) | |||
| CC = clang | |||
| CXX = clang++ | |||
| ifeq ($(ARCH), mac) | |||
| SOURCES += ext/noc/noc_file_dialog.m | |||
| CFLAGS += -DNOC_FILE_DIALOG_OSX | |||
| CXXFLAGS += -DAPPLE -stdlib=libc++ -I$(HOME)/local/include | |||
| @@ -32,13 +24,10 @@ LDFLAGS += -stdlib=libc++ -L$(HOME)/local/lib -lpthread -lglew -lglfw3 -framewor | |||
| TARGET = Rack | |||
| endif | |||
| # Windows | |||
| ifeq ($(ARCH), windows) | |||
| CC = x86_64-w64-mingw32-gcc | |||
| CXX = x86_64-w64-mingw32-g++ | |||
| ifeq ($(ARCH), win) | |||
| SOURCES += ext/noc/noc_file_dialog.c | |||
| CFLAGS += -DNOC_FILE_DIALOG_WIN32 | |||
| CXXFLAGS += -DWINDOWS -D_USE_MATH_DEFINES -DGLEW_STATIC \ | |||
| CXXFLAGS += -DGLEW_STATIC \ | |||
| -I$(HOME)/pkg/portaudio-r1891-build/include | |||
| LDFLAGS += \ | |||
| -Wl,-Bstatic,--whole-archive \ | |||
| @@ -1,4 +1,31 @@ | |||
| FLAGS += -MMD | |||
| CXXFLAGS += -std=c++11 | |||
| ifeq ($(ARCH), lin) | |||
| CC ?= gcc | |||
| CXX ?= g++ | |||
| FLAGS += -DLINUX | |||
| endif | |||
| ifeq ($(ARCH), mac) | |||
| CC ?= clang | |||
| CXX ?= clang++ | |||
| FLAGS += -DAPPLE | |||
| CXXFLAGS += -stdlib=libc++ | |||
| LDFLAGS += -stdlib=libc++ | |||
| endif | |||
| ifeq ($(ARCH), win) | |||
| CC ?= x86_64-w64-mingw32-gcc | |||
| CXX ?= x86_64-w64-mingw32-g++ | |||
| FLAGS += -DWINDOWS -D_USE_MATH_DEFINES | |||
| endif | |||
| CFLAGS := $(FLAGS) $(CFLAGS) | |||
| CXXFLAGS := $(FLAGS) $(CXXFLAGS) | |||
| OBJECTS += $(patsubst %, build/%.o, $(SOURCES)) | |||
| DEPS = $(patsubst %, build/%.d, $(SOURCES)) | |||
| @@ -5,59 +5,84 @@ | |||
| namespace rack { | |||
| //////////////////// | |||
| // knobs | |||
| // Knobs | |||
| //////////////////// | |||
| struct KnobDavies1900h : SpriteKnob { | |||
| KnobDavies1900h() { | |||
| // box.size = Vec(36, 36); | |||
| // spriteOffset = Vec(-8, -8); | |||
| // spriteSize = Vec(64, 64); | |||
| // minIndex = 44; | |||
| // maxIndex = -46; | |||
| // spriteCount = 120; | |||
| box.size = Vec(42, 42); | |||
| spriteOffset = Vec(-9, -9); | |||
| spriteSize = Vec(60, 60); | |||
| minIndex = 0; | |||
| maxIndex = 119; | |||
| box.size = Vec(36, 36); | |||
| spriteOffset = Vec(-2, -2); | |||
| spriteSize = Vec(42, 42); | |||
| minIndex = 44; | |||
| maxIndex = -46; | |||
| spriteCount = 120; | |||
| spriteImage = Image::load("res/Black Plastic small 01.png"); | |||
| } | |||
| }; | |||
| struct KnobDavies1900hWhite : KnobDavies1900h { | |||
| KnobDavies1900hWhite() { | |||
| // spriteImage = Image::load("res/ComponentLibrary/Davies1900hWhite.png"); | |||
| spriteImage = Image::load("res/ComponentLibrary/Davies1900hWhite.png"); | |||
| } | |||
| }; | |||
| struct KnobDavies1900hBlack : KnobDavies1900h { | |||
| KnobDavies1900hBlack() { | |||
| // spriteImage = Image::load("res/ComponentLibrary/Davies1900hBlack.png"); | |||
| spriteImage = Image::load("res/ComponentLibrary/Davies1900hBlack.png"); | |||
| } | |||
| }; | |||
| struct KnobDavies1900hRed : KnobDavies1900h { | |||
| KnobDavies1900hRed() { | |||
| // spriteImage = Image::load("res/ComponentLibrary/Davies1900hRed.png"); | |||
| spriteImage = Image::load("res/ComponentLibrary/Davies1900hRed.png"); | |||
| } | |||
| }; | |||
| struct BefacoBigKnob : SpriteKnob { | |||
| BefacoBigKnob() { | |||
| box.size = Vec(75, 75); | |||
| spriteOffset = Vec(-2, -2); | |||
| spriteSize = Vec(81, 81); | |||
| minIndex = 44; | |||
| maxIndex = -46; | |||
| spriteCount = 120; | |||
| spriteImage = Image::load("res/ComponentLibrary/BefacoBigKnob.png"); | |||
| } | |||
| }; | |||
| struct BefacoTinyKnob : SpriteKnob { | |||
| BefacoTinyKnob() { | |||
| box.size = Vec(26, 26); | |||
| spriteOffset = Vec(-2, -2); | |||
| spriteSize = Vec(32, 32); | |||
| minIndex = 44; | |||
| maxIndex = -46; | |||
| spriteCount = 120; | |||
| spriteImage = Image::load("res/ComponentLibrary/BefacoTinyKnob.png"); | |||
| } | |||
| }; | |||
| struct BefacoSlidePot : SpriteKnob { | |||
| BefacoSlidePot() { | |||
| box.size = Vec(12, 122); | |||
| spriteOffset = Vec(-2, -6); | |||
| spriteSize = Vec(18, 134); | |||
| minIndex = 97; | |||
| maxIndex = 0; | |||
| spriteCount = 98; | |||
| spriteImage = Image::load("res/ComponentLibrary/BefacoSlidePot.png"); | |||
| } | |||
| }; | |||
| //////////////////// | |||
| // ports | |||
| // Jacks | |||
| //////////////////// | |||
| struct PJ301M : SpriteWidget { | |||
| PJ301M() { | |||
| // box.size = Vec(24, 24); | |||
| // spriteOffset = Vec(-10, -10); | |||
| // spriteSize = Vec(48, 48); | |||
| // spriteImage = Image::load("res/ComponentLibrary/PJ301M.png"); | |||
| box.size = Vec(26, 26); | |||
| spriteOffset = Vec(-16, -16); | |||
| spriteSize = Vec(56, 56); | |||
| spriteImage = Image::load("res/port.png"); | |||
| box.size = Vec(24, 24); | |||
| spriteOffset = Vec(-2, -2); | |||
| spriteSize = Vec(30, 30); | |||
| spriteImage = Image::load("res/ComponentLibrary/PJ301M.png"); | |||
| } | |||
| }; | |||
| struct InputPortPJ301M : InputPort, PJ301M {}; | |||
| @@ -65,14 +90,10 @@ struct OutputPortPJ301M: OutputPort, PJ301M {}; | |||
| struct PJ3410 : SpriteWidget { | |||
| PJ3410() { | |||
| // box.size = Vec(31, 31); | |||
| // spriteOffset = Vec(-9, -9); | |||
| // spriteSize = Vec(54, 54); | |||
| // spriteImage = Image::load("res/ComponentLibrary/PJ3410.png"); | |||
| box.size = Vec(26, 26); | |||
| spriteOffset = Vec(-12, -12); | |||
| spriteSize = Vec(56, 56); | |||
| spriteImage = Image::load("res/port.png"); | |||
| box.size = Vec(32, 32); | |||
| spriteOffset = Vec(-1, -1); | |||
| spriteSize = Vec(36, 36); | |||
| spriteImage = Image::load("res/ComponentLibrary/PJ3410.png"); | |||
| } | |||
| }; | |||
| struct InputPortPJ3410 : InputPort, PJ3410 {}; | |||
| @@ -80,25 +101,40 @@ struct OutputPortPJ3410: OutputPort, PJ3410 {}; | |||
| struct CL1362 : SpriteWidget { | |||
| CL1362() { | |||
| // box.size = Vec(33, 29); | |||
| // spriteOffset = Vec(-10, -10); | |||
| // spriteSize = Vec(57, 54); | |||
| // spriteImage = Image::load("res/ComponentLibrary/CL1362.png"); | |||
| box.size = Vec(26, 26); | |||
| spriteOffset = Vec(-12, -12); | |||
| spriteSize = Vec(56, 56); | |||
| spriteImage = Image::load("res/port.png"); | |||
| box.size = Vec(33, 29); | |||
| spriteOffset = Vec(-2, -2); | |||
| spriteSize = Vec(39, 36); | |||
| spriteImage = Image::load("res/ComponentLibrary/CL1362.png"); | |||
| } | |||
| }; | |||
| struct InputPortCL1362 : InputPort, CL1362 {}; | |||
| struct OutputPortCL1362 : OutputPort, CL1362 {}; | |||
| //////////////////// | |||
| // panels | |||
| // Misc | |||
| //////////////////// | |||
| /** If you don't add these to your ModuleWidget, it will fall out of the rack... */ | |||
| struct Screw : SpriteWidget { | |||
| Screw() { | |||
| box.size = Vec(15, 14); | |||
| spriteOffset = Vec(0, 0); | |||
| spriteSize = Vec(15, 14); | |||
| } | |||
| }; | |||
| struct BlackScrew : Screw { | |||
| BlackScrew() { | |||
| spriteImage = Image::load("res/ComponentLibrary/ScrewBlack.png"); | |||
| } | |||
| }; | |||
| struct SilverScrew : Screw { | |||
| SilverScrew() { | |||
| spriteImage = Image::load("res/ComponentLibrary/ScrewSilver.png"); | |||
| } | |||
| }; | |||
| struct LightPanel : Panel { | |||
| LightPanel() { | |||
| backgroundColor = nvgRGB(0xe8, 0xe8, 0xe8); | |||
| @@ -61,9 +61,9 @@ OutputPort *createOutput(Vec pos, Module *module, int outputId) { | |||
| return port; | |||
| } | |||
| inline | |||
| template <class TScrew> | |||
| Screw *createScrew(Vec pos) { | |||
| Screw *screw = new Screw(); | |||
| Screw *screw = new TScrew(); | |||
| screw->box.pos = pos; | |||
| return screw; | |||
| } | |||
| @@ -104,16 +104,11 @@ struct Panel : TransparentWidget { | |||
| // params | |||
| //////////////////// | |||
| struct Light : TransparentWidget, SpriteWidget { | |||
| struct Light : TransparentWidget { | |||
| NVGcolor color; | |||
| void draw(NVGcontext *vg); | |||
| }; | |||
| // If you don't add these to your ModuleWidget, it will fall out of the RackWidget | |||
| struct Screw : TransparentWidget { | |||
| Screw(); | |||
| }; | |||
| struct ParamWidget : OpaqueWidget, QuantityWidget { | |||
| Module *module = NULL; | |||
| int paramId; | |||
| @@ -69,8 +69,10 @@ struct Widget { | |||
| Gives ownership of widget to this widget instance. | |||
| */ | |||
| void addChild(Widget *widget); | |||
| // Does not delete widget but transfers ownership to caller | |||
| // Silenty fails if widget is not a child | |||
| /** Removes widget from list of children if it exists. | |||
| Does not delete widget but transfers ownership to caller | |||
| Silently fails if widget is not a child | |||
| */ | |||
| void removeChild(Widget *widget); | |||
| void clearChildren(); | |||
| @@ -3,37 +3,35 @@ | |||
| namespace rack { | |||
| void Light::draw(NVGcontext *vg) { | |||
| SpriteWidget::draw(vg); | |||
| if (color.a == 0.0) | |||
| return; | |||
| // Draw glow | |||
| void Light::draw(NVGcontext *vg) { | |||
| NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | |||
| Vec c = box.getCenter(); | |||
| float radius = box.size.x / 2.0; | |||
| NVGcolor icol, ocol; | |||
| NVGpaint paint; | |||
| // Inner glow | |||
| icol = nvgRGBf(1.0, 1.0, 1.0); | |||
| icol.a = clampf(color.a, 0.0, 1.0); | |||
| ocol = color; | |||
| ocol.a = clampf(color.a, 0.0, 1.0); | |||
| paint = nvgRadialGradient(vg, c.x+1, c.y+3, 0.0, radius, icol, ocol); | |||
| nvgFillPaint(vg, paint); | |||
| Vec r = box.size.div(2.0); | |||
| nvgBeginPath(vg); | |||
| nvgCircle(vg, c.x, c.y, radius); | |||
| nvgEllipse(vg, c.x, c.y, r.x, r.y); | |||
| nvgFillColor(vg, colorOutline); | |||
| nvgFill(vg); | |||
| // Outer glow | |||
| icol = color; | |||
| icol.a = clampf(color.a / 10.0, 0.0, 1.0); | |||
| ocol = color; | |||
| ocol.a = 0.0; | |||
| float oradius = radius + 20.0; | |||
| paint = nvgRadialGradient(vg, c.x, c.y, radius, oradius, icol, ocol); | |||
| nvgFillPaint(vg, paint); | |||
| nvgBeginPath(vg); | |||
| nvgRect(vg, c.x - oradius, c.y - oradius, 2*oradius, 2*oradius); | |||
| nvgEllipse(vg, c.x, c.y, r.x - 1.0, r.y - 1.0); | |||
| nvgFillColor(vg, color); | |||
| nvgFill(vg); | |||
| // float radius = box.size.x / 2.0; | |||
| // NVGcolor icol, ocol; | |||
| // NVGpaint paint; | |||
| // icol = color; | |||
| // icol.a = clampf(color.a / 10.0, 0.0, 1.0); | |||
| // ocol = color; | |||
| // ocol.a = 0.0; | |||
| // float oradius = radius + 20.0; | |||
| // paint = nvgRadialGradient(vg, c.x, c.y, radius, oradius, icol, ocol); | |||
| // nvgFillPaint(vg, paint); | |||
| // nvgBeginPath(vg); | |||
| // nvgRect(vg, c.x - oradius, c.y - oradius, 2*oradius, 2*oradius); | |||
| // nvgFill(vg); | |||
| } | |||
| @@ -1,16 +0,0 @@ | |||
| #include "scene.hpp" | |||
| namespace rack { | |||
| Screw::Screw() { | |||
| // box.size = Vec(15, 15); | |||
| // spriteOffset = Vec(-7, -7); | |||
| // spriteSize = Vec(29, 29); | |||
| // spriteImage = Image::load("res/screw.png"); | |||
| // index = randomu32() % 5; | |||
| } | |||
| } // namespace rack | |||