diff options
author | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:57:03 +0900 |
---|---|---|
committer | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:57:03 +0900 |
commit | 35ffec694df3a47e02c943f246f0a5f374b951b7 (patch) | |
tree | 0480c5ed02b9e0e064162ca8a126be875d7cbc94 | |
parent | c8192a33ff31c2cd502c36e0cffdd99604d1af3d (diff) | |
download | TiltableImageViewer-35ffec694df3a47e02c943f246f0a5f374b951b7.tar.gz TiltableImageViewer-35ffec694df3a47e02c943f246f0a5f374b951b7.tar.bz2 TiltableImageViewer-35ffec694df3a47e02c943f246f0a5f374b951b7.zip |
Tizen 2.0 Releasesubmit/tizen_2.0/20130215.192310tizen_2.0
30 files changed, 1047 insertions, 0 deletions
@@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://www.tizenopensource.org/license + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Compatibility Definition Document +and passes the Compatibility Test Suite as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. + +You may add Your own attribution notices within Derivative Works +that You distribute, alongside or as an addendum to the NOTICE text +from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional or +different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works +as a whole, provided Your use, reproduction, and distribution of +the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.tizenopensource.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. + @@ -0,0 +1,4 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE file for Flora License terms and conditions. + diff --git a/description.xml b/description.xml new file mode 100644 index 0000000..0003df1 --- /dev/null +++ b/description.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<?xml-stylesheet type="text/xsl" href="../../../../description.xsl"?> + +<Overview version="0.17.1"> + <SampleName> TiltableImageViewer </SampleName> + <SampleVersion>1.0</SampleVersion> + <Preview>screenshot.png</Preview> + <Description>The TiltableImageViewer sample application demonstrates how you can use the tilt sensor to display a changing image on the device screen.</Description> +</Overview> diff --git a/project/data/nofile.dummy b/project/data/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/data/nofile.dummy diff --git a/project/home/nofile.dummy b/project/home/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/home/nofile.dummy diff --git a/project/inc/ImageForm.h b/project/inc/ImageForm.h new file mode 100644 index 0000000..1be5af7 --- /dev/null +++ b/project/inc/ImageForm.h @@ -0,0 +1,68 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.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 _IMAGE_FORM_H_ +#define _IMAGE_FORM_H_ + +#include <FBase.h> +#include <FUi.h> +#include <FMedia.h> +#include <FIo.h> +#include <FUix.h> +#include <FMedia.h> +#include <FApp.h> +#include <FSystem.h> + +class ImageForm + : public Tizen::Base::Runtime::ITimerEventListener + , public Tizen::Ui::Controls::Form + , public Tizen::Uix::Sensor::ISensorEventListener + , public Tizen::Ui::Controls::IFormBackEventListener +{ +public: + ImageForm(void); + virtual ~ImageForm(void); + + bool Initialize(void); + virtual result OnDraw(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnDataReceived(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData, result r); + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer & timer); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); +private: + result InitializeTimer(void); + void TerminateTimer(void); + void StartTimer(void); + void StopTimer(void); + + result GetFileList(Tizen::Base::String folder); + result AddElementInFileList(Tizen::Io::DirEntry &DirEntry, result r); + +private: + Tizen::Uix::Sensor::SensorManager __sensorMgr; + Tizen::Base::String __dirBase; + Tizen::Base::Collection::ArrayList __fileList; + Tizen::Media::Image* __pImage; + Tizen::Base::Runtime::Timer * __pTimer; + int __fileIndex; + int __numFileList; + int __btCount; + static const int INTERVAL_TIMER = 200; +}; + +#endif // _IMAGE_FORM_H_ diff --git a/project/inc/TiltableImageViewer.h b/project/inc/TiltableImageViewer.h new file mode 100644 index 0000000..f7ad1c9 --- /dev/null +++ b/project/inc/TiltableImageViewer.h @@ -0,0 +1,47 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.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 _TILTABLE_IMAGE_VIEWER_H_ +#define _TILTABLE_IMAGE_VIEWER_H_ + +#include <FApp.h> +#include <FSystem.h> + +class TiltableImageViewer + : public Tizen::App::Application + , public Tizen::System::IScreenEventListener +{ +public: + static Tizen::App::Application* CreateInstance(void); + + TiltableImageViewer(void); + virtual ~TiltableImageViewer(void); + + virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + virtual void OnForeground(void); + virtual void OnBackground(void); + virtual void OnLowMemory(void); + + // Called when the screen turns on. + virtual void OnScreenOn(void); + + // Called when the screen turns off. + virtual void OnScreenOff(void); +}; + +#endif // _TILTABLE_IMAGE_VIEWER_H_ diff --git a/project/inc/TiltableImageViewerFrame.h b/project/inc/TiltableImageViewerFrame.h new file mode 100644 index 0000000..7e67c8a --- /dev/null +++ b/project/inc/TiltableImageViewerFrame.h @@ -0,0 +1,19 @@ +#ifndef _TILTABLEIMAGEVIEWERFRAME_H_ +#define _TILTABLEIMAGEVIEWERFRAME_H_ + +#include <FBase.h> +#include <FUi.h> + +class TiltableImageViewerFrame + : public Tizen::Ui::Controls::Frame +{ +public: + TiltableImageViewerFrame(void); + virtual ~TiltableImageViewerFrame(void); + +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); +}; + +#endif //_TILTABLEIMAGEVIEWERFRAME_H_ diff --git a/project/manifest.xml b/project/manifest.xml new file mode 100755 index 0000000..738f4bb --- /dev/null +++ b/project/manifest.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest"> + <Id>$(manifestAppId)</Id> + <Version>1.0.0</Version> + <Type>C++App</Type> + <Author/> + <Descriptions/> + <Requirements/> + <Apps> + <ApiVersion >2.0</ApiVersion> + <Privileges/> + <UiApp Main="True" MenuIconVisible="True" Name="$(projectName)"> + <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="480"/> + <UiTheme SystemTheme="White"/> + <DisplayNames> + <DisplayName Locale="eng-GB">$(projectName)</DisplayName> + </DisplayNames> + <Icons> + <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon> + </Icons> + <AppControls/> + <LaunchConditions/> + <Notifications> + <Notification Name="Ticker">On</Notification> + <Notification Name="Sound">On</Notification> + <Notification Name="Contents">Off</Notification> + <Notification Name="Badge">On</Notification> + </Notifications> + </UiApp> + </Apps> +</Manifest> diff --git a/project/packaging/org.tizen.TiltableImageViewer.spec b/project/packaging/org.tizen.TiltableImageViewer.spec new file mode 100755 index 0000000..96b4bf6 --- /dev/null +++ b/project/packaging/org.tizen.TiltableImageViewer.spec @@ -0,0 +1,49 @@ +Name: org.tizen.TiltableImageViewer +Summary: TiltableImageViewer sample application +Version: 1.2.1.0 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(osp-uifw) +BuildRequires: pkgconfig(osp-image) +BuildRequires: pkgconfig(osp-media) +BuildRequires: pkgconfig(osp-net) +BuildRequires: osp-appfw-internal-devel + +%description +TiltableImageViewer sample application + +%prep +%setup -q + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%ifarch %{ix86} +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%else +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%endif + +# Call make instruction with smp support +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post -p /sbin/ldconfig +APP_ID=unm99y390y +echo "/usr/etc/package-manager/backend/oap -i /opt/apps/org.tizen."${APP_ID} +/usr/etc/package-manager/backend/oap -i /opt/apps/org.tizen.${APP_ID} + +%postun -p /sbin/ldconfig +APP_ID=unm99y390y +echo "/usr/etc/package-manager/backend/oap -u "${APP_ID} +/usr/etc/package-manager/backend/oap -u ${APP_ID} + +%files +%defattr(-,root,root,-) +/opt/apps/* diff --git a/project/res/0.jpg b/project/res/0.jpg Binary files differnew file mode 100644 index 0000000..790140f --- /dev/null +++ b/project/res/0.jpg diff --git a/project/res/1.jpg b/project/res/1.jpg Binary files differnew file mode 100644 index 0000000..dfe0b5e --- /dev/null +++ b/project/res/1.jpg diff --git a/project/res/2.jpg b/project/res/2.jpg Binary files differnew file mode 100644 index 0000000..97eaf53 --- /dev/null +++ b/project/res/2.jpg diff --git a/project/res/3.jpg b/project/res/3.jpg Binary files differnew file mode 100644 index 0000000..8744574 --- /dev/null +++ b/project/res/3.jpg diff --git a/project/res/4.jpg b/project/res/4.jpg Binary files differnew file mode 100644 index 0000000..42f7dc9 --- /dev/null +++ b/project/res/4.jpg diff --git a/project/res/5.jpg b/project/res/5.jpg Binary files differnew file mode 100644 index 0000000..cba22d7 --- /dev/null +++ b/project/res/5.jpg diff --git a/project/res/6.jpg b/project/res/6.jpg Binary files differnew file mode 100644 index 0000000..62cb284 --- /dev/null +++ b/project/res/6.jpg diff --git a/project/res/7.jpg b/project/res/7.jpg Binary files differnew file mode 100644 index 0000000..ea88117 --- /dev/null +++ b/project/res/7.jpg diff --git a/project/res/8.jpg b/project/res/8.jpg Binary files differnew file mode 100644 index 0000000..3b5959b --- /dev/null +++ b/project/res/8.jpg diff --git a/project/res/9.jpg b/project/res/9.jpg Binary files differnew file mode 100644 index 0000000..b398c77 --- /dev/null +++ b/project/res/9.jpg diff --git a/project/res/tilt.txt b/project/res/tilt.txt new file mode 100644 index 0000000..c2984f4 --- /dev/null +++ b/project/res/tilt.txt @@ -0,0 +1,37 @@ +100,10,125,30
+200,11,131,30
+300,12,132,30
+400,13,133,30
+800,14,134,30
+900,15,135,30
+1000,16,136,30
+1100,17,137,30
+1200,18,138,30
+1300,19,139,30
+1400,20,140,30
+1500,21,141,30
+1600,22,142,30
+1700,23,143,30
+1800,24,144,30
+1900,25,145,30
+2000,26,146,30
+2100,27,147,30
+2200,28,148,30
+2300,29,139,30
+2400,30,130,30
+2500,31,131,30
+2600,32,-132,30
+2700,33,-133,30
+2800,34,-134,30
+2900,35,-135,30
+3000,36,-136,30
+3100,37,-137,30
+3200,38,-138,30
+3300,41,-139,30
+3400,42,-130,30
+3500,43,-111,30
+3600,44,-122,30
+3700,45,-153,30
+3800,46,144,30
+3900,47,135,30
+4000,48,126,30
\ No newline at end of file diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/shared/data/nofile.dummy diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png Binary files differnew file mode 100755 index 0000000..983c883 --- /dev/null +++ b/project/shared/res/screen-density-xhigh/mainmenu.png diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/shared/trusted/nofile.dummy diff --git a/project/src/ImageForm.cpp b/project/src/ImageForm.cpp new file mode 100644 index 0000000..322ac95 --- /dev/null +++ b/project/src/ImageForm.cpp @@ -0,0 +1,341 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.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 <new> +#include "ImageForm.h" + +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Uix::Sensor; +using namespace Tizen::Io; +using namespace Tizen::Media; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::System; + +static const int THIRD_QUADRANT_MIN = -150; +static const int THIRD_QUADRANT_MAX = -120; + +static const int FOURTH_QUADRANT_MIN = -60; +static const int FOURTH_QUADRANT_MAX = -30; + +static const int IMAGE_COUNT = 10; + +static const wchar_t IMAGE_EXT[] = L"jpg"; + +ImageForm::ImageForm(void) + : __sensorMgr() + , __dirBase() + , __fileList() + , __pImage(null) + , __pTimer(null) + , __fileIndex(0) + , __numFileList(0) + , __btCount(0) +{ + __fileList.Construct(); +} + +ImageForm::~ImageForm(void) +{ + __fileList.RemoveAll(true); +} + +result +ImageForm::OnDraw(void) +{ + String* nextImageName = static_cast<String*>(__fileList.GetAt(__fileIndex)); + + Bitmap* pBmp = __pImage->DecodeN(*nextImageName, BITMAP_PIXEL_FORMAT_ARGB8888); + TryReturn(pBmp != null, E_OUT_OF_MEMORY, "DecodeN failed! [srcImagePath:%ls]", nextImageName->GetPointer()); + + Canvas* pCanvas = GetCanvasN(); + if (pCanvas == null) + { + AppLogException("Get canvas failed."); + delete pBmp; + pBmp = null; + + return E_OUT_OF_MEMORY; + } + + Rectangle rect = GetClientAreaBounds(); + int boundWidth = rect.width; + rect.width /= 2; + rect.x = (boundWidth - rect.width) / 2; + + pCanvas->DrawBitmap(rect, *pBmp); + + delete pBmp; + pBmp = null; + delete pCanvas; + pCanvas = null; + + StartTimer(); + + return E_SUCCESS; +} + +bool +ImageForm::Initialize(void) +{ + Form::Construct(FORM_STYLE_NORMAL|FORM_STYLE_FOOTER|FORM_STYLE_HEADER|FORM_STYLE_INDICATOR); + SetName(L"TiltableImageViewer"); + + // Set Header title + Header* pHeader = this->GetHeader(); + pHeader->SetTitleText(L"TILTABLE IMAGE VIEWER"); + + Footer* pFooter = this->GetFooter(); + pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT); + pFooter->SetBackButton(); + this->SetFormBackEventListener(this); + + return true; +} + +result +ImageForm::OnInitializing(void) +{ + SetOrientation(ORIENTATION_LANDSCAPE); + + SetBackgroundColor(Color::GetColor(COLOR_ID_WHITE)); + + __sensorMgr.Construct(); + + if(!__sensorMgr.IsAvailable(SENSOR_TYPE_TILT)) + { + AppLog("[Fail]TILT Sensor does not supported. This sample cannot be activated."); + + Application::GetInstance()->Terminate(); + + return E_FAILURE; + } + + result r = GetFileList(App::GetInstance()->GetAppRootPath() + String(L"res/")); + TryReturn(!IsFailed(r), r, "GetFileList failed! [result = %s]", GetErrorMessage(r)); + + r = InitializeTimer(); + TryReturn(!IsFailed(r), r, "Timer initialization failed"); + + __pImage = new (std::nothrow) Image(); + TryReturn(__pImage != null, E_OUT_OF_MEMORY, "Image creation failed"); + + __pImage->Construct(); + + long interval = 0; + + AppLog("Activating Tilt Sensor"); + __sensorMgr.GetMaxInterval(SENSOR_TYPE_TILT, interval); + + __sensorMgr.AddSensorListener(*this, SENSOR_TYPE_TILT, interval, false); + + StartTimer(); + + return r; +} + +result +ImageForm::OnTerminating(void) +{ + StopTimer(); + TerminateTimer(); + + if (__pImage != null) + { + delete __pImage; + __pImage = null; + } + + AppLog("Deactivating Tilt Sensor"); + __sensorMgr.RemoveSensorListener(*this); + + return E_SUCCESS; +} + +void +ImageForm::OnDataReceived(SensorType sensorType, SensorData& sensorData, result r) +{ + float pitch = 0.0F; + + sensorData.GetValue(static_cast<SensorDataKey>(TILT_DATA_KEY_PITCH), pitch); + //FIRST_QUADRANT : Quadrant I, MIN : Left boundary to get direction "left", MAX : Right boundary to get direction "left" + if (pitch >= THIRD_QUADRANT_MIN && pitch <= THIRD_QUADRANT_MAX) + { + __fileIndex--; + } + //FOURTH_QUADRANT : Quadrant IV, MIN : Left boundary to get direction "right", MAX : Right boundary to get direction "right" + else if (pitch >= FOURTH_QUADRANT_MIN && pitch <= FOURTH_QUADRANT_MAX) + { + __fileIndex++; + } + + AppLog("OnDataReceived: Get Tilt Sensor Data pitch[%f]", pitch); + + __fileIndex = (__fileIndex + __numFileList) % __numFileList; + __numFileList = __fileList.GetCount(); +} + + +/********************************************* + * Timer + *********************************************/ +result +ImageForm::InitializeTimer(void) +{ + __pTimer = new (std::nothrow) Timer(); + TryReturn(__pTimer != null, E_OUT_OF_MEMORY, "Timer creation failed"); + + __pTimer->Construct(*this); + + return E_SUCCESS; +} + +void +ImageForm::StartTimer(void) +{ + if (__pTimer != null) + { + __pTimer->Start(INTERVAL_TIMER); + } +} + +void +ImageForm::StopTimer(void) +{ + if (__pTimer != null) + { + __pTimer->Cancel(); + } +} + +void +ImageForm::TerminateTimer(void) +{ + if (__pTimer != null) + { + delete __pTimer; + __pTimer = null; + } +} + +void +ImageForm::OnTimerExpired(Timer & timer) +{ + this->RequestRedraw(true); +} + +result +ImageForm::GetFileList(String folder) +{ + result r = E_SUCCESS; + + __dirBase.Append(folder); + + String dirName(__dirBase); + Directory* pDir = new (std::nothrow) Directory(); + TryReturn(pDir != null, E_OUT_OF_MEMORY, "[Fail]Directory Create"); + + pDir->Construct(__dirBase); + + DirEnumerator* pDirEnum = pDir->ReadN(); + if (pDirEnum == null) + { + AppLog("IO Exception on Reading jpg image files"); + + delete pDir; + pDir = null; + return E_IO; + } + + while (pDirEnum->MoveNext() == E_SUCCESS) + { + DirEntry dirEntry = pDirEnum->GetCurrentDirEntry(); + AddElementInFileList(dirEntry, r); + } + + delete pDirEnum; + pDirEnum = null; + delete pDir; + pDir = null; + + TryReturn(__fileList.GetCount() == IMAGE_COUNT, E_IO, "Unexpected IO Exception"); + + String filename[IMAGE_COUNT]; + String* pTemp; + String subtemp; + int index = 0; + for (int i = 0; i < IMAGE_COUNT; i++) + { + pTemp = static_cast<String*>(__fileList.GetAt(i)); + pTemp->SubString(pTemp->GetLength() - 5, 1, subtemp); + Integer::Parse(subtemp, index); + filename[index] = *pTemp; + } + + __fileList.RemoveAll(true); + + for (int i = 0; i < IMAGE_COUNT; i++) + { + __fileList.Add(*(new (std::nothrow) String(filename[i]))); + } + + if (__fileList.GetCount() != IMAGE_COUNT) + { + __fileList.RemoveAll(true); + return E_IO; + } + + __numFileList = __fileList.GetCount(); + + return r; +} + +result +ImageForm::AddElementInFileList(DirEntry &DirEntry, result r) +{ + if (!DirEntry.IsDirectory()) + { + String ext(IMAGE_EXT); + String subStr; + String tempStr(__dirBase); + String fileName(DirEntry.GetName()); + + fileName.SubString(fileName.GetLength() - 3, 3, subStr); + if (subStr.Equals(ext, false)) + { + tempStr.Append(fileName); + + String* pNewString = new (std::nothrow) String(tempStr); + TryReturn(pNewString != null, E_OUT_OF_MEMORY, ""); + + __fileList.Add(*pNewString); + } + } + + return E_SUCCESS; +} + +void +ImageForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + UiApp* pApp = UiApp::GetInstance(); + AppAssert(pApp); + pApp->Terminate(); +} diff --git a/project/src/TiltableImageViewer.cpp b/project/src/TiltableImageViewer.cpp new file mode 100644 index 0000000..6894042 --- /dev/null +++ b/project/src/TiltableImageViewer.cpp @@ -0,0 +1,86 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.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 <new> +#include "TiltableImageViewer.h" +#include "TiltableImageViewerFrame.h" + +#include "ImageForm.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::System; + +TiltableImageViewer::TiltableImageViewer(void) +{ +} + +TiltableImageViewer::~TiltableImageViewer(void) +{ +} + +Application* +TiltableImageViewer::CreateInstance(void) +{ + return new (std::nothrow) TiltableImageViewer(); +} + +bool +TiltableImageViewer::OnAppInitializing(AppRegistry& appRegistry) +{ + TiltableImageViewerFrame* pTiltableImageViewerFrame = new TiltableImageViewerFrame(); + + pTiltableImageViewerFrame->Construct(); + pTiltableImageViewerFrame->SetName(L"TiltableImageViewer"); + AddFrame(*pTiltableImageViewerFrame); + + + + + return true; +} + +bool +TiltableImageViewer::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + return true; +} + +void +TiltableImageViewer::OnForeground(void) +{ +} + +void +TiltableImageViewer::OnBackground(void) +{ +} + +void +TiltableImageViewer::OnLowMemory(void) +{ +} + +void +TiltableImageViewer::OnScreenOn(void) +{ +} + +void +TiltableImageViewer::OnScreenOff(void) +{ +} diff --git a/project/src/TiltableImageViewerEntry.cpp b/project/src/TiltableImageViewerEntry.cpp new file mode 100644 index 0000000..b35be71 --- /dev/null +++ b/project/src/TiltableImageViewerEntry.cpp @@ -0,0 +1,61 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.tizenopensource.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. +// + +/** + * This file contains the Tizen application entry point. + */ + +#include <new> +#include "TiltableImageViewer.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +_EXPORT_ int OspMain(int argc, char *pArgv[]); + +/** + * The entry function of Tizen application called by the operating system. + */ +int +OspMain(int argc, char *pArgv[]) +{ + result r = E_SUCCESS; + + AppLog("Application started."); + ArrayList args; + args.Construct(); + for (int i = 0; i < argc; i++) + { + args.Add(*(new (std::nothrow) String(pArgv[i]))); + } + + r = Tizen::App::Application::Execute(TiltableImageViewer::CreateInstance, &args); + TryLog(r == E_SUCCESS, "[%s] Application execution failed", GetErrorMessage(r)); + + args.RemoveAll(true); + AppLog("Application finished."); + + return static_cast<int>(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/project/src/TiltableImageViewerFrame.cpp b/project/src/TiltableImageViewerFrame.cpp new file mode 100644 index 0000000..df80d9b --- /dev/null +++ b/project/src/TiltableImageViewerFrame.cpp @@ -0,0 +1,52 @@ +#include "TiltableImageViewerFrame.h" +#include "ImageForm.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +TiltableImageViewerFrame::TiltableImageViewerFrame(void) +{ +} + +TiltableImageViewerFrame::~TiltableImageViewerFrame(void) +{ +} + +result +TiltableImageViewerFrame::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Create a form + ImageForm *pImageForm = new (std::nothrow) ImageForm(); + pImageForm->Initialize(); + + // Add the form to the frame + AddControl(*pImageForm); + + // Set the current form + SetCurrentForm(*pImageForm); + + // Draw the form + pImageForm->Invalidate(true); + + // TODO: Add your initialization code here + + + + + return r; +} + +result +TiltableImageViewerFrame::OnTerminating(void) +{ + result r = E_SUCCESS; + + // TODO: Add your termination code here + + return r; +} + + diff --git a/sample.xml b/sample.xml new file mode 100644 index 0000000..3e4872a --- /dev/null +++ b/sample.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<template> + + <slp-property> + <property-group> + <sample-name>TiltableImageViewer</sample-name> + <category>Sample</category> + <sdk-version>1.00</sdk-version> + <project-type>org.tizen.nativecpp.buildArtefactType.app</project-type> + <sample-description>description.xml</sample-description> + </property-group> + </slp-property> + + <process type="org.tizen.nativeappcommon.TizenCopyFolder"> + <simple name="projectName" value="$(projectName)"/> + <simple name="folderPath" value="project"/> + <complex-array name="replaceableFiles"> + <element> + <simple name="sourcePath" value="manifest.xml"/> + <simple name="targetPath" value="manifest.xml"/> + <simple name="replaceable" value = "true"/> + </element> + </complex-array> + </process> + <process type="org.tizen.nativecpp.SetDefaultFrameworks"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="frameworkList"> + <element> + <simple name="framework" value="osp"/> + </element> + <element> + <simple name="framework" value="osp-compat"/> + </element> + </complex-array> + </process> + +</template> diff --git a/screenshot.png b/screenshot.png Binary files differnew file mode 100755 index 0000000..269977d --- /dev/null +++ b/screenshot.png |