Browse Source

Allow param data entry in context menu. Don't allow nested FramebufferWidget drawing.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
9a4a89b234
8 changed files with 24 additions and 56 deletions
  1. +1
    -3
      Makefile
  2. +1
    -0
      compile.mk
  3. +0
    -1
      include/app/ParamWidget.hpp
  4. +0
    -1
      include/math.hpp
  5. +0
    -2
      plugin.mk
  6. +7
    -2
      src/app/Knob.cpp
  7. +9
    -44
      src/app/ParamWidget.cpp
  8. +6
    -3
      src/widgets/FramebufferWidget.cpp

+ 1
- 3
Makefile View File

@@ -7,9 +7,7 @@ FLAGS += -Idep/include -Idep/lib/libzip/include

include arch.mk

STRIP ?= strip
SED := perl -p -i -e
# SED := sed -i
SED := perl -pi -e

# Sources and build flags



+ 1
- 0
compile.mk View File

@@ -5,6 +5,7 @@ endif
include $(RACK_DIR)/arch.mk

OBJCOPY ?= objcopy
STRIP ?= strip

# Generate dependency files alongside the object files
FLAGS += -MMD -MP


+ 0
- 1
include/app/ParamWidget.hpp View File

@@ -23,7 +23,6 @@ struct ParamWidget : OpaqueWidget {

/** For legacy patch loading */
void fromJson(json_t *rootJ);
void createParamField();
void createContextMenu();
void resetAction();
};


+ 0
- 1
include/math.hpp View File

@@ -109,7 +109,6 @@ inline float sgn(float x) {
}

/** Converts -0.f to 0.f. Leaves all other values unchanged. */
__attribute__((optimize("signed-zeros")))
inline float normalizeZero(float x) {
return x + 0.f;
}


+ 0
- 2
plugin.mk View File

@@ -5,8 +5,6 @@ endif
SLUG := $(shell jq ".slug" plugin.json)
VERSION := $(shell jq ".version" plugin.json)

STRIP ?= strip

DISTRIBUTABLES += plugin.json

FLAGS += -fPIC


+ 7
- 2
src/app/Knob.cpp View File

@@ -66,9 +66,14 @@ void Knob::onDragMove(const event::DragMove &e) {
}
float delta = KNOB_SENSITIVITY * -e.mouseDelta.y * speed * range;

// Drag slower if shift is held
if ((app()->window->getMods() & WINDOW_MOD_MASK) == GLFW_MOD_SHIFT)
// Drag slower if mod is held
if ((app()->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) {
delta /= 16.f;
}
// Drag even slower if mod+shift is held
if ((app()->window->getMods() & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL | GLFW_MOD_SHIFT)) {
delta /= 256.f;
}

if (snap) {
snapValue += delta;


+ 9
- 44
src/app/ParamWidget.cpp View File

@@ -51,12 +51,6 @@ struct ParamField : TextField {
e.consume(this);
}

if (e.action == GLFW_PRESS && e.key == GLFW_KEY_ESCAPE) {
MenuOverlay *overlay = getAncestorOfType<MenuOverlay>();
overlay->requestedDelete = true;
e.consume(this);
}

if (!e.getConsumed())
TextField::onSelectKey(e);
}
@@ -103,18 +97,6 @@ struct ParamResetItem : MenuItem {
};


struct ParamFieldItem : MenuItem {
ParamWidget *paramWidget;
ParamFieldItem() {
text = "Enter value";
rightText = WINDOW_MOD_ALT_NAME "+Click";
}
void onAction(const event::Action &e) override {
paramWidget->createParamField();
}
};


struct ParamFineItem : MenuItem {
ParamFineItem() {
text = "Fine adjust";
@@ -166,20 +148,14 @@ void ParamWidget::onButton(const event::Button &e) {
e.consume(this);
}

// Mod-click to reset
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) {
// Shift-click to reset
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & WINDOW_MOD_MASK) == GLFW_MOD_SHIFT) {
resetAction();
// HACK so that dragging won't occur
e.consume(NULL);
return;
}

// Shift-click to open value entry
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & WINDOW_MOD_MASK) == GLFW_MOD_ALT) {
createParamField();
e.consume(this);
}

if (!e.getConsumed())
OpaqueWidget::onButton(e);
}
@@ -209,18 +185,6 @@ void ParamWidget::fromJson(json_t *rootJ) {
}
}

void ParamWidget::createParamField() {
// Create ParamField
MenuOverlay *overlay = new MenuOverlay;
app()->scene->addChild(overlay);

ParamField *paramField = new ParamField;
paramField->box.size.x = 100;
paramField->box.pos = getAbsoluteOffset(box.size).round();
paramField->setParamWidget(this);
overlay->addChild(paramField);
}

void ParamWidget::createContextMenu() {
Menu *menu = createMenu();

@@ -228,16 +192,17 @@ void ParamWidget::createContextMenu() {
paramLabel->paramWidget = this;
menu->addChild(paramLabel);

ParamField *paramField = new ParamField;
paramField->box.size.x = 100;
paramField->setParamWidget(this);
menu->addChild(paramField);

ParamResetItem *resetItem = new ParamResetItem;
resetItem->paramWidget = this;
menu->addChild(resetItem);

ParamFieldItem *fieldItem = new ParamFieldItem;
fieldItem->paramWidget = this;
menu->addChild(fieldItem);

// ParamFineItem *fineItem = new ParamFineItem;
// menu->addChild(fineItem);
ParamFineItem *fineItem = new ParamFineItem;
menu->addChild(fineItem);
}

void ParamWidget::resetAction() {


+ 6
- 3
src/widgets/FramebufferWidget.cpp View File

@@ -15,9 +15,12 @@ FramebufferWidget::~FramebufferWidget() {
}

void FramebufferWidget::draw(NVGcontext *vg) {
// Bypass framebuffer rendering entirely
// Widget::draw(vg);
// return;
// Bypass framebuffer rendering if we're already drawing in a framebuffer
// In other words, disallow nested framebuffers. They look bad.
if (vg == app()->window->fbVg) {
Widget::draw(vg);
return;
}

// Get world transform
float xform[6];


Loading…
Cancel
Save