Crop implementation
authorchitta ranjan <chitta.rs@samsung.com>
Mon, 25 Mar 2013 12:28:53 +0000 (21:28 +0900)
committerchitta ranjan <chitta.rs@samsung.com>
Mon, 25 Mar 2013 12:28:53 +0000 (21:28 +0900)
Change-Id: I35e7850e97d81990aaf029e2f21a1332a0569cc4
Signed-off-by: chitta ranjan <chitta.rs@samsung.com>
19 files changed:
inc/IvImageCrop.h [new file with mode: 0644]
inc/IvImageSetterForm.h
inc/IvImageViewerForm.h
inc/IvTypes.h
res/screen-density-xhigh/EditBackground.png [new file with mode: 0644]
res/screen-density-xhigh/T01-1_control_icon_CCW.png [new file with mode: 0644]
res/screen-density-xhigh/T01-1_control_icon_CW.png [new file with mode: 0644]
res/screen-density-xhigh/T01-1_control_icon_cancel.png [new file with mode: 0644]
res/screen-density-xhigh/T01-1_control_icon_save.png [new file with mode: 0644]
res/screen-density-xhigh/T01-1_crop_rectangle.png [new file with mode: 0644]
res/screen-density-xhigh/T01_1_controlbar_bg.png [new file with mode: 0644]
res/screen-size-normal/IDL_FORM_IMAGE_CROP.xml [new file with mode: 0644]
src/IvFormFactory.cpp
src/IvImageCrop.cpp [new file with mode: 0644]
src/IvImageSetterForm.cpp
src/IvImageViewerApp.cpp
src/IvImageViewerForm.cpp
src/IvMainFrame.cpp
src/IvTypes.cpp

diff --git a/inc/IvImageCrop.h b/inc/IvImageCrop.h
new file mode 100644 (file)
index 0000000..c247b0d
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// 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.
+//
+
+/**
+ * @file               IvImageCrop.h
+ * @brief              This is the implementation file for Image Crop.
+ */
+
+#ifndef _IV_IMAGE_CROP_H_
+#define _IV_IMAGE_CROP_H_
+
+#include <FUi.h>
+
+using namespace Tizen::Ui;
+
+enum TouchLocation
+{
+       INSIDE_CROPBOX = 0,
+       OUTSIDE_CROPBOX,
+       INSIDE_TOP_RECTANGLE,
+       INSIDE_BOTTOM_RECTANGLE,
+       INSIDE_LEFT_RECTANGLE,
+       INSIDE_RIGHT_RECTANGLE,
+       INSIDE_TOP_LEFT_RECTANGLE,
+       INSIDE_TOP_RIGHT_RECTANGLE,
+       INSIDE_BOTTOM_LEFT_RECTANGLE,
+       INSIDE_BOTTOM_RIGHT_RECTANGLE,
+};
+
+class ImageCropForm
+       : public Tizen::Ui::Controls::Form
+       , public::Tizen::Ui::IActionEventListener
+       , public Tizen::Ui::Scenes::ISceneEventListener
+       , public Tizen::Ui::ITouchEventListener
+{
+public:
+       ImageCropForm(void);
+
+       ~ImageCropForm(void);
+
+       /*! @fn Initialize(void)
+        * @brief Called to construct the corresponding form of the file.
+        */
+       bool Initialize(void);
+
+       /*! @fn OnInitializing(void)
+        * @brief Called once the form has been constructed to initialize the controls within the form.
+        */
+       virtual result OnInitializing(void);
+
+       result OnDraw(void);
+
+       virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+       virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
+                       const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
+       virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
+                       const Tizen::Ui::Scenes::SceneId& nextSceneId);
+
+       // Callbacks from ITouchEventListener
+       virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
+       virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
+       virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
+       virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
+       virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
+
+       void CheckCurrentPosition(const Tizen::Graphics::Point currentPosition);
+
+private:
+       static const int IDA_BUTTON_SAVE = 105;
+       static const int IDA_BUTTON_CW_ROTATION = 102;
+       static const int IDA_BUTTON_CCW_ROATTION = 103;
+       static const int IDA_BUTTON_CANCEL = 104;
+
+       Tizen::Graphics::Rectangle __cropBox;
+       Tizen::Base::String __destFilePath;
+       Tizen::Graphics::Rectangle __imageBox;
+       Tizen::Media::ImageBuffer __imageBuffer;
+       int __imageHeight;
+       int __imageWidth;
+       Tizen::Graphics::Canvas* __pCanvas;
+       Tizen::Graphics::Bitmap* __pCurrentBitmap;
+       Tizen::Graphics::Bitmap* __pRectangleBitmap;
+       TouchLocation __pointLocation;
+       Tizen::Graphics::Point __touchStart;
+       Tizen::Media::ImageFormat __imageFormat;
+};
+
+#endif /* _IV_IMAGE_CROP_H_ */
index 7b1c7dd..cc3a9fe 100644 (file)
@@ -51,7 +51,7 @@ public:
 
        virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
 
-       virtual void OnOrientationChanged(const Tizen::Ui::Control &source,
+       virtual void OnOrientationChanged(const Tizen::Ui::Controlsource,
                        Tizen::Ui::OrientationStatus orientationStatus);
 
        virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
@@ -81,7 +81,7 @@ private:
        int __statusValue;
        int __currentImageIndex;
        long long __contentId;
-       Tizen::Graphics::Bitmap* __currentBitmap;
+       Tizen::Graphics::Bitmap* __pCurrentBitmap;
        ImageViewerPresentationModel* __pPresentationModel;
 };
 
index fc6f92d..059d97f 100644 (file)
@@ -139,7 +139,7 @@ private:
        result ShowPanelDetail(bool showStatus);
        result ChangeFooterItem(bool isChanged, Tizen::Ui::Controls::Footer* pFooter, int position);
        long long GetFileSize(Tizen::Base::String filePath);
