Browse Source

When patching wires, invalid ports are rendered at 50% opacity

tags/v0.3.0
Andrew Belt 7 years ago
parent
commit
6964942204
4 changed files with 43 additions and 22 deletions
  1. +24
    -21
      include/components.hpp
  2. +3
    -1
      include/scene.hpp
  3. +8
    -0
      src/widgets/InputPort.cpp
  4. +8
    -0
      src/widgets/OutputPort.cpp

+ 24
- 21
include/components.hpp View File

@@ -77,38 +77,41 @@ struct BefacoSlidePot : SpriteKnob {
// Jacks
////////////////////

struct PJ301M : SpriteWidget {
template <typename BASE>
struct PJ301M : BASE {
PJ301M() {
box.size = Vec(24, 24);
spriteOffset = Vec(-2, -2);
spriteSize = Vec(30, 30);
spriteImage = Image::load("res/ComponentLibrary/PJ301M.png");
this->box.size = Vec(24, 24);
this->spriteOffset = Vec(-2, -2);
this->spriteSize = Vec(30, 30);
this->spriteImage = Image::load("res/ComponentLibrary/PJ301M.png");
}
};
struct InputPortPJ301M : InputPort, PJ301M {};
struct OutputPortPJ301M: OutputPort, PJ301M {};
typedef PJ301M<InputPort> InputPortPJ301M;
typedef PJ301M<OutputPort> OutputPortPJ301M;

struct PJ3410 : SpriteWidget {
template <typename BASE>
struct PJ3410 : BASE {
PJ3410() {
box.size = Vec(32, 32);
spriteOffset = Vec(-1, -1);
spriteSize = Vec(36, 36);
spriteImage = Image::load("res/ComponentLibrary/PJ3410.png");
this->box.size = Vec(32, 32);
this->spriteOffset = Vec(-1, -1);
this->spriteSize = Vec(36, 36);
this->spriteImage = Image::load("res/ComponentLibrary/PJ3410.png");
}
};
struct InputPortPJ3410 : InputPort, PJ3410 {};
struct OutputPortPJ3410: OutputPort, PJ3410 {};
typedef PJ3410<InputPort> InputPortPJ3410;
typedef PJ3410<OutputPort> OutputPortPJ3410;

struct CL1362 : SpriteWidget {
template <typename BASE>
struct CL1362 : BASE {
CL1362() {
box.size = Vec(33, 29);
spriteOffset = Vec(-2, -2);
spriteSize = Vec(39, 36);
spriteImage = Image::load("res/ComponentLibrary/CL1362.png");
this->box.size = Vec(33, 29);
this->spriteOffset = Vec(-2, -2);
this->spriteSize = Vec(39, 36);
this->spriteImage = Image::load("res/ComponentLibrary/CL1362.png");
}
};
struct InputPortCL1362 : InputPort, CL1362 {};
struct OutputPortCL1362 : OutputPort, CL1362 {};
typedef CL1362<InputPort> InputPortCL1362;
typedef CL1362<OutputPort> OutputPortCL1362;

////////////////////
// Misc


+ 3
- 1
include/scene.hpp View File

@@ -168,7 +168,7 @@ struct MomentarySwitch : virtual Switch {
// ports
////////////////////

struct Port : OpaqueWidget {
struct Port : OpaqueWidget, SpriteWidget {
Module *module = NULL;
WireWidget *connectedWire = NULL;

@@ -187,6 +187,7 @@ struct InputPort : Port {
void onDragDrop(Widget *origin);
void onDragEnter(Widget *origin);
void onDragLeave(Widget *origin);
void draw(NVGcontext *vg);
};

struct OutputPort : Port {
@@ -196,6 +197,7 @@ struct OutputPort : Port {
void onDragDrop(Widget *origin);
void onDragEnter(Widget *origin);
void onDragLeave(Widget *origin);
void draw(NVGcontext *vg);
};

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


+ 8
- 0
src/widgets/InputPort.cpp View File

@@ -42,4 +42,12 @@ void InputPort::onDragLeave(Widget *origin) {
}
}

void InputPort::draw(NVGcontext *vg) {
if (gRackWidget->activeWire) {
if (gRackWidget->activeWire->inputPort)
nvgGlobalAlpha(vg, 0.5);
}
SpriteWidget::draw(vg);
}

} // namespace rack

+ 8
- 0
src/widgets/OutputPort.cpp View File

@@ -42,4 +42,12 @@ void OutputPort::onDragLeave(Widget *origin) {
}
}

void OutputPort::draw(NVGcontext *vg) {
if (gRackWidget->activeWire) {
if (gRackWidget->activeWire->outputPort)
nvgGlobalAlpha(vg, 0.5);
}
SpriteWidget::draw(vg);
}

} // namespace rack

Loading…
Cancel
Save