2
* Copyright (C) 2010 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Gord Allott <gord.allott@canonical.com>
21
#include "NuxCore/Logger.h"
24
nux::logging::Logger logger("unity.hud.icon");
32
Icon::Icon(nux::BaseTexture* texture, guint width, guint height)
33
: unity::IconTexture(texture, width, height)
36
icon_renderer_.SetTargetSize(54, 46, 0);
39
Icon::Icon(const char* icon_name, unsigned int size, bool defer_icon_loading)
40
: unity::IconTexture(icon_name, size, defer_icon_loading)
53
background_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_back_54.png", -1, true));
54
gloss_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_shine_54.png", -1, true));
55
edge_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_edge_54.png", -1, true));
57
texture_updated.connect([&] (nux::BaseTexture* texture)
59
icon_texture_source_ = new HudIconTextureSource(nux::ObjectPtr<nux::BaseTexture>(texture));
60
icon_texture_source_->ColorForIcon(_pixbuf_cached);
62
LOG_DEBUG(logger) << "got our texture";
66
void Icon::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
68
if (texture() == nullptr)
71
unity::ui::RenderArg arg;
72
arg.icon = icon_texture_source_.GetPointer();
73
arg.colorify = nux::color::White;
74
arg.running_arrow = true;
75
arg.running_on_viewport = true;
76
arg.render_center = nux::Point3(32, 32, 0);
77
arg.logical_center = nux::Point3(52, 50, 0);
78
arg.window_indicators = true;
79
arg.backlight_intensity = 1.0f;
82
std::list<unity::ui::RenderArg> args;
86
auto toplevel = GetToplevel();
87
icon_renderer_.SetTargetSize(54, 46, 0);
88
icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry());
89
icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry());