~thalexander/unity/update-fsf-address

702.3.1 by Michael Terry
add modelines and fix up some inconsistent tabbings
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
604.4.1 by Mirco Müller
inital commit, doesn't compile atm, still missing much
2
/*
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
3
 * Copyright (C) 2010-2012 Canonical Ltd
604.4.1 by Mirco Müller
inital commit, doesn't compile atm, still missing much
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>
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
18
 *              Marco Trevisan <marco.trevisan@canonical.com>
604.4.1 by Mirco Müller
inital commit, doesn't compile atm, still missing much
19
 */
20
2350.2.4 by Gord Allott
shortcuts and unityshell working woo
21
#include "unity-shared/CairoTexture.h"
1187 by Tim Penhey
Revert the _align changes that were merged by mistake.
22
#include "QuicklistMenuItemRadio.h"
23
1885.4.35 by Marco Trevisan (Treviño)
Quicklist: adding quicklists to unity namespace
24
namespace unity
25
{
1468.2.4 by Tim Penhey
Damn namespaces.
26
2547.2.11 by Marco Trevisan (Treviño)
QuicklistMenuItem: always use glib::Object<DbusmenuMenuitem>
27
QuicklistMenuItemRadio::QuicklistMenuItemRadio(glib::Object<DbusmenuMenuitem> const& item, NUX_FILE_LINE_DECL)
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
28
  : QuicklistMenuItem(QuicklistMenuItemType::RADIO, item, NUX_FILE_LINE_PARAM)
29
{
30
  InitializeText();
31
}
32
33
std::string QuicklistMenuItemRadio::GetDefaultText() const
604.4.1 by Mirco Müller
inital commit, doesn't compile atm, still missing much
34
{
1739.5.6 by Marco Trevisan (Treviño)
QuicklistMenuItem*: removed some code duplication and better text initialization
35
  return "Radio Button";
604.4.1 by Mirco Müller
inital commit, doesn't compile atm, still missing much
36
}
37
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
38
std::string QuicklistMenuItemRadio::GetName() const
39
{
40
  return "QuicklistMenuItemRadio";
41
}
42
3680.1.37 by Marco Trevisan (Treviño)
QuicklistMenuItem: add support to scale factor when generating items textures
43
void QuicklistMenuItemRadio::UpdateTexture(nux::CairoGraphics& cairoGraphics, double width, double height)
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
44
{
3680.1.37 by Marco Trevisan (Treviño)
QuicklistMenuItem: add support to scale factor when generating items textures
45
  cairo_t* cr = cairoGraphics.GetInternalContext();
613.3.3 by Mirco Müller
implemented rendering for the radio-button-ql-menuitems, fixed some mem-leaks
46
47
  // draw normal, disabled version
1307 by Neil Jagdish Patel
Update formatting to match style (as close as possible)
48
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
49
  cairo_paint(cr);
50
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
51
  DrawText(cairoGraphics, width, height, nux::color::White);
52
53
  _normalTexture[0].Adopt(texture_from_cairo_graphics(cairoGraphics));
613.3.3 by Mirco Müller
implemented rendering for the radio-button-ql-menuitems, fixed some mem-leaks
54
55
  // draw normal, enabled version
1307 by Neil Jagdish Patel
Update formatting to match style (as close as possible)
56
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
57
  cairo_paint(cr);
58
59
  cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
60
  cairo_scale(cr, 1.0f, 1.0f);
61
  cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
62
  cairo_set_line_width(cr, 1.0f);
63
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
64
  double x = Align((ITEM_INDENT_ABS + ITEM_MARGIN) / 2.0f);
65
  double y = Align(static_cast<double>(height) / 2.0f);
613.3.3 by Mirco Müller
implemented rendering for the radio-button-ql-menuitems, fixed some mem-leaks
66
  double radius = 3.5f;
67
1307 by Neil Jagdish Patel
Update formatting to match style (as close as possible)
68
  cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
69
  cairo_arc(cr, x, y, radius, 0.0f * (G_PI / 180.0f), 360.0f * (G_PI / 180.0f));
70
  cairo_fill(cr);
71
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
72
  DrawText(cairoGraphics, width, height, nux::color::White);
73
74
  _normalTexture[1].Adopt(texture_from_cairo_graphics(cairoGraphics));
75
76
  // draw active/prelight, unchecked version
77
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
78
  cairo_paint(cr);
79
80
  DrawPrelight(cairoGraphics, width, height, nux::color::White);
81
  DrawText(cairoGraphics, width, height, nux::color::White * 0.0f);
82
83
  _prelightTexture[0].Adopt(texture_from_cairo_graphics(cairoGraphics));
84
85
  // draw active/prelight, unchecked version
86
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
87
  cairo_paint(cr);
88
89
  DrawPrelight(cairoGraphics, width, height, nux::color::White);
1307 by Neil Jagdish Patel
Update formatting to match style (as close as possible)
90
91
  cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
92
93
  cairo_arc(cr, x, y, radius, 0.0f * (G_PI / 180.0f), 360.0f * (G_PI / 180.0f));
94
  cairo_fill(cr);
95
2547.2.1 by Marco Trevisan (Treviño)
QuicklistMenuItem: remove debug bits, factorize duplicated code, remove friendship, use smart pointers
96
  DrawText(cairoGraphics, width, height, nux::color::White * 0.0f);
97
98
  _prelightTexture[1].Adopt(texture_from_cairo_graphics(cairoGraphics));
726.3.3 by Jason Smith
Make as many animations work as logically possible
99
}
1489.1.5 by Andrea Azzarone
C++ files should end with an extra line.
100
1885.4.35 by Marco Trevisan (Treviño)
Quicklist: adding quicklists to unity namespace
101
} // NAMESPACE