Browse Source

Update blendish. Add TextField::prevField/nextField.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
a4f3542217
7 changed files with 27 additions and 32 deletions
  1. +2
    -1
      Makefile
  2. +1
    -1
      dep/oui-blendish
  3. +5
    -0
      include/ui/TextField.hpp
  4. +6
    -26
      src/app/MenuBar.cpp
  5. +1
    -1
      src/ui/Label.cpp
  6. +0
    -3
      src/ui/MenuItem.cpp
  7. +12
    -0
      src/ui/TextField.cpp

+ 2
- 1
Makefile View File

@@ -16,6 +16,7 @@ SED := perl -pi -e

SOURCES += dep/nanovg/src/nanovg.c
SOURCES += dep/osdialog/osdialog.c
SOURCES += dep/oui-blendish/blendish.c
SOURCES += dep/pffft/pffft.c dep/pffft/fftpack.c
SOURCES += $(wildcard src/*.c src/*/*.c)
SOURCES += $(wildcard src/*.cpp src/*/*.cpp)
@@ -130,7 +131,7 @@ valgrind: $(STANDALONE_TARGET)
valgrind --suppressions=valgrind.supp ./$< -d

clean:
rm -rfv $(TARGET) $(STANDALONE_TARGET) libRack.dll.a Rack.res build dist *.d
rm -rfv build dist *.a Rack.res *.d $(TARGET) $(STANDALONE_TARGET)


# For Windows resources


+ 1
- 1
dep/oui-blendish

@@ -1 +1 @@
Subproject commit 910847b53396fd394e5fa25c3430caea02a3fe70
Subproject commit 008cceaa10d18661129fb94b2b678c1827c04cd3

+ 5
- 0
include/ui/TextField.hpp View File

@@ -19,6 +19,11 @@ struct TextField : widget::OpaqueWidget {
*/
int selection = 0;

/** For Tab and Shift-Tab focusing.
*/
Widget* prevField = NULL;
Widget* nextField = NULL;

TextField();
void draw(const DrawArgs& args) override;
void onDragHover(const DragHoverEvent& e) override;


+ 6
- 26
src/app/MenuBar.cpp View File

@@ -608,31 +608,10 @@ struct EngineButton : MenuButton {

static bool isLoggingIn = false;

struct AccountEmailField : ui::TextField {
ui::TextField* passwordField;

void onSelectKey(const SelectKeyEvent& e) override {
if (e.action == GLFW_PRESS && e.key == GLFW_KEY_TAB) {
APP->event->setSelected(passwordField);
e.consume(this);
}

if (!e.getTarget())
ui::TextField::onSelectKey(e);
}
};

struct AccountPasswordField : ui::PasswordField {
struct AccountPasswordField : ui::TextField {
ui::MenuItem* logInItem;

void onSelectKey(const SelectKeyEvent& e) override {
if (e.action == GLFW_PRESS && (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER)) {
logInItem->doAction();
e.consume(this);
}

if (!e.getTarget())
ui::PasswordField::onSelectKey(e);
void onAction(const ActionEvent& e) override {
logInItem->doAction();
}
};

@@ -802,7 +781,7 @@ struct LibraryMenu : ui::Menu {
registerItem->url = "https://vcvrack.com/login";
addChild(registerItem);

AccountEmailField* emailField = new AccountEmailField;
ui::TextField* emailField = new ui::TextField;
emailField->placeholder = "Email";
emailField->box.size.x = 240.0;
addChild(emailField);
@@ -810,7 +789,8 @@ struct LibraryMenu : ui::Menu {
AccountPasswordField* passwordField = new AccountPasswordField;
passwordField->placeholder = "Password";
passwordField->box.size.x = 240.0;
emailField->passwordField = passwordField;
passwordField->nextField = emailField;
emailField->nextField = passwordField;
addChild(passwordField);

LogInItem* logInItem = new LogInItem;


+ 1
- 1
src/ui/Label.cpp View File

@@ -7,7 +7,7 @@ namespace ui {

Label::Label() {
box.size.y = BND_WIDGET_HEIGHT;
fontSize = 13;
fontSize = BND_LABEL_FONT_SIZE;
lineHeight = 1.2;
color = bndGetTheme()->regularTheme.textColor;
}


+ 0
- 3
src/ui/MenuItem.cpp View File

@@ -6,9 +6,6 @@ namespace rack {
namespace ui {


#define BND_LABEL_FONT_SIZE 13


void MenuItem::draw(const DrawArgs& args) {
BNDwidgetState state = BND_DEFAULT;



+ 12
- 0
src/ui/TextField.cpp View File

@@ -220,6 +220,18 @@ void TextField::onSelectKey(const SelectKeyEvent& e) {
}
e.consume(this);
}
// Tab
if (e.key == GLFW_KEY_TAB && (e.mods & RACK_MOD_MASK) == 0) {
if (nextField)
APP->event->setSelected(nextField);
e.consume(this);
}
// Shift-Tab
if (e.key == GLFW_KEY_TAB && (e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) {
if (prevField)
APP->event->setSelected(prevField);
e.consume(this);
}
// Consume all printable keys
if (e.keyName != "") {
e.consume(this);


Loading…
Cancel
Save