Only show user-presets in favorite sidebar
[ardour.git] / libs / widgets / widgets / ardour_spacer.h
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18
19 #ifndef _WIDGETS_ARDOUR_SPACER_H_
20 #define _WIDGETS_ARDOUR_SPACER_H_
21
22 #include "gtkmm2ext/cairo_widget.h"
23
24 #include "widgets/visibility.h"
25
26 namespace ArdourWidgets {
27
28 class LIBWIDGETS_API ArdourVSpacer : public CairoWidget
29 {
30 public:
31         ArdourVSpacer (float r = 0.75f);
32
33 protected:
34         void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*) {
35
36                 float height = get_height();
37
38                 float h = height * ratio;
39                 float t = .5f * (height - h);
40                 ctx->rectangle (0, t, 1, h);
41                 ctx->set_source_rgb (0, 0, 0);
42                 ctx->fill ();
43         }
44
45         void on_size_request (Gtk::Requisition* req) {
46                 req->width = 1;
47                 req->height = 0;
48                 CairoWidget::on_size_request (req);
49         }
50
51         float ratio;
52 };
53
54 class LIBWIDGETS_API ArdourDropShadow : public CairoWidget
55 {
56 public:
57         enum ShadowMode {
58                 DropShadowLongSideOnly,
59                 DropShadowBoth,
60         };
61
62         ArdourDropShadow (ShadowMode m = DropShadowLongSideOnly, float a = 0.55f);
63
64         void set_mode(ShadowMode m) {mode = m;}
65
66 protected:
67         void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*) {
68                 float width = get_width();
69                 float height = get_height();
70
71                 Cairo::RefPtr<Cairo::LinearGradient> _gradient;
72
73                 if ( (width>height) || mode == DropShadowBoth ) {
74                         _gradient = Cairo::LinearGradient::create (0, 0, 0, 4);
75                         _gradient->add_color_stop_rgba (0, 0, 0, 0, alpha);
76                         _gradient->add_color_stop_rgba (1, 0, 0, 0, 0);
77                         ctx->set_source (_gradient);
78                         ctx->rectangle (0, 0, width, 4);
79                         ctx->fill ();
80                 }
81
82                 if ( (height>width) || mode == DropShadowBoth ) {
83                         _gradient = Cairo::LinearGradient::create (0, 0, 4, 0);
84                         _gradient->add_color_stop_rgba (0, 0, 0, 0, alpha);
85                         _gradient->add_color_stop_rgba (1, 0, 0, 0, 0);
86                         ctx->set_source (_gradient);
87                         ctx->rectangle (0, 0, 4, height);
88                         ctx->fill ();
89                 }               
90         }
91
92         float alpha;
93         ShadowMode mode;
94 };
95
96 } /* end namespace */
97
98 #endif