Back to index

nux  3.0.0
coverflow.cpp
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2012 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Jason Smith <jason.smith@canonical.com>
00018  * Authored by: Jay Taoko <jay.taoko@canonical.com>
00019  */
00020 
00021 const char* movie_list[] = {
00022 "nux.png",
00023 "nux.png",
00024 "nux.png",
00025 "nux.png",
00026 "nux.png",
00027 "nux.png",
00028 "nux.png",
00029 "nux.png",
00030 "nux.png",
00031 "nux.png",
00032 "nux.png",
00033 "nux.png",
00034 "nux.png",
00035 "nux.png",
00036 "nux.png",
00037 "nux.png",
00038 "nux.png",
00039 "nux.png",
00040 "nux.png",
00041 "nux.png",
00042 "nux.png",
00043 "nux.png",
00044 "nux.png",
00045 "nux.png",
00046 "nux.png",
00047 "nux.png",
00048 "nux.png",
00049 "nux.png",
00050 "nux.png",
00051 "nux.png",
00052 "nux.png",
00053 "nux.png",
00054 "nux.png",
00055 "nux.png",
00056 "nux.png",
00057 "nux.png",
00058 "nux.png",
00059 "nux.png",
00060 "nux.png",
00061 "nux.png",
00062 "nux.png",
00063 "nux.png",
00064 "nux.png",
00065 "nux.png",
00066 "nux.png",
00067 "nux.png",
00068 "nux.png",
00069 "nux.png",
00070 "nux.png",
00071 "nux.png",
00072 "nux.png",
00073 "nux.png",
00074 0
00075 };
00076 
00077 #include "Nux/Nux.h"
00078 #include "Nux/HLayout.h"
00079 
00080 #include "NuxGraphics/GraphicsDisplay.h"
00081 #include "NuxGraphics/GLShader.h"
00082 #include "NuxGraphics/GpuDevice.h"
00083 #include "NuxGraphics/GLDeviceObjects.h"
00084 #include "NuxGraphics/GLShader.h"
00085 #include "NuxGraphics/GraphicsEngine.h"
00086 
00087 #include "Nux/Coverflow.h"
00088 #include "Nux/CoverflowItem.h"
00089 
00090 namespace nux
00091 {
00092 //class BaseTexture;
00093 
00094 class BasicCoverflowItem : public CoverflowItem
00095 {
00096 public:
00097   BasicCoverflowItem(std::string const& name, std::string const& filename);
00098   ObjectPtr<BaseTexture> GetTexture() const;
00099 
00100 private:
00101   ObjectPtr<BaseTexture> texture_;
00102 };
00103 
00104 BasicCoverflowItem::BasicCoverflowItem(std::string const& name,
00105                                        std::string const& filename)
00106 : CoverflowItem(name)
00107 {
00108   texture_.Adopt(LoadTextureFromFile(filename));
00109 }
00110 
00111 ObjectPtr<BaseTexture> BasicCoverflowItem::GetTexture() const
00112 {
00113   return texture_;
00114 }
00115 
00116 }
00117 
00118 void CoverflowThread(nux::NThread* thread, void* InitData)
00119 {
00120   nux::Coverflow* coverflow = new nux::Coverflow();
00121   coverflow->fov = 45;
00122   coverflow->true_perspective = false;
00123   coverflow->folding_angle = 45;
00124   coverflow->reflection_size = 0.5f;
00125   coverflow->show_reflection = true;
00126   nux::HLayout* main_layout(new nux::HLayout(NUX_TRACKER_LOCATION));
00127   main_layout->AddView(coverflow, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
00128 
00129   static_cast<nux::WindowThread*>(thread)->SetLayout(main_layout);
00130 
00131   int i = 0;
00132   nux::CoverflowModel::Ptr model = coverflow->model();
00133   std::string base_path = PKGDATADIR"/UITextures/";
00134   while(movie_list[i] != NULL)
00135   {
00136     std::string name = "Nux The Movie";
00137     std::string movie_path = base_path + movie_list[i];
00138     nux::CoverflowItem::Ptr item(new nux::BasicCoverflowItem(name, movie_path));
00139     model->AddItem(item);
00140     i++;
00141   }
00142 }
00143 
00144 int main()
00145 {
00146   nux::NuxInitialize(0);
00147 
00148   std::unique_ptr<nux::WindowThread> wt(nux::CreateGUIThread("CoverFlow", 1100, 480, 0, &CoverflowThread, 0));
00149   wt->Run(0);
00150 
00151   return 0;
00152 }