~l3kn/quad

704cf4f4c1b1b6f82fcaa0a40747d7131bbd14b4 — Leon Rische 5 months ago 796172f
Allow dragging from inside rules
1 files changed, 23 insertions(+), 2 deletions(-)

M quad.c
M quad.c => quad.c +23 -2
@@ 269,8 269,29 @@ void handleMouse(SDL_Event* event) {
      selection.type = RULE;
      selection.index = tx / 6;
      selection.index += 2 * ((ty - 5) / 3);
    } else {
      selection.type = NONE;
    } else if (tx >= 0 && tx < 10 && ty >= 5 && ty < 16) {
      ty -= 5;

      int rule = 2 * (ty / 3);
      ty %= 3;
      if (tx >= 6) {
        tx -= 6;
        rule += 1;
      }

      if (tx == 0 && ty == 1) {
        selection = rules[rule].fallback;
      } else if (tx == 2 && ty == 0) {
        selection = rules[rule].tl;
      } else if (tx == 3 && ty == 0) {
        selection = rules[rule].tr;
      } else if (tx == 2 && ty == 1) {
        selection = rules[rule].bl;
      } else if (tx == 3 && ty == 1) {
        selection = rules[rule].br;
      } else {
        selection.type = NONE;
      }
    }
    break;
  }