Ardour  9.0-pre0-582-g084a23a80d
stateful_image.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2015 Paul Davis <paul@linuxaudiosystems.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __canvas_stateful_image_h__
20 #define __canvas_stateful_image_h__
21 
22 #include <string>
23 #include <vector>
24 #include <map>
25 
26 #include <cairomm/cairomm.h>
27 
28 #include "pbd/search_path.h"
29 
30 #include "canvas/item.h"
31 
32 class XMLNode;
33 
34 namespace Pango {
35  class FontDescription;
36 }
37 
38 namespace ArdourCanvas {
39 
40 class StatefulImage : public Item
41 {
42  private:
43  typedef Cairo::RefPtr<Cairo::ImageSurface> ImageHandle;
44 
45  class State {
46  public:
48  };
49 
50  typedef std::vector<State> States;
51 
52  public:
53 
57 
58  bool set_state (States::size_type);
59  void set_text (const std::string&);
60 
61  void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
62  void compute_bounding_box () const;
63 
64  static void set_image_search_path (const std::string&);
65 
66  private:
68  States::size_type _state;
69  std::string _text;
70  Pango::FontDescription* _font;
71  uint32_t _text_color;
72  double _text_x;
73  double _text_y;
74 
75  int load_states (const XMLNode&);
76 
77  typedef std::map<std::string,Cairo::RefPtr<Cairo::ImageSurface> > ImageCache;
80 
81  static ImageHandle find_image (const std::string&);
82 };
83 
84 }
85 
86 #endif /* __canvas_stateful_image_h__ */
void set_text(const std::string &)
void render(Rect const &area, Cairo::RefPtr< Cairo::Context >) const
static PBD::Searchpath _image_search_path
StatefulImage(Item *, const XMLNode &)
StatefulImage(Canvas *, const XMLNode &)
bool set_state(States::size_type)
States::size_type _state
std::vector< State > States
std::map< std::string, Cairo::RefPtr< Cairo::ImageSurface > > ImageCache
Cairo::RefPtr< Cairo::ImageSurface > ImageHandle
static void set_image_search_path(const std::string &)
void compute_bounding_box() const
int load_states(const XMLNode &)
static ImageHandle find_image(const std::string &)
Pango::FontDescription * _font
static ImageCache _image_cache
Definition: xml++.h:114