Subversion Repositories DIN Is Noise

Rev

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

Rev Author Line No. Line
1528 jag 1
/*
2
* levels.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
 
9
#ifndef __levels__
10
#define __levels__
11
 
12
#include "widget.h"
13
#include "box.h"
1584 jag 14
#include "button.h"
15
#include "checkbutton.h"
16
#include "plus_button.h"
17
#include "minus_button.h"
18
#include "cross_button.h"
1586 jag 19
#include "filled_button.h"
1584 jag 20
#include "mouse_slider.h"
1587 jag 21
#include "state_button.h"
1528 jag 22
 
23
#include <string>
24
#include <vector>
25
 
1562 jag 26
struct levels;
1587 jag 27
 
1562 jag 28
struct paint_listener {
29
  virtual void paint (levels&) = 0;
30
};
31
 
1585 jag 32
struct shift_listener {
33
  virtual void shifted (levels&) = 0;
34
};
35
 
1587 jag 36
struct bookmark : state_button {
37
  std::vector<int> ids;
38
};
39
 
1586 jag 40
struct levels : widget, move_listener {
1528 jag 41
 
1587 jag 42
  int n;
43
  int last;
1528 jag 44
 
1587 jag 45
  int elem; // element width
1528 jag 46
  int height;
47
 
48
  int lev; // edited level
49
  float val; // edited val
50
  int hgt; // edited height
51
 
1587 jag 52
  int saveable;
53
  int editable;
1528 jag 54
 
55
  enum {STARTED=1, FINISH};
56
  int editing; // editing element?
57
  int stop_editing ();
58
 
59
  int paint; // paint levels with mouse?
1585 jag 60
  paint_listener* paintl;
1528 jag 61
 
62
  std::vector<float> values; // 0 to 1 for each level
63
  std::vector<int> heights; // 0 to height
1587 jag 64
 
1528 jag 65
  bool* selection;
66
  int nsel;
67
  int sel_sz;
68
 
1588 jag 69
  std::vector<bookmark*> bmk; // bookmarks of selections
1587 jag 70
  void addbookmark ();
1588 jag 71
  void removebookmark ();
1587 jag 72
  void removeallbookmarks ();
73
  void clearbookmarks ();
74
 
1588 jag 75
  MAKE_STATE_LISTENER (bmlis, bml)
1587 jag 76
 
1528 jag 77
  levels (const std::string& s);
1587 jag 78
  void load ();
79
 
80
  void save ();
1528 jag 81
  ~levels ();
1587 jag 82
 
1528 jag 83
  int handle_input ();
84
 
85
  float a, a0;
86
  void draw ();
87
 
88
  void clear_hgt_val ();
89
  void calc_lev ();
90
  void calc_hgt_val ();
91
  int set (int i, float v, int h = -1);
92
  void set_only (int i, float v);
93
  int change (int i, float d);
94
  int update_mul_lev (int dy);
95
 
96
  void update ();
97
 
1585 jag 98
  change_listener<levels>* chgl;
1528 jag 99
 
100
  int rshift ();
101
  int lshift ();
1585 jag 102
  shift_listener* shftl;
1528 jag 103
 
104
  void chkpos ();
105
  void reheight ();
106
 
1587 jag 107
  // manipulation
1584 jag 108
  button ball, binvert, bnone;
109
  button bslide, blshift, brshift;
110
  checkbutton cbwrap;
111
  MAKE_CLICK_LISTENER(alllis, alll)
112
  MAKE_CLICK_LISTENER(invlis, invl)
113
  MAKE_CLICK_LISTENER(nonlis, nonl)
114
  MAKE_CLICK_LISTENER(lshiftlis, lsl)
115
  MAKE_CLICK_LISTENER(rshiftlis, rsl)
116
 
117
  struct slide : click_listener, mouse_slider_listener {
118
    void clicked (button& b);
119
    void moused (int dir, double scl);
120
  } sll;
121
 
122
  void selall ();
123
  void selnon ();
124
  void invsel ();
125
 
126
  plus_button plus;
1587 jag 127
  MAKE_CLICK_LISTENER(pluslis, pll)
1584 jag 128
  minus_button minus;
1588 jag 129
  MAKE_CLICK_LISTENER(minuslis, mil)
1584 jag 130
  cross_button cross;
1588 jag 131
  MAKE_CLICK_LISTENER (crosslis, crol)
1587 jag 132
 
1586 jag 133
  filled_button szr;
1625 jag 134
  void moved ();
1584 jag 135
 
136
  void moused (int dir, double scl);
137
 
1585 jag 138
  void set_pos (int x, int y);
139
 
1587 jag 140
  int lmb_clicked;
141
  int prev_mousey;
1586 jag 142
 
143
 
1528 jag 144
};
145
 
146
#endif