Subversion Repositories DIN Is Noise

Rev

Rev 1905 | Rev 1908 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
* gravity.h
* DIN Is Noise is copyright (c) 2006-2022 Jagannathan Sampath
* DIN Is Noise is released under GNU Public License 2.0
* For more information, please visit https://dinisnoise.org/
*/


#ifndef __GRAVITY
#define __GRAVITY

#include "widget.h"
#include "arrow_button.h"
#include "checkbutton.h"
#include "spinner2.h"
#include "point.h"
#include "mouse_slider.h"
#include "multi_curve.h"
#include "mod_params.h"
#include "curve_editor.h"
#include "ui_list.h"
#include "options_list.h"

#define DONTCALCMAG 0

struct drone;

struct gravity_t : widget, click_listener, mouse_slider_listener {

  arrow_button fold;
  label lbl;
  button zero, reset;
  checkbutton keepsize;
  arrow_button left, right, up, down;
  button base2manual, base2drone;
  button tip2manual, tip2drone;

  DECL_CLICK_LISTENER (manlis)
  DECL_CLICK_LISTENER (drolis)
  manlis b2ml, t2ml;
  drolis b2dl, t2dl;

  int lmb_clicked;
  int hitt;
  enum {NEXT_TO_NOTHING = -1, NOTHING, BASE, TIP};
  int hit (const point<float>& p, float mx, float my);

  int handlesize;
  point<float> base;
  point<float> tip;
  point<float> base2tip, base2tip_ms;
  point<float> p_base2tip;
  double btux, btuy;
  point<float> bottomleft, topright;
  point<int> textpos;

  float strength;
  float gx, gy;

  int ldwx[2], ldwy[2]; // last tracked drone pos on din window
  drone* tracked_drone[2];
  void track (int i, float vx, float vy);

  double mag0, mag;
  int keep_size;
  void updmag (double m);

  gravity_t ();
  void load (std::ifstream& file);
  void save (std::ofstream& file);
  int handle_input ();
  int handle_input2 ();

  void set (point<float>& p, float mx, float my, int calc_mag = 1);
  void move (float tox, float toy);
  void calcbase2tip ();
  void calcvisual ();
  void calc (int calc_mag = 1);
  void calcui ();
  void initui ();
  void preset (int id);
  void doreset (int keep_size = 0);
  int stop_editing ();

  int gl_base [8];
  float gl_arrow[12];

  void draw ();
  void drawrrow ();

  void clicked (button& b);
  void moused (int dir, double scl);
  void after_slide ();

  int unfolded ();

};

#endif