Platform specific resource locations for dali demos 04/82204/8
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Mon, 1 Aug 2016 16:25:04 +0000 (17:25 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Thu, 18 Aug 2016 12:08:27 +0000 (13:08 +0100)
"res" directory houses resources like images, models and videos.

Change-Id: I7af9c4b1cf3aac06feb06113104c7f8fbc48867d

build/tizen/CMakeLists.txt
build/tizen/demo/CMakeLists.txt
build/tizen/examples/CMakeLists.txt
build/tizen/resources-location.in [new file with mode: 0644]
packaging/com.samsung.dali-demo.spec
resources/style/demo-theme.json.in
resources/style/style-example-theme-two.json.in

index 89df63b08c7c48ce34e4f10350144b33c49ff03f..d7bc88798ba807d569eddd0272475dc9789cbf00 100644 (file)
@@ -5,17 +5,22 @@ SET(dali-demo_VERSION_MAJOR 1)
 SET(dali-demo_VERSION_MINOR 0)
 
 SET(ROOT_SRC_DIR ${CMAKE_SOURCE_DIR}/../..)
+SET(DEMO_SHARED ${CMAKE_SOURCE_DIR}/../../shared)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
 IF(DEFINED DALI_APP_DIR)
-        SET(APP_DATA_DIR ${DALI_APP_DIR})
-        SET(BINDIR ${APP_DATA_DIR}/bin)
+        SET(BINDIR ${DALI_APP_DIR}/bin)
 ELSE()
-        SET(APP_DATA_DIR ${PREFIX}/share/com.samsung.dali-demo)
         SET(BINDIR ${PREFIX}/bin)
 ENDIF()
 
+IF(DEFINED DALI_APP_RES_DIR)
+        SET(APP_DATA_RES_DIR ${DALI_APP_RES_DIR})
+ELSE()
+        SET(APP_DATA_RES_DIR ${PREFIX}/share/com.samsung.dali-demo/res)
+ENDIF()
+
 MESSAGE( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )
 if(CMAKE_BUILD_TYPE MATCHES Debug)
     MESSAGE("Setting variable: DEBUG_ENABLED")
@@ -31,11 +36,11 @@ IF(NOT DEFINED LOCAL_STYLE_DIR)
         SET(LOCAL_STYLE_DIR ${RESOURCE_DIR}/style)
 ENDIF()
 
-SET(IMAGES_DIR ${APP_DATA_DIR}/images/)
-SET(VIDEOS_DIR ${APP_DATA_DIR}/videos/)
-SET(MODELS_DIR ${APP_DATA_DIR}/models/)
-SET(SCRIPTS_DIR ${APP_DATA_DIR}/scripts/)
-SET(STYLE_DIR ${APP_DATA_DIR}style/)
+SET(IMAGES_DIR ${APP_DATA_RES_DIR}/images/)
+SET(VIDEOS_DIR ${APP_DATA_RES_DIR}/videos/)
+SET(MODELS_DIR ${APP_DATA_RES_DIR}/models/)
+SET(SCRIPTS_DIR ${APP_DATA_RES_DIR}/scripts/)
+SET(STYLE_DIR ${APP_DATA_RES_DIR}/style/)
 
 IF(NOT DEFINED LOCALE_DIR)
         SET(LOCALE_DIR ${PREFIX}/share/locale)
@@ -83,6 +88,9 @@ FOREACH(flag ${LOCAL_SCRIPTS_LIST})
         INSTALL(FILES ${LOCAL_SCRIPTS_DIR}/${flag} DESTINATION ${SCRIPTS_DIR})
 ENDFOREACH(flag)
 
+#Create resources location file
+CONFIGURE_FILE( resources-location.in ${DEMO_SHARED}/resources-location.cpp )
+
 #Replace @DEMO_STYLE_IMAGE_DIR@ in following files
 CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/demo-theme.json.in ${LOCAL_STYLE_DIR}/demo-theme.json )
 CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-one.json.in ${LOCAL_STYLE_DIR}/style-example-theme-one.json )
