Subversion Repositories DIN Is Noise

Rev

Rev 2036 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1528 jag 1
/*
2
* mouse_slider.h
2097 jag 3
* DIN Is Noise is copyright (c) 2006-2024 Jagannathan Sampath
1713 jag 4
* DIN Is Noise is released under GNU Public License 2.0
1528 jag 5
* For more information, please visit https://dinisnoise.org/
6
*/
7
 
8
#ifndef __mouse_slider
9
#define __mouse_slider
10
 
11
#include "widget.h"
12
#include "arrow_button.h"
2027 jag 13
#include "checkbutton.h"
1528 jag 14
 
15
#include <list>
16
 
17
struct mouse_slider_listener {
1595 jag 18
 
1528 jag 19
  std::string name;
20
  enum {X, Y, NONE};
21
  int orient;
1595 jag 22
  double delta0, delta;
2029 jag 23
  checkbutton* vary;
2027 jag 24
  checkbutton* lim;
2029 jag 25
  void togger (checkbutton* cb, const char* str);
26
  void togvary ();
2027 jag 27
  void toglim ();
1595 jag 28
  mouse_slider_listener ();
1584 jag 29
  virtual void moused (int dir, double scl = 1.0) {}
1528 jag 30
  virtual void after_slide () {}
31
};
32
 
33
struct mouse_slider : widget {
34
 
35
  int sz, sz_2, szn, szn_1;
36
  arrow_button axl, axr;
37
  arrow_button ayb, ayt;
38
  void update_x_arrows ();
39
  void update_y_arrows ();
40
 
41
  static const int margin = 10;
42
  int lowx, highx, midx;
43
  int lowy, highy, midy;
44
  int prevx, prevy;
45
  int initx, inity, inityy;
46
 
47
  std::list<mouse_slider_listener*> mslx, msly;
48
  int nmslx, nmsly;
1595 jag 49
  void print (std::list<mouse_slider_listener*>&, std::list<mouse_slider_listener*>&);
50
  void print (std::list<mouse_slider_listener*>&);
51
 
1528 jag 52
  int dx, dy;
1579 jag 53
 
1578 jag 54
  int justx ();
55
  int justy ();
1528 jag 56
 
57
  int active;
58
 
1988 jag 59
  static int warp;
1610 jag 60
 
1528 jag 61
  int lmb_clicked;
62
 
63
  mouse_slider ();
64
  ~mouse_slider ();
65
  int handle_input ();
66
 
1650 jag 67
  int pts [8];
1528 jag 68
  void draw ();
1742 jag 69
 
1528 jag 70
  void add (mouse_slider_listener* sl);
71
  void remove (mouse_slider_listener* sl);
72
 
1566 jag 73
  double base;
1627 jag 74
  int shift;
1608 jag 75
  struct scalet {
1627 jag 76
    enum {FIXED, CHANGING};
77
    int style;
1608 jag 78
    double value;
79
    void operator*= (const double& v) { value *= v; }
80
    void operator/= (const double& v) { value /= v; }
1749 jag 81
    void calcvalue (double& b, int s);
1608 jag 82
  } scale;
1566 jag 83
 
1742 jag 84
  int activate (int shft = 0, int scalestyle = scalet::CHANGING);
1608 jag 85
  int deactivate ();
86
 
1528 jag 87
};
88
 
89
void cant_mouse_slide ();
1742 jag 90
void activate_mouse_slider (int shift = 0, int scalestyle = mouse_slider::scalet::CHANGING);
1608 jag 91
 
1528 jag 92
extern mouse_slider mouse_slider0;
93
 
1566 jag 94
#define MAKE_MOUSE_SLIDER_LISTENER(name,var) struct name : mouse_slider_listener { void after_slide (); void moused (int dir, double scl); }; name var;
1528 jag 95
#define AFTER_SLIDE(scope,name) void scope::name::after_slide () 
1566 jag 96
#define MOUSED(scope,name) void scope::name::moused (int dir, double scl)
1528 jag 97
 
98
#endif