Ardour  9.0-pre0-582-g084a23a80d
ardour_spacer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2017-2019 Robin Gareus <robin@gareus.org>
4  * Copyright (C) 2018 Ben Loftis <ben@harrisonconsoles.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef _WIDGETS_ARDOUR_SPACER_H_
22 #define _WIDGETS_ARDOUR_SPACER_H_
23 
24 #include "gtkmm2ext/cairo_widget.h"
25 #include "gtkmm2ext/colors.h"
26 #include "widgets/ui_config.h"
27 
28 #include "widgets/visibility.h"
29 
30 namespace ArdourWidgets {
31 
33 {
34 public:
35  ArdourVSpacer (float r = 0.75f);
36 
37 protected:
38  void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*) {
39 
40  float height = get_height();
41 
42  float h = height * ratio;
43  float t = .5f * (height - h);
44  ctx->rectangle (0, t, 1, h);
45  uint32_t c = UIConfigurationBase::instance().color ("neutral:backgroundest");
47  ctx->fill ();
48  }
49 
51  req->width = 1;
52  req->height = 0;
54  }
55 
56  float ratio;
57 };
58 
60 {
61 public:
62  ArdourHSpacer (float r = 0.75f);
63 
64 protected:
65  void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*) {
66 
67  float width = get_width();
68 
69  float w = width * ratio;
70  float t = .5f * (width - w);
71  ctx->rectangle (t, 0, w, 1);
72  uint32_t c = UIConfigurationBase::instance().color ("neutral:backgroundest");
74  ctx->fill ();
75  }
76 
78  req->width = 0;
79  req->height = 1;
81  }
82 
83  float ratio;
84 };
85 
87 {
88 public:
89  enum ShadowMode {
92  };
93 
94  ArdourDropShadow (ShadowMode m = DropShadowLongSideOnly, float a = 0.55f);
95 
96  void set_mode(ShadowMode m) {mode = m;}
97 
98 protected:
99  void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*) {
100  float width = get_width();
101  float height = get_height();
102 
103  Cairo::RefPtr<Cairo::LinearGradient> _gradient;
104 
105  if ( (width>height) || mode == DropShadowBoth ) {
106  _gradient = Cairo::LinearGradient::create (0, 0, 0, 4);
107  _gradient->add_color_stop_rgba (0, 0, 0, 0, alpha);
108  _gradient->add_color_stop_rgba (1, 0, 0, 0, 0);
109  ctx->set_source (_gradient);
110  ctx->rectangle (0, 0, width, 4);
111  ctx->fill ();
112  }
113 
114  if ( (height>width) || mode == DropShadowBoth ) {
115  _gradient = Cairo::LinearGradient::create (0, 0, 4, 0);
116  _gradient->add_color_stop_rgba (0, 0, 0, 0, alpha);
117  _gradient->add_color_stop_rgba (1, 0, 0, 0, 0);
118  ctx->set_source (_gradient);
119  ctx->rectangle (0, 0, 4, height);
120  ctx->fill ();
121  }
122  }
123 
124  float alpha;
126 };
127 
128 } /* end namespace */
129 
130 #endif
void render(Cairo::RefPtr< Cairo::Context > const &ctx, cairo_rectangle_t *)
Definition: ardour_spacer.h:99
ArdourDropShadow(ShadowMode m=DropShadowLongSideOnly, float a=0.55f)
void on_size_request(Gtk::Requisition *req)
This is a default handler for the signal signal_size_request().
Definition: ardour_spacer.h:77
void render(Cairo::RefPtr< Cairo::Context > const &ctx, cairo_rectangle_t *)
Definition: ardour_spacer.h:65
void on_size_request(Gtk::Requisition *req)
This is a default handler for the signal signal_size_request().
Definition: ardour_spacer.h:50
void render(Cairo::RefPtr< Cairo::Context > const &ctx, cairo_rectangle_t *)
Definition: ardour_spacer.h:38
virtual Gtkmm2ext::Color color(const std::string &, bool *failed=0) const =0
virtual void on_size_request(Requisition *requisition)
This is a default handler for the signal signal_size_request().
void set_source_rgba(Cairo::RefPtr< Cairo::Context >, Gtkmm2ext::Color)
#define LIBWIDGETS_API
gint height
Definition: xcursors.h:1
gint width
Definition: xcursors.h:1