~unity-team/unity/trunk

3566.5.120 by Marco Trevisan (Treviño)
DecorationsDataPool: add new singleton-based class for handling shared textures
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
/*
3
 * Copyright (C) 2013 Canonical Ltd
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 3 as
7
 * published by the Free Software Foundation.
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, see <http://www.gnu.org/licenses/>.
16
 *
17
 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18
 */
19
20
#ifndef UNITY_DECORATIONS_DATA_POOL
21
#define UNITY_DECORATIONS_DATA_POOL
22
3680.1.78 by Marco Trevisan (Treviño)
DecorationsDataPool: use gdk pixbuf + cairo to load the window buttons, and scale them up to match monitor settings
23
#include <unordered_map>
3566.5.120 by Marco Trevisan (Treviño)
DecorationsDataPool: add new singleton-based class for handling shared textures
24
#include "DecorationStyle.h"
25
#include "DecorationsEdge.h"
26
27
namespace unity
28
{
29
namespace decoration
30
{
31
3566.5.189 by Marco Trevisan (Treviño)
DecorationsDataPool: reload buttons textures when theme changed
32
class DataPool : public sigc::trackable
3566.5.120 by Marco Trevisan (Treviño)
DecorationsDataPool: add new singleton-based class for handling shared textures
33
{
34
public:
35
  typedef std::shared_ptr<DataPool> Ptr;
36
37
  static DataPool::Ptr const& Get();
3748.8.1 by Marco Trevisan (Treviño)
DecorationsDataPool: add static Reset method that allows to reset our textures
38
  static void Reset();
3566.5.122 by Marco Trevisan (Treviño)
DecorationsDataPool: add shared Edge cursors, so we don't need to recreate them multiple-times
39
  virtual ~DataPool();
3566.5.120 by Marco Trevisan (Treviño)
DecorationsDataPool: add new singleton-based class for handling shared textures
40
3566.5.122 by Marco Trevisan (Treviño)
DecorationsDataPool: add shared Edge cursors, so we don't need to recreate them multiple-times
41
  Cursor EdgeCursor(Edge::Type) const;
3566.5.221 by Marco Trevisan (Treviño)
DecorationsDataPool: load the glow texture on startup and use it in UnityWindow
42
  cu::SimpleTexture::Ptr const& GlowTexture() const;
3566.5.122 by Marco Trevisan (Treviño)
DecorationsDataPool: add shared Edge cursors, so we don't need to recreate them multiple-times
43
  cu::SimpleTexture::Ptr const& ButtonTexture(WindowButtonType, WidgetState) const;
3680.1.78 by Marco Trevisan (Treviño)
DecorationsDataPool: use gdk pixbuf + cairo to load the window buttons, and scale them up to match monitor settings
44
  cu::SimpleTexture::Ptr const& ButtonTexture(double scale, WindowButtonType, WidgetState) const;
3566.5.120 by Marco Trevisan (Treviño)
DecorationsDataPool: add new singleton-based class for handling shared textures
45
46
private:
47
  DataPool();
48
  DataPool(DataPool const&) = delete;
49
  DataPool& operator=(DataPool const&) = delete;
50
3566.5.122 by Marco Trevisan (Treviño)
DecorationsDataPool: add shared Edge cursors, so we don't need to recreate them multiple-times
51
  void SetupCursors();
3566.5.221 by Marco Trevisan (Treviño)
DecorationsDataPool: load the glow texture on startup and use it in UnityWindow
52
  void SetupTextures();
3566.5.120 by Marco Trevisan (Treviño)
DecorationsDataPool: add new singleton-based class for handling shared textures
53
3566.5.122 by Marco Trevisan (Treviño)
DecorationsDataPool: add shared Edge cursors, so we don't need to recreate them multiple-times
54
  std::array<Cursor, size_t(Edge::Type::Size)> edge_cursors_;
3566.5.221 by Marco Trevisan (Treviño)
DecorationsDataPool: load the glow texture on startup and use it in UnityWindow
55
  cu::SimpleTexture::Ptr glow_texture_;
3680.1.78 by Marco Trevisan (Treviño)
DecorationsDataPool: use gdk pixbuf + cairo to load the window buttons, and scale them up to match monitor settings
56
57
  typedef std::array<std::array<cu::SimpleTexture::Ptr, size_t(WidgetState::Size)>, size_t(WindowButtonType::Size)> WindowButtonsArray;
58
  WindowButtonsArray window_buttons_;
59
  std::unordered_map<double, WindowButtonsArray> scaled_window_buttons_;
3566.5.120 by Marco Trevisan (Treviño)
DecorationsDataPool: add new singleton-based class for handling shared textures
60
};
61
62
} // decoration namespace
63
} // unity namespace
64
65
#endif // UNITY_DECORATIONS_DATA_POOL