Back to index

unity  6.0.0
StandaloneDash.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License version 3, as published
00006  * by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * version 3 along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>
00016  *
00017  * Authored by: Gordon Allott <gord.allott@canonical.com>
00018  *              Neil Jagdish Patel <neil.patel@canonical.com>
00019  *
00020  */
00021 #include <gtk/gtk.h>
00022 
00023 #include "Nux/Nux.h"
00024 #include "Nux/VLayout.h"
00025 #include "Nux/WindowThread.h"
00026 #include "NuxGraphics/GraphicsEngine.h"
00027 #include <NuxCore/Logger.h>
00028 
00029 #include "unity-shared/BGHash.h"
00030 #include "unity-shared/FontSettings.h"
00031 #include "DashView.h"
00032 #include "unity-shared/UnitySettings.h"
00033 #include "unity-shared/DashStyle.h"
00034 
00035 #define WIDTH 1024
00036 #define HEIGHT 768
00037 
00038 using namespace unity::dash;
00039 
00040 class TestRunner
00041 {
00042 public:
00043   TestRunner ();
00044   ~TestRunner ();
00045 
00046   static void InitWindowThread (nux::NThread* thread, void* InitData);
00047   void Init ();
00048   nux::Layout *layout;
00049 };
00050 
00051 TestRunner::TestRunner ()
00052 {
00053 }
00054 
00055 TestRunner::~TestRunner ()
00056 {
00057 }
00058 
00059 void TestRunner::Init ()
00060 {
00061   layout = new nux::HLayout(NUX_TRACKER_LOCATION);
00062 
00063   DashView* view = new DashView();
00064   view->DisableBlur();
00065   view->SetMinMaxSize(WIDTH, HEIGHT);
00066   layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);
00067   layout->SetMinMaxSize(WIDTH, HEIGHT);
00068 
00069   view->AboutToShow();
00070 
00071   nux::GetWindowThread()->SetLayout (layout);
00072 }
00073 
00074 void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
00075 {
00076   TestRunner *self =  (TestRunner *) InitData;
00077   self->Init ();
00078 }
00079 
00080 int main(int argc, char **argv)
00081 {
00082   nux::WindowThread* wt = NULL;
00083 
00084   gtk_init (&argc, &argv);
00085 
00086   unity::BGHash bghash;
00087   unity::FontSettings font_settings;
00088 
00089   nux::NuxInitialize(0);
00090   nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));
00091   // The instances for the pseudo-singletons.
00092   unity::Settings settings;
00093   unity::dash::Style dash_style;
00094 
00095   TestRunner *test_runner = new TestRunner ();
00096   wt = nux::CreateGUIThread(TEXT("Unity Dash"),
00097                             WIDTH, HEIGHT,
00098                             0,
00099                             &TestRunner::InitWindowThread,
00100                             test_runner);
00101 
00102   wt->Run (NULL);
00103   delete wt;
00104   return 0;
00105 }