Browse Source

Merge branch 'master' of https://github.com/VCVRack/Rack into 2017-10-bontric-midi-interface-revamp

tags/v0.4.0
ben 7 years ago
parent
commit
98bfa08911
5 changed files with 21 additions and 14 deletions
  1. +1
    -1
      compile.mk
  2. +2
    -2
      include/widgets.hpp
  3. +10
    -8
      src/app/ModuleWidget.cpp
  4. +6
    -2
      src/gui.cpp
  5. +2
    -1
      src/widgets/TextField.cpp

+ 1
- 1
compile.mk View File

@@ -1,5 +1,5 @@
VERSION ?= dev
FLAGS += -DVERSION=$(VERSION)
FLAGS += -DVERSION=$(VERSION) -DVERSION_$(subst .,_,$(VERSION))

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


+ 2
- 2
include/widgets.hpp View File

@@ -112,7 +112,7 @@ struct Widget {
virtual void onMouseEnter() {}
/** Called when another widget begins responding to `onMouseMove` events */
virtual void onMouseLeave() {}
virtual void onFocus() {}
virtual bool onFocus() {return false;}
virtual void onDefocus() {}
virtual bool onFocusText(int codepoint) {return false;}
virtual bool onFocusKey(int key) {return false;}
@@ -409,7 +409,7 @@ struct TextField : OpaqueWidget {
Widget *onMouseDown(Vec pos, int button);
bool onFocusText(int codepoint);
bool onFocusKey(int scancode);
void onFocus();
bool onFocus();
void insertText(std::string newText);
};



+ 10
- 8
src/app/ModuleWidget.cpp View File

@@ -152,14 +152,16 @@ void ModuleWidget::draw(NVGcontext *vg) {
}

Widget *ModuleWidget::onMouseMove(Vec pos, Vec mouseRel) {
// Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget.
if (glfwGetKey(gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) {
if (!guiIsModPressed() && !guiIsShiftPressed()) {
gRackWidget->deleteModule(this);
this->finalizeEvents();
delete this;
// Kinda sketchy because events will be passed further down the tree
return NULL;
if (!gFocusedWidget) {
// Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget.
if (glfwGetKey(gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) {
if (!guiIsModPressed() && !guiIsShiftPressed()) {
gRackWidget->deleteModule(this);
this->finalizeEvents();
delete this;
// Kinda sketchy because events will be passed further down the tree
return NULL;
}
}
}
return OpaqueWidget::onMouseMove(pos, mouseRel);


+ 6
- 2
src/gui.cpp View File

@@ -59,12 +59,16 @@ void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods) {

if (w != gFocusedWidget) {
if (gFocusedWidget) {
// onDefocus
w->onDefocus();
}
gFocusedWidget = NULL;
if (w) {
w->onFocus();
// onFocus
if (w->onFocus()) {
gFocusedWidget = w;
}
}
gFocusedWidget = w;
}
}
}


+ 2
- 1
src/widgets/TextField.cpp View File

@@ -103,9 +103,10 @@ bool TextField::onFocusKey(int key) {
return true;
}

void TextField::onFocus() {
bool TextField::onFocus() {
begin = 0;
end = text.size();
return true;
}

void TextField::insertText(std::string newText) {


Loading…
Cancel
Save