-       void GetHeaderString(int index, Tizen::Base::String &fileName, Tizen::Base::String &page);
+       void GetHeaderString(int index, Tizen::Base::String& fileName, Tizen::Base::String& page);
        void DownloadFile(void);
        void CallVideoPlayer(void);
        result DeleteImageFile(void);
@@ -164,7 +164,6 @@ private:
        Tizen::Ui::Controls::FooterItem* __pDetailFooterItem;
        Tizen::Ui::Controls::Gallery* __pGallery;
        Tizen::Base::Runtime::Timer* __pTimer;
-       Tizen::Graphics::Bitmap* __pDecodeBitmap;
        Tizen::Ui::Controls::ContextMenu* __pContextMenuMore;
        Tizen::Ui::Controls::ContextMenu* __pContextMenuCopy;
        Tizen::Ui::Controls::ContextMenu* __pContextMenuSetAs;
index 4efeaeb..a40e602 100644 (file)
@@ -58,6 +58,7 @@ enum ActionID
        , ACTION_ID_FOOTER_BUTTON_SLIDE = 407
        , ACTION_ID_FOOTER_BUTTON_SHARE = 408
        , ACTION_ID_FOOTER_BUTTON_SAVE = 409
+       , ACTION_ID_FOOTER_BUTTON_CROP = 412
        , ACTION_ID_FOOTER_MORE = 501
        , ACTION_ID_PANEL_HEADER_DETAILS_RENAME = 601
 };
@@ -72,13 +73,16 @@ enum SlideShowTransitionEffect
 extern const wchar_t* IDL_FORM_IMAGE_VIEWER;
 extern const wchar_t* IDL_FORM_IMAGE_SETTER;
 extern const wchar_t* IDL_FORM_NAME_EDITOR;
+extern const wchar_t* IDL_FORM_IMAGE_CROP;
 
 extern const wchar_t* FORM_IMAGE_VIEWER;
 extern const wchar_t* FORM_IMAGE_SETTER;
+extern const wchar_t* FORM_IMAGE_CROP;
 extern const wchar_t* FORM_IMAGE_NAME_EDITOR;
 
 extern const wchar_t* IDSCN_IMAGE_VIEWER;
 extern const wchar_t* IDSCN_IMAGE_SETTER;
+extern const wchar_t* IDSCN_IMAGE_CROP;
 extern const wchar_t* IDSCN_IMAGE_NAME_EDITOR;
 
 extern const wchar_t* APPCONTROL_PROVIDER_ID_MESSAGES;
@@ -159,6 +163,12 @@ extern const wchar_t* IDB_IMAGE_VIEWERFORM_MORE_NORMAL;
 extern const wchar_t* IDB_IMAGE_VIEWERFORM_MORE_PRESSED;
 extern const wchar_t* IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL;
 extern const wchar_t* IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL;
+extern const wchar_t* IDB_IMAGE_CROP_FORM_SAVE_ICON;
+extern const wchar_t* IDB_IMAGE_CROP_FORM_CANCEL_ICON;
+extern const wchar_t* IDB_IMAGE_CROP_FORM_CW_ROTATION_ICON;
+extern const wchar_t* IDB_IMAGE_CROP_FORM_CCW_ROTATION_ICON;
+extern const wchar_t* IDB_IMAGE_CROP_FORM_ITEM_DIVIDER_ICON;
+extern const wchar_t* IDB_IMAGE_CROP_RECTANGLE;
 
 extern const wchar_t* IDB_IMAGE_SETTERFORM_BUTTON_SET;
 extern const wchar_t* IDB_IMAGE_SETTERFORM_BUTTON_SET_PRESS;
@@ -179,4 +189,8 @@ extern const wchar_t* ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE;
 extern const wchar_t* DEVICE_STORAGE_CARD_MOUNTED;
 extern const wchar_t* DEVICE_STORAGE_CARD_UNMOUNTED;
 
+extern const int FOOTER_PANEL_HEIGHT;
+extern const int INDICATOR_BAR_HEIGHT;
+extern const int CROP_RECTANGLE_HEIGHT;
+
 #endif /* _IV_TYPES_H_ */
