TizenRefApp-8219 [Gallery] Integrate rotatry support into thumbnail page 07/121307/2
authorIgor Nazarov <i.nazarov@samsung.com>
Mon, 27 Mar 2017 13:15:48 +0000 (16:15 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Tue, 28 Mar 2017 09:09:31 +0000 (12:09 +0300)
- Added presentation/helpers.h with Circle Surface functionality;
- Circle Surface functionality integretaed into Instance, ThumbnailPage
  and ImageGrid classes;
- Files from "main" folder moved to "presentation" folder except
  "main.cpp";
- UCL functionality extended.

Change-Id: I390c29e58b87f1642fc1b448f7ae8b9436b28519

25 files changed:
inc/main/Instance.h [deleted file]
inc/main/InstanceManager.h [deleted file]
inc/presentation/ImageGrid.h
inc/presentation/Instance.h [new file with mode: 0644]
inc/presentation/InstanceManager.h [new file with mode: 0644]
inc/presentation/ThumbnailPage.h
inc/presentation/types.h
src/main.cpp [new file with mode: 0644]
src/main/Instance.cpp [deleted file]
src/main/InstanceManager.cpp [deleted file]
src/main/main.cpp [deleted file]
src/presentation/ImageGrid.cpp
src/presentation/Instance.cpp [new file with mode: 0644]
src/presentation/InstanceManager.cpp [new file with mode: 0644]
src/presentation/Page.cpp
src/presentation/ThumbnailPage.cpp
src/presentation/common.h
src/presentation/helpers.cpp [new file with mode: 0644]
src/presentation/helpers.h [new file with mode: 0644]
ucl/inc/ucl/gui/ElmWidget.h
ucl/inc/ucl/gui/ElmWidget.hpp
ucl/inc/ucl/gui/Widget.h
ucl/inc/ucl/gui/Widget.hpp
ucl/inc/ucl/gui/types.h
ucl/src/gui/ElmWidget.cpp

diff --git a/inc/main/Instance.h b/inc/main/Instance.h
deleted file mode 100644 (file)
index 09e53ea..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MAIN_INSTANCE_H__
-#define __GALLERY_MAIN_INSTANCE_H__
-
-#include "types.h"
-
-#include "ucl/appfw/IInstance.h"
-#include "ucl/appfw/IInstanceAppControlExt.h"
-
-#include "ucl/gui/Theme.h"
-#include "ucl/gui/Naviframe.h"
-
-#include "model/types.h"
-#include "presentation/types.h"
-
-namespace gallery {
-
-       class Instance final :
-                       public ucl::IInstance,
-                       public ucl::IInstanceAppControlExt {
-       public:
-               Instance(ucl::SysEventProvider &sysEventProvider);
-               virtual ~Instance();
-
-               // IInstance //
-
-               virtual ucl::Result onCreate(
-                               ucl::IInstanceContext *context) final override;
-               virtual void onPause() final override;
-               virtual void onResume() final override;
-
-               // IInstanceAppControlExt //
-
-               virtual void onAppControl(app_control_h appControl) final override;
-
-       private:
-               ucl::Result setupTheme();
-
-               void rescanMediaContent();
-               void stopMediaContentScan();
-               void startMediaContentScan();
-               void onScanComplete(media_content_error_e error);
-
-               void onSysEvent(const ucl::SysEvent sysEvent);
-
-               void onPageExitRequest(Page &page);
-
-       private:
-               ucl::SysEventProvider &m_sysEventProvider;
-               ucl::IInstanceContext *m_context;
-
-               GallerySRef m_gallery;
-               bool m_isScanInProgress;
-
-               ucl::WindowSRef m_win;
-               ucl::Theme m_theme;
-               ucl::NaviframeSRef m_navi;
-
-               PageWRef m_page;
-       };
-}
-
-#endif // __GALLERY_MAIN_INSTANCE_H__
diff --git a/inc/main/InstanceManager.h b/inc/main/InstanceManager.h
deleted file mode 100644 (file)
index b9e98fd..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __GALLERY_MAIN_INSTANCE_MANAGER_H__
-#define __GALLERY_MAIN_INSTANCE_MANAGER_H__
-
-#include "types.h"
-
-#include "ucl/appfw/InstanceManagerBase.h"
-
-namespace gallery {
-
-       class InstanceManager : public ucl::InstanceManagerBase {
-       public:
-               InstanceManager();
-
-               // ucl::InstanceManagerBase //
-
-               virtual ucl::IInstanceSRef newInstance() const final override;
-       };
-}
-
-#endif // __GALLERY_MAIN_INSTANCE_MANAGER_H__
index 084d41022ee290f5f65636b34d980f38c7754ebb..88a44144a780f600031afb5737557831347e705b 100644 (file)
@@ -63,7 +63,10 @@ namespace gallery {
 
                ucl::Result updateItem(int itemIndex, const ItemParams &params);
 
-               ucl::Result isItemRealized(int itemIndex);
+               ucl::Result isItemRealized(int itemIndex) const;
+
+               void activateRotary();
+               void deactivateRotary();
 
        private:
                class Slot;
@@ -79,13 +82,14 @@ namespace gallery {
                static const Info &getInfo(Type type);
 
                template <class FUNC>
-               ucl::Result doWithItem(int itemIndex, FUNC &&func);
+               ucl::Result doWithItem(int itemIndex, FUNC &&func) const;
 
                void addUnrealizeLock();
                void removeUnrealizeLock();
 
                // Initialization
                void prepare();
+               void createCircleScroller();
 
                // Actual slots count
                bool updateSlotCount();
@@ -146,6 +150,7 @@ namespace gallery {
                ucl::ElmWidget m_box;
                ucl::Widget m_rect1;
                ucl::Widget m_rect2;
+               Evas_Object *m_circleScroller;
 
                IImageGridListener *m_listener;
                int m_itemCount;
diff --git a/inc/presentation/Instance.h b/inc/presentation/Instance.h
new file mode 100644 (file)
index 0000000..6c48c94
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_PRESENTATION_INSTANCE_H__
+#define __GALLERY_PRESENTATION_INSTANCE_H__
+
+#include "types.h"
+
+#include "ucl/appfw/IInstance.h"
+#include "ucl/appfw/IInstanceAppControlExt.h"
+
+#include "ucl/gui/Theme.h"
+#include "ucl/gui/Naviframe.h"
+
+#include "types.h"
+#include "model/types.h"
+
+namespace gallery {
+
+       class Instance final :
+                       public ucl::IInstance,
+                       public ucl::IInstanceAppControlExt {
+       public:
+               Instance(ucl::SysEventProvider &sysEventProvider);
+               virtual ~Instance();
+
+               // IInstance //
+
+               virtual ucl::Result onCreate(
+                               ucl::IInstanceContext *context) final override;
+               virtual void onPause() final override;
+               virtual void onResume() final override;
+
+               // IInstanceAppControlExt //
+
+               virtual void onAppControl(app_control_h appControl) final override;
+
+       private:
+               ucl::Result setupTheme();
+
+               void rescanMediaContent();
+               void stopMediaContentScan();
+               void startMediaContentScan();
+               void onScanComplete(media_content_error_e error);
+
+               void onSysEvent(const ucl::SysEvent sysEvent);
+
+               void onPageExitRequest(Page &page);
+
+       private:
+               ucl::SysEventProvider &m_sysEventProvider;
+               ucl::IInstanceContext *m_context;
+
+               GallerySRef m_gallery;
+               bool m_isScanInProgress;
+
+               ucl::WindowSRef m_win;
+               ucl::Theme m_theme;
+               ucl::NaviframeSRef m_navi;
+
+               PageWRef m_page;
+       };
+}
+
+#endif // __GALLERY_PRESENTATION_INSTANCE_H__
diff --git a/inc/presentation/InstanceManager.h b/inc/presentation/InstanceManager.h
new file mode 100644 (file)
index 0000000..9320544
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_PRESENTATION_INSTANCE_MANAGER_H__
+#define __GALLERY_PRESENTATION_INSTANCE_MANAGER_H__
+
+#include "types.h"
+
+#include "ucl/appfw/InstanceManagerBase.h"
+
+namespace gallery {
+
+       class InstanceManager : public ucl::InstanceManagerBase {
+       public:
+               InstanceManager();
+
+               // ucl::InstanceManagerBase //
+
+               virtual ucl::IInstanceSRef newInstance() const final override;
+       };
+}
+
+#endif // __GALLERY_PRESENTATION_INSTANCE_MANAGER_H__
index 00ab02a7d17829199cabf600d53d18f3ccd87133..8f39816f775d72a544ea4a57f2e816e990ba4114 100644 (file)
@@ -53,6 +53,11 @@ namespace gallery {
 
                bool onEachMedia(MediaItemUPtr media);
 
+               // Page //
+
+               virtual void onActivate() final override;
+               virtual void onDeactivate() final override;
+
                // IImageGridListener //
 
                virtual void onItemRealized(int itemIndex) final override;
index b8cf606c08f6098dafa5f691ecf74264debd2c43..fed835777d51270eef64a14a6cdfe6d918d8fb06 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __GALLERY_PRESENTATION_TYPES_H__
 #define __GALLERY_PRESENTATION_TYPES_H__
 
+#include <efl_extension.h>
+
 #include "../types.h"
 
 namespace gallery {
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644 (file)
index 0000000..526bf3d
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ucl/appfw/UIApp.h"
+
+#include "presentation/InstanceManager.h"
+
+#include "common.h"
+
+using namespace ucl;
+using namespace gallery;
+
+int main(int argc, char *argv[])
+{
+       InstanceManager mgr;
+       const int ret = UIApp(mgr).run(argc, argv);
+       ILOG("ret: %d", ret);
+       return ret;
+}
diff --git a/src/main/Instance.cpp b/src/main/Instance.cpp
deleted file mode 100644 (file)
index e2fc956..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "main/Instance.h"
-
-#include <system_settings.h>
-
-#include "ucl/appfw/SysEventProvider.h"
-#include "ucl/appfw/helpers.h"
-
-#include "model/Gallery.h"
-
-#include "presentation/ThumbnailPage.h"
-
-#include "resources.h"
-
-#include "../common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       // TODO Since feature is temporary using hard-coded path
-       constexpr auto MEDIA_FOLDER = "/opt/usr/home/owner/media";
-}}}
-
-namespace gallery {
-
-       using namespace ucl;
-
-       Instance::Instance(SysEventProvider &sysEventProvider) :
-               m_sysEventProvider(sysEventProvider),
-               m_isScanInProgress(false)
-       {
-       }
-
-       Instance::~Instance()
-       {
-               stopMediaContentScan();
-       }
-
-       Result Instance::onCreate(IInstanceContext *const context)
-       {
-               m_context = context;
-
-               m_gallery = Gallery::newInstance();
-               if (!m_gallery) {
-                       LOG_RETURN(RES_FAIL, "Gallery::newInstance() failed!");
-               }
-
-               m_win = m_context->getWindow();
-
-               FAIL_RETURN(setupTheme(), "setupTheme() failed!");
-
-               m_navi = Naviframe::Builder().
-                               build(m_win->getConformant());
-               if (!m_navi) {
-                       LOG_RETURN(RES_FAIL, "Naviframe::build() failed!");
-               }
-
-               m_win->getConformant().setContent(*m_navi);
-
-               m_sysEventProvider.addEventHandler(
-                               DELEGATE(Instance::onSysEvent, this));
-
-               return RES_OK;
-       }
-
-       Result Instance::setupTheme()
-       {
-               m_theme = Theme::create();
-               if (isNotValid(m_theme)) {
-                       LOG_RETURN(RES_FAIL, "Theme::create() failed!");
-               }
-
-               m_theme.addExtension(getResPath(THEME_EDJE_PATH));
-
-               m_win->setTheme(m_theme);
-
-               return RES_OK;
-       }
-
-       void Instance::onPause()
-       {
-               DLOG("PAUSE");
-       }
-
-       void Instance::onResume()
-       {
-               DLOG("RESUME");
-
-               if (SCAN_MEDIA_ON_RESUME) {
-                       rescanMediaContent();
-               }
-       }
-
-       void Instance::rescanMediaContent()
-       {
-               stopMediaContentScan();
-               startMediaContentScan();
-       }
-
-       void Instance::stopMediaContentScan()
-       {
-               if (m_isScanInProgress) {
-                       m_isScanInProgress = false;
-                       DLOG("Scan is in progress. Terminating...");
-                       const int ret = media_content_cancel_scan_folder(
-                                       impl::MEDIA_FOLDER);
-                       if (ret != 0) {
-                               WLOG("media_content_cancel_scan_folder() failed: %d", ret);
-                       }
-               }
-       }
-
-       void Instance::startMediaContentScan()
-       {
-               DLOG("Starting media scan...");
-
-               int ret = media_content_scan_folder(impl::MEDIA_FOLDER, true,
-                               CALLBACK_B(Instance::onScanComplete), this);
-               if (ret != 0) {
-                       ELOG("media_content_scan_folder() failed: %d", ret);
-                       return;
-               }
-
-               m_isScanInProgress = true;
-       }
-
-       void Instance::onScanComplete(media_content_error_e error)
-       {
-               DLOG("Media scan complete. error: %d", error);
-
-               m_isScanInProgress = false;
-
-               const auto thumbPage = dynamicRefCast<ThumbnailPage>(m_page);
-               if (thumbPage) {
-                       DLOG("Reloading the ThumbnailPage...");
-                       thumbPage->reload();
-               }
-       }
-
-       void Instance::onAppControl(app_control_h appControl)
-       {
-               DLOG("APP CONTROL");
-
-               if (!m_page) {
-                       DLOG("Creating ThumbnailPage.");
-                       m_page = ThumbnailPage::Builder().
-                                       setNaviframe(m_navi).
-                                       setAlbum(m_gallery->getAlbum()).
-                                       build(DELEGATE(Instance::onPageExitRequest, this));
-               }
-
-               if (!m_win->isVisible()) {
-                       DLOG("Show the window.");
-                       show(*m_win);
-               }
-       }
-
-       void Instance::onSysEvent(const SysEvent sysEvent)
-       {
-               switch(sysEvent) {
-               case SysEvent::LANGUAGE_CHANGED:
-                       DLOG("SysEvent::LANGUAGE_CHANGED");
-                       {
-                               char *locale = NULL;
-                               system_settings_get_value_string(
-                                               SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
-                               elm_language_set(locale);
-                               free(locale);
-                       }
-                       break;
-               default:
-                       DLOG("sysEvent: %d", sysEvent);
-                       break;
-               }
-       }
-
-       void Instance::onPageExitRequest(Page &page)
-       {
-               if (isLast(page)) {
-                       DLOG("Last page. Lowering the window.");
-                       m_win->lower();
-               } else {
-                       DLOG("Exit page.");
-                       page.exit();
-               }
-       }
-}
diff --git a/src/main/InstanceManager.cpp b/src/main/InstanceManager.cpp
deleted file mode 100644 (file)
index 1ede15e..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "main/InstanceManager.h"
-
-#include "main/Instance.h"
-
-namespace gallery {
-
-       using namespace ucl;
-
-       InstanceManager::InstanceManager() :
-               InstanceManagerBase(AppParams().
-                               set(AppParam::WINDOW_NAME, WINDOW_NAME).
-                               set(AppParam::BASE_SCALE, BASE_SCALE))
-       {
-       }
-
-       IInstanceSRef InstanceManager::newInstance() const
-       {
-               return makeShared<Instance>(getSysEventProvider());
-       }
-}
diff --git a/src/main/main.cpp b/src/main/main.cpp
deleted file mode 100644 (file)
index 8fb41e2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ucl/appfw/UIApp.h"
-
-#include "main/InstanceManager.h"
-
-#include "../common.h"
-
-using namespace ucl;
-using namespace gallery;
-
-int main(int argc, char *argv[])
-{
-       InstanceManager mgr;
-       const int ret = UIApp(mgr).run(argc, argv);
-       ILOG("ret: %d", ret);
-       return ret;
-}
index 7b7be9c29d4b4b02a5a760adbb18e3f2aa9b450d..70a41c408628d4f616cf743c78f0cf534e387054 100644 (file)
@@ -339,6 +339,7 @@ namespace gallery {
                m_box(elm_box_add(*m_scroller)),
                m_rect1(evas_object_rectangle_add(m_box.getEvas())),
                m_rect2(evas_object_rectangle_add(m_box.getEvas())),
+               m_circleScroller(nullptr),
 
                m_listener(nullptr),
                m_itemCount(0),
@@ -409,6 +410,8 @@ namespace gallery {
                }
                show(*m_scroller);
 
+               createCircleScroller();
+
                m_scroller->addEventHandler(WidgetEvent::RESIZE,
                                WEAK_DELEGATE(ImageGrid::onScrollerResize, asWeak(this)));
 
@@ -419,6 +422,23 @@ namespace gallery {
                                WEAK_DELEGATE(ImageGrid::onBoxMove, asWeak(this)));
        }
 
+       void ImageGrid::createCircleScroller()
+       {
+               const auto sfc = getCircleSurface(*m_scroller);
+               if (!sfc) {
+                       LOG_RETURN_VOID(RES_FAIL, "getCircleSurface() failed!");
+               }
+
+               m_circleScroller = eext_circle_object_scroller_add(*m_scroller, sfc);
+               if (!m_circleScroller) {
+                       LOG_RETURN_VOID(RES_FAIL,
+                                       "eext_circle_object_scroller_add() failed!");
+               }
+
+               eext_circle_object_scroller_policy_set(m_circleScroller,
+                               ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
+       }
+
        void ImageGrid::setListener(IImageGridListener *const listener)
        {
                m_listener = listener;
@@ -460,7 +480,7 @@ namespace gallery {
                        });
        }
 
-       Result ImageGrid::isItemRealized(const int itemIndex)
+       Result ImageGrid::isItemRealized(const int itemIndex) const
        {
                return doWithItem(itemIndex,
                        [](Slot &slot, const int itemOffset)
@@ -470,7 +490,7 @@ namespace gallery {
        }
 
        template <class FUNC>
-       Result ImageGrid::doWithItem(const int itemIndex, FUNC &&func)
+       Result ImageGrid::doWithItem(const int itemIndex, FUNC &&func) const
        {
                if ((itemIndex < 0) || (itemIndex >= m_itemCount)) {
                        LOG_RETURN(RES_INVALID_ARGUMENTS,
@@ -489,6 +509,16 @@ namespace gallery {
                return func(*m_slots[slotOffset], itemOffset);
        }
 
+       void ImageGrid::activateRotary()
+       {
+               eext_rotary_object_event_activated_set(m_circleScroller, EINA_TRUE);
+       }
+
+       void ImageGrid::deactivateRotary()
+       {
+               eext_rotary_object_event_activated_set(m_circleScroller, EINA_FALSE);
+       }
+
        void ImageGrid::addUnrealizeLock()
        {
                unrealizeSlots(0, m_slotCount);
diff --git a/src/presentation/Instance.cpp b/src/presentation/Instance.cpp
new file mode 100644 (file)
index 0000000..3586a76
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "presentation/Instance.h"
+
+#include <system_settings.h>
+
+#include "ucl/appfw/SysEventProvider.h"
+#include "ucl/appfw/helpers.h"
+
+#include "model/Gallery.h"
+
+#include "presentation/ThumbnailPage.h"
+
+#include "resources.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       // TODO Since feature is temporary using hard-coded path
+       constexpr auto MEDIA_FOLDER = "/opt/usr/home/owner/media";
+}}}
+
+namespace gallery {
+
+       using namespace ucl;
+
+       Instance::Instance(SysEventProvider &sysEventProvider) :
+               m_sysEventProvider(sysEventProvider),
+               m_isScanInProgress(false)
+       {
+       }
+
+       Instance::~Instance()
+       {
+               stopMediaContentScan();
+       }
+
+       Result Instance::onCreate(IInstanceContext *const context)
+       {
+               m_context = context;
+
+               m_gallery = Gallery::newInstance();
+               if (!m_gallery) {
+                       LOG_RETURN(RES_FAIL, "Gallery::newInstance() failed!");
+               }
+
+               m_win = m_context->getWindow();
+
+               FAIL_RETURN(setupTheme(), "setupTheme() failed!");
+
+               m_navi = Naviframe::Builder().
+                               build(m_win->getConformant());
+               if (!m_navi) {
+                       LOG_RETURN(RES_FAIL, "Naviframe::build() failed!");
+               }
+
+               m_win->getConformant().setContent(*m_navi);
+
+               FAIL_RETURN(createCircleSurface(*m_navi),
+                               "createCircleSurface() failed!");
+
+               m_sysEventProvider.addEventHandler(
+                               DELEGATE(Instance::onSysEvent, this));
+
+               return RES_OK;
+       }
+
+       Result Instance::setupTheme()
+       {
+               m_theme = Theme::create();
+               if (isNotValid(m_theme)) {
+                       LOG_RETURN(RES_FAIL, "Theme::create() failed!");
+               }
+
+               m_theme.addExtension(getResPath(THEME_EDJE_PATH));
+
+               m_win->setTheme(m_theme);
+
+               return RES_OK;
+       }
+
+       void Instance::onPause()
+       {
+               DLOG("PAUSE");
+       }
+
+       void Instance::onResume()
+       {
+               DLOG("RESUME");
+
+               if (SCAN_MEDIA_ON_RESUME) {
+                       rescanMediaContent();
+               }
+       }
+
+       void Instance::rescanMediaContent()
+       {
+               stopMediaContentScan();
+               startMediaContentScan();
+       }
+
+       void Instance::stopMediaContentScan()
+       {
+               if (m_isScanInProgress) {
+                       m_isScanInProgress = false;
+                       DLOG("Scan is in progress. Terminating...");
+                       const int ret = media_content_cancel_scan_folder(
+                                       impl::MEDIA_FOLDER);
+                       if (ret != 0) {
+                               WLOG("media_content_cancel_scan_folder() failed: %d", ret);
+                       }
+               }
+       }
+
+       void Instance::startMediaContentScan()
+       {
+               DLOG("Starting media scan...");
+
+               int ret = media_content_scan_folder(impl::MEDIA_FOLDER, true,
+                               CALLBACK_B(Instance::onScanComplete), this);
+               if (ret != 0) {
+                       ELOG("media_content_scan_folder() failed: %d", ret);
+                       return;
+               }
+
+               m_isScanInProgress = true;
+       }
+
+       void Instance::onScanComplete(media_content_error_e error)
+       {
+               DLOG("Media scan complete. error: %d", error);
+
+               m_isScanInProgress = false;
+
+               const auto thumbPage = dynamicRefCast<ThumbnailPage>(m_page);
+               if (thumbPage) {
+                       DLOG("Reloading the ThumbnailPage...");
+                       thumbPage->reload();
+               }
+       }
+
+       void Instance::onAppControl(app_control_h appControl)
+       {
+               DLOG("APP CONTROL");
+
+               if (!m_page) {
+                       DLOG("Creating ThumbnailPage.");
+                       m_page = ThumbnailPage::Builder().
+                                       setNaviframe(m_navi).
+                                       setAlbum(m_gallery->getAlbum()).
+                                       build(DELEGATE(Instance::onPageExitRequest, this));
+               }
+
+               if (!m_win->isVisible()) {
+                       DLOG("Show the window.");
+                       show(*m_win);
+               }
+       }
+
+       void Instance::onSysEvent(const SysEvent sysEvent)
+       {
+               switch(sysEvent) {
+               case SysEvent::LANGUAGE_CHANGED:
+                       DLOG("SysEvent::LANGUAGE_CHANGED");
+                       {
+                               char *locale = NULL;
+                               system_settings_get_value_string(
+                                               SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+                               elm_language_set(locale);
+                               free(locale);
+                       }
+                       break;
+               default:
+                       DLOG("sysEvent: %d", sysEvent);
+                       break;
+               }
+       }
+
+       void Instance::onPageExitRequest(Page &page)
+       {
+               if (isLast(page)) {
+                       DLOG("Last page. Lowering the window.");
+                       m_win->lower();
+               } else {
+                       DLOG("Exit page.");
+                       page.exit();
+               }
+       }
+}
diff --git a/src/presentation/InstanceManager.cpp b/src/presentation/InstanceManager.cpp
new file mode 100644 (file)
index 0000000..e0b3f2f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "presentation/InstanceManager.h"
+
+#include "presentation/Instance.h"
+
+namespace gallery {
+
+       using namespace ucl;
+
+       InstanceManager::InstanceManager() :
+               InstanceManagerBase(AppParams().
+                               set(AppParam::WINDOW_NAME, WINDOW_NAME).
+                               set(AppParam::BASE_SCALE, BASE_SCALE))
+       {
+       }
+
+       IInstanceSRef InstanceManager::newInstance() const
+       {
+               return makeShared<Instance>(getSysEventProvider());
+       }
+}
index 43f290e2938801f0f0de0ec025476d6c672b0988..0f4bf2d1a512ca784b29805fb21e3e4ae10dedc6 100644 (file)
@@ -16,8 +16,6 @@
 
 #include "presentation/Page.h"
 
-#include <efl_extension.h>
-
 #include "common.h"
 
 namespace gallery { namespace { namespace impl {
index 4d96a2c44a879ada9fb707ec05600e24953111dc..162cc60db2707199edfba9df5ce71ac81afca24d 100644 (file)
@@ -170,6 +170,16 @@ namespace gallery {
                return true;
        }
 
+       void ThumbnailPage::onActivate()
+       {
+               m_imageGrid->activateRotary();
+       }
+
+       void ThumbnailPage::onDeactivate()
+       {
+               m_imageGrid->deactivateRotary();
+       }
+
        void ThumbnailPage::onItemRealized(const int itemIndex)
        {
                m_realizedItems.emplace_back(new RealizedItem(*this, itemIndex));
index 63664e17b53cb3d4e6e4c3c3b1a62c830733ef45..ec0a4883a01626b3433782ed16f8613f4ed2ee35 100644 (file)
@@ -19,4 +19,6 @@
 
 #include "../common.h"
 
+#include "helpers.h"
+
 #endif // __GALLERY_PRESENTATION_COMMON_H__
diff --git a/src/presentation/helpers.cpp b/src/presentation/helpers.cpp
new file mode 100644 (file)
index 0000000..3bf55ce
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "helpers.h"
+
+#include "ucl/gui/Window.h"
+#include "ucl/gui/Naviframe.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       using namespace ucl;
+
+       constexpr EoDataKey CIRCLE_SURFACE {"gallery,eext,circle,surface"};
+}}}
+
+namespace gallery {
+
+       using namespace ucl;
+
+       Result createCircleSurface(Naviframe &navi)
+       {
+               const auto win = navi.getWindow();
+               if (!win) {
+                       LOG_RETURN(RES_FAIL, "Failed to get Window from Naviframe!");
+               }
+
+               if (win->getData(impl::CIRCLE_SURFACE)) {
+                       LOG_RETURN(RES_ILLEGAL_STATE, "Circle Surface data already set!");
+               }
+
+               const auto sfc = eext_circle_surface_naviframe_add(navi);
+               if (!sfc) {
+                       LOG_RETURN(RES_FAIL,
+                                       "eext_circle_surface_conformant_add() failed!");
+               }
+
+               win->setData(impl::CIRCLE_SURFACE, sfc);
+
+               return RES_OK;
+       }
+
+       Eext_Circle_Surface *getCircleSurface(const ElmWidget &widget)
+       {
+               const auto win = widget.getWindow();
+               if (!win) {
+                       LOG_RETURN_VALUE(RES_FAIL, nullptr,
+                                       "Failed to get Window from widget!");
+               }
+
+               const auto sfc = static_cast<Eext_Circle_Surface *>(
+                               win->getData(impl::CIRCLE_SURFACE));
+               if (!sfc) {
+                       LOG_RETURN_VALUE(RES_FAIL, nullptr,
+                                       "Failed to get Eext_Circle_Surface from window!");
+               }
+
+               return sfc;
+       }
+}
+
diff --git a/src/presentation/helpers.h b/src/presentation/helpers.h
new file mode 100644 (file)
index 0000000..fa3d195
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_PRESENTATION_HELPERS_H__
+#define __GALLERY_PRESENTATION_HELPERS_H__
+
+#include "presentation/types.h"
+
+namespace ucl {
+
+       class ElmWidget;
+       class Naviframe;
+}
+
+namespace gallery {
+
+       ucl::Result createCircleSurface(ucl::Naviframe &navi);
+
+       Eext_Circle_Surface *getCircleSurface(const ucl::ElmWidget &widget);
+}
+
+#endif // __GALLERY_PRESENTATION_HELPERS_H__
index 6e27717d0fa7c9ca5347c88bda3792fa6328838e..91825d6cf579be4c268369e84e0ea8ff97c3ef2d 100644 (file)
@@ -21,6 +21,8 @@
 
 namespace ucl {
 
+       class Window;
+
        UCL_DECLARE_REF_ALIASES(ElmWidget);
 
        class ElmWidget : public Widget {
@@ -34,6 +36,9 @@ namespace ucl {
                void setTheme(Elm_Theme *th);
                Elm_Theme *getTheme();
 
+               Evas_Object *getTopWidget() const;
+               Window *getWindow() const;
+
        protected:
                virtual void setFocusedImpl(bool value) final override;
                virtual bool isFocusedImpl() const final override;
index 8a68dd1957627fbeee2b9a22368af803d8b2d17d..482367379f37f1f259f63e8aa0ddd0a84bed7041 100644 (file)
@@ -36,6 +36,11 @@ namespace ucl {
                return elm_object_theme_get(getEo());
        }
 
+       inline Evas_Object *ElmWidget::getTopWidget() const
+       {
+               return elm_object_top_widget_get(getEo());
+       }
+
        // Non-member functions //
 
        inline void enable(ElmWidget &widget)
index 3e6afa5784fde33d062c40daff509d7a11e452ca..27ef0e671875bdef53c8b27d96c9d8a79fabc052 100644 (file)
@@ -49,6 +49,10 @@ namespace ucl {
 
                Evas *getEvas() const;
 
+               void setData(EoDataKey key, void *data);
+               void delData(EoDataKey key);
+               void *getData(EoDataKey key) const;
+
                void addEventHandler(WidgetEvent event, WidgetEventHandler handler);
                void addEventHandler(SmartEvent event, WidgetEventHandler handler);
 
index 996558a667e32d5b140716890c6d11352f3748e5..1e4a648e8a84b501e0c59aa4a352134d7b7a5a8a 100644 (file)
@@ -59,6 +59,21 @@ namespace ucl {
                return evas_object_evas_get(getEo());
        }
 
+       inline void Widget::setData(const EoDataKey key, void *const data)
+       {
+               evas_object_data_set(getEo(), key.name, data);
+       }
+
+       inline void Widget::delData(const EoDataKey key)
+       {
+               evas_object_data_del(getEo(), key.name);
+       }
+
+       inline void *Widget::getData(const EoDataKey key) const
+       {
+               return evas_object_data_get(getEo(), key.name);
+       }
+
        inline void Widget::callSmartEvent(SmartEvent event, void *eventInfo)
        {
                evas_object_smart_callback_call(getEo(), event, eventInfo);
index bb6badba16904a00896e6989aff02827d3e53079..ed7d03f9f61f9fbf17c363b984bb1c16c516644c 100644 (file)
@@ -43,6 +43,8 @@ namespace ucl {
 
        struct SmartEvent : Aspect<SmartEvent> { using Aspect::Aspect; };
 
+       struct EoDataKey : Aspect<EoDataKey> { using Aspect::Aspect; };
+
        // WidgetEventHandler //
 
        class Widget;
index 9b0e49b1ea60f98c84cb28e335f216df7d6c7eea..cf99eb7c7f835b5ac30d248668ca62b856134ce5 100644 (file)
@@ -16,6 +16,9 @@
 
 #include "ucl/gui/ElmWidget.h"
 
+#include "ucl/gui/Window.h"
+#include "ucl/gui/helpers.h"
+
 namespace ucl {
 
        void ElmWidget::setFocusedImpl(const bool value)
@@ -27,4 +30,9 @@ namespace ucl {
        {
                return elm_object_focus_get(getEo());
        }
+
+       Window *ElmWidget::getWindow() const
+       {
+               return dynamicCast<Window>(getTopWidget());
+       }
 }