Ardour  8.12
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 "canvas/item.h"
29 
30 class XMLNode;
31 
32 namespace Pango {
33  class FontDescription;
34 }
35 
36 namespace ArdourCanvas {
37 
38 class StatefulImage : public Item
39 {
40  private:
41  typedef Cairo::RefPtr<Cairo::ImageSurface> ImageHandle;
42 
43  class State {
44  public:
46  };
47 
48  typedef std::vector<State> States;
49 
50  public:
51 
55 
56  bool set_state (States::size_type);
57  void set_text (const std::string&);
58 
59  void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
60  void compute_bounding_box () const;
61 
62  static void set_image_search_path (const std::string&);
63 
64  private:
66  States::size_type _state;
67  std::string _text;
68  Pango::FontDescription* _font;
69  uint32_t _text_color;
70  double _text_x;
71  double _text_y;
72 
73  int load_states (const XMLNode&);
74 
75  typedef std::map<std::string,Cairo::RefPtr<Cairo::ImageSurface> > ImageCache;
78 
79  static ImageHandle find_image (const std::string&);
80 };
81 
82 }
83 
84 #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