diff --git a/res/screen-density-xhigh/EditBackground.png b/res/screen-density-xhigh/EditBackground.png
new file mode 100644 (file)
index 0000000..a6bcaa5
Binary files /dev/null and b/res/screen-density-xhigh/EditBackground.png differ
diff --git a/res/screen-density-xhigh/T01-1_control_icon_CCW.png b/res/screen-density-xhigh/T01-1_control_icon_CCW.png
new file mode 100644 (file)
index 0000000..a39964e
Binary files /dev/null and b/res/screen-density-xhigh/T01-1_control_icon_CCW.png differ
diff --git a/res/screen-density-xhigh/T01-1_control_icon_CW.png b/res/screen-density-xhigh/T01-1_control_icon_CW.png
new file mode 100644 (file)
index 0000000..c2a192c
Binary files /dev/null and b/res/screen-density-xhigh/T01-1_control_icon_CW.png differ
diff --git a/res/screen-density-xhigh/T01-1_control_icon_cancel.png b/res/screen-density-xhigh/T01-1_control_icon_cancel.png
new file mode 100644 (file)
index 0000000..1840a7a
Binary files /dev/null and b/res/screen-density-xhigh/T01-1_control_icon_cancel.png differ
diff --git a/res/screen-density-xhigh/T01-1_control_icon_save.png b/res/screen-density-xhigh/T01-1_control_icon_save.png
new file mode 100644 (file)
index 0000000..b332e33
Binary files /dev/null and b/res/screen-density-xhigh/T01-1_control_icon_save.png differ
diff --git a/res/screen-density-xhigh/T01-1_crop_rectangle.png b/res/screen-density-xhigh/T01-1_crop_rectangle.png
new file mode 100644 (file)
index 0000000..6e89c37
Binary files /dev/null and b/res/screen-density-xhigh/T01-1_crop_rectangle.png differ
diff --git a/res/screen-density-xhigh/T01_1_controlbar_bg.png b/res/screen-density-xhigh/T01_1_controlbar_bg.png
new file mode 100644 (file)
index 0000000..cafdd3f
Binary files /dev/null and b/res/screen-density-xhigh/T01_1_controlbar_bg.png differ
diff --git a/res/screen-size-normal/IDL_FORM_IMAGE_CROP.xml b/res/screen-size-normal/IDL_FORM_IMAGE_CROP.xml
new file mode 100644 (file)
index 0000000..516bb82
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+       This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<!DOCTYPE Scene SYSTEM "UIForm.dtd">
+<Scene Bversion="2.0.0.201303182057" Dversion="20120315">
+    <LogicalCoordinate>720</LogicalCoordinate>
+    <Form id="IDL_FORM_IMAGE_CROP">
+        <property backgroundColor="" backgroundColorOpacity="100" notificationTrayOpenEnabled="false" orientation="Portrait" softKey0NormalIcon="" softKey0PressedIcon="" softKey0Text="" softKey1NormalIcon="" softKey1PressedIcon="" softKey1Text="" title="" titleAlign="ALIGN_CENTER" titleIcon="" translucentFooter="false" translucentHeader="false" translucentIndicator="false"/>
+        <layout mode="Portrait" style="FORM_STYLE_INDICATOR" type="LAYOUT_RELATIVE"/>
+        <layout mode="Landscape" style="FORM_STYLE_INDICATOR" type="LAYOUT_RELATIVE"/>
+    </Form>
+    <Panel id="IDC_FOOTER_PANEL" parent="IDL_FORM_IMAGE_CROP">
+        <property backgroundColor="" backgroundColorOpacity="0" compositeEnabled="true" groupStyle="GROUP_STYLE_NONE"/>
+        <layout bottomRelation="IDL_FORM_IMAGE_CROP" bottomRelationType="RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM" centerHorizontal="false" centerVertical="false" height="98.0" horizontalFitPolicy="FIT_POLICY_PARENT" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Portrait" rightRelation="" rightRelationType="" topRelation="" topRelationType="" type="LAYOUT_RELATIVE" verticalFitPolicy="FIT_POLICY_FIXED" width="720.0" x="0" y="1122.0"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="46.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" type="LAYOUT_RELATIVE" verticalFitPolicy="FIT_POLICY_FIXED" width="474.0" x="805.0" y="613.0"/>
+    </Panel>
+    <Label id="IDC_PANEL_LABEL" parent="IDC_FOOTER_PANEL">
+        <property accessibilityHint="" backgroundBitmapPath="" backgroundColor="#383838" backgroundColorOpacity="100" horizontalAlign="ALIGN_LEFT" leftMargin="16" text="" textColor="" textSize="33.0" textStyle="LABEL_TEXT_STYLE_NORMAL" topMargin="0" verticalAlign="ALIGN_TOP"/>
+        <layout bottomRelation="IDC_FOOTER_PANEL" bottomRelationType="RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM" centerHorizontal="false" centerVertical="false" height="98.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="IDC_FOOTER_PANEL" leftRelationType="RECT_EDGE_RELATION_LEFT_TO_LEFT" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Portrait" rightRelation="IDC_FOOTER_PANEL" rightRelationType="RECT_EDGE_RELATION_RIGHT_TO_RIGHT" topRelation="IDC_FOOTER_PANEL" topRelationType="RECT_EDGE_RELATION_TOP_TO_TOP" verticalFitPolicy="FIT_POLICY_FIXED" width="720.0" x="0.0" y="0.0"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="46.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="40.0" x="30.0" y="0.0"/>
+    </Label>
+    <Button id="IDC_SAVE_BUTTON" parent="IDC_FOOTER_PANEL">
+        <property DisabledBitmapX="0.0" DisabledBitmapY="0.0" NormalBitmapX="0.0" NormalBitmapY="0.0" PressedBitmapX="0.0" PressedBitmapY="0.0" accessibilityHint="" disableTextColor="" disabledBGBitmapPath="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedBitmapPath="" highlightedBitmapX="0.0" highlightedBitmapY="0.0" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="EditBackground.png" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="EditBackground.png" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="" textSize="32.0" verticalAlign="ALIGN_MIDDLE"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="98.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Portrait" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="179.0" x="0.0" y="0.0"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="46.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="48.0" x="13.0" y="0.0"/>
+    </Button>
+    <Button id="IDC_CW_ROTATION_BUTTON" parent="IDC_FOOTER_PANEL">
+        <property DisabledBitmapX="0.0" DisabledBitmapY="0.0" NormalBitmapX="0.0" NormalBitmapY="0.0" PressedBitmapX="0.0" PressedBitmapY="0.0" accessibilityHint="" disableTextColor="" disabledBGBitmapPath="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedBitmapPath="" highlightedBitmapX="0.0" highlightedBitmapY="0.0" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="EditBackground.png" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="EditBackground.png" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="" textSize="32.0" verticalAlign="ALIGN_MIDDLE"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="98.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Portrait" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="179.0" x="180.0" y="0.0"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="46.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="48.0" x="60.0" y="0.0"/>
+    </Button>
+    <Button id="IDC_CCW_ROTATION_BUTTON" parent="IDC_FOOTER_PANEL">
+        <property DisabledBitmapX="0.0" DisabledBitmapY="0.0" NormalBitmapX="0.0" NormalBitmapY="0.0" PressedBitmapX="0.0" PressedBitmapY="0.0" accessibilityHint="" disableTextColor="" disabledBGBitmapPath="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedBitmapPath="" highlightedBitmapX="0.0" highlightedBitmapY="0.0" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="EditBackground.png" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="EditBackground.png" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="" textSize="32.0" verticalAlign="ALIGN_MIDDLE"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="98.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Portrait" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="179.0" x="359.0" y="0.0"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="46.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="48.0" x="65.0" y="0.0"/>
+    </Button>
+    <Button id="IDC_CANCEL_BUTTON" parent="IDC_FOOTER_PANEL">
+        <property DisabledBitmapX="0.0" DisabledBitmapY="0.0" NormalBitmapX="0.0" NormalBitmapY="0.0" PressedBitmapX="0.0" PressedBitmapY="0.0" accessibilityHint="" disableTextColor="" disabledBGBitmapPath="" disabledBitmapPath="" disabledColor="" disabledColorOpacity="100" highlightedBGBitmapPath="" highlightedBitmapPath="" highlightedBitmapX="0.0" highlightedBitmapY="0.0" highlightedColor="" highlightedColorOpacity="100" highlightedTextColor="" horizontalAlign="ALIGN_CENTER" normalBGBitmapPath="EditBackground.png" normalBitmapPath="" normalColor="" normalColorOpacity="100" normalTextColor="" pressedBGBitmapPath="EditBackground.png" pressedBitmapPath="" pressedColor="" pressedColorOpacity="100" pressedTextColor="" text="" textSize="32.0" verticalAlign="ALIGN_MIDDLE"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="98.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Portrait" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="180.0" x="540.0" y="0.0"/>
+        <layout bottomRelation="" bottomRelationType="" centerHorizontal="false" centerVertical="false" height="46.0" horizontalFitPolicy="FIT_POLICY_FIXED" leftRelation="" leftRelationType="" marginBottom="0.0" marginLeft="0.0" marginRight="0.0" marginTop="0.0" mode="Landscape" rightRelation="" rightRelationType="" topRelation="" topRelationType="" verticalFitPolicy="FIT_POLICY_FIXED" width="48.0" x="76.0" y="0.0"/>
+    </Button>
+</Scene>
index fab0b52..e70474f 100644 (file)
@@ -23,6 +23,7 @@
 #include "IvImageNameEditorForm.h"
 #include "IvImageViewerForm.h"
 #include "IvImageSetterForm.h"
