1 /* -----------------------------------------------------------------------------
2  *
3  * Giada - Your Hardcore Loopmachine
4  *
5  * gLiquidScroll
6  * custom scroll that tells children to follow scroll's width when
7  * resized. Thanks to Greg Ercolano from FLTK dev team.
8  * http://seriss.com/people/erco/fltk/
9  *
10  * -----------------------------------------------------------------------------
11  *
12  * Copyright (C) 2010-2020 Giovanni A. Zuliani | Monocasual
13  *
14  * This file is part of Giada - Your Hardcore Loopmachine.
15  *
16  * Giada - Your Hardcore Loopmachine is free software: you can
17  * redistribute it and/or modify it under the terms of the GNU General
18  * Public License as published by the Free Software Foundation, either
19  * version 3 of the License, or (at your option) any later version.
20  *
21  * Giada - Your Hardcore Loopmachine is distributed in the hope that it
22  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
23  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24  * See the GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with Giada - Your Hardcore Loopmachine. If not, see
28  * <http://www.gnu.org/licenses/>.
29  *
30  * -------------------------------------------------------------------------- */
31 
32 
33 #ifndef GE_LIQUID_SCROLL_H
34 #define GE_LIQUID_SCROLL_H
35 
36 
37 #include "scroll.h"
38 
39 
40 class geLiquidScroll : public geScroll
41 {
42 public:
43 
44 	geLiquidScroll(int x, int y, int w, int h);
45 
46 	void resize(int x, int y, int w, int h) override;
47 
48     /* addWidget
49     Adds a new widget to the bottom, with proper spacing. */
50 
51     template<typename T>
addWidget(T * wg)52     T* addWidget(T* wg)
53     {
54         int numChildren = countChildren();
55 
56         int wx = x();
57         int wy = y() - yposition() + (numChildren * (wg->h() + G_GUI_INNER_MARGIN));
58         int ww = w() - 24;
59         int wh = wg->h();
60 
61         wg->resize(wx, wy, ww, wh);
62         add(wg);
63         redraw();
64 
65         return wg;
66     }
67 };
68 
69 
70 #endif
71