index affd6209834a9bb3024a98f2a8b1593170bf2dcd..6aaf03255d1376908754e86a74ba97c9630ce7c8 100644 (file)
@@ -2,6 +2,12 @@ SET(DEMO_SRC_DIR ${ROOT_SRC_DIR}/demo)
 
 AUX_SOURCE_DIRECTORY(${DEMO_SRC_DIR} DEMO_SRCS)
 
+
+IF(NOT DEFINED DALI_APP_RES_DIR)
+  message([STATUS] "Setting application resource path from resource-location file")
+  SET( DEMO_SRCS ${DEMO_SRCS} "${ROOT_SRC_DIR}/shared/resources-location.cpp")
+ENDIF()
+
 ADD_EXECUTABLE(${PROJECT_NAME} ${DEMO_SRCS})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${REQUIRED_PKGS_LDFLAGS} -pie)
 
index 7fa03fe04528dcc5f2d77bae132d7414f4104959..cc1183ac8633a467c024533ca9be4fd056842fea 100644 (file)
@@ -15,6 +15,9 @@ SUBDIRLIST(SUBDIRS ${EXAMPLES_SRC_DIR})
 
 FOREACH(EXAMPLE ${SUBDIRS})
   FILE(GLOB SRCS "${EXAMPLES_SRC_DIR}/${EXAMPLE}/*.cpp")
+  IF(NOT DEFINED DALI_APP_RES_DIR)
+    SET( DEMO_SRCS ${DEMO_SRCS} "${ROOT_SRC_DIR}/shared/resources-location.cpp")
+  ENDIF()
   ADD_EXECUTABLE(${EXAMPLE}.example ${SRCS})
   TARGET_LINK_LIBRARIES(${EXAMPLE}.example ${REQUIRED_PKGS_LDFLAGS} -pie)
   INSTALL(TARGETS ${EXAMPLE}.example DESTINATION ${BINDIR})
diff --git a/build/tizen/resources-location.in b/build/tizen/resources-location.in
new file mode 100644 (file)
index 0000000..89b0b87
--- /dev/null
@@ -0,0 +1,8 @@
+/**
+ * This file defines the location dali-demo resources
+   It is used exclusively for Ubuntu builds where an application resource directory is explicity defined.
+ */
+
+#include <cstdlib>
+
+int dali_demo_RESOURCE_DIR = setenv("DALI_APPLICATION_PACKAGE",  "@APP_DATA_RES_DIR@" , 1);
index c138b83aa9a5086232e26e0bb1e6e597f56ce888..d0a49b258ea6c5e9bcd6772ae5028baff816e51a 100755 (executable)
@@ -53,8 +53,9 @@ of the capability of the toolkit.
 %define smack_rule_dir        %TZ_SYS_SMACK/accesses2.d/
 %endif
 
+%define dali_app_res_dir      %{dali_app_ro_dir}/res/
 %define dali_app_exe_dir      %{dali_app_ro_dir}/bin/
-%define locale_dir            %{dali_app_ro_dir}/res/locale
+%define locale_dir            %{dali_app_res_dir}/locale
 %define local_style_dir       ../../resources/style/mobile
 
 ##############################
@@ -73,6 +74,7 @@ cd %{_builddir}/%{name}-%{version}/build/tizen
 
 cmake -DDALI_APP_DIR=%{dali_app_ro_dir} \
       -DLOCALE_DIR=%{locale_dir} \
+      -DDALI_APP_RES_DIR=%{dali_app_res_dir} \
 %if 0%{?enable_debug}
       -DCMAKE_BUILD_TYPE=Debug \
 %endif
@@ -89,12 +91,13 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 cd build/tizen
 %make_install DALI_APP_DIR=%{dali_app_ro_dir}
+%make_install DDALI_APP_RES_DIR=%{dali_app_res_dir}
 
 mkdir -p %{buildroot}%{dali_xml_file_dir}
 cp -f %{_builddir}/%{name}-%{version}/%{name}.xml %{buildroot}%{dali_xml_file_dir}
 
 mkdir -p %{buildroot}%{dali_icon_dir}
