Merge lp:~nux-team/nuxplayground/jhodapp into lp:nuxplayground

Proposed by Jim Hodapp
Status: Merged
Merged at revision: 12
Proposed branch: lp:~nux-team/nuxplayground/jhodapp
Merge into: lp:nuxplayground
Diff against target: 165 lines (+122/-0)
5 files modified
README (+2/-0)
configure.ac (+1/-0)
src/Makefile.am (+1/-0)
src/helloworld/Makefile.am (+33/-0)
src/helloworld/helloworld.cpp (+85/-0)
To merge this branch: bzr merge lp:~nux-team/nuxplayground/jhodapp
Reviewer Review Type Date Requested Status
Jay Taoko Approve
Review via email: mp+111409@code.launchpad.net

Description of the change

Added a more verbose note to the README that explains why it's imperative to do a make install before running the demos.

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) wrote :

+1

review: Approve
lp:~nux-team/nuxplayground/jhodapp updated
14. By Jim Hodapp

Added a very simple hello world demo with heavily commented code.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2012-05-30 15:58:11 +0000
3+++ README 2012-06-21 19:27:22 +0000
4@@ -7,6 +7,8 @@
5
6 Then go into the src/'demo' directories and run the executable. You may also find all the demos in the bin/ directory where you installed nuxplayground.
7
8+NOTE: Some demos will not work unless they are installed to $prefix. In particular, coverflow will segfault because it won't be able to find the cover textures to load.
9+
10 nuxplayground requires the Nux library to be installed on your system. In case you built and installed a local version of Nux and you want to use it with nuxplayground then you need to set PKG_CONFIG_PATH before you do autogen.sh in nuxplayground.
11
12 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/path/to/the/pkgconfig/files/of/your/local/nux/install
13
14=== modified file 'configure.ac'
15--- configure.ac 2012-06-20 00:26:23 +0000
16+++ configure.ac 2012-06-21 19:27:22 +0000
17@@ -203,6 +203,7 @@
18 src/coverflow/Makefile
19 src/fbo-test/Makefile
20 src/gstreamer-test-src/Makefile
21+ src/helloworld/Makefile
22 src/radio-button/Makefile
23 src/shader-lighting/Makefile
24 src/shader-test-src/Makefile
25
26=== modified file 'src/Makefile.am'
27--- src/Makefile.am 2012-06-20 00:26:23 +0000
28+++ src/Makefile.am 2012-06-21 19:27:22 +0000
29@@ -8,6 +8,7 @@
30 coverflow \
31 fbo-test \
32 gstreamer-test-src \
33+ helloworld \
34 radio-button \
35 shader-lighting \
36 shader-test-src \
37
38=== added directory 'src/helloworld'
39=== added file 'src/helloworld/Makefile.am'
40--- src/helloworld/Makefile.am 1970-01-01 00:00:00 +0000
41+++ src/helloworld/Makefile.am 2012-06-21 19:27:22 +0000
42@@ -0,0 +1,33 @@
43+CLEANFILES =
44+DISTCLEANFILES =
45+EXTRA_DIST =
46+
47+
48+# This tells automake that we want to build binaries, but they shouldn't be
49+# installed. For each individual example, add it's binary name here
50+
51+bin_PROGRAMS = helloworld
52+
53+
54+# We only have to do this AM_ once to affect all the binaries we build from
55+# this Makefile
56+AM_CPPFLAGS = \
57+ -I$(srcdir) \
58+ -I$(top_srcdir) \
59+ -DPREFIX=\""$(prefix)"\" \
60+ -DLIBDIR=\""$(libdir)"\" \
61+ -DDATADIR=\""$(datadir)"\" \
62+ -DPKGDATADIR=\""$(pkgdatadir)/@NUX_SAMPLES_PACKAGE_VERSION@"\" \
63+ -DG_LOG_DOMAIN=\"NuxSamples\" \
64+ $(GCC_FLAGS) \
65+ $(NUX_SAMPLES_CFLAGS) \
66+ $(MAINTAINER_CFLAGS) \
67+ -I../common
68+
69+
70+# This is the individual executable build. For every $exe in noinst_PROGRAMS
71+# you need a $exe_SOURCES and $exe_LDADD so it builds
72+
73+
74+helloworld_SOURCES = helloworld.cpp
75+helloworld_LDADD = $(NUX_SAMPLES_LIBS)
76
77=== added file 'src/helloworld/helloworld.cpp'
78--- src/helloworld/helloworld.cpp 1970-01-01 00:00:00 +0000
79+++ src/helloworld/helloworld.cpp 2012-06-21 19:27:22 +0000
80@@ -0,0 +1,85 @@
81+/*
82+ * Copyright 2012 Canonical, Ltd.
83+ *
84+ * This program is free software: you can redistribute it and/or modify it
85+ * under the terms of the GNU General Public License version 3, as published
86+ * by the Free Software Foundation.
87+ *
88+ * This program is distributed in the hope that it will be useful, but
89+ * WITHOUT ANY WARRANTY; without even the implied warranties of
90+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
91+ * PURPOSE. See the GNU General Public License for more details.
92+ *
93+ * You should have received a copy of the GNU General Public License
94+ * version 3 along with this program. If not, see
95+ * <http://www.gnu.org/licenses/>
96+ *
97+ * Authored by: Jim Hodapp <jim.hodapp@canonical.com>
98+ *
99+ */
100+
101+#include <memory>
102+
103+#include <Nux/Nux.h>
104+#include <Nux/HLayout.h>
105+#include <Nux/VLayout.h>
106+#include <Nux/WindowThread.h>
107+#include <Nux/StaticText.h>
108+
109+nux::Layout* GetTextLayout()
110+{
111+ // Create a horizontal layout element
112+ nux::VLayout *layout = new nux::VLayout(NUX_TRACKER_LOCATION);
113+
114+ // Create a new StaticText object and set its text
115+ nux::StaticText *text = new nux::StaticText("Hello World!", NUX_TRACKER_LOCATION);
116+ {
117+ // Set some common properties on the text object
118+ text->SetFontSize(40);
119+ text->SetTextAlignment(nux::StaticText::ALIGN_CENTER);
120+ // White text
121+ text->SetTextColor(nux::Color(0xFFFFFFFF));
122+ // Add the text to the layout
123+ layout->AddView(text, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
124+ layout->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
125+ layout->SetScaleFactor(1);
126+ }
127+
128+ return layout;
129+}
130+
131+void UserInterfaceInitialization(nux::NThread* thread, void* init_data)
132+{
133+ // Create a horizontal layout element
134+ nux::HLayout *hlayout = new nux::HLayout();
135+
136+ // Get the text layout which holds the StaticText object and add it to the horizontal layout
137+ hlayout->AddLayout(GetTextLayout(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
138+
139+ // Add the layout to the window
140+ nux::GetWindowThread()->SetLayout(hlayout);
141+
142+ // Set the background color of the window to be black
143+ nux::ColorLayer background(nux::Color(0x0), false);
144+ static_cast<nux::WindowThread*>(thread)->SetWindowBackgroundPaintLayer(&background);
145+}
146+
147+int main(int argc, char **argv)
148+{
149+ // Initialize Nux subsystem
150+ nux::NuxInitialize(0);
151+
152+ // Create a Window thread
153+ std::unique_ptr<nux::WindowThread> wt(nux::CreateGUIThread(
154+ "Hello World",
155+ 500,
156+ 300,
157+ 0,
158+ &UserInterfaceInitialization,
159+ 0));
160+
161+ // Start the main loop
162+ wt->Run();
163+
164+ return 0;
165+}

Subscribers

People subscribed via source and target branches

to all changes: