~3v1n0/unity/light-shortcuts

« back to all changes in this revision

Viewing changes to launcher/QuicklistMenuItemLabel.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2013-04-26 12:41:09 UTC
  • Revision ID: mail@3v1n0.net-20130426124109-t3b2shjah2omiqa2
Unity: Remove all the views, but the Shortcuts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
 
/*
3
 
 * Copyright (C) 2010-2012 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: Mirco Müller <mirco.mueller@canonical.com>
18
 
 *              Jay Taoko <jay.taoko@canonical.com>
19
 
 *              Marco Trevisan <marco.trevisan@canonical.com>
20
 
 */
21
 
 
22
 
#include "unity-shared/CairoTexture.h"
23
 
#include "QuicklistMenuItemLabel.h"
24
 
 
25
 
namespace unity
26
 
{
27
 
 
28
 
QuicklistMenuItemLabel::QuicklistMenuItemLabel(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_DECL)
29
 
  : QuicklistMenuItem(QuicklistMenuItemType::LABEL, item, NUX_FILE_LINE_PARAM)
30
 
{
31
 
  InitializeText();
32
 
}
33
 
 
34
 
std::string QuicklistMenuItemLabel::GetDefaultText() const
35
 
{
36
 
  return "Label";
37
 
}
38
 
 
39
 
std::string QuicklistMenuItemLabel::GetName() const
40
 
{
41
 
  return "QuicklistMenuItemLabel";
42
 
}
43
 
 
44
 
void QuicklistMenuItemLabel::UpdateTexture()
45
 
{
46
 
  int width = GetBaseWidth();
47
 
  int height = GetBaseHeight();
48
 
 
49
 
  nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, width, height);
50
 
  std::shared_ptr<cairo_t> cairo_context(cairoGraphics.GetContext(), cairo_destroy);
51
 
  cairo_t* cr = cairo_context.get();
52
 
 
53
 
  // draw normal, unchecked version
54
 
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
55
 
  cairo_paint(cr);
56
 
 
57
 
  DrawText(cairoGraphics, width, height, nux::color::White);
58
 
 
59
 
  _normalTexture[0].Adopt(texture_from_cairo_graphics(cairoGraphics));
60
 
 
61
 
  // draw active/prelight, unchecked version
62
 
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
63
 
  cairo_paint(cr);
64
 
 
65
 
  DrawPrelight(cairoGraphics, width, height, nux::color::White);
66
 
  DrawText(cairoGraphics, width, height, nux::color::White * 0.0f);
67
 
 
68
 
  _prelightTexture[0].Adopt(texture_from_cairo_graphics(cairoGraphics));
69
 
}
70
 
 
71
 
} // NAMESPACE