+#include "IvImageCrop.h"
 
 using namespace Tizen::Base;
 using namespace Tizen::Ui::Controls;
@@ -60,6 +61,13 @@ FormFactory::CreateFormN(const String& formId, const SceneId& sceneId)
                SceneManager::GetInstance()->AddSceneEventListener(sceneId, *pForm);
                pNewForm = pForm;
        }
+       else if (formId == FORM_IMAGE_CROP)
+       {
+               ImageCropForm* pForm = new (std::nothrow) ImageCropForm();
+               pForm->Initialize();
+               SceneManager::GetInstance()->AddSceneEventListener(sceneId, *pForm);
+               pNewForm = pForm;
+       }
        else if (formId == FORM_IMAGE_NAME_EDITOR)
        {
                ImageNameEditorForm* pForm = new (std::nothrow) ImageNameEditorForm();
diff --git a/src/IvImageCrop.cpp b/src/IvImageCrop.cpp
new file mode 100644 (file)
index 0000000..6c06fc5
--- /dev/null
@@ -0,0 +1,418 @@
+//
+// 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.
+//
+
+/**
+ * @file               IvImageCrop.cpp
+ * @brief              This is the implementation file for Image Crop.
+ */
+
+#include <FApp.h>
+#include <FMedia.h>
+#include "IvImageCrop.h"
+#include "IvImageViewerPresentationModel.h"
+#include "IvTypes.h"
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+using namespace Tizen::Ui::Controls;
+using namespace Tizen::Ui::Scenes;
+
+static const unsigned int CROP_BOX_RECTANGLE_COLOR = Color32<199, 110, 6>::Value;
+static const int CROP_BOX_LINE_WIDTH = 5;
+
+ImageCropForm::ImageCropForm(void)
+       : __imageHeight(0)
+       , __imageWidth(0)
+       , __pCanvas(null)
+       , __pCurrentBitmap(null)
+       , __pRectangleBitmap(null)
+{
+       __pointLocation = OUTSIDE_CROPBOX;
+}
+
+ImageCropForm::~ImageCropForm(void)
+{
+       if (__pCurrentBitmap != null)
+       {
+               delete __pCurrentBitmap;
+       }
+
+       if (__pRectangleBitmap != null)
+       {
+               delete __pRectangleBitmap;
+       }
+
+       if (__pCanvas != null)
+       {
+               delete __pCanvas;
+               __pCanvas = null;
+       }
+}
+
+bool
+ImageCropForm::Initialize(void)
+{
+       Form::Construct(IDL_FORM_IMAGE_CROP);
+       Form::SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR);
+       return true;
+}
+
+result
+ImageCropForm::OnInitializing(void)
+{
+       result r = E_SUCCESS;
+
+       AppResource* pAppResource = null;
+       Bitmap* pSaveButtonBitmap = null;
+       Bitmap* pCancelButtonBitmap  = null;
+       Bitmap* pCWRotationButtonBitmap  = null;
+       Bitmap* pCCWRotationButtonBitmap  = null;
+       Panel* pPanel = null;
+       Button* pSaveButton = null;
+       Button* pCancelButton = null;
+       pAppResource = UiApp::App::GetInstance()->GetAppResource();
+       if (pAppResource != null)
+       {
+               pSaveButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_SAVE_ICON);
+               pCancelButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CANCEL_ICON);
+               pCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CW_ROTATION_ICON);
+               pCCWRotationButtonBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_FORM_CCW_ROTATION_ICON);
+               __pRectangleBitmap = pAppResource->GetBitmapN(IDB_IMAGE_CROP_RECTANGLE);
+       }
+
+       pPanel = static_cast<Panel*>(GetControl(L"IDC_FOOTER_PANEL"));
+       if (pPanel != null)
+       {
+               pSaveButton = static_cast<Button*>(pPanel->GetControl(L"IDC_SAVE_BUTTON"));
+               if (pSaveButton != null)
+               {
+                       Point startPoint((pSaveButton->GetWidth() - pSaveButtonBitmap->GetWidth()) / 2,(pSaveButton->GetHeight() - pSaveButtonBitmap->GetHeight()) / 2 );
+                       pSaveButton->SetNormalBitmap(startPoint, *pSaveButtonBitmap);
+                       pSaveButton->AddActionEventListener(*this);
+                       pSaveButton->SetActionId(IDA_BUTTON_SAVE);
+               }
+
+               pCancelButton = static_cast<Button*>(pPanel->GetControl(L"IDC_CANCEL_BUTTON"));
+               if (pCancelButton != null)
+               {
+                       Point startPoint((pCancelButton->GetWidth() - pCancelButtonBitmap->GetWidth()) / 2,(pCancelButton->GetHeight() - pCancelButtonBitmap->GetHeight()) / 2 );
+                       pCancelButton->SetNormalBitmap(startPoint, *pCancelButtonBitmap);
+                       pCancelButton->AddActionEventListener(*this);
+                       pCancelButton->SetActionId(IDA_BUTTON_CANCEL);
+               }
+               Label* pLabel = static_cast<Label*>(pPanel->GetControl(L"IDC_PANEL_LABEL"));
+               if (pLabel != null)
+               {
+                       SetControlAlwaysOnTop(*pPanel, true);
+               }
+               SetControlAlwaysAtBottom(*pLabel, true);
+       }
+       AddTouchEventListener(*this);
+
+       delete pSaveButtonBitmap;
+       delete pCancelButtonBitmap;
+       delete pCWRotationButtonBitmap;
+       delete pCCWRotationButtonBitmap;
+       return r;
+}
+
+void
+ImageCropForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
+{
+       AppLogDebug("ENTER");
+       String* pFilePath = null;
+       if (pArgs != null)
+       {
+               pFilePath = static_cast<String*>(pArgs->GetAt(0));
+               delete pArgs;
+       }
+       __destFilePath.Append(*pFilePath);
+       __destFilePath.Reverse();
+       int index = 0;
+       String delimiter = L".";
+       __destFilePath.IndexOf(delimiter, 0, index);
+       __destFilePath.Reverse();
+       String stringToInsert = L"_1";
+       __destFilePath.Insert(stringToInsert, __destFilePath.GetLength() - index - 1);
+       __imageBuffer.GetImageInfo(pFilePath->GetPointer(), __imageFormat, __imageWidth, __imageHeight);
+       __imageBuffer.Construct(pFilePath->GetPointer());
+       __pCurrentBitmap = __imageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_RGB565, BUFFER_SCALING_AUTO);
+
+       if (__imageWidth > GetClientAreaBounds().width && __imageHeight > GetClientAreaBounds().height)
+       {
+               if (__imageHeight > __imageWidth)
+               {
+                       __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
+                       __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
+                       __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
+                       __imageBox.y = INDICATOR_BAR_HEIGHT;
+               }
+               else
+               {
+                       __imageBox.width = GetClientAreaBounds().width;
+                       __imageBox.height = (GetClientAreaBounds().width * __imageHeight) / __imageWidth;
+                       __imageBox.x = 0;
+                       __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
+               }
+       }
+       else if (__imageWidth > GetClientAreaBounds().width)
+       {
+               __imageBox.width = GetClientAreaBounds().width;
+               __imageBox.height = (__imageHeight * GetClientAreaBounds().width) / __imageWidth;
+               __imageBox.x = 0;
+               __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2;
+
+       }
+       else if (__imageHeight > GetClientAreaBounds().height)
+       {
+               __imageBox.height = GetClientAreaBounds().height - FOOTER_PANEL_HEIGHT;
+               __imageBox.width = (__imageWidth * GetClientAreaBounds().height) / __imageHeight;
+               __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
+               __imageBox.y = INDICATOR_BAR_HEIGHT;
+       }
+       else
+       {
+               __imageBox.height = __imageHeight;
+               __imageBox.width = __imageWidth;
+               __imageBox.x = (GetClientAreaBounds().width - __imageBox.width) / 2;
+               __imageBox.y = (GetClientAreaBounds().height - __imageBox.height) / 2 ;
+       }
+       if (__imageHeight >= __imageWidth)
+       {
+               __cropBox.height = __imageBox.height / 2;
+               __cropBox.width = __imageBox.width / 2;
+               __cropBox.y =  __imageBox.y + (__imageBox.height / 4);
+               __cropBox.x = __imageBox.x + (__imageBox.width / 4);
+       }
+       else
+       {
+               __cropBox.height = (2 * __imageBox.height) / 3;
+               __cropBox.width = (2 * __imageBox.width) / 3;
+               __cropBox.y = __imageBox.y + (__imageBox.height - __cropBox.height) / 2;
+               __cropBox.x = __imageBox.x + (__imageBox.width - __cropBox.width) / 2;
+       }
+
+       __pCanvas = GetCanvasN();
+       __pCanvas->SetForegroundColor(CROP_BOX_RECTANGLE_COLOR);
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
+ImageCropForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
+{
+       AppLogDebug("ENTER");
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+result
+ImageCropForm::OnDraw(void)
+{
+       result r = E_SUCCESS;
+       AppLogDebug("ENTER");
+       if (__pCanvas != null)
+       {
+               __pCanvas->SetLineWidth(CROP_BOX_LINE_WIDTH);
+               __pCanvas->DrawBitmap(Rectangle(__imageBox.x, __imageBox.y, __imageBox.width, __imageBox.height), *__pCurrentBitmap);
+               __pCanvas->DrawRectangle(Rectangle(__cropBox.x, __cropBox.y, __cropBox.width, __cropBox.height));
+               __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2), __cropBox.y - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Top Rectangle
+               __pCanvas->DrawBitmap(Rectangle((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); // Bottom Rectangle
+               __pCanvas->DrawBitmap(Rectangle(__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); //Left Rectangle
+               __pCanvas->DrawBitmap(Rectangle(__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2), (__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2), CROP_RECTANGLE_HEIGHT, CROP_RECTANGLE_HEIGHT), *__pRectangleBitmap); //Right Rectangle
+       }
+       AppLogDebug("EXIT");
+       return r;
+}
+
+void
+ImageCropForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+       SceneManager* pSceneManager = SceneManager::GetInstance();
+       switch(actionId)
+       {
+       case IDA_BUTTON_CANCEL:
+               pSceneManager->GoBackward(BackwardSceneTransition());
+               break;
+       case IDA_BUTTON_SAVE:
+       {
+               ImageBuffer* pCropbuffer = null;
+               pCropbuffer = __imageBuffer.CropN(((__cropBox.x - __imageBox.x) * __imageWidth) / __imageBox.width, ((__cropBox.y - __imageBox.y) * __imageHeight) / __imageBox.height,
+                                        (__cropBox.width * __imageWidth) / __imageBox.width, (__cropBox.height * __imageHeight) / __imageBox.height);
+               pCropbuffer->EncodeToFile(__destFilePath, __imageFormat, true, 100);
+               delete pCropbuffer;
+
+               pSceneManager->GoBackward(BackwardSceneTransition());
+               AppLog("Exit");
+       }
+       break;
+       }
+}
+
+void
+ImageCropForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+       AppLogDebug("ENTER");
+       __touchStart = currentPosition;
+       CheckCurrentPosition(currentPosition);
+       AppLogDebug("EXIT");
+}
+
+void
+ImageCropForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+       AppLogDebug("ENTER");
+       if (__pointLocation == INSIDE_TOP_RECTANGLE)
+       {
+               int deltaY = currentPosition.y - __touchStart.y;
+
+               if ((__cropBox.y + deltaY) > __imageBox.y)
+               {
+                       if (__cropBox.height <= (CROP_RECTANGLE_HEIGHT * 2) && deltaY > 0)
+                       {
+                               __cropBox.height = (CROP_RECTANGLE_HEIGHT * 2);
+                       }
+                       else
+                       {
+                               __cropBox.y += deltaY;
+                               __cropBox.height -= deltaY;
+                       }
+               }
+               RequestRedraw(false);
+       }
+       else if (__pointLocation == INSIDE_BOTTOM_RECTANGLE)
+       {
+               int deltaY = currentPosition.y - __touchStart.y;
+               if ((__cropBox.y + __cropBox.height + deltaY ) < (__imageBox.y + __imageBox.height) && deltaY < __cropBox.height)
+               {
+                       if (__cropBox.height <= (CROP_RECTANGLE_HEIGHT * 2) && deltaY < 0)
+                       {
+                               __cropBox.height = (CROP_RECTANGLE_HEIGHT * 2);
+                       }
+                       else
+                       {
+                               __cropBox.height += deltaY;
+                       }
+               }
+               RequestRedraw(false);
+       }
+       else if (__pointLocation == INSIDE_LEFT_RECTANGLE)
+       {
+               int deltaX = currentPosition.x - __touchStart.x;
+               if ((__cropBox.x + deltaX) > __imageBox.x && deltaX < __cropBox.width)
+               {
+                       if (__cropBox.width <= (CROP_RECTANGLE_HEIGHT * 2) && deltaX > 0)
+                       {
+                               __cropBox.width = (CROP_RECTANGLE_HEIGHT * 2);
+                       }
+                       else
+                       {
+                               __cropBox.x += deltaX;
+                               __cropBox.width -= deltaX;
+                       }
+               }
+               RequestRedraw(false);
+       }
+       else if (__pointLocation == INSIDE_RIGHT_RECTANGLE)
+       {
+               int deltaX = currentPosition.x - __touchStart.x;
+               if ((__cropBox.x + __cropBox.width + deltaX) < (__imageBox.x + __imageBox.width) && deltaX < __cropBox.width)
+               {
+                       if (__cropBox.width <= (CROP_RECTANGLE_HEIGHT * 2) && deltaX < 0)
+                               __cropBox.width = (CROP_RECTANGLE_HEIGHT * 2);
+                       else
+                       __cropBox.width += deltaX;
+               }
+               RequestRedraw(false);
+       }
+       else if (__pointLocation == INSIDE_CROPBOX)
+       {
+               int deltaX = currentPosition.x - __touchStart.x;
+               int deltaY = currentPosition.y - __touchStart.y;
+               if ((__cropBox.x + deltaX) > __imageBox.x)
+               {
+                       __cropBox.x += deltaX;
+               }
+               else
+               {
+                       __cropBox.x = __imageBox.x;
+               }
+               if ((__cropBox.y + deltaY) > __imageBox.y)
+               {
+                       __cropBox.y += deltaY;
+               }
+               else
+               {
+                       __cropBox.y = __imageBox.y;
+               }
+               if ((__cropBox.x + __cropBox.width + deltaX) > (__imageBox.x + __imageBox.width))
+               {
+                       __cropBox.x = __imageBox.x + __imageBox.width - __cropBox.width;
+               }
+               if ((__cropBox.y + __cropBox.height + deltaY) > (__imageBox.y + __imageBox.height))
+               {
+                       __cropBox.y = __imageBox.y + __imageBox.height - __cropBox.height;
+               }
+               RequestRedraw(false);
+       }
+       __touchStart = currentPosition;
+       AppLogDebug("EXIT");
+}
+
+void
+ImageCropForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
+{
+       AppLogDebug("ENTER");
+       __pointLocation = OUTSIDE_CROPBOX;
+       AppLogDebug("EXIT");
+}
+
+void
+ImageCropForm::CheckCurrentPosition(const Point currentPosition)
+{
+       AppLogDebug("ENTER");
+       if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
+               && currentPosition.y >  (__cropBox.y - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + (CROP_RECTANGLE_HEIGHT / 2)))
+       {
+               __pointLocation = INSIDE_TOP_RECTANGLE;
+       }
+       else if (currentPosition.x > (__cropBox.x - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + (CROP_RECTANGLE_HEIGHT / 2))
+               && currentPosition.y >  ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
+       {
+               __pointLocation = INSIDE_LEFT_RECTANGLE;
+       }
+       else if (currentPosition.x > (__cropBox.x + __cropBox.width - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < (__cropBox.x + __cropBox.width + (CROP_RECTANGLE_HEIGHT / 2))
+               && currentPosition.y > ((__cropBox.y + __cropBox.height / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < ((__cropBox.y + __cropBox.height / 2) + (CROP_RECTANGLE_HEIGHT / 2)))
+       {
+               __pointLocation = INSIDE_RIGHT_RECTANGLE;
+       }
+       else if (currentPosition.x > ((__cropBox.x + __cropBox.width / 2) - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.x < ((__cropBox.x + __cropBox.width / 2) + (CROP_RECTANGLE_HEIGHT / 2))
+               && currentPosition.y > (__cropBox.y + __cropBox.height - (CROP_RECTANGLE_HEIGHT / 2)) && currentPosition.y < (__cropBox.y + __cropBox.height + (CROP_RECTANGLE_HEIGHT / 2)))
+       {
+               __pointLocation = INSIDE_BOTTOM_RECTANGLE;
+       }
+       else if (currentPosition.x > __cropBox.x && currentPosition.x < (__cropBox.x + __cropBox.width) && currentPosition.y > __cropBox.y && currentPosition.y < (__cropBox.y + __cropBox.height))
+       {
+               __pointLocation = INSIDE_CROPBOX;
+       }
+       else
+       {
+               __pointLocation = OUTSIDE_CROPBOX;
+       }
+       AppLogDebug("EXIT");
+       return;
+}
index 4b8e986..305cbf6 100644 (file)
@@ -57,7 +57,7 @@ ImageSetterForm::ImageSetterForm()
        , __statusValue(0)
        , __currentImageIndex(0)
        , __contentId(0)
-       , __currentBitmap(null)
+       , __pCurrentBitmap(null)
        , __pPresentationModel(null)
 {
        AppLogDebug("ENTER");
@@ -218,8 +218,8 @@ ImageSetterForm::CreateItem(int index)
                pBitmap = pImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_AUTO);
        }
 
-       __currentBitmap = pBitmap;
-       pGallery->Construct(*__currentBitmap, filePath);
+       __pCurrentBitmap = pBitmap;
+       pGallery->Construct(*__pCurrentBitmap, filePath);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return pGallery;
@@ -230,6 +230,7 @@ ImageSetterForm::DeleteItem(int index, GalleryItem* pItem)
 {
        AppLogDebug("ENTER");
        delete pItem;
+       pItem = null;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return true;
@@ -267,9 +268,9 @@ result
 ImageSetterForm::OnTerminating(void)
 {
        AppLogDebug("ENTER");
-       if (__currentBitmap != null)
+       if (__pCurrentBitmap != null)
        {
-               delete __currentBitmap;
+               delete __pCurrentBitmap;
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -296,7 +297,7 @@ ImageSetterForm::OnActionPerformed(const Control& source, int actionId)
                        if (r == E_SUCCESS)
                        {
                                String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_HOME_SCREEN_WALLPAPER;
-                               r = image.EncodeToFile(*__currentBitmap, IMG_FORMAT_JPG, destPath, true);
+                               r = image.EncodeToFile(*__pCurrentBitmap, IMG_FORMAT_JPG, destPath, true);
                                if (r == E_SUCCESS)
                                {
                                        r = SettingInfo::SetValue(SETTING_VALUE_HOME_SCREEN_WALLPAPER, destPath);
@@ -317,7 +318,7 @@ ImageSetterForm::OnActionPerformed(const Control& source, int actionId)
                        if (r == E_SUCCESS)
                        {
                                String destPath = App::GetInstance()->GetAppRootPath() + TEMP_FILE_PATH_LOCK_SCREEN_WALLPAPER;
-                               r = image.EncodeToFile(*__currentBitmap, IMG_FORMAT_JPG, destPath, true);
+                               r = image.EncodeToFile(*__pCurrentBitmap, IMG_FORMAT_JPG, destPath, true);
                                if (r == E_SUCCESS)
                                {
                                        r = SettingInfo::SetValue(SETTING_VALUE_LOCK_SCREEN_WALLPAPER, destPath);
index 7fae9de..496273e 100644 (file)
@@ -209,6 +209,7 @@ ImageViewerApp::OnAppControlRequestReceived(RequestId reqId, const String& opera
                else
                {
                        delete pArguments;
+                       pArguments = null;
                }
        }
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
index 0e7cde9..75b2f46 100644 (file)
@@ -103,7 +103,6 @@ ImageViewerForm::ImageViewerForm(void)
 , __pDetailFooterItem(null)
 , __pGallery(null)
 , __pTimer(null)
-, __pDecodeBitmap(null)
 , __pContextMenuMore(null)
 , __pContextMenuCopy(null)
 , __pContextMenuSetAs(null)
@@ -192,9 +191,9 @@ ImageViewerForm::OnInitializing(void)
        InitializePanelDetail();
        InitializePopup();
 
-       if (    __initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
-                       || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
-                       || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
+       if (__initializeDisplayModeCurrent == APPCONTROL_MODE_NORMAL
+               || __initializeDisplayModeCurrent == APPCONTROL_MODE_MESSAGE
+               || __initializeDisplayModeCurrent == APPCONTROL_MODE_EMAIL)
        {
                int index = __pPresentationModel->GetStartIndex();
                __pGallery->UpdateGallery();
@@ -215,7 +214,6 @@ ImageViewerForm::OnInitializing(void)
                __pTimer->Construct(*this);
                __pTimer->Start(1);
        }
-
        result r = SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
        AddOrientationEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -303,13 +301,13 @@ ImageViewerForm::InitializeDisplay(AppControlMode status)
                __pFooter->RemoveButtonAt(BUTTON_POSITION_LEFT);
                __pFooter->SetBackButton();
 
-               FooterItem  footerItem1;
+               FooterItem footerItem1;
                footerItem1.Construct(ACTION_ID_FOOTER_BUTTON_SHARE);
                Bitmap* pFooterItemShareNomal =
                                ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL);
                footerItem1.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pFooterItemShareNomal);
 
-               FooterItem  footerItem2;
+               FooterItem footerItem2;
                footerItem2.Construct(ACTION_ID_FOOTER_BUTTON_DELETE);
                Bitmap* pFooterItemDeleteNomal =
                                ResourceManager::GetBitmapN(IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL);
@@ -725,6 +723,7 @@ ImageViewerForm::InitializeContextMenuMore(void)
        {
                __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_IV_OPT_SET_AS"),
                                ACTION_ID_CONTEXTMENU_SET_AS);
+               __pContextMenuMore->AddItem("Crop", ACTION_ID_FOOTER_BUTTON_CROP);
        }
 
        if (__pGallery->GetItemCount() > 1)
@@ -1355,6 +1354,15 @@ ImageViewerForm::OnActionPerformed(const Control& source, int actionId)
                }
                break;
        }
+       case ACTION_ID_FOOTER_BUTTON_CROP:
+       {
+               String filePath;
+               ArrayList* pList = new (std::nothrow) ArrayList(SingleObjectDeleter);
+               filePath = __pPresentationModel->GetFilePathAt(__pGallery->GetCurrentItemIndex());
+               pList->Add(new (std::nothrow) String(filePath));
+               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_CROP), pList);
+       }
+       break;
        case ACTION_ID_FOOTER_BUTTON_DETAILS:
        {
                ShowPanelDetail(__detail);
index 9589071..0f1707e 100644 (file)
@@ -55,6 +55,7 @@ MainFrame::OnInitializing(void)
 
        pSceneManager->RegisterScene(IDSCN_IMAGE_VIEWER, FORM_IMAGE_VIEWER, PANEL_BLANK);
        pSceneManager->RegisterScene(IDSCN_IMAGE_SETTER, FORM_IMAGE_SETTER, PANEL_BLANK);
+       pSceneManager->RegisterScene(IDSCN_IMAGE_CROP, FORM_IMAGE_CROP, PANEL_BLANK);
        pSceneManager->RegisterScene(IDSCN_IMAGE_NAME_EDITOR, FORM_IMAGE_NAME_EDITOR, PANEL_BLANK);
 
        ImageViewerApp* pImageViewerApp = static_cast<ImageViewerApp*>(ImageViewerApp::GetInstance());
index 3f2ac5a..32e56c2 100644 (file)
 const wchar_t* IDL_FORM_IMAGE_VIEWER = L"IDL_FORM_IMAGE_VIEWER";
 const wchar_t* IDL_FORM_IMAGE_SETTER = L"IDL_FORM_IMAGE_SETTER";
 const wchar_t* IDL_FORM_NAME_EDITOR = L"IDL_FORM_NAME_EDITOR";
+const wchar_t* IDL_FORM_IMAGE_CROP = L"IDL_FORM_IMAGE_CROP";
 
 const wchar_t* FORM_IMAGE_VIEWER = L"ImageViewerForm";
 const wchar_t* FORM_IMAGE_SETTER = L"ImageSetterForm";
+const wchar_t* FORM_IMAGE_CROP = L"ImageCropForm";
 const wchar_t* FORM_IMAGE_NAME_EDITOR = L"ImageNameEditorForm";
 
 const wchar_t* IDSCN_IMAGE_VIEWER = L"SceneImageView";
 const wchar_t* IDSCN_IMAGE_SETTER = L"SceneImageSetterForm";
+const wchar_t* IDSCN_IMAGE_CROP = L"SceneImageCropForm";
 const wchar_t* IDSCN_IMAGE_NAME_EDITOR = L"SceneImageNameEditorForm";
 
 const wchar_t* APPCONTROL_PROVIDER_ID_MESSAGES = L"tizen.messages";
@@ -113,6 +116,12 @@ const wchar_t* IDB_IMAGE_VIEWERFORM_MORE_NORMAL = L"00_icon_more.png";
 const wchar_t* IDB_IMAGE_VIEWERFORM_MORE_PRESSED = L"00_icon_more_press.png";
 const wchar_t* IDB_IMAGE_VIEWERFORM_FOOTER_ICON_SHARE_NORMAL = L"T01_controlbar_icon_share02.png";
 const wchar_t* IDB_IMAGE_VIEWERFORM_FOOTER_ICON_DELETE_NORMAL = L"T01_controlbar_icon_delete.png";
+const wchar_t* IDB_IMAGE_CROP_FORM_SAVE_ICON = L"T01-1_control_icon_save.png";
+const wchar_t* IDB_IMAGE_CROP_FORM_CANCEL_ICON = L"T01-1_control_icon_cancel.png";
+const wchar_t* IDB_IMAGE_CROP_FORM_CW_ROTATION_ICON = L"T01-1_control_icon_CW.png";
+const wchar_t* IDB_IMAGE_CROP_FORM_CCW_ROTATION_ICON = L"T01-1_control_icon_CCW.png";
+const wchar_t* IDB_IMAGE_CROP_FORM_ITEM_DIVIDER_ICON = L"T01_1_controlbar_bg.png";
+const wchar_t* IDB_IMAGE_CROP_RECTANGLE = L"T01-1_crop_rectangle.png";
 
 const wchar_t* IDB_IMAGE_SETTERFORM_BUTTON_SET = L"T01_btn_SetCallerimage.png";
 const wchar_t* IDB_IMAGE_SETTERFORM_BUTTON_SET_PRESS = L"T01_btn_SetCallerimage_press.png";
@@ -130,3 +139,7 @@ const wchar_t* ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE = L"SHUFFLE_VALUE";
 
 const wchar_t* DEVICE_STORAGE_CARD_MOUNTED = L"Mounted";
 const wchar_t* DEVICE_STORAGE_CARD_UNMOUNTED = L"Unmounted";
+
+const int FOOTER_PANEL_HEIGHT = 98;
+const int INDICATOR_BAR_HEIGHT = 60;
+const int CROP_RECTANGLE_HEIGHT = 20;