2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrlOverlayPanel.h
20 * @brief This is the header file for the %OverlayPanel class.
22 * This header file contains the declarations of the %OverlayPanel class.
25 #ifndef _FUI_CTRL_OVERLAY_PANEL_H_
26 #define _FUI_CTRL_OVERLAY_PANEL_H_
28 #include <FBaseTypes.h>
29 #include <FGrpCanvas.h>
30 #include <FUiCtrlPanel.h>
32 namespace Tizen { namespace Ui { namespace Controls
36 * @enum OverlayPanelEvaluationOption
38 * Defines the option for evaluating the bounds of an overlay panel.
42 enum OverlayPanelEvaluationOption
44 OVERLAY_PANEL_EVAL_OPT_GREATER_THAN, /**< The option evaluating the overlay panel bounds and finding the minimum bounds greater than the input bounds */
45 OVERLAY_PANEL_EVAL_OPT_LESS_THAN /**< The option evaluating the overlay panel bounds and finding the maximum bounds smaller than input bounds */
50 * @brief This class is an implementation of %OverlayPanel.
54 * @remarks The %OverlayPanel control can only be attached to a %Form control by using Tizen::Ui::Container::AddControl method, because of its native
55 * characteristics. Since %OverlayPanel inherits a Panel control, it can be used as a container if needed.
57 * The %OverlayPanel class is an implementation of the %OverlayPanel control.
58 * The %OverlayPanel is a special type of panel which is used to specify area where the developer
59 * can playback video or camera preview. It is called an overlay because it is possible to overlay
60 * other graphics and controls on top of the panel.
61 * The %OverlayPanel consists of two layers, the foreground panel and background buffer which supports
62 * H/W accelerated rendering. Due to the hardware accelerated nature, there is a limitation with an
63 * %OverlayPanel. The Form that houses an %OverlayPanel can only have a black, opaque background.
64 * The overlay panel can manipulate the rotation and the size of input buffer.
66 * Example: Please refer to the camera preview example of %Tizen::Media::Camera
69 //Sample code for OverlayPanelSampleForm.h
74 class OverlayPanelSampleForm
75 : public Tizen::Ui::Controls::Form
76 , public Tizen::Ui::IActionEventListener
77 , public Tizen::Media::IPlayerEventListener
80 OverlayPanelSampleForm(void);
81 virtual ~OverlayPanelSampleForm(void);
83 bool Initialize(void);
84 virtual result OnInitializing(void);
85 virtual result OnTerminating(void);
86 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
88 // IPlayerEventListener
89 virtual void OnPlayerOpened(result r);
90 virtual void OnPlayerEndOfClip(void);
91 virtual void OnPlayerSeekCompleted(result r);
92 virtual void OnPlayerBuffering(int percent);
93 virtual void OnPlayerErrorOccurred(const Tizen::Media::PlayerErrorReason r);
94 virtual void OnPlayerInterrupted(void);
95 virtual void OnPlayerReleased(void);
98 static const int ID_BUTTON_OK = 101;
100 Tizen::Media::Player* __pPlayer;
101 Tizen::Ui::Controls::OverlayPanel* __pOverlayPanel;
106 //Sample code for OverlayPanelSampleForm.cpp
108 #include "OverlayPanelSampleForm.h"
110 using namespace Tizen::App;
111 using namespace Tizen::Base;
112 using namespace Tizen::Graphics;
113 using namespace Tizen::Media;
114 using namespace Tizen::Ui::Controls;
116 OverlayPanelSampleForm::OverlayPanelSampleForm(void)
120 OverlayPanelSampleForm::~OverlayPanelSampleForm(void)
125 OverlayPanelSampleForm::Initialize(void)
127 Construct(FORM_STYLE_NORMAL);
132 OverlayPanelSampleForm::OnInitializing(void)
134 // Set bounds of overlay panel
135 Rectangle overlayPanelBounds(10, 10, GetClientAreaBounds().width - 20, 500);
138 bool isModifiedBounds = false;
139 result r = OverlayPanel::EvaluateBounds(OVERLAY_PANEL_EVAL_OPT_GREATER_THAN, overlayPanelBounds, isModifiedBounds);
141 // Creates an instance of overlay panel
142 __pOverlayPanel = new OverlayPanel();
143 __pOverlayPanel->Construct(overlayPanelBounds);
144 AddControl(__pOverlayPanel);
146 // Gets a background buffer info
147 BufferInfo bufferinfo;
148 __pOverlayPanel->GetBackgroundBufferInfo(bufferinfo);
150 // Gets a video file path (/res/video.mp4)
151 String videoFilePath = App::GetInstance()->GetAppResourcePath() + L"video.mp4";
153 // Creates an instance of Player
154 __pPlayer = new Player();
155 __pPlayer->Construct(*this, &bufferinfo);
156 __pPlayer->OpenFile(videoFilePath);
159 // Creates an instance of Button
160 Button *pButton = new Button();
161 pButton->Construct(Rectangle(10, 10, 300, 100));
162 pButton->SetText(L"Resize & Rotate");
163 pButton->SetActionId(ID_BUTTON_OK);
164 pButton->AddActionEventListener(*this);
165 __pOverlayPanel->AddControl(pButton);
171 OverlayPanelSampleForm::OnTerminating(void)
173 result r = E_SUCCESS;
175 // Deallocates controls
186 OverlayPanelSampleForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
192 //Modify renderer size & Rotate renderer
193 __pOverlayPanel->SetRenderSize(Dimension(400, 400));
194 __pOverlayPanel->SetRendererRotation(OverlayPanel::ROTATION_270);
202 // IPlayerEventListener implementation
204 OverlayPanelSampleForm::OnPlayerOpened(result r)
210 OverlayPanelSampleForm::OnPlayerEndOfClip(void)
216 OverlayPanelSampleForm::OnPlayerSeekCompleted(result r)
222 OverlayPanelSampleForm::OnPlayerBuffering(int percent)
228 OverlayPanelSampleForm::OnPlayerErrorOccurred(const PlayerErrorReason r)
234 OverlayPanelSampleForm::OnPlayerInterrupted(void)
240 OverlayPanelSampleForm::OnPlayerReleased(void)
247 class _OSP_EXPORT_ OverlayPanel
248 : public Tizen::Ui::Controls::Panel
254 * Defines the various rotation options.
260 ROTATION_NONE, /**< No rotation*/
261 ROTATION_90, /**< The 90 degree rotation */
262 ROTATION_180, /**< The 180 degree rotation */
263 ROTATION_270, /**< The 270 degree rotation */
264 ROTATION_NONE_LR, /**< The horizontal mirroring */
265 ROTATION_NONE_UD, /**< The vertical mirroring */
266 ROTATION_90_LR, /**< The 90 degree rotation with horizontal mirroring */
267 ROTATION_90_UD, /**< The 90 degree rotation with vertical mirroring */
268 ROTATION_180_LR, /**< The 180 degree rotation with horizontal mirroring */
269 ROTATION_180_UD, /**< The 180 degree rotation with vertical mirroring */
270 ROTATION_270_LR, /**< The 270 degree rotation with horizontal mirroring */
271 ROTATION_270_UD, /**< The 270 degree rotation with vertical mirroring */
276 * @enum BufferPixelFormat
278 * Defines the pixel formats.
282 enum BufferPixelFormat
284 BUFFER_PIXEL_FORMAT_ARGB8888, /**< The ARGB8888 pixel format */
285 BUFFER_PIXEL_FORMAT_RGB565, /**< The RGB565 pixel format */
286 BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR, /**< The 8 bit Y plane followed by 8 bit 2 X 2 subsampled U and V planes */
287 BUFFER_PIXEL_FORMAT_NV12, /**< The NV12 pixel format */
288 BUFFER_PIXEL_FORMAT_UYVY /**< The UYVY pixel format */
292 * This is the default constructor for this class.
293 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
300 * This destructor overrides Tizen::Base::Object::~Object().
304 virtual ~OverlayPanel(void);
307 * Initializes this instance of %OverlayPanel at the specified rectangle.
311 * @return An error code
312 * @param[in] rect The location and size of the %OverlayPanel control @n
313 * The maximum size is equal to screen size. for example 720 x 1280 on a HD screen, or 480 x 800 on a WVGA screen. @n
314 * @exception E_SUCCESS The method is successful.
315 * @exception E_INVALID_ARG A specified input parameter @c is invalid.
316 * @exception E_SYSTEM A system error has occurred.
317 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
318 * To guarantee the size of the render buffer equal to the size of the %OverlayPanel after constructed, checks bounds of @c rect using EvaluateBounds() method before calling this method.
319 * @remarks Do not use %OverlayPanel in combination with %OverlayRegion. If used, %OverlayPanel may not work as expected.
320 * @see %Tizen::Ui::Container
322 result Construct(const Tizen::Graphics::Rectangle& rect);
325 * Initializes this instance of %OverlayPanel at the specified rectangle.
329 * @return An error code
330 * @param[in] rect The location and size of the %OverlayPanel control @n
331 * The maximum size is equal to screen size. for example 720 x 1280 on a HD screen, or 480 x 800 on a WVGA screen. @n
332 * @exception E_SUCCESS The method is successful.
333 * @exception E_INVALID_ARG A specified input parameter @c is invalid.
334 * @exception E_SYSTEM A system error has occurred.
335 * @remarks The size of the control must be within the range defined by the minimum size and the maximum size.
336 * To guarantee the size of the render buffer equal to the size of the %OverlayPanel after constructed, checks bounds of @c rect using EvaluateBounds() method before calling this method.
337 * @remarks Do not use %OverlayPanel in combination with %OverlayRegion. If used, %OverlayPanel may not work as expected.
338 * @see %Tizen::Ui::Container
340 result Construct(const Tizen::Graphics::FloatRectangle& rect);
343 * Sets the rotation of the input buffer. @n
347 * @param[in] rotation The rotation
349 void SetRendererRotation(OverlayPanel::Rotation rotation);
353 * Changes the size of the displayed renderer.
355 * @brief <i> [Deprecated] </i>
356 * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview.
359 * @param[in] dim The dimension of the window to draw
363 void SetRendererSize(Tizen::Graphics::Dimension& dim);
366 * Changes the size of the displayed renderer.
370 * @return An error code
371 * @param[in] dim The dimension of the window to draw
372 * @exception E_SUCCESS The method is successful.
373 * @exception E_INVALID_ARG A specified input parameter is invalid.
374 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
375 * @remarks A OverlayPanel becomes displayable only after it has been added to a form.
376 * If you want to resize window to draw render buffer, calls this function after the OverlayPanel is added to a %Form control
378 * OverlayPanel* pOverlayPanel = new OverlayPanel();
379 * pOverlayPanel->Construct(Rectangle(100, 250, 300, 300));
380 * AddControl(pOverlayPanel);
383 * result r = pOverlayPanel->SetRenderSize(Dimesion(300, 200));
387 result SetRenderSize(const Tizen::Graphics::Dimension& dim);
390 * Changes the size of the displayed renderer.
394 * @return An error code
395 * @param[in] dim The dimension of the window to draw
396 * @exception E_SUCCESS The method is successful.
397 * @exception E_INVALID_ARG A specified input parameter is invalid.
398 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
399 * @remarks A OverlayPanel becomes displayable only after it has been added to a form.
400 * If you want to resize window to draw render buffer, calls this function after the OverlayPanel is added to a %Form control
402 * OverlayPanel* pOverlayPanel = new OverlayPanel();
403 * pOverlayPanel->Construct(FloatRectangle(100.0, 250.0, 300.0, 300.0));
404 * AddControl(pOverlayPanel);
407 * result r = pOverlayPanel->SetRenderSize(FloatDimesion(300.0, 200.0));
411 result SetRenderSize(const Tizen::Graphics::FloatDimension& dim);
414 * Sets the input buffer.
418 * @param[in] destDim The dimension of the window to be drawn
419 * @param[in] srcBuffer The source buffer
420 * @param[in] srcDim The source dimension
421 * @param[in] srcFormat The pixel format of buffer data
422 * @exception E_SUCCESS The method is successful.
423 * @exception E_INVALID_ARG A specified input parameter is invalid.
424 * @exception E_SYSTEM A system error has occurred.
425 * @exception E_UNSUPPORTED_FORMAT The specified pixel format is not supported.
426 * @remarks Control::Invalidate() methods must be called to properly display the input buffer.
428 result SetInputBuffer(const Tizen::Graphics::Dimension& destDim, const Tizen::Base::ByteBuffer& srcBuffer, const Tizen::Graphics::Dimension& srcDim, BufferPixelFormat srcFormat);
431 * Sets the input buffer.
435 * @param[in] destDim The dimension of the window to be drawn
436 * @param[in] srcBuffer The source buffer
437 * @param[in] srcDim The source dimension
438 * @param[in] srcFormat The pixel format of buffer data
439 * @exception E_SUCCESS The method is successful.
440 * @exception E_INVALID_ARG A specified input parameter is invalid.
441 * @exception E_SYSTEM A system error has occurred.
442 * @exception E_UNSUPPORTED_FORMAT The specified pixel format is not supported.
443 * @remarks Control::Invalidate() methods must be called to properly display the input buffer.
445 result SetInputBuffer(const Tizen::Graphics::FloatDimension& destDim, const Tizen::Base::ByteBuffer& srcBuffer, const Tizen::Graphics::Dimension& srcDim, BufferPixelFormat srcFormat);
448 * Gets the information of the background buffer.
452 * @return An error code
453 * @param[out] info The information of the background buffer
454 * @exception E_SUCCESS The method is successful.
455 * @exception E_OPERATION_FAILED The operation has failed.
456 * @remarks Currently, this method provides buffer information except the pointer of the RGB color buffer. @n
457 * Therefore, info.pPixels is always assigned @c null.
459 result GetBackgroundBufferInfo(Tizen::Graphics::BufferInfo& info) const;
463 * Sets the aspect ratio of the renderer.
465 * @brief <i> [Deprecated] </i>
466 * @deprecated This method is deprecated because the renderer aspect ratio is not guaranteed any more.
469 * @param[in] fix Set to @c true if the renderer will display the aspect ratio of the input buffer even if the renderer and input data have
470 * different aspect ratios, @n
472 * @remarks This method has no effects for hardware accelerated GL backend.
475 void SetRendererAspectRatio(bool fix);
479 * Gets the masking color of this control.
481 * @brief <i> [Deprecated] </i>
482 * @deprecated This method is deprecated because masking color does not exist on OverlayPanel any more.
483 * @remarks Do not call this method. It is not supported.
486 * @return Always returns Tizen::Graphics::Color(0x00000000)
489 Tizen::Graphics::Color GetMaskingColor(void) const;
492 * Evaluates and returns the valid position and size that are closest to the specified bounds.
496 * @return An error code
497 * @param[in] option The option for evaluating the bounds of the overlay panel
498 * @param[in, out] rect An instance of %Tizen::Graphics::Rectangle that represents the validated bounds of %OverlayPanel @n
499 * The width and height of the input rectangle must be greater than @c 0.
500 * @param[out] modified A boolean flag that indicates whether the specified @c rectangle is modified
501 * @exception E_SUCCESS The method is successful.
502 * @exception E_INVALID_ARG The specified input parameter @c is invalid.
503 * @exception E_UNSUPPORTED_OPTION The specified input parameter @c is not supported.
504 * @exception E_OPERATION_FAILED The operation has failed.
505 * @remarks Due to the hardware accelerated rendering, there are limitations for an overlay panel. @n
506 * The hardware capability for an overlay region is checked by using the GetWidthUnit(), GetHeightUnit() and GetMaxCount(). @n
507 * If the application runs on multi-screen resolutions, the specified bounds may not meet the hardware limitations of the overlay panel.
508 * In such cases, Construct() will return E_INVALID_ARG. @n
509 * To prevent this kind of problem, the application must use the OverlayPanel::EvaluateBounds() method to get a validated bounds
510 * @remarks The specific error code can be accessed using the GetLastResult() method.
512 static result EvaluateBounds(OverlayPanelEvaluationOption option, Tizen::Graphics::Rectangle& rect, bool& modified);
515 * Evaluates and returns the valid position and size that are closest to the specified bounds.
519 * @return An error code
520 * @param[in] option The option for evaluating the bounds of the overlay panel
521 * @param[in, out] rect An instance of %Tizen::Graphics::FloatRectangle that represents the validated bounds of %OverlayPanel @n
522 * The width and height of the input float rectangle must be greater than @c 0.
523 * @param[out] modified A boolean flag that indicates whether the specified @c rectangle is modified
524 * @exception E_SUCCESS The method is successful.
525 * @exception E_INVALID_ARG The specified input parameter @c is invalid.
526 * @exception E_UNSUPPORTED_OPTION The specified input parameter @c is not supported.
527 * @exception E_OPERATION_FAILED The operation has failed.
528 * @remarks Due to the hardware accelerated rendering, there are limitations for an overlay panel. @n
529 * The hardware capability for an overlay region is checked by using the GetWidthUnit(), GetHeightUnit() and GetMaxCount(). @n
530 * If the application runs on multi-screen resolutions, the specified bounds may not meet the hardware limitations of the overlay panel.
531 * In such cases, Construct() will return E_INVALID_ARG. @n
532 * To prevent this kind of problem, the application must use the OverlayPanel::EvaluateBounds() method to get a validated bounds
533 * @remarks The specific error code can be accessed using the GetLastResult() method.
535 static result EvaluateBounds(OverlayPanelEvaluationOption option, Tizen::Graphics::FloatRectangle& rect, bool& modified);
538 * Gets the BufferPixelFormat list for the %OverlayPanel class. @n
539 * Each list item has a Tizen::UI::Controls::OverlayPanel::BufferPixelFormat value.
543 * @return A list of the pixel formats supported by the %OverlayPanel class, @n
544 * else @c null if no pixel format is supported or an exception occurs
545 * @remark The specific error code can be accessed using the GetLastResult() method. @n
546 * The return value and each item in the list must be deleted by the caller. @n
547 * The format list can vary depending on the device. After checking the supported formats using this API, it's better to use a proper pixel format. @n
549 static Tizen::Base::Collection::IListT<BufferPixelFormat>* GetSupportedBufferPixelFormatListN(void);
552 * Gets the width unit. @n
553 * Only a multiple of this value can be allowed as the width of an overlay panel.
557 * @return The value of width
559 static int GetWidthUnit(void);
562 * Gets the height unit. @n
563 * Only a multiple of this value can be allowed as the height of an overlay panel.
567 * @return The value of the height
569 static int GetHeightUnit(void);
572 * Gets the maximum count of overlay panel that can be used simultaneously per application.
576 * @return The maximum count of overlay panel that can be used simultaneously per application
578 static int GetMaxCount(void);
582 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
584 OverlayPanel(const OverlayPanel& rhs);
587 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
589 OverlayPanel& operator =(const OverlayPanel& rhs);
592 }}} // Tizen::Ui::Controls
594 #endif // _FUI_CTRL_OVERLAY_PANEL_H_