~sil2100/nux/precise_sru-1

« back to all changes in this revision

Viewing changes to examples/coverflow.cpp

  • Committer: Didier Roche
  • Date: 2012-02-17 10:28:35 UTC
  • mfrom: (159.3.34)
  • Revision ID: didier.roche@canonical.com-20120217102835-7fyqcabz0vad239t
New upstream release.

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) 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: Jason Smith <jason.smith@canonical.com>
 
18
 * Authored by: Jay Taoko <jay.taoko@canonical.com>
 
19
 */
 
20
 
 
21
const char* movie_list[] = {
 
22
"nux.png",
 
23
"nux.png",
 
24
"nux.png",
 
25
"nux.png",
 
26
"nux.png",
 
27
"nux.png",
 
28
"nux.png",
 
29
"nux.png",
 
30
"nux.png",
 
31
"nux.png",
 
32
"nux.png",
 
33
"nux.png",
 
34
"nux.png",
 
35
"nux.png",
 
36
"nux.png",
 
37
"nux.png",
 
38
"nux.png",
 
39
"nux.png",
 
40
"nux.png",
 
41
"nux.png",
 
42
"nux.png",
 
43
"nux.png",
 
44
"nux.png",
 
45
"nux.png",
 
46
"nux.png",
 
47
"nux.png",
 
48
"nux.png",
 
49
"nux.png",
 
50
"nux.png",
 
51
"nux.png",
 
52
"nux.png",
 
53
"nux.png",
 
54
"nux.png",
 
55
"nux.png",
 
56
"nux.png",
 
57
"nux.png",
 
58
"nux.png",
 
59
"nux.png",
 
60
"nux.png",
 
61
"nux.png",
 
62
"nux.png",
 
63
"nux.png",
 
64
"nux.png",
 
65
"nux.png",
 
66
"nux.png",
 
67
"nux.png",
 
68
"nux.png",
 
69
"nux.png",
 
70
"nux.png",
 
71
"nux.png",
 
72
"nux.png",
 
73
"nux.png",
 
74
0
 
75
};
 
76
 
 
77
#include "Nux/Nux.h"
 
78
#include "Nux/HLayout.h"
 
79
 
 
80
#include "NuxGraphics/GraphicsDisplay.h"
 
81
#include "NuxGraphics/GLShader.h"
 
82
#include "NuxGraphics/GpuDevice.h"
 
83
#include "NuxGraphics/GLDeviceObjects.h"
 
84
#include "NuxGraphics/GLShader.h"
 
85
#include "NuxGraphics/GraphicsEngine.h"
 
86
 
 
87
#include "Nux/Coverflow.h"
 
88
#include "Nux/CoverflowItem.h"
 
89
 
 
90
namespace nux
 
91
{
 
92
//class BaseTexture;
 
93
 
 
94
class BasicCoverflowItem : public CoverflowItem
 
95
{
 
96
public:
 
97
  BasicCoverflowItem(std::string const& name, std::string const& filename);
 
98
  ObjectPtr<BaseTexture> GetTexture() const;
 
99
 
 
100
private:
 
101
  ObjectPtr<BaseTexture> texture_;
 
102
};
 
103
 
 
104
BasicCoverflowItem::BasicCoverflowItem(std::string const& name,
 
105
                                       std::string const& filename)
 
106
: CoverflowItem(name)
 
107
{
 
108
  texture_.Adopt(LoadTextureFromFile(filename));
 
109
}
 
110
 
 
111
ObjectPtr<BaseTexture> BasicCoverflowItem::GetTexture() const
 
112
{
 
113
  return texture_;
 
114
}
 
115
 
 
116
}
 
117
 
 
118
void CoverflowThread(nux::NThread* thread, void* InitData)
 
119
{
 
120
  nux::Coverflow* coverflow = new nux::Coverflow();
 
121
  coverflow->fov = 45;
 
122
  coverflow->true_perspective = false;
 
123
  coverflow->folding_angle = 45;
 
124
  coverflow->reflection_size = 0.5f;
 
125
  coverflow->show_reflection = true;
 
126
  nux::HLayout* main_layout(new nux::HLayout(NUX_TRACKER_LOCATION));
 
127
  main_layout->AddView(coverflow, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
 
128
 
 
129
  static_cast<nux::WindowThread*>(thread)->SetLayout(main_layout);
 
130
 
 
131
  int i = 0;
 
132
  nux::CoverflowModel::Ptr model = coverflow->model();
 
133
  std::string base_path = PKGDATADIR"/UITextures/";
 
134
  while(movie_list[i] != NULL)
 
135
  {
 
136
    std::string name = "Nux The Movie";
 
137
    std::string movie_path = base_path + movie_list[i];
 
138
    nux::CoverflowItem::Ptr item(new nux::BasicCoverflowItem(name, movie_path));
 
139
    model->AddItem(item);
 
140
    i++;
 
141
  }
 
142
}
 
143
 
 
144
int main()
 
145
{
 
146
  nux::NuxInitialize(0);
 
147
 
 
148
  std::unique_ptr<nux::WindowThread> wt(nux::CreateGUIThread("CoverFlow", 1100, 480, 0, &CoverflowThread, 0));
 
149
  wt->Run(0);
 
150
 
 
151
  return 0;
 
152
}