diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:12:41 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:12:41 +0900 |
commit | 9688d4ec8a49265cb7cf60dab4fced71e684ecd0 (patch) | |
tree | 1a4d65e0b1894a0e1f378312d69bd14afeb32005 | |
parent | c51b79566a4595a663f8fd86cf971e26d9db792a (diff) | |
download | UiFrameMode-9688d4ec8a49265cb7cf60dab4fced71e684ecd0.tar.gz UiFrameMode-9688d4ec8a49265cb7cf60dab4fced71e684ecd0.tar.bz2 UiFrameMode-9688d4ec8a49265cb7cf60dab4fced71e684ecd0.zip |
Tizen 2.1 base
-rw-r--r-- | LICENSE.Flora | 206 | ||||
-rw-r--r-- | NOTICE | 4 | ||||
-rw-r--r-- | description.xml | 11 | ||||
-rw-r--r-- | project/data/nofile.dummy | 0 | ||||
-rw-r--r-- | project/inc/UiFrameMode.h | 71 | ||||
-rw-r--r-- | project/inc/UiFrameModeForm.h | 63 | ||||
-rw-r--r-- | project/inc/UiFrameModeFrame.h | 39 | ||||
-rw-r--r-- | project/manifest.xml | 21 | ||||
-rw-r--r-- | project/res/nofile.dummy | 0 | ||||
-rw-r--r-- | project/shared/data/nofile.dummy | 0 | ||||
-rwxr-xr-x | project/shared/res/screen-density-xhigh/mainmenu.png | bin | 0 -> 17581 bytes | |||
-rw-r--r-- | project/shared/trusted/nofile.dummy | 0 | ||||
-rw-r--r-- | project/src/UiFrameMode.cpp | 154 | ||||
-rw-r--r-- | project/src/UiFrameModeEntry.cpp | 65 | ||||
-rw-r--r-- | project/src/UiFrameModeForm.cpp | 374 | ||||
-rw-r--r-- | project/src/UiFrameModeFrame.cpp | 75 | ||||
-rw-r--r-- | sample.xml | 34 | ||||
-rw-r--r-- | screenshot.png | bin | 0 -> 11512 bytes |
18 files changed, 1117 insertions, 0 deletions
diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100644 index 0000000..9c95663 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://floralicense.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://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. + @@ -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..ca27cdd --- /dev/null +++ b/description.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<?xml-stylesheet type="text/xsl" href="../../../../description.xsl"?> + +<Overview version="0.17.1"> + <SampleName> UiFrameMode </SampleName> + <SampleVersion>1.0</SampleVersion> + <Preview>screenshot.png</Preview> + <Description> +The UiFrameMode sample application demonstrates how you can move and resize a frame which is in floating mode. + </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/inc/UiFrameMode.h b/project/inc/UiFrameMode.h new file mode 100644 index 0000000..ea5403b --- /dev/null +++ b/project/inc/UiFrameMode.h @@ -0,0 +1,71 @@ +// +// 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://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 _UI_FRAME_MODE_H_ +#define _UI_FRAME_MODE_H_ + +#include <FApp.h> +#include <FBase.h> +#include <FSystem.h> +#include <FUi.h> + +/** + * [UiFrameMode] UiApp must inherit from UiApp class + * which provides basic features necessary to define an UiApp. + */ +class UiFrameMode + : public Tizen::App::UiApp + , public Tizen::System::IScreenEventListener +{ +public: + UiFrameMode(void); + virtual ~UiFrameMode(void); + + static Tizen::App::UiApp* CreateInstance(void); + + // Called when the UiApp is initializing. + bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + + // Called when the UiApp initializing is finished. + bool OnAppInitialized(void); + + // Called when the UiApp is requested to terminate. + bool OnAppWillTerminate(void); + + // Called when the UiApp is terminating. + bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + + // Called when the UiApp's frame moves to the top of the screen. + void OnForeground(void); + + // Called when this UiApp's frame is moved from top of the screen to the background. + void OnBackground(void); + + // Called when the system memory is not sufficient to run the UiApp any further. + void OnLowMemory(void); + + // Called when the battery level changes. + void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); + + // Called when the screen turns on. + void OnScreenOn(void); + + // Called when the screen turns off. + void OnScreenOff(void); +}; // UiFrameMode + +#endif // _UI_FRAME_MODE_H_
\ No newline at end of file diff --git a/project/inc/UiFrameModeForm.h b/project/inc/UiFrameModeForm.h new file mode 100644 index 0000000..4574ba1 --- /dev/null +++ b/project/inc/UiFrameModeForm.h @@ -0,0 +1,63 @@ +// +// 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://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 _UI_FRAME_MODE_FORM_H_ +#define _UI_FRAME_MODE_FORM_H_ + +#include <FBase.h> +#include <FUi.h> + +class LabelTouchEventListener; + +class UiFrameModeForm + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::IOrientationEventListener + , public Tizen::Ui::Controls::IFormBackEventListener +{ +public: + UiFrameModeForm(void); + virtual ~UiFrameModeForm(void); + + bool Initialize(void); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + virtual void OnOrientationChanged(const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus); + + void UpdateInfo(bool move = false); + +private: + void Minimize(void); + void Restore(void); + void SetHeader(void); + void UpdateFrameBounds(void); + +private: + Tizen::Ui::Controls::Panel* __pPanel; + Tizen::Ui::Controls::Label* __pLabelMode; + Tizen::Ui::Controls::Label* __pLabelPos; + Tizen::Ui::Controls::Label* __pLabelSize; + Tizen::Ui::Controls::Label* __pLabelMoveFrame; + Tizen::Ui::Controls::Button* __pButton; + + LabelTouchEventListener* __pLabelTouchListener; +}; // UiFrameModeForm + +#endif // _UI_FRAME_MODE_FORM_H_ diff --git a/project/inc/UiFrameModeFrame.h b/project/inc/UiFrameModeFrame.h new file mode 100644 index 0000000..0dcba98 --- /dev/null +++ b/project/inc/UiFrameModeFrame.h @@ -0,0 +1,39 @@ +// +// 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://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 _UI_FRAME_MODE_FRAME_H_ +#define _UI_FRAME_MODE_FRAME_H_ + +#include <FBase.h> +#include <FUi.h> + +class UiFrameModeFrame + : public Tizen::Ui::Controls::Frame +{ +public: + UiFrameModeFrame(void); + virtual ~UiFrameModeFrame(void); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + +private: + bool __constructed; +}; // UiFrameModeFrame + +#endif // _UI_FRAME_MODE_FRAME_H_ diff --git a/project/manifest.xml b/project/manifest.xml new file mode 100644 index 0000000..bba9580 --- /dev/null +++ b/project/manifest.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest"> + <Id>$(manifestAppId)</Id> + <Version>1.0.0</Version> + <Type>C++App</Type> + <Author/> + <Apps> + <ApiVersion>2.0</ApiVersion> + <Privileges/> + <UiApp Main="True" MenuIconVisible="True" Name="$(projectName)"> + <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="720"/> + <UiTheme SystemTheme="White"/> + <DisplayNames> + <DisplayName Locale="eng-GB">$(projectName)</DisplayName> + </DisplayNames> + <Icons> + <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon> + </Icons> + </UiApp> + </Apps> +</Manifest> diff --git a/project/res/nofile.dummy b/project/res/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/res/nofile.dummy 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/UiFrameMode.cpp b/project/src/UiFrameMode.cpp new file mode 100644 index 0000000..7a48577 --- /dev/null +++ b/project/src/UiFrameMode.cpp @@ -0,0 +1,154 @@ +// +// 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://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 "UiFrameMode.h" +#include "UiFrameModeFrame.h" +#include "UiFrameModeForm.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::System; + +const int FRAME_X = 100; +const int FRAME_Y = 100; +const int FRAME_WIDTH = 600; +const int FRAME_HEIGHT = 500; + +UiFrameMode::UiFrameMode(void) +{ +} + +UiFrameMode::~UiFrameMode(void) +{ +} + +UiApp* +UiFrameMode::CreateInstance(void) +{ + // Create the instance through the constructor. + return new (std::nothrow) UiFrameMode(); +} + +bool +UiFrameMode::OnAppInitializing(AppRegistry& appRegistry) +{ + // TODO: + // Initialize Frame and App specific data. + // The App's permanent data and context can be obtained from the appRegistry. + // + // If this method is successful, return true; otherwise, return false. + // If this method returns false, the App will be terminated. + + // Uncomment the following statement to listen to the screen on/off events. + //PowerManager::SetScreenEventListener(*this); + + // TODO: + // Add your initialization code here + return true; +} + +bool +UiFrameMode::OnAppInitialized(void) +{ + // Create a Frame + UiFrameModeFrame* pUiFrameModeFrame = new (std::nothrow) UiFrameModeFrame(); + pUiFrameModeFrame->Construct(Rectangle(FRAME_X, FRAME_Y, FRAME_WIDTH, FRAME_HEIGHT)); + pUiFrameModeFrame->SetName(L"UiFrameMode"); + AddFrame(*pUiFrameModeFrame); + + // Create a form + UiFrameModeForm* pUiFrameModeForm = new (std::nothrow) UiFrameModeForm(); + pUiFrameModeForm->Initialize(); + + // Add the form to the frame + pUiFrameModeFrame->AddControl(*pUiFrameModeForm); + + // Set the current form + pUiFrameModeFrame->SetCurrentForm(*pUiFrameModeForm); + + // Draw the form + pUiFrameModeForm->Draw(); + + return true; +} + +bool +UiFrameMode::OnAppWillTerminate(void) +{ + // TODO: + // Comment. + return true; +} + +bool +UiFrameMode::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + // TODO: + // Deallocate resources allocated by this App for termination. + // The App's permanent data and context can be saved via appRegistry. + return true; +} + +void +UiFrameMode::OnForeground(void) +{ + // TODO: + // Start or resume drawing when the application is moved to the foreground. +} + +void +UiFrameMode::OnBackground(void) +{ + // TODO: + // Stop drawing when the application is moved to the background. +} + +void +UiFrameMode::OnLowMemory(void) +{ + // TODO: + // Free unused resources or close the application. +} + +void +UiFrameMode::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ + // TODO: + // Handle any changes in battery level here. + // Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL. +} + +void +UiFrameMode::OnScreenOn(void) +{ + // TODO: + // Get the released resources or resume the operations that were paused or stopped in OnScreenOff(). +} + +void +UiFrameMode::OnScreenOff(void) +{ + // TODO: + // Unless there is a strong reason to do otherwise, release resources (such as 3D, media, and sensors) to allow the device + // to enter the sleep mode to save the battery. + // Invoking a lengthy asynchronous method within this listener method can be risky, because it is not guaranteed to invoke a + // callback before the device enters the sleep mode. + // Similarly, do not perform lengthy operations in this listener method. Any operation must be a quick one. +} diff --git a/project/src/UiFrameModeEntry.cpp b/project/src/UiFrameModeEntry.cpp new file mode 100644 index 0000000..5b2e37b --- /dev/null +++ b/project/src/UiFrameModeEntry.cpp @@ -0,0 +1,65 @@ +// +// 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://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. +// + +/** + * This file contains the Tizen application entry point. + */ + +#include "UiFrameMode.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::UiApp::Execute(UiFrameMode::CreateInstance, &args); + if (IsFailed(r)) + { + AppLogException("Application execution failed-[%s].", GetErrorMessage(r)); + r &= 0x0000FFFF; + } + + args.RemoveAll(true); + AppLog("Application finished."); + + return static_cast<int>(r); +} + +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/project/src/UiFrameModeForm.cpp b/project/src/UiFrameModeForm.cpp new file mode 100644 index 0000000..8521e9c --- /dev/null +++ b/project/src/UiFrameModeForm.cpp @@ -0,0 +1,374 @@ +// +// 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://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 <FApp.h> +#include "UiFrameModeForm.h" + +using namespace Tizen::Base; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +const int ID_BUTTON = 101; +const int PANEL_WIDTH = 600; +const int PANEL_HEIGHT = 400; +const int LABEL_HEIGHT = 80; +const int PORTRAIT_FRAME_WIDTH = 600; +const int LANDSCAPE_FRAME_WIDTH = 700; +const int FRAME_HEIGHT = 500; +const int BUTTON_GAP = 15; +const int TEXT_HEIGHT = 42; + +class LabelTouchEventListener + : public ITouchEventListener +{ +public: + LabelTouchEventListener(void); + ~LabelTouchEventListener(void) {} + + virtual void OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo & touchInfo); + virtual void OnTouchLongPressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) {} + virtual void OnTouchReleased(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) {} + virtual void OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo); + virtual void OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusIn(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusOut(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) {} + virtual void OnTouchCanceled(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) {} + +private: + unsigned long __pointId; + + int __prevX; + int __prevY; +}; // LabelTouchEventListener + +LabelTouchEventListener::LabelTouchEventListener(void) + : __prevX(0) + , __prevY(0) +{ +} + +void +LabelTouchEventListener::OnTouchPressed(const Control& source, const Point& currentPosition, const TouchEventInfo & touchInfo) +{ + __pointId = touchInfo.GetPointId(); + + Touch touch; + Point startPos = touch.GetPosition(__pointId); + + __prevX = startPos.x; + __prevY = startPos.y; +} + +void +LabelTouchEventListener::OnTouchMoved(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo) +{ + Frame* pFrame = dynamic_cast<Frame*>(source.GetParent()->GetParent()); + if (!pFrame) + { + return; + } + + Touch touch; + Point curPos = touch.GetPosition(__pointId); + + int gapX = curPos.x - __prevX; + int gapY = curPos.y - __prevY; + + Point framePos = pFrame->GetPosition(); + + int newX = framePos.x + gapX; + int newY = framePos.y + gapY; + + pFrame->SetPosition(newX, newY); + + __prevX = curPos.x; + __prevY = curPos.y; + + return; +} + +UiFrameModeForm::UiFrameModeForm(void) + : __pPanel(null) + , __pLabelMode(null) + , __pLabelPos(null) + , __pLabelSize(null) + , __pLabelMoveFrame(null) + , __pButton(null) + , __pLabelTouchListener(null) +{ +} + +UiFrameModeForm::~UiFrameModeForm(void) +{ +} + +bool +UiFrameModeForm::Initialize(void) +{ + Form::Construct(FORM_STYLE_NORMAL|FORM_STYLE_INDICATOR|FORM_STYLE_HEADER|FORM_STYLE_FOOTER); + + return true; +} + +result +UiFrameModeForm::OnInitializing(void) +{ + result r = E_SUCCESS; + + __pPanel = new (std::nothrow) Panel(); + __pPanel->Construct(Rectangle((GetClientAreaBounds().width - PANEL_WIDTH)/2, (GetClientAreaBounds().height - PANEL_HEIGHT)/2, PANEL_WIDTH, PANEL_HEIGHT)); + AddControl(*__pPanel); + + Label* pLabelTitle = new (std::nothrow) Label(); + pLabelTitle->Construct(Rectangle(0, 0, PANEL_WIDTH, LABEL_HEIGHT), L"Frame Status"); + pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_CENTER); + pLabelTitle->SetTextConfig(TEXT_HEIGHT, LABEL_TEXT_STYLE_NORMAL); + __pPanel->AddControl(*pLabelTitle); + + __pLabelMode = new (std::nothrow) Label(); + __pLabelMode->Construct(Rectangle(0, LABEL_HEIGHT, PANEL_WIDTH, LABEL_HEIGHT), L""); + __pLabelMode->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pPanel->AddControl(*__pLabelMode); + + __pLabelPos = new (std::nothrow) Label(); + __pLabelPos->Construct(Rectangle(0, LABEL_HEIGHT*2, PANEL_WIDTH, LABEL_HEIGHT), L""); + __pLabelPos->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pPanel->AddControl(*__pLabelPos); + + __pLabelSize = new (std::nothrow) Label(); + __pLabelSize->Construct(Rectangle(0, LABEL_HEIGHT*3, PANEL_WIDTH, LABEL_HEIGHT), L""); + __pLabelSize->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pPanel->AddControl(*__pLabelSize); + + UpdateInfo(); + + __pButton = new (std::nothrow) Button(); + __pButton->Construct(Rectangle(BUTTON_GAP, LABEL_HEIGHT*4, PANEL_WIDTH-(BUTTON_GAP*2), LABEL_HEIGHT), L"Change to floating mode"); + __pButton->SetActionId(ID_BUTTON); + __pButton->AddActionEventListener(*this); + __pPanel->AddControl(*__pButton); + + SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION); + AddOrientationEventListener(*this); + + SetHeader(); + + Footer* pFooter = GetFooter(); + pFooter->SetBackButton(); + + SetFormBackEventListener(this); + + return r; +} + +void +UiFrameModeForm::Minimize(void) +{ + SetFormStyle(FORM_STYLE_NORMAL); + + Frame* pFrame = static_cast<Frame*>(GetParent()); + pFrame->SetShowMode(FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING); + + __pLabelMoveFrame = new (std::nothrow) Label(); + __pLabelMoveFrame->Construct(Rectangle(0, 0, PANEL_WIDTH, LABEL_HEIGHT), L"Drag here to move Frame"); + __pLabelMoveFrame->SetBackgroundColor(Color(0xFF293D5E)); + __pLabelMoveFrame->SetTextColor(Color(0xFFFFFFFF)); + __pLabelMoveFrame->SetTextConfig(TEXT_HEIGHT, LABEL_TEXT_STYLE_NORMAL); + AddControl(*__pLabelMoveFrame); + + __pLabelTouchListener = new (std::nothrow) LabelTouchEventListener(); + __pLabelMoveFrame->AddTouchEventListener(*__pLabelTouchListener); + + __pPanel->SetPosition(0, LABEL_HEIGHT); + __pButton->SetText(L"Change to full-screen mode"); + + UpdateFrameBounds(); + + UpdateInfo(); +} + +void +UiFrameModeForm::Restore(void) +{ + Frame* pFrame = static_cast<Frame*>(GetParent()); + pFrame->SetShowMode(FRAME_SHOW_MODE_FULL_SCREEN); + + SetFormStyle(FORM_STYLE_NORMAL|FORM_STYLE_INDICATOR|FORM_STYLE_HEADER|FORM_STYLE_FOOTER); + + __pLabelMoveFrame->RemoveTouchEventListener(*__pLabelTouchListener); + delete __pLabelTouchListener; + __pLabelTouchListener = null; + + RemoveControl(*__pLabelMoveFrame); + __pLabelMoveFrame = null; + + __pPanel->SetPosition((GetClientAreaBounds().width - PANEL_WIDTH)/2, (GetClientAreaBounds().height - PANEL_HEIGHT)/2); + + __pButton->SetText(L"Change to floating mode"); + + SetHeader(); + + Footer* pFooter = GetFooter(); + pFooter->SetBackButton(); + + SetFormBackEventListener(this); + + UpdateInfo(); +} + +void +UiFrameModeForm::SetHeader(void) +{ + Header* pHeader = GetHeader(); + pHeader->RemoveAllButtons(); + pHeader->RemoveAllItems(); + + pHeader->SetStyle(HEADER_STYLE_TITLE); + pHeader->SetTitleText(L"UI FRAME MODE"); +} + +void +UiFrameModeForm::UpdateFrameBounds(void) +{ + OrientationStatus status = GetOrientationStatus(); + + int frameW = 0; + if ((status == ORIENTATION_STATUS_LANDSCAPE)||(status == ORIENTATION_STATUS_LANDSCAPE_REVERSE)) + { + frameW = LANDSCAPE_FRAME_WIDTH; + } + else + { + frameW = PORTRAIT_FRAME_WIDTH; + } + + Frame* pFrame = static_cast<Frame*>(GetParent()); + pFrame->SetSize(frameW, FRAME_HEIGHT); + + __pLabelMoveFrame->SetSize(frameW, LABEL_HEIGHT); + __pPanel->SetPosition((frameW - PANEL_WIDTH)/2, LABEL_HEIGHT); +} + +void +UiFrameModeForm::UpdateInfo(bool move) +{ + Frame* pFrame = static_cast<Frame*>(GetParent()); + Rectangle frameBounds = pFrame->GetBounds(); + + if (__pLabelPos) + { + String pos("2. Position : x = "); + pos.Append(frameBounds.x); + pos.Append(", y = "); + pos.Append(frameBounds.y); + + __pLabelPos->SetText(pos); + __pLabelPos->Draw(); + } + + if (move) + { + return; + } + + if (__pLabelMode) + { + FrameShowMode showMode = pFrame->GetShowMode(); + + if (showMode == FRAME_SHOW_MODE_FULL_SCREEN) + { + __pLabelMode->SetText(L"1. Show Mode : Full screen"); + } + else + { + __pLabelMode->SetText(L"1. Show Mode : Floating"); + } + + __pLabelMode->Draw(); + } + + if (__pLabelSize) + { + String size("3. Size : w = "); + size.Append(frameBounds.width); + size.Append(", h = "); + size.Append(frameBounds.height); + + __pLabelSize->SetText(size); + __pLabelSize->Draw(); + } +} + +result +UiFrameModeForm::OnTerminating(void) +{ + result r = E_SUCCESS; + + return r; +} + +void +UiFrameModeForm::OnActionPerformed(const Control& source, int actionId) +{ + Frame* pFrame = static_cast<Frame*>(GetParent()); + FrameShowMode showMode = pFrame->GetShowMode(); + + switch(actionId) + { + case ID_BUTTON: + if (showMode == FRAME_SHOW_MODE_FULL_SCREEN) + { + Minimize(); + } + else + { + Restore(); + } + break; + default: + break; + } +} + +void +UiFrameModeForm::OnFormBackRequested(Controls::Form& source) +{ + UiApp* pApp = UiApp::GetInstance(); + AppAssert(pApp); + pApp->Terminate(); +} + +void +UiFrameModeForm::OnOrientationChanged(const Control &source, OrientationStatus orientationStatus) +{ + Frame* pFrame = static_cast<Frame*>(GetParent()); + + FrameShowMode showMode = pFrame->GetShowMode(); + if (showMode == FRAME_SHOW_MODE_FULL_SCREEN) + { + __pPanel->SetBounds(Rectangle((GetClientAreaBounds().width - PANEL_WIDTH)/2, (GetClientAreaBounds().height - PANEL_HEIGHT)/2, PANEL_WIDTH, PANEL_HEIGHT)); + } + else + { + UpdateFrameBounds(); + } + + UpdateInfo(); +} + diff --git a/project/src/UiFrameModeFrame.cpp b/project/src/UiFrameModeFrame.cpp new file mode 100644 index 0000000..620a363 --- /dev/null +++ b/project/src/UiFrameModeFrame.cpp @@ -0,0 +1,75 @@ +// +// 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://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 "UiFrameModeFrame.h" +#include "UiFrameModeForm.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +UiFrameModeFrame::UiFrameModeFrame(void) + : __constructed(false) +{ +} + +UiFrameModeFrame::~UiFrameModeFrame(void) +{ +} + +result +UiFrameModeFrame::OnInitializing(void) +{ + result r = E_SUCCESS; + + __constructed = true; + + return r; +} + +result +UiFrameModeFrame::OnTerminating(void) +{ + result r = E_SUCCESS; + + // TODO: Add your termination code here + + return r; +} + +void +UiFrameModeFrame::OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect) +{ + if (__constructed == false) + { + return; + } + + Form* pForm = GetCurrentForm(); + if (!pForm) + { + return; + } + + UiFrameModeForm* pUiFrameModeForm = static_cast<UiFrameModeForm*>(pForm); + if (pUiFrameModeForm) + { + pUiFrameModeForm->UpdateInfo(true); + } +} + diff --git a/sample.xml b/sample.xml new file mode 100644 index 0000000..3e67041 --- /dev/null +++ b/sample.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<template> + + <slp-property> + <property-group> + <sample-name>UiFrameMode</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> + </complex-array> + </process> + +</template> diff --git a/screenshot.png b/screenshot.png Binary files differnew file mode 100644 index 0000000..a6f3b5f --- /dev/null +++ b/screenshot.png |