-mv %{buildroot}/%{dali_app_ro_dir}/images/%{name}.png %{buildroot}%{dali_icon_dir}
+mv %{buildroot}/%{dali_app_res_dir}/images/%{name}.png %{buildroot}%{dali_icon_dir}
 
 %if 0%{?enable_dali_smack_rules} && !%{with wayland}
 mkdir -p %{buildroot}%{smack_rule_dir}
@@ -133,12 +136,12 @@ exit 0
 %{dali_app_exe_dir}/dali-demo
 %{dali_app_exe_dir}/*.example
 %{dali_app_exe_dir}/dali-builder
-%{dali_app_ro_dir}/images/*
-%{dali_app_ro_dir}/videos/*
-%{dali_app_ro_dir}/models/*
-%{dali_app_ro_dir}/scripts/*
-%{dali_app_ro_dir}/style/*
-%{dali_app_ro_dir}/style/images/*
+%{dali_app_res_dir}/images/*
+%{dali_app_res_dir}/videos/*
+%{dali_app_res_dir}/models/*
+%{dali_app_res_dir}/scripts/*
+%{dali_app_res_dir}/style/*
+%{dali_app_res_dir}/style/images/*
 %{dali_xml_file_dir}/%{name}.xml
 %{dali_icon_dir}/*
 %{locale_dir}/*
index 3e680ba404d61f74f7d14df36cbd34eaa40fd33e..21e0f2ef78b148caa127781a2fd01d48d03bce74 100644 (file)
  */
 
 {
-  "constants":
-  {
-    "DEMO_IMAGE_DIR":"@DEMO_STYLE_IMAGE_DIR@"
-  },
-
   "styles":
   {
     "confirmationpopup":{
-      "popupBackgroundImage":"{DEMO_IMAGE_DIR}00_popup_bg.9.png"
+      "popupBackgroundImage":"{APPLICATION_RESOURCE_PATH}/images/00_popup_bg.9.png"
     },
 
     "textlabel-Rosemary":
index 884d1ca171b0b5df4f37c2d3dc9192e58c8eb4ab..61c78a9b513b4342f226acd361dcbadfa86fc534 100644 (file)
@@ -1,7 +1,7 @@
 {
   "constants":
   {
-    "DEMO_IMAGE_DIR":"@DEMO_STYLE_IMAGE_DIR@"
+    "STYLE_DIR":"{APPLICATION_RESOURCE_PATH}/style"
   },
   "styles":
   {
@@ -25,9 +25,9 @@
 
     // Change an icon size, see if it gets properly re-sized
     "radiobutton":{
-      "unselectedStateImage":"{DEMO_IMAGE_DIR}/radio-button-unselected.png",
-      "selectedStateImage":"{DEMO_IMAGE_DIR}/radio-button-selected.png",
-      "disabledStateImage":"{DEMO_IMAGE_DIR}/radio-button-unselected-disabled.png",
+      "unselectedStateImage":"{STYLE_DIR}/images/radio-button-unselected.png",
+      "selectedStateImage":"{STYLE_DIR}/images/radio-button-selected.png",
+      "disabledStateImage":"{STYLE_DIR}/images/radio-button-unselected-disabled.png",
       "imageLabelGap":10,
       "label":{
         "textColor": [0.1,1,1,1]
     "colorSlider1":{
       "styles":["thinslider"],
       "progressVisual":{
-        "url":"{DEMO_IMAGE_DIR}/slider-skin-progress-red.9.png"
+        "url":"{STYLE_DIR}/images/slider-skin-progress-red.9.png"
       }
     },
     "colorSlider2":{
       "styles":["thinslider"],
       "progressVisual":{
-        "url":"{DEMO_IMAGE_DIR}/slider-skin-progress-green.9.png"
+        "url":"{STYLE_DIR}/images/slider-skin-progress-green.9.png"
       }
     },
     "colorSlider3":{
       "styles":["thinslider"],
       "progressVisual":{
-        "url":"{DEMO_IMAGE_DIR}/slider-skin-progress-blue.9.png"
+        "url":"{STYLE_DIR}/images/slider-skin-progress-blue.9.png"
       }
     }
   }