Browse Source

Cleanup widget code

tags/v0.3.2
Andrew Belt 7 years ago
parent
commit
24cb2f506b
8 changed files with 22 additions and 22 deletions
  1. +4
    -4
      include/app.hpp
  2. +6
    -6
      include/widgets.hpp
  3. +2
    -2
      src/app/ModuleWidget.cpp
  4. +1
    -1
      src/app/ParamWidget.cpp
  5. +1
    -1
      src/app/Port.cpp
  6. +1
    -1
      src/app/RackScene.cpp
  7. +1
    -1
      src/app/RackWidget.cpp
  8. +6
    -6
      src/util/request.cpp

+ 4
- 4
include/app.hpp View File

@@ -61,7 +61,7 @@ struct ModuleWidget : OpaqueWidget {
void onDragStart();
void onDragMove(Vec mouseRel);
void onDragEnd();
void onMouseDown(int button);
void onMouseDownOpaque(int button);
};

struct WireWidget : OpaqueWidget {
@@ -107,7 +107,7 @@ struct RackWidget : OpaqueWidget {
void step();
void draw(NVGcontext *vg);

void onMouseDown(int button);
void onMouseDownOpaque(int button);
};

struct RackRail : TransparentWidget {
@@ -145,7 +145,7 @@ struct ParamWidget : OpaqueWidget, QuantityWidget {

json_t *toJson();
void fromJson(json_t *root);
void onMouseDown(int button);
void onMouseDownOpaque(int button);
void onChange();
};

@@ -255,7 +255,7 @@ struct Port : OpaqueWidget {
void disconnect();

void draw(NVGcontext *vg);
void onMouseDown(int button);
void onMouseDownOpaque(int button);
void onDragEnd();
void onDragStart();
void onDragDrop(Widget *origin);


+ 6
- 6
include/widgets.hpp View File

@@ -150,28 +150,28 @@ struct OpaqueWidget : virtual Widget {
Widget *onMouseDown(Vec pos, int button) {
Widget *w = Widget::onMouseDown(pos, button);
if (w) return w;
onMouseDown(button);
onMouseDownOpaque(button);
return this;
}
Widget *onMouseUp(Vec pos, int button) {
Widget *w = Widget::onMouseUp(pos, button);
if (w) return w;
onMouseUp(button);
onMouseUpOpaque(button);
return this;
}
Widget *onMouseMove(Vec pos, Vec mouseRel) {
Widget *w = Widget::onMouseMove(pos, mouseRel);
if (w) return w;
onMouseMove(mouseRel);
onMouseMoveOpaque(mouseRel);
return this;
}

/** "High level" events called by the above lower level events.
Use these if you don't care about the clicked position.
*/
virtual void onMouseDown(int button) {}
virtual void onMouseUp(int button) {}
virtual void onMouseMove(Vec mouseRel) {}
virtual void onMouseDownOpaque(int button) {}
virtual void onMouseUpOpaque(int button) {}
virtual void onMouseMoveOpaque(Vec mouseRel) {}
};

struct SpriteWidget : virtual Widget {


+ 2
- 2
src/app/ModuleWidget.cpp View File

@@ -82,7 +82,7 @@ void ModuleWidget::fromJson(json_t *rootJ) {
size_t paramId;
json_t *paramJ;
json_array_foreach(paramsJ, paramId, paramJ) {
if (0 <= paramId && paramId < params.size()) {
if (paramId < params.size()) {
params[paramId]->fromJson(paramJ);
}
}
@@ -223,7 +223,7 @@ struct DeleteMenuItem : MenuItem {
}
};

void ModuleWidget::onMouseDown(int button) {
void ModuleWidget::onMouseDownOpaque(int button) {
if (button == 1) {
Menu *menu = gScene->createMenu();



+ 1
- 1
src/app/ParamWidget.cpp View File

@@ -13,7 +13,7 @@ void ParamWidget::fromJson(json_t *rootJ) {
setValue(json_number_value(rootJ));
}

void ParamWidget::onMouseDown(int button) {
void ParamWidget::onMouseDownOpaque(int button) {
if (button == 1) {
setValue(defaultValue);
}


+ 1
- 1
src/app/Port.cpp View File

@@ -34,7 +34,7 @@ void Port::draw(NVGcontext *vg) {
}
}

void Port::onMouseDown(int button) {
void Port::onMouseDownOpaque(int button) {
if (button == 1) {
disconnect();
}


+ 1
- 1
src/app/RackScene.cpp View File

@@ -40,7 +40,7 @@ RackScene::RackScene() {
scrollWidget->box.pos.y = toolbar->box.size.y;

// Check for new version
if (gApplicationVersion != "dev" || true) {
if (gApplicationVersion != "dev") {
std::thread versionThread(checkVersion);
versionThread.detach();
}


+ 1
- 1
src/app/RackWidget.cpp View File

@@ -326,7 +326,7 @@ struct AddModuleMenuItem : MenuItem {
}
};

void RackWidget::onMouseDown(int button) {
void RackWidget::onMouseDownOpaque(int button) {
if (button == 1) {
Vec modulePos = gMousePos.minus(getAbsolutePos());
Menu *menu = gScene->createMenu();


+ 6
- 6
src/util/request.cpp View File

@@ -23,7 +23,7 @@ json_t *requestJson(RequestMethod method, std::string url, json_t *dataJ) {

// Process data
if (dataJ) {
if (method == GET_METHOD) {
if (method == METHOD_GET) {
// Append ?key=value&... to url
url += "?";
bool isFirst = true;
@@ -53,16 +53,16 @@ json_t *requestJson(RequestMethod method, std::string url, json_t *dataJ) {

// Set HTTP method
switch (method) {
case GET_METHOD:
// This is default
case METHOD_GET:
// This is CURL's default
break;
case POST_METHOD:
case METHOD_POST:
curl_easy_setopt(curl, CURLOPT_POST, true);
break;
case PUT_METHOD:
case METHOD_PUT:
curl_easy_setopt(curl, CURLOPT_PUT, true);
break;
case DELETE_METHOD:
case METHOD_DELETE:
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
break;
}


Loading…
Cancel
Save