$(FRIBIDI_LIBS) \
$(HTMLCXX_LIBS)
- # Install Base headers
-
- toplevelbasedir = $(devincludepath)/dali-toolkit
-
- publicapibasedir = $(toplevelbasedir)/public-api
- publicapibasecontrolsdir = $(publicapibasedir)/controls
- publicapibasealignmentdir = $(publicapibasedir)/controls/alignment
- publicapibasebuttonsdir = $(publicapibasedir)/controls/buttons
- publicapibasedefaultcontrolsdir = $(publicapibasedir)/controls/default-controls
- publicapibaseitemviewdir = $(publicapibasedir)/controls/scrollable/item-view
- publicapibasepopupdir = $(publicapibasedir)/controls/popup
- publicapibasescrollbardir = $(publicapibasedir)/controls/scroll-bar
- publicapibasescrollcomponentdir = $(publicapibasedir)/controls/scroll-component
- publicapibasescrollabledir = $(publicapibasedir)/controls/scrollable
- publicapibasescrollviewdir = $(publicapibasedir)/controls/scrollable/scroll-view
- publicapibasetableviewdir = $(publicapibasedir)/controls/table-view
- publicapibasetextcontrolsdir = $(publicapibasedir)/controls/text-controls
- publicapibasetextdir = $(publicapibasedir)/text
- publicapibasetextlayoutsdir = $(publicapibasedir)/text/layouts
- publicapibasetextrenderingdir = $(publicapibasedir)/text/rendering
- publicapibasetextrenderingbasicdir = $(publicapibasedir)/text/rendering/basic
- publicapibasetextrenderingshadersdir = $(publicapibasedir)/text/rendering/shaders
- publicapibasefactorydir = $(publicapibasedir)/factory
- publicapibasefocusmanagerdir = $(publicapibasedir)/focus-manager
- publicapibasemarkupprocessordir = $(publicapibasedir)/markup-processor
- publicapibaseshadereffectsdir = $(publicapibasedir)/shader-effects
- publicapibasestylingdir = $(publicapibasedir)/styling
- publicapibasebuilderdir = $(publicapibasedir)/builder
-
- publicapibase_HEADERS = $(public_api_base_header_files)
- publicapibasecontrols_HEADERS = $(public_api_base_controls_header_files)
- publicapibasealignment_HEADERS = $(public_api_base_alignment_header_files)
- publicapibasebuttons_HEADERS = $(public_api_base_buttons_header_files)
- publicapibasedefaultcontrols_HEADERS = $(public_api_base_default_controls_header_files)
- publicapibaseitemview_HEADERS = $(public_api_base_item_view_header_files)
- publicapibasepopup_HEADERS = $(public_api_base_popup_header_files)
- publicapibasescrollbar_HEADERS = $(public_api_base_scroll_bar_header_files)
- publicapibasescrollcomponent_HEADERS = $(public_api_base_scroll_component_header_files)
- publicapibasescrollable_HEADERS = $(public_api_base_scrollable_header_files)
- publicapibasescrollview_HEADERS = $(public_api_base_scroll_view_header_files)
- publicapibasetableview_HEADERS = $(public_api_base_table_view_header_files)
- publicapibasetextcontrols_HEADERS = $(public_api_base_text_controls_header_files)
- publicapibasetext_HEADERS = $(public_api_base_text_header_files)
- publicapibasetextlayouts_HEADERS = $(public_api_base_text_layouts_header_files)
- publicapibasetextrendering_HEADERS = $(public_api_base_text_rendering_header_files)
- publicapibasetextrenderingbasic_HEADERS = $(public_api_base_text_rendering_basic_header_files)
- publicapibasetextrenderingshaders_HEADERS = $(public_api_base_text_rendering_shaders_header_files)
- publicapibasefocusmanager_HEADERS = $(public_api_base_focus_manager_header_files)
- publicapibasemarkupprocessor_HEADERS = $(public_api_base_markup_processor_header_files)
- publicapibaseshadereffects_HEADERS = $(public_api_base_shader_effects_header_files)
- publicapibasestyling_HEADERS = $(public_api_base_styling_header_files)
- publicapibasebuilder_HEADERS = $(public_api_base_builder_header_files)
-
- # Install Optional headers
-
- topleveloptionaldir = $(devincludepath)/dali-toolkit
- topleveloptional_HEADERS = ../../../optional/dali-toolkit/dali-toolkit.h
-
- publicapioptionaldir = $(topleveloptionaldir)/public-api
- publicapioptionalcontrolsdir = $(publicapioptionaldir)/controls
- publicapioptionalbloomviewdir = $(publicapioptionaldir)/controls/bloom-view
- publicapioptionalclusterdir = $(publicapioptionaldir)/controls/cluster
- publicapioptionaleffectsviewdir = $(publicapioptionaldir)/controls/effects-view
- publicapioptionalgaussianblurviewdir = $(publicapioptionaldir)/controls/gaussian-blur-view
- publicapioptionalimageviewdir = $(publicapioptionaldir)/controls/image-view
- publicapioptionalmagnifierdir = $(publicapioptionaldir)/controls/magnifier
- publicapioptionalpageturnviewdir = $(publicapioptionaldir)/controls/page-turn-view
- publicapioptionalsliderdir = $(publicapioptionaldir)/controls/slider
- publicapioptionaltoolbardir = $(publicapioptionaldir)/controls/tool-bar
- publicapioptionalselectorsdir = $(publicapioptionaldir)/controls/selectors
- publicapioptionalshadowviewdir = $(publicapioptionaldir)/controls/shadow-view
- publicapioptionalbubbleemitterdir = $(publicapioptionaldir)/controls/bubble-effect
- publicapioptionalsuperblurviewdir = $(publicapioptionaldir)/controls/super-blur-view
- publicapioptionalviewdir = $(publicapioptionaldir)/controls/view
- publicapioptionalnavigationframedir = $(publicapioptionaldir)/controls/navigation-frame
- publicapioptionalshadereffectsdir = $(publicapioptionaldir)/shader-effects
- publicapioptionalbubbleeffectdir = $(publicapioptionaldir)/shader-effects/bubble-effect
- publicapioptionaltransitioneffectsdir = $(publicapioptionaldir)/transition-effects
-
- publicapioptional_HEADERS = $(public_api_optional_header_files)
- publicapioptionalcontrols_HEADERS = $(public_api_optional_controls_header_files)
- publicapioptionalbloomview_HEADERS = $(public_api_optional_bloom_view_header_files)
- publicapioptionalcluster_HEADERS = $(public_api_optional_cluster_header_files)
- publicapioptionaleffectsview_HEADERS = $(public_api_optional_effects_view_header_files)
- publicapioptionalgaussianblurview_HEADERS = $(public_api_optional_gaussian_blur_view_header_files)
- publicapioptionalimageview_HEADERS = $(public_api_optional_image_view_header_files)
- publicapioptionalmagnifier_HEADERS = $(public_api_optional_magnifier_header_files)
- publicapioptionalpageturnview_HEADERS = $(public_api_optional_page_turn_view_header_files)
- publicapioptionalslider_HEADERS = $(public_api_optional_slider_header_files)
- publicapioptionaltoolbar_HEADERS = $(public_api_optional_tool_bar_header_files)
- publicapioptionalselectors_HEADERS = $(public_api_optional_selectors_header_files)
- publicapioptionalshadowview_HEADERS = $(public_api_optional_shadow_view_header_files)
- publicapioptionalbubbleemitter_HEADERS = $(public_api_optional_bubble_emitter_header_files)
- publicapioptionalsuperblurview_HEADERS = $(public_api_optional_super_blur_view_header_files)
- publicapioptionalview_HEADERS = $(public_api_optional_view_header_files)
- publicapioptionalnavigationframe_HEADERS = $(public_api_optional_navigation_frame_header_files)
- publicapioptionalshadereffects_HEADERS = $(public_api_optional_shader_effects_header_files)
- publicapioptionalbubbleeffect_HEADERS = $(public_api_optional_bubble_effect_header_files)
- publicapioptionaltransitioneffects_HEADERS = $(public_api_optional_transition_effects_header_files)
+ # Install headers
+
+ topleveldir = $(devincludepath)/dali-toolkit
+ toplevel_HEADERS = ../../../dali-toolkit/dali-toolkit.h
+
+ publicapidir = $(topleveldir)/public-api
+
+ publicapicontrolsdir = $(publicapidir)/controls
+ publicapialignmentdir = $(publicapicontrolsdir)/alignment
+ publicapibloomviewdir = $(publicapicontrolsdir)/bloom-view
+ publicapibubbleemitterdir = $(publicapicontrolsdir)/bubble-effect
+ publicapibuttonsdir = $(publicapicontrolsdir)/buttons
+ publicapiclusterdir = $(publicapicontrolsdir)/cluster
+ publicapidefaultcontrolsdir = $(publicapicontrolsdir)/default-controls
+ publicapieffectsviewdir = $(publicapicontrolsdir)/effects-view
+ publicapigaussianblurviewdir = $(publicapicontrolsdir)/gaussian-blur-view
+ publicapiimageviewdir = $(publicapicontrolsdir)/image-view
+ publicapiitemviewdir = $(publicapicontrolsdir)/scrollable/item-view
+ publicapimagnifierdir = $(publicapicontrolsdir)/magnifier
+ publicapinavigationframedir = $(publicapicontrolsdir)/navigation-frame
+ publicapipageturnviewdir = $(publicapicontrolsdir)/page-turn-view
+ publicapipopupdir = $(publicapicontrolsdir)/popup
+ publicapiscrollbardir = $(publicapicontrolsdir)/scroll-bar
+ publicapiscrollcomponentdir = $(publicapicontrolsdir)/scroll-component
+ publicapiscrollabledir = $(publicapicontrolsdir)/scrollable
+ publicapiscrollviewdir = $(publicapicontrolsdir)/scrollable/scroll-view
+ publicapiselectorsdir = $(publicapicontrolsdir)/selectors
+ publicapishadowviewdir = $(publicapicontrolsdir)/shadow-view
+ publicapisliderdir = $(publicapicontrolsdir)/slider
+ publicapisuperblurviewdir = $(publicapicontrolsdir)/super-blur-view
+ publicapitableviewdir = $(publicapicontrolsdir)/table-view
-publicapitextviewdir = $(publicapicontrolsdir)/text-view
-publicapitextinputdir = $(publicapicontrolsdir)/text-input
++publicapitextcontrolsdir = $(publicapidir)/controls/text-controls
++publicapitextdir = $(publicapidir)/text
++publicapitextlayoutsdir = $(publicapidir)/text/layouts
++publicapitextrenderingdir = $(publicapidir)/text/rendering
++publicapitextrenderingbasicdir = $(publicapidir)/text/rendering/basic
++publicapitextrenderingshadersdir = $(publicapidir)/text/rendering/shaders
+ publicapitoolbardir = $(publicapicontrolsdir)/tool-bar
+ publicapiviewdir = $(publicapicontrolsdir)/view
-
+ publicapibuilderdir = $(publicapidir)/builder
+ publicapifocusmanagerdir = $(publicapidir)/focus-manager
-publicapimarkupprocessordir = $(publicapidir)/markup-processor
+ publicapishadereffectsdir = $(publicapidir)/shader-effects
+ publicapibubbleeffectdir = $(publicapidir)/shader-effects/bubble-effect
+ publicapistylingdir = $(publicapidir)/styling
+ publicapitransitioneffectsdir = $(publicapidir)/transition-effects
+
+ publicapi_HEADERS = $(public_api_header_files)
+ publicapicontrols_HEADERS = $(public_api_controls_header_files)
+ publicapialignment_HEADERS = $(public_api_alignment_header_files)
+ publicapibloomview_HEADERS = $(public_api_bloom_view_header_files)
+ publicapibubbleemitter_HEADERS = $(public_api_bubble_emitter_header_files)
+ publicapibuttons_HEADERS = $(public_api_buttons_header_files)
+ publicapicluster_HEADERS = $(public_api_cluster_header_files)
+ publicapidefaultcontrols_HEADERS = $(public_api_default_controls_header_files)
+ publicapieffectsview_HEADERS = $(public_api_effects_view_header_files)
+ publicapigaussianblurview_HEADERS = $(public_api_gaussian_blur_view_header_files)
+ publicapiimageview_HEADERS = $(public_api_image_view_header_files)
+ publicapiitemview_HEADERS = $(public_api_item_view_header_files)
+ publicapimagnifier_HEADERS = $(public_api_magnifier_header_files)
+ publicapinavigationframe_HEADERS = $(public_api_navigation_frame_header_files)
+ publicapipageturnview_HEADERS = $(public_api_page_turn_view_header_files)
+ publicapipopup_HEADERS = $(public_api_popup_header_files)
+ publicapiscrollbar_HEADERS = $(public_api_scroll_bar_header_files)
+ publicapiscrollcomponent_HEADERS = $(public_api_scroll_component_header_files)
+ publicapiscrollable_HEADERS = $(public_api_scrollable_header_files)
+ publicapiscrollview_HEADERS = $(public_api_scroll_view_header_files)
+ publicapiselectors_HEADERS = $(public_api_selectors_header_files)
+ publicapishadowview_HEADERS = $(public_api_shadow_view_header_files)
+ publicapislider_HEADERS = $(public_api_slider_header_files)
+ publicapisuperblurview_HEADERS = $(public_api_super_blur_view_header_files)
+ publicapitableview_HEADERS = $(public_api_table_view_header_files)
-publicapitextview_HEADERS = $(public_api_text_view_header_files)
-publicapitextinput_HEADERS = $(public_api_text_input_header_files)
++publicapitextcontrols_HEADERS = $(public_api_text_controls_header_files)
++publicapitext_HEADERS = $(public_api_text_header_files)
++publicapitextlayouts_HEADERS = $(public_api_text_layouts_header_files)
++publicapitextrendering_HEADERS = $(public_api_text_rendering_header_files)
++publicapitextrenderingbasic_HEADERS = $(public_api_text_rendering_basic_header_files)
++publicapitextrenderingshaders_HEADERS = $(public_api_text_rendering_shaders_header_files)
+ publicapitoolbar_HEADERS = $(public_api_tool_bar_header_files)
+ publicapiview_HEADERS = $(public_api_view_header_files)
-
+ publicapibuilder_HEADERS = $(public_api_builder_header_files)
+ publicapifocusmanager_HEADERS = $(public_api_focus_manager_header_files)
-publicapimarkupprocessor_HEADERS = $(public_api_markup_processor_header_files)
+ publicapishadereffects_HEADERS = $(public_api_shader_effects_header_files)
+ publicapibubbleeffect_HEADERS = $(public_api_bubble_effect_header_files)
+ publicapistyling_HEADERS = $(public_api_styling_header_files)
+ publicapitransitioneffects_HEADERS = $(public_api_transition_effects_header_files)
++
--- /dev/null
-#include <dali-toolkit/public-api/controls/text-input/text-input.h>
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ #ifndef __DALI_TOOLKIT_H__
+ #define __DALI_TOOLKIT_H__
+
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <dali/dali.h>
+
+ // Toolkit
+
+ #include <dali-toolkit/public-api/controls/alignment/alignment.h>
+ #include <dali-toolkit/public-api/controls/bloom-view/bloom-view.h>
+ #include <dali-toolkit/public-api/controls/bubble-effect/bubble-emitter.h>
+ #include <dali-toolkit/public-api/controls/buttons/button.h>
+ #include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
+ #include <dali-toolkit/public-api/controls/buttons/push-button.h>
+ #include <dali-toolkit/public-api/controls/buttons/radio-button.h>
+ #include <dali-toolkit/public-api/controls/cluster/cluster-style.h>
+ #include <dali-toolkit/public-api/controls/cluster/cluster.h>
+ #include <dali-toolkit/public-api/controls/control-impl.h>
+ #include <dali-toolkit/public-api/controls/control.h>
+ #include <dali-toolkit/public-api/controls/default-controls/check-button-factory.h>
+ #include <dali-toolkit/public-api/controls/default-controls/push-button-factory.h>
+ #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
+ #include <dali-toolkit/public-api/controls/effects-view/effects-view.h>
+ #include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
+ #include <dali-toolkit/public-api/controls/image-view/masked-image-view.h>
+ #include <dali-toolkit/public-api/controls/magnifier/magnifier.h>
+ #include <dali-toolkit/public-api/controls/navigation-frame/navigation-control.h>
+ #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
+ #include <dali-toolkit/public-api/controls/page-turn-view/page-factory.h>
+ #include <dali-toolkit/public-api/controls/page-turn-view/page-turn-view.h>
+ #include <dali-toolkit/public-api/controls/page-turn-view/page-turn-landscape-view.h>
+ #include <dali-toolkit/public-api/controls/page-turn-view/page-turn-portrait-view.h>
+ #include <dali-toolkit/public-api/controls/popup/popup.h>
+ #include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
+ #include <dali-toolkit/public-api/controls/scrollable/item-view/depth-layout.h>
+ #include <dali-toolkit/public-api/controls/scrollable/item-view/grid-layout.h>
+ #include <dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h>
+ #include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
+ #include <dali-toolkit/public-api/controls/scrollable/item-view/item-view.h>
+ #include <dali-toolkit/public-api/controls/scrollable/item-view/navigation-layout.h>
+ #include <dali-toolkit/public-api/controls/scrollable/item-view/roll-layout.h>
+ #include <dali-toolkit/public-api/controls/scrollable/item-view/spiral-layout.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-carousel-effect.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-constraints.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-cube-effect.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-depth-effect.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-page-carousel-effect.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-page-cube-effect.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-page-spiral-effect.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-wobble-effect.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
+ #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
+ #include <dali-toolkit/public-api/controls/shadow-view/shadow-view.h>
+ #include <dali-toolkit/public-api/controls/slider/slider.h>
+ #include <dali-toolkit/public-api/controls/super-blur-view/super-blur-view.h>
+ #include <dali-toolkit/public-api/controls/table-view/table-view.h>
-#include <dali-toolkit/public-api/markup-processor/markup-processor.h>
-
++#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+ #include <dali-toolkit/public-api/controls/tool-bar/tool-bar.h>
+ #include <dali-toolkit/public-api/controls/view/view.h>
+
+ #include <dali-toolkit/public-api/focus-manager/focus-manager.h>
+ #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+ #include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
+
+ #include <dali-toolkit/public-api/shader-effects/alpha-discard-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/bendy-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/blind-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/carousel-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/displacement-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/dissolve-local-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/distance-field-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/mirror-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/motion-blur-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/motion-stretch-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/overlay-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/shear-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/soft-button-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/spot-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/square-dissolve-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/water-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/bubble-effect/bubble-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/bubble-effect/color-adjuster.h>
+ #include <dali-toolkit/public-api/shader-effects/dissolve-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/iris-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/mask-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/nine-patch-mask-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/page-turn-book-spine-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/page-turn-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/ripple-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/ripple2d-effect.h>
+ #include <dali-toolkit/public-api/shader-effects/swirl-effect.h>
+
++#include <dali-toolkit/public-api/text/bidirectional-line-info-run.h>
++#include <dali-toolkit/public-api/text/bidirectional-paragraph-info-run.h>
++#include <dali-toolkit/public-api/text/bidirectional-support.h>
++#include <dali-toolkit/public-api/text/character-run.h>
++#include <dali-toolkit/public-api/text/character-set-conversion.h>
++#include <dali-toolkit/public-api/text/font-run.h>
++#include <dali-toolkit/public-api/text/logical-model.h>
++#include <dali-toolkit/public-api/text/multi-language-support.h>
++#include <dali-toolkit/public-api/text/script.h>
++#include <dali-toolkit/public-api/text/segmentation.h>
++#include <dali-toolkit/public-api/text/text-controller.h>
++#include <dali-toolkit/public-api/text/text-definitions.h>
++#include <dali-toolkit/public-api/text/text-view.h>
++#include <dali-toolkit/public-api/text/text-view-interface.h>
++#include <dali-toolkit/public-api/text/visual-model.h>
++#include <dali-toolkit/public-api/text/layouts/layout-engine.h>
++#include <dali-toolkit/public-api/text/rendering/text-renderer.h>
++#include <dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.h>
++#include <dali-toolkit/public-api/text/rendering/shaders/text-basic-shader.h>
++
+ #include <dali-toolkit/public-api/transition-effects/cube-transition-effect.h>
+ #include <dali-toolkit/public-api/transition-effects/cube-transition-wave-effect.h>
+ #include <dali-toolkit/public-api/transition-effects/cube-transition-cross-effect.h>
+ #include <dali-toolkit/public-api/transition-effects/cube-transition-fold-effect.h>
+
+ #include <dali-toolkit/public-api/dali-toolkit-version.h>
+ #include <dali-toolkit/public-api/enums.h>
+
+ #endif // __DALI_TOOLKIT_H__
--- /dev/null
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // CLASS HEADER
+ #include "push-button-default-painter-impl.h"
+
+ // EXTERNAL INCLUDES
+ #include <dali/public-api/actors/image-actor.h>
+ #include <dali/public-api/adaptor-framework/timer.h>
+ #include <dali/public-api/animation/constraints.h>
+ #include <dali/public-api/object/ref-object.h>
+
+ // INTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/buttons/push-button.h>
+ #include "push-button-impl.h"
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ namespace
+ {
+ const float LABEL_DEPTH( 0.75f );
+ const float FOREGROUND_DEPTH( 0.5f );
+ const float BACKGROUND_DEPTH( 0.25f );
+
+ const float ANIMATION_TIME( 0.2f );
+
+ inline Toolkit::Internal::PushButton& GetPushButtonImpl( Toolkit::Button& button )
+ {
+ DALI_ASSERT_ALWAYS( button );
+
+ Dali::RefObject& handle = button.GetImplementation();
+
+ return static_cast<Toolkit::Internal::PushButton&>( handle );
+ }
+
+ inline const Toolkit::Internal::PushButton& GetPushButtonImpl( const Toolkit::Button& button )
+ {
+ DALI_ASSERT_ALWAYS( button );
+
+ const Dali::RefObject& handle = button.GetImplementation();
+
+ return static_cast<const Toolkit::Internal::PushButton&>( handle );
+ }
+
+ }
+
+ PushButtonDefaultPainter::PushButtonDefaultPainter()
+ : PushButtonPainter(),
+ mAutoRepeating( false ),
+ mDisabled( false ),
+ mPaintState( ReleasedState ),
+ mButton( NULL ),
+ mAnimationTime( ANIMATION_TIME ),
+ mSize()
+ {
+ }
+
+ PushButtonDefaultPainter::~PushButtonDefaultPainter()
+ {
+ if( mFadeInAnimation )
+ {
+ mFadeInAnimation.Clear();
+ }
+ if( mFadeOutAnimation )
+ {
+ mFadeOutAnimation.Clear();
+ }
+ }
+
+ void PushButtonDefaultPainter::SetButtonImage( Toolkit::PushButton& pushButton, Actor image )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetImplementation( pushButton );
+ Actor& buttonImage = pushButtonImpl.GetButtonImage();
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+
+ switch( mPaintState )
+ {
+ case ReleasedState:
+ {
+ if( buttonImage && buttonImage.GetParent() )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Foreground, buttonImage );
+
+ buttonImage = image;
+
+ FadeInImage( pushButton, buttonImage );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+ }
+ else
+ {
+ buttonImage = image;
+ pushButton.Add( buttonImage );
+ }
+ break;
+ }
+ case ReleasedPressedTransition: // FALLTHROUGH
+ case ReleasedDisabledTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton );
+
+ // Replaces the button image.
+ buttonImage = image;
+
+ pushButton.Add( buttonImage );
+ FadeOutImage( pushButton, Foreground, buttonImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ break;
+ }
+ case PressedReleasedTransition: // FALLTHROUGH
+ case DisabledReleasedTransition:
+ {
+ StopFadeInAnimation();
+ pushButton.Remove( buttonImage );
+
+ buttonImage = image;
+
+ FadeInImage( pushButton, buttonImage );
+ StartFadeInAnimation();
+ break;
+ }
+ default:
+ buttonImage = image;
+ break;
+ }
+
+ buttonImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ buttonImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( buttonImage, FOREGROUND_DEPTH );
+ }
+
+ void PushButtonDefaultPainter::SetBackgroundImage( Toolkit::PushButton& pushButton, Actor image )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetImplementation( pushButton );
+ Actor& backgroundImage = pushButtonImpl.GetBackgroundImage();
+ Actor& fadeOutBackgroundImage = pushButtonImpl.GetFadeOutBackgroundImage();
+
+ switch( mPaintState )
+ {
+ case ReleasedState: // FALLTHROUGH
+ case PressedState:
+ case ReleasedPressedTransition:
+ case PressedReleasedTransition:
+ {
+ if( backgroundImage && backgroundImage.GetParent() )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Background, backgroundImage );
+
+ backgroundImage = image;
+
+ FadeInImage( pushButton, backgroundImage );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+ }
+ else
+ {
+ backgroundImage = image;
+ pushButton.Add( backgroundImage );
+ }
+ break;
+ }
+ case ReleasedDisabledTransition: // FALLTHROUGH
+ case PressedDisabledTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
+ {
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton );
+
+ // Replaces the button image.
+ backgroundImage = image;
+
+ pushButton.Add( backgroundImage );
+ FadeOutImage( pushButton, Background, backgroundImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ break;
+ }
+ case DisabledReleasedTransition: // FALLTHROUGH
+ case DisabledPressedTransition:
+ {
+ StopFadeInAnimation();
+ pushButton.Remove( backgroundImage );
+
+ backgroundImage = image;
+
+ FadeInImage( pushButton, backgroundImage );
+ StartFadeInAnimation();
+ break;
+ }
+ default:
+ backgroundImage = image;
+ break;
+ }
+
+ backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
+ }
+
+ void PushButtonDefaultPainter::SetSelectedImage( Toolkit::PushButton& pushButton, Actor image )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetImplementation( pushButton );
+ Actor& selectedImage = pushButtonImpl.GetSelectedImage();
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+
+ switch( mPaintState )
+ {
+ case PressedState:
+ {
+ if( selectedImage && selectedImage.GetParent() )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Foreground, selectedImage );
+
+ selectedImage = image;
+
+ FadeInImage( pushButton, selectedImage );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+ }
+ else
+ {
+ selectedImage = image;
+ pushButton.Add( selectedImage );
+ }
+ break;
+ }
+ case PressedReleasedTransition: // FALLTHROUGH
+ case PressedDisabledTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton );
+
+ // Replaces the button image.
+ selectedImage = image;
+
+ pushButton.Add( selectedImage );
+ FadeOutImage( pushButton, Foreground, selectedImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ break;
+ }
+ case ReleasedPressedTransition: // FALLTHROUGH
+ case DisabledPressedTransition:
+ {
+ StopFadeInAnimation();
+ pushButton.Remove( selectedImage );
+
+ selectedImage = image;
+
+ FadeInImage( pushButton, selectedImage );
+ StartFadeInAnimation();
+ break;
+ }
+ default:
+ selectedImage = image;
+ break;
+ }
+
+ selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( selectedImage, FOREGROUND_DEPTH );
+ }
+
+ void PushButtonDefaultPainter::SetDisabledImage( Toolkit::PushButton& pushButton, Actor image )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetImplementation( pushButton );
+ Actor& disabledImage = pushButtonImpl.GetDisabledImage();
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+
+ switch( mPaintState )
+ {
+ case DisabledReleasedState: // FALLTHROUGH
+ case DisabledPressedState:
+ {
+ if( disabledImage && disabledImage.GetParent() )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Foreground, disabledImage );
+
+ disabledImage = image;
+
+ FadeInImage( pushButton, disabledImage );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+ }
+ else
+ {
+ disabledImage = image;
+ pushButton.Add( disabledImage );
+ }
+ break;
+ }
+ case ReleasedDisabledTransition: // FALLTHROUGH
+ case PressedDisabledTransition:
+ {
+ StopFadeInAnimation();
+ pushButton.Remove( disabledImage );
+
+ disabledImage = image;
+
+ FadeInImage( pushButton, disabledImage );
+ StartFadeInAnimation();
+ break;
+ }
+ case DisabledReleasedTransition: // FALLTHROUGH
+ case DisabledPressedTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton );
+
+ // Replaces the button image.
+ disabledImage = image;
+
+ pushButton.Add( disabledImage );
+ FadeOutImage( pushButton, Foreground, disabledImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ break;
+ }
+ default:
+ disabledImage = image;
+ break;
+ }
+
+ disabledImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ disabledImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( disabledImage, FOREGROUND_DEPTH );
+ }
+
+ void PushButtonDefaultPainter::SetDisabledBackgroundImage( Toolkit::PushButton& pushButton, Actor image )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetImplementation( pushButton );
+ Actor& disabledBackgroundImage = pushButtonImpl.GetDisabledBackgroundImage();
+ Actor& fadeOutBackgroundImage = pushButtonImpl.GetFadeOutBackgroundImage();
+
+ switch( mPaintState )
+ {
+ case DisabledReleasedState: // FALLTHROUGH
+ case DisabledPressedState:
+ {
+ if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Background, disabledBackgroundImage );
+
+ disabledBackgroundImage = image;
+
+ FadeInImage( pushButton, disabledBackgroundImage );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+ }
+ else
+ {
+ disabledBackgroundImage = image;
+ pushButton.Add( disabledBackgroundImage );
+ }
+ break;
+ }
+ case ReleasedDisabledTransition: // FALLTHROUGH
+ case PressedDisabledTransition:
+ {
+ StopFadeInAnimation();
+ pushButton.Remove( disabledBackgroundImage );
+
+ disabledBackgroundImage = image;
+
+ FadeInImage( pushButton, disabledBackgroundImage );
+ StartFadeInAnimation();
+ break;
+ }
+ case DisabledReleasedTransition: // FALLTHROUGH
+ case DisabledPressedTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutBackgroundImage )
+ {
+ opacity = fadeOutBackgroundImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton );
+
+ // Replaces the button image.
+ disabledBackgroundImage = image;
+
+ pushButton.Add( disabledBackgroundImage );
+ FadeOutImage( pushButton, Background, disabledBackgroundImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ break;
+ }
+ default:
+ disabledBackgroundImage = image;
+ break;
+ }
+
+ disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
+ }
+
+ void PushButtonDefaultPainter::SetLabel( Toolkit::PushButton& pushButton, Actor label )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetImplementation( pushButton );
+ Actor& labelActor = pushButtonImpl.GetLabel();
+
+ if( labelActor && labelActor.GetParent() )
+ {
+ labelActor.GetParent().Remove( labelActor );
+ }
+
+ labelActor = label;
+ labelActor.SetAnchorPoint( AnchorPoint::CENTER );
+ labelActor.SetParentOrigin( ParentOrigin::CENTER );
+
+ labelActor.SetPosition( 0.f, 0.f, LABEL_DEPTH );
+ labelActor.SetSize( mSize );
+
+ pushButton.Add( labelActor );
+ }
+
+ void PushButtonDefaultPainter::Initialize( Toolkit::Button& button )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( button );
+ Actor& buttonImage = pushButtonImpl.GetButtonImage();
+ Actor& selectedImage = pushButtonImpl.GetSelectedImage();
+ Actor& backgroundImage = pushButtonImpl.GetBackgroundImage();
+ Actor& disabledImage = pushButtonImpl.GetDisabledImage();
+ Actor& disabledBackgroundImage = pushButtonImpl.GetDisabledBackgroundImage();
+ Actor& label = pushButtonImpl.GetLabel();
+
+ Toolkit::PushButton& pushButton = static_cast<Toolkit::PushButton&>( button );
+
+ if( buttonImage )
+ {
+ SetButtonImage( pushButton, buttonImage );
+ }
+
+ if( backgroundImage )
+ {
+ SetBackgroundImage( pushButton, backgroundImage );
+ }
+
+ if( selectedImage )
+ {
+ SetSelectedImage( pushButton, selectedImage );
+ }
+
+ if( disabledImage )
+ {
+ SetDisabledImage( pushButton, disabledImage );
+ }
+
+ if( disabledBackgroundImage )
+ {
+ SetDisabledBackgroundImage( pushButton, disabledBackgroundImage );
+ }
+
+ if( label )
+ {
+ SetLabel( pushButton, label );
+ }
+
+ SetDisabled( pushButton, mDisabled );
+ }
+
+ void PushButtonDefaultPainter::SetSize( Toolkit::Button& button, const Vector3& size )
+ {
+ if( size != mSize )
+ {
+ mSize = size;
+
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( button );
+ Actor& buttonImage = pushButtonImpl.GetButtonImage();
+ Actor& selectedImage = pushButtonImpl.GetSelectedImage();
+ Actor& backgroundImage = pushButtonImpl.GetBackgroundImage();
+ Actor& disabledImage = pushButtonImpl.GetDisabledImage();
+ Actor& disabledBackgroundImage = pushButtonImpl.GetDisabledBackgroundImage();
+ Actor& label = pushButtonImpl.GetLabel();
+
+ ApplyConstraint( buttonImage, FOREGROUND_DEPTH );
+ ApplyConstraint( backgroundImage, BACKGROUND_DEPTH );
+ ApplyConstraint( selectedImage, FOREGROUND_DEPTH );
+ ApplyConstraint( disabledImage, FOREGROUND_DEPTH );
+ ApplyConstraint( disabledBackgroundImage, BACKGROUND_DEPTH );
+
+ if( label )
+ {
+ label.SetPosition( 0.f, 0.f, LABEL_DEPTH );
+ label.SetSize( mSize );
+ }
+ }
+ }
+
+ void PushButtonDefaultPainter::SetDisabled( Toolkit::Button& button, bool disabled )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( button );
+ Actor& buttonImage = pushButtonImpl.GetButtonImage();
+ Actor& selectedImage = pushButtonImpl.GetSelectedImage();
+ Actor& backgroundImage = pushButtonImpl.GetBackgroundImage();
+ Actor& disabledImage = pushButtonImpl.GetDisabledImage();
+ Actor& disabledBackgroundImage = pushButtonImpl.GetDisabledBackgroundImage();
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+
+ Toolkit::PushButton& pushButton = static_cast<Toolkit::PushButton&>( button );
+
+ mDisabled = disabled;
+
+ switch( mPaintState )
+ {
+ case ReleasedState:
+ {
+ if( disabled )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Background, backgroundImage );
+ FadeOutImage( pushButton, Foreground, buttonImage );
+ FadeInImage( pushButton, disabledBackgroundImage );
+ FadeInImage( pushButton, disabledImage );
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = ReleasedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledReleasedState;
+ }
+ }
+ break;
+ }
+ case PressedState:
+ {
+ if( disabled )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Background, backgroundImage );
+ FadeOutImage( pushButton, Foreground, selectedImage );
+ FadeInImage( pushButton, disabledBackgroundImage );
+ FadeInImage( pushButton, disabledImage );
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = PressedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledPressedState;
+ }
+ }
+ break;
+ }
+ case DisabledReleasedState:
+ {
+ if( !disabled )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Background, disabledBackgroundImage );
+ FadeOutImage( pushButton, Foreground, disabledImage );
+ FadeInImage( pushButton, backgroundImage );
+ FadeInImage( pushButton, buttonImage );
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = DisabledReleasedTransition;
+ }
+ else
+ {
+ mPaintState = ReleasedState;
+ }
+ }
+ break;
+ }
+ case DisabledPressedState:
+ {
+ if( !disabled )
+ {
+ StopFadeOutAnimation( pushButton );
+ FadeOutImage( pushButton, Background, disabledBackgroundImage );
+ FadeOutImage( pushButton, Foreground, disabledImage );
+ FadeInImage( pushButton, backgroundImage );
+ FadeInImage( pushButton, selectedImage );
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = DisabledPressedTransition;
+ }
+ else
+ {
+ mPaintState = PressedState;
+ }
+ }
+ break;
+ }
+ case ReleasedPressedTransition:
+ {
+ if( disabled )
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton );
+ StopFadeInAnimation();
+
+ FadeOutImage( pushButton, Foreground, selectedImage, 1.f - opacity );
+ FadeOutImage( pushButton, Background, backgroundImage );
+
+ FadeInImage( pushButton, disabledImage );
+ FadeInImage( pushButton, disabledBackgroundImage );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = PressedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledPressedState;
+ }
+ }
+ break;
+ }
+ case PressedReleasedTransition:
+ {
+ if( disabled )
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton );
+ StopFadeInAnimation();
+
+ FadeOutImage( pushButton, Foreground, buttonImage, 1.f - opacity );
+ FadeOutImage( pushButton, Background, backgroundImage );
+
+ FadeInImage( pushButton, disabledImage );
+ FadeInImage( pushButton, disabledBackgroundImage );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = ReleasedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledReleasedState;
+ }
+ }
+ break;
+ }
+ case ReleasedDisabledTransition:
+ {
+ if( !disabled )
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton, false );
+ StopFadeInAnimation();
+
+ FadeOutImage( pushButton, Foreground, disabledImage, 1.f - opacity );
+ FadeOutImage( pushButton, Background, disabledBackgroundImage, 1.f - opacity );
+ FadeInImage( pushButton, buttonImage, opacity );
+ FadeInImage( pushButton, backgroundImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = DisabledReleasedTransition;
+ }
+ else
+ {
+ mPaintState = ReleasedState;
+ }
+ }
+ break;
+ }
+ case DisabledReleasedTransition:
+ {
+ if( disabled )
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton, false );
+ StopFadeInAnimation();
+
+ FadeOutImage( pushButton, Foreground, buttonImage, 1.f - opacity );
+ FadeOutImage( pushButton, Background, backgroundImage, 1.f - opacity );
+ FadeInImage( pushButton, disabledImage, opacity );
+ FadeInImage( pushButton, disabledBackgroundImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = ReleasedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledReleasedState;
+ }
+ }
+ break;
+ }
+ case PressedDisabledTransition:
+ {
+ if( !disabled )
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton, false );
+ StopFadeInAnimation();
+
+ FadeOutImage( pushButton, Foreground, disabledImage, 1.f - opacity );
+ FadeOutImage( pushButton, Background, disabledBackgroundImage, 1.f - opacity );
+ FadeInImage( pushButton, selectedImage, opacity );
+ FadeInImage( pushButton, backgroundImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = DisabledPressedTransition;
+ }
+ else
+ {
+ mPaintState = PressedState;
+ }
+ }
+ break;
+ }
+ case DisabledPressedTransition:
+ {
+ if( disabled )
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( pushButton, false );
+ StopFadeInAnimation();
+
+ FadeOutImage( pushButton, Foreground, selectedImage, 1.f - opacity );
+ FadeOutImage( pushButton, Background, backgroundImage, 1.f - opacity );
+ FadeInImage( pushButton, disabledImage, opacity );
+ FadeInImage( pushButton, disabledBackgroundImage, opacity );
+
+ StartFadeOutAnimation( pushButton );
+ StartFadeInAnimation();
+
+ if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
+ {
+ mPaintState = PressedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledPressedState;
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ void PushButtonDefaultPainter::SetAnimationTime( float animationTime )
+ {
+ mAnimationTime = animationTime;
+ }
+
+ float PushButtonDefaultPainter::GetAnimationTime() const
+ {
+ return mAnimationTime;
+ }
+
+ void PushButtonDefaultPainter::SetAutoRepeating( bool autorepeating )
+ {
+ mAutoRepeating = autorepeating;
+ }
+
+ void PushButtonDefaultPainter::Pressed( Toolkit::PushButton& button )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( button );
+ Actor& selectedImage = pushButtonImpl.GetSelectedImage();
+ Actor& buttonImage = pushButtonImpl.GetButtonImage();
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+
+ switch( mPaintState )
+ {
+ case ReleasedState:
+ {
+ StopFadeOutAnimation( button );
+ FadeOutImage( button, Foreground, buttonImage );
+ FadeInImage( button, selectedImage );
+ StartFadeOutAnimation( button );
+ StartFadeInAnimation();
+
+ if( buttonImage || selectedImage )
+ {
+ mPaintState = ReleasedPressedTransition;
+ }
+ else
+ {
+ mPaintState = PressedState;
+ }
+ break;
+ }
+ case ReleasedPressedTransition:
+ {
+ if( !mAutoRepeating )
+ {
+ mPaintState = PressedReleasedTransition;
+ }
+ break;
+ }
+ case PressedReleasedTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( button, false );
+ StopFadeInAnimation();
+
+ FadeOutImage( button, Foreground, buttonImage, 1.f - opacity );
+ FadeInImage( button, selectedImage, opacity );
+
+ StartFadeOutAnimation( button );
+ StartFadeInAnimation();
+
+ if( buttonImage || selectedImage )
+ {
+ mPaintState = ReleasedPressedTransition;
+ }
+ else
+ {
+ mPaintState = PressedState;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ void PushButtonDefaultPainter::Released( Toolkit::PushButton& button )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( button );
+ Actor& selectedImage = pushButtonImpl.GetSelectedImage();
+ Actor& buttonImage = pushButtonImpl.GetButtonImage();
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+
+ switch( mPaintState )
+ {
+ case PressedState:
+ {
+ StopFadeOutAnimation( button );
+ FadeOutImage( button, Foreground, selectedImage );
+ FadeInImage( button, buttonImage );
+ StartFadeOutAnimation( button );
+ StartFadeInAnimation();
+
+ if( buttonImage || selectedImage )
+ {
+ mPaintState = PressedReleasedTransition;
+ }
+ else
+ {
+ mPaintState = ReleasedState;
+ }
+ break;
+ }
+ case ReleasedPressedTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( button, false );
+ StopFadeInAnimation();
+
+ FadeOutImage( button, Foreground, selectedImage, 1.f - opacity );
+ FadeInImage( button, buttonImage, opacity );
+
+ StartFadeOutAnimation( button );
+ StartFadeInAnimation();
+
+ if( buttonImage || selectedImage )
+ {
+ mPaintState = PressedReleasedTransition;
+ }
+ else
+ {
+ mPaintState = ReleasedState;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+
+ void PushButtonDefaultPainter::Clicked( Toolkit::PushButton& button )
+ {
+ Released( button );
+ }
+
+ void PushButtonDefaultPainter::Toggled( Toolkit::PushButton& button )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( button );
+ Actor& selectedImage = pushButtonImpl.GetSelectedImage();
+ Actor& buttonImage = pushButtonImpl.GetButtonImage();
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+
+ switch( mPaintState )
+ {
+ case ReleasedState:
+ {
+ StopFadeOutAnimation( button );
+ FadeOutImage( button, Foreground, buttonImage );
+ FadeInImage( button, selectedImage );
+ StartFadeOutAnimation( button );
+ StartFadeInAnimation();
+
+ if( buttonImage || selectedImage )
+ {
+ mPaintState = ReleasedPressedTransition;
+ }
+ else
+ {
+ mPaintState = PressedState;
+ }
+ break;
+ }
+ case PressedState:
+ {
+ StopFadeOutAnimation( button );
+ FadeOutImage( button, Foreground, selectedImage );
+ FadeInImage( button, buttonImage );
+ StartFadeOutAnimation( button );
+ StartFadeInAnimation();
+
+ if( buttonImage || selectedImage )
+ {
+ mPaintState = PressedReleasedTransition;
+ }
+ else
+ {
+ mPaintState = ReleasedState;
+ }
+ break;
+ }
+ case ReleasedPressedTransition:
+ {
+ float opacity = 1.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( button, false );
+ StopFadeInAnimation();
+
+ FadeOutImage( button, Foreground, selectedImage, 1.f - opacity );
+ FadeInImage( button, buttonImage, opacity );
+
+ StartFadeOutAnimation( button );
+ StartFadeInAnimation();
+
+ if( buttonImage || selectedImage )
+ {
+ mPaintState = PressedReleasedTransition;
+ }
+ else
+ {
+ mPaintState = ReleasedState;
+ }
+ break;
+ }
+ case PressedReleasedTransition:
+ {
+ float opacity = 0.f;
+ if( fadeOutButtonImage )
+ {
+ opacity = 1.f - fadeOutButtonImage.GetCurrentOpacity();
+ }
+ StopFadeOutAnimation( button, false );
+ StopFadeInAnimation();
+
+ FadeOutImage( button, Foreground, buttonImage, 1.f - opacity );
+ FadeInImage( button, selectedImage, opacity );
+
+ StartFadeOutAnimation( button );
+ StartFadeInAnimation();
+
+ if( buttonImage || selectedImage )
+ {
+ mPaintState = ReleasedPressedTransition;
+ }
+ else
+ {
+ mPaintState = PressedState;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+
+ void PushButtonDefaultPainter::ApplyConstraint( Actor& actor, float depth )
+ {
+ if( actor )
+ {
+ actor.SetPosition( 0.f, 0.f, depth );
+ actor.RemoveConstraints();
+ actor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+ }
+ }
+
+ void PushButtonDefaultPainter::AddToFadeInAnimation( const Actor& actor )
+ {
+ if( !mFadeInAnimation )
+ {
+ mFadeInAnimation = Dali::Animation::New( mAnimationTime );
+ }
+
+ mFadeInAnimation.OpacityTo( actor, 1.f );
+ }
+
+ void PushButtonDefaultPainter::StartFadeInAnimation()
+ {
+ if( mFadeInAnimation )
+ {
+ mFadeInAnimation.FinishedSignal().Connect( this, &PushButtonDefaultPainter::PressedReleasedFadeInAnimationFinished );
+ mFadeInAnimation.Play();
+ }
+ }
+
+ void PushButtonDefaultPainter::StopFadeInAnimation()
+ {
+ if( mFadeInAnimation )
+ {
+ mFadeInAnimation.Clear();
+ mFadeInAnimation.Reset();
+ }
+ }
+
+ void PushButtonDefaultPainter::AddToFadeOutAnimation( const Actor& actor )
+ {
+ if( !mFadeOutAnimation )
+ {
+ mFadeOutAnimation = Dali::Animation::New( mAnimationTime );
+ }
+
+ mFadeOutAnimation.OpacityTo( actor, 0.f );
+ }
+
+ void PushButtonDefaultPainter::StartFadeOutAnimation( Toolkit::PushButton& pushButton )
+ {
+ if( mFadeOutAnimation )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( pushButton );
+ mButton = &pushButtonImpl;
+
+ mFadeOutAnimation.FinishedSignal().Connect( this, &PushButtonDefaultPainter::PressedReleasedFadeOutAnimationFinished );
+ mFadeOutAnimation.Play();
+ }
+ }
+
+ void PushButtonDefaultPainter::StopFadeOutAnimation( Toolkit::PushButton& pushButton, bool remove )
+ {
+ if( mFadeOutAnimation )
+ {
+ mFadeOutAnimation.Clear();
+ }
+
+ mFadeOutAnimation.Reset();
+
+ if( remove )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( pushButton );
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+ Actor& fadeOutBackgroundImage = pushButtonImpl.GetFadeOutBackgroundImage();
+
+ if( fadeOutButtonImage && fadeOutButtonImage.GetParent() )
+ {
+ fadeOutButtonImage.GetParent().Remove( fadeOutButtonImage );
+ }
+
+ if( fadeOutBackgroundImage && fadeOutBackgroundImage.GetParent() )
+ {
+ fadeOutBackgroundImage.GetParent().Remove( fadeOutBackgroundImage );
+ }
+
+ fadeOutButtonImage.Reset();
+ fadeOutBackgroundImage.Reset();
+ }
+ }
+
+ void PushButtonDefaultPainter::FadeInImage( Toolkit::PushButton& pushButton, Actor& image, float opacity )
+ {
+ if( image )
+ {
+ image.SetOpacity( opacity );
+ if( !image.GetParent() )
+ {
+ pushButton.Add( image );
+ }
+
+ AddToFadeInAnimation( image );
+ }
+ }
+
+ void PushButtonDefaultPainter::FadeOutImage( Toolkit::PushButton& pushButton, ImageLayer layer, Actor& image, float opacity )
+ {
+ if( image )
+ {
+ Toolkit::Internal::PushButton& pushButtonImpl = GetPushButtonImpl( pushButton );
+ Actor& fadeOutButtonImage = pushButtonImpl.GetFadeOutButtonImage();
+ Actor& fadeOutBackgroundImage = pushButtonImpl.GetFadeOutBackgroundImage();
+
+ Actor& actorLayer = ( ( Background == layer ) ? fadeOutBackgroundImage : fadeOutButtonImage );
+
+ actorLayer = image;
+ actorLayer.SetOpacity( opacity );
+
+ AddToFadeOutAnimation( actorLayer );
+ }
+ }
+
+ void PushButtonDefaultPainter::PressedReleasedFadeOutAnimationFinished( Dali::Animation& source )
+ {
+ switch( mPaintState )
+ {
+ case ReleasedPressedTransition:
+ {
+ mPaintState = PressedState;
+ break;
+ }
+ case PressedReleasedTransition:
+ {
+ mPaintState = ReleasedState;
+ break;
+ }
+ case ReleasedDisabledTransition:
+ {
+ mPaintState = DisabledReleasedState;
+ break;
+ }
+ case DisabledReleasedTransition:
+ {
+ mPaintState = ReleasedState;
+ break;
+ }
+ case PressedDisabledTransition:
+ {
+ mPaintState = DisabledPressedState;
+ break;
+ }
+ case DisabledPressedTransition:
+ {
+ mPaintState = PressedState;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ Toolkit::PushButton handle( mButton->GetOwner() );
+ StopFadeOutAnimation( handle );
+ mButton = NULL;
+ }
+
+ void PushButtonDefaultPainter::PressedReleasedFadeInAnimationFinished( Dali::Animation& source )
+ {
+ switch( mPaintState )
+ {
+ case ReleasedPressedTransition:
+ {
+ mPaintState = PressedState;
+ break;
+ }
+ case PressedReleasedTransition:
+ {
+ mPaintState = ReleasedState;
+ break;
+ }
+ case ReleasedDisabledTransition:
+ {
+ mPaintState = DisabledReleasedState;
+ break;
+ }
+ case DisabledReleasedTransition:
+ {
+ mPaintState = ReleasedState;
+ break;
+ }
+ case PressedDisabledTransition:
+ {
+ mPaintState = DisabledPressedState;
+ break;
+ }
+ case DisabledPressedTransition:
+ {
+ mPaintState = PressedState;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ StopFadeInAnimation();
+ }
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // CLASS HEADER
+ #include "push-button-impl.h"
+
+ // EXTERNAL INCLUDES
+ #include <algorithm>
+ #include <dali/public-api/actors/image-actor.h>
+ #include <dali/public-api/object/type-registry.h>
+ #include <dali/public-api/scripting/scripting.h>
+
+ // INTERNAL INCLUDES
+ #include "push-button-default-painter-impl.h"
+
- Toolkit::TextView textView ( Toolkit::TextView::New( label ) );
- textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button
- SetLabel( textView );
+ #include <dali-toolkit/internal/controls/relayout-helper.h>
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ namespace
+ {
+
+ BaseHandle Create()
+ {
+ return Toolkit::PushButton::New();
+ }
+
+ TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create );
+
+ SignalConnectorType signalConnector1( typeRegistration, Toolkit::PushButton::SIGNAL_PRESSED , &PushButton::DoConnectSignal );
+ SignalConnectorType signalConnector2( typeRegistration, Toolkit::PushButton::SIGNAL_RELEASED, &PushButton::DoConnectSignal );
+
+ TypeAction action1( typeRegistration, Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK, &PushButton::DoAction );
+
+ } // unnamed namespace
+
+ namespace
+ {
+
+ const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
+ const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
+
+ const float TEXT_PADDING = 12.0f;
+
+ // Helper function used to cast a ButtonPainter to PushButtonDefaultPainter
+ PushButtonDefaultPainterPtr GetPushButtonPainter( Dali::Toolkit::Internal::ButtonPainterPtr painter )
+ {
+ return static_cast<PushButtonDefaultPainter*>( painter.Get() );
+ }
+
+ /**
+ * Find the first image actor in the actor hierarchy
+ */
+ ImageActor FindImageActor( Actor root )
+ {
+ ImageActor imageActor = ImageActor::DownCast( root );
+ if( !imageActor && root )
+ {
+ for( unsigned int i = 0, numChildren = root.GetChildCount(); i < numChildren; ++i )
+ {
+ ImageActor childImageActor = FindImageActor( root.GetChildAt( i ) );
+ if( childImageActor )
+ {
+ return childImageActor;
+ }
+ }
+ }
+
+ return imageActor;
+ }
+
+
+ } // unnamed namespace
+
+ Dali::Toolkit::PushButton PushButton::New()
+ {
+ // Create the implementation, temporarily owned on stack
+ IntrusivePtr< PushButton > internalPushButton = new PushButton();
+
+ // Pass ownership to CustomActor
+ Dali::Toolkit::PushButton pushButton( *internalPushButton );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ internalPushButton->Initialize();
+
+ return pushButton;
+ }
+
+ void PushButton::SetAutoRepeating( bool autoRepeating )
+ {
+ mAutoRepeating = autoRepeating;
+
+ // An autorepeating button can't be a toggle button.
+ if( autoRepeating )
+ {
+ mToggleButton = false;
+ if( mToggled )
+ {
+ // Emit a signal is not wanted, only change the appearance.
+ Toolkit::PushButton handle( GetOwner() );
+ GetPushButtonPainter( mPainter )->Toggled( handle );
+ mToggled = false;
+ }
+ }
+
+ // Notifies the painter.
+ GetPushButtonPainter( mPainter )->SetAutoRepeating( mAutoRepeating );
+ }
+
+ bool PushButton::IsAutoRepeating() const
+ {
+ return mAutoRepeating;
+ }
+
+ void PushButton::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
+ {
+ DALI_ASSERT_ALWAYS( initialAutoRepeatingDelay > 0.f );
+ mInitialAutoRepeatingDelay = initialAutoRepeatingDelay;
+ }
+
+ float PushButton::GetInitialAutoRepeatingDelay() const
+ {
+ return mInitialAutoRepeatingDelay;
+ }
+
+ void PushButton::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
+ {
+ DALI_ASSERT_ALWAYS( nextAutoRepeatingDelay > 0.f );
+ mNextAutoRepeatingDelay = nextAutoRepeatingDelay;
+ }
+
+ float PushButton::GetNextAutoRepeatingDelay() const
+ {
+ return mNextAutoRepeatingDelay;
+ }
+
+ void PushButton::SetToggleButton( bool toggle )
+ {
+ mToggleButton = toggle;
+
+ // A toggle button can't be an autorepeating button.
+ if( toggle )
+ {
+ mAutoRepeating = false;
+
+ // Notifies the painter.
+ GetPushButtonPainter( mPainter )->SetAutoRepeating( mAutoRepeating );
+ }
+ }
+
+ bool PushButton::IsToggleButton() const
+ {
+ return mToggleButton;
+ }
+
+ void PushButton::SetToggled( bool toggle )
+ {
+ if( !mDisabled && mToggleButton && ( toggle != mToggled ) )
+ {
+ mToggled = toggle;
+
+ Toolkit::PushButton handle( GetOwner() );
+
+ // Notifies the painter the button has been toggled.
+ GetPushButtonPainter( mPainter )->Toggled( handle );
+
+ // Emit signal.
+ mStateChangedSignal.Emit( handle, mToggled );
+ }
+ }
+
+ bool PushButton::IsToggled() const
+ {
+ return mToggleButton && mToggled;
+ }
+
+ void PushButton::SetButtonImage( Image image )
+ {
+ SetButtonImage( ImageActor::New( image ) );
+ }
+
+ void PushButton::SetButtonImage( Actor image )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+ GetPushButtonPainter( mPainter )->SetButtonImage( handle, image );
+ }
+
+ Actor& PushButton::GetButtonImage()
+ {
+ return mButtonImage;
+ }
+
+ Actor PushButton::GetButtonImage() const
+ {
+ return mButtonImage;
+ }
+
+ void PushButton::SetBackgroundImage( Image image )
+ {
+ SetBackgroundImage( ImageActor::New( image ) );
+ }
+
+ void PushButton::SetBackgroundImage( Actor image )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+ GetPushButtonPainter( mPainter )->SetBackgroundImage( handle, image );
+ }
+
+ Actor& PushButton::GetBackgroundImage()
+ {
+ return mBackgroundImage;
+ }
+
+ Actor PushButton::GetBackgroundImage() const
+ {
+ return mBackgroundImage;
+ }
+
+ void PushButton::SetSelectedImage( Image image )
+ {
+ SetSelectedImage( ImageActor::New( image ) );
+ }
+
+ void PushButton::SetSelectedImage( Actor image )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+ GetPushButtonPainter( mPainter )->SetSelectedImage( handle, image );
+ }
+
+ Actor& PushButton::GetSelectedImage()
+ {
+ return mSelectedImage;
+ }
+
+ Actor PushButton::GetSelectedImage() const
+ {
+ return mSelectedImage;
+ }
+
+ void PushButton::SetDisabledBackgroundImage( Image image )
+ {
+ SetDisabledBackgroundImage( ImageActor::New( image ) );
+ }
+
+ void PushButton::SetDisabledBackgroundImage( Actor image )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+ GetPushButtonPainter( mPainter )->SetDisabledBackgroundImage( handle, image );
+ }
+
+ Actor& PushButton::GetDisabledBackgroundImage()
+ {
+ return mDisabledBackgroundImage;
+ }
+
+ Actor PushButton::GetDisabledBackgroundImage() const
+ {
+ return mDisabledBackgroundImage;
+ }
+
+ void PushButton::SetDisabledImage( Image image )
+ {
+ SetDisabledImage( ImageActor::New( image ) );
+ }
+
+ void PushButton::SetDisabledImage( Actor image )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+ GetPushButtonPainter( mPainter )->SetDisabledImage( handle, image );
+ }
+
+ Actor& PushButton::GetDisabledImage()
+ {
+ return mDisabledImage;
+ }
+
+ Actor PushButton::GetDisabledImage() const
+ {
+ return mDisabledImage;
+ }
+
+ void PushButton::SetLabel( const std::string& label )
+ {
-
- // If label, test against it's size
- Toolkit::TextView textView = Toolkit::TextView::DownCast( mLabel );
- if( textView )
- {
- Vector3 textViewSize = textView.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
- }
-
- if( heightIsZero )
- {
- size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
- }
- }
++ // TODO
+ }
+
+ void PushButton::SetLabel( Actor label )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+ GetPushButtonPainter( mPainter )->SetLabel( handle, label );
+ }
+
+ Actor PushButton::GetLabel() const
+ {
+ return mLabel;
+ }
+
+ Actor& PushButton::GetLabel()
+ {
+ return mLabel;
+ }
+
+ Actor& PushButton::GetFadeOutBackgroundImage()
+ {
+ return mFadeOutBackgroundImage;
+ }
+
+ Actor& PushButton::GetFadeOutButtonImage()
+ {
+ return mFadeOutButtonImage;
+ }
+
+ Toolkit::PushButton::PressedSignalType& PushButton::PressedSignal()
+ {
+ return mPressedSignal;
+ }
+
+ Toolkit::PushButton::ReleasedSignalType& PushButton::ReleasedSignal()
+ {
+ return mReleasedSignal;
+ }
+
+ bool PushButton::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+ {
+ Dali::BaseHandle handle( object );
+
+ bool connected( true );
+ Toolkit::PushButton button = Toolkit::PushButton::DownCast(handle);
+
+ if( Toolkit::PushButton::SIGNAL_STATE_CHANGED == signalName )
+ {
+ button.StateChangedSignal().Connect( tracker, functor );
+ }
+ else if( Toolkit::PushButton::SIGNAL_PRESSED == signalName )
+ {
+ button.PressedSignal().Connect( tracker, functor );
+ }
+ else if( Toolkit::PushButton::SIGNAL_RELEASED == signalName )
+ {
+ button.ReleasedSignal().Connect( tracker, functor );
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+ }
+
+ void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
+ {
+ Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) );
+
+ if ( pushButton )
+ {
+ PushButton& pushButtonImpl( GetImplementation( pushButton ) );
+
+ if ( propertyIndex == Toolkit::Button::PROPERTY_AUTO_REPEATING )
+ {
+ pushButtonImpl.SetAutoRepeating( value.Get< bool >() );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY )
+ {
+ pushButtonImpl.SetInitialAutoRepeatingDelay( value.Get< float >() );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY )
+ {
+ pushButtonImpl.SetNextAutoRepeatingDelay( value.Get< float >() );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLABLE )
+ {
+ pushButtonImpl.SetToggleButton( value.Get< bool >() );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED )
+ {
+ pushButtonImpl.SetToggled( value.Get< bool >() );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR )
+ {
+ pushButtonImpl.SetButtonImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR )
+ {
+ pushButtonImpl.SetSelectedImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR )
+ {
+ pushButtonImpl.SetDisabledImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR )
+ {
+ pushButtonImpl.SetLabel( Scripting::NewActor( value.Get< Property::Map >() ) );
+ }
+ }
+ }
+
+ Property::Value PushButton::GetProperty( BaseObject* object, Property::Index propertyIndex )
+ {
+ Property::Value value;
+
+ Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) );
+
+ if ( pushButton )
+ {
+ PushButton& pushButtonImpl( GetImplementation( pushButton ) );
+
+ if ( propertyIndex == Toolkit::Button::PROPERTY_AUTO_REPEATING )
+ {
+ value = pushButtonImpl.mAutoRepeating;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY )
+ {
+ value = pushButtonImpl.mInitialAutoRepeatingDelay;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY )
+ {
+ value = pushButtonImpl.mNextAutoRepeatingDelay;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLABLE )
+ {
+ value = pushButtonImpl.mToggleButton;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED )
+ {
+ value = pushButtonImpl.mToggled;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR )
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( pushButtonImpl.mButtonImage, map );
+ value = map;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR )
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( pushButtonImpl.mSelectedImage, map );
+ value = map;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR )
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( pushButtonImpl.mDisabledImage, map );
+ value = map;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR )
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( pushButtonImpl.mLabel, map );
+ value = map;
+ }
+ }
+
+ return value;
+ }
+
+ void PushButton::OnButtonInitialize()
+ {
+ // Push button requires the Leave event.
+ Actor root = Self();
+ root.SetLeaveRequired( true );
+ }
+
+ void PushButton::OnButtonDown()
+ {
+ if( !mToggleButton )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+
+ // Notifies the painter the button has been pressed.
+ GetPushButtonPainter( mPainter )->Pressed( handle );
+
+ if( mAutoRepeating )
+ {
+ SetUpTimer( mInitialAutoRepeatingDelay );
+ }
+
+ //Emit signal.
+ mPressedSignal.Emit( handle );
+ }
+ }
+
+ void PushButton::OnButtonUp()
+ {
+ if( ButtonDown == mState )
+ {
+ if( mToggleButton )
+ {
+ mToggled = !mToggled;
+
+ Toolkit::PushButton handle( GetOwner() );
+
+ // Notifies the painter the button has been toggled.
+ GetPushButtonPainter( mPainter )->Toggled( handle );
+
+ // Emit signal.
+ mStateChangedSignal.Emit( handle, mToggled );
+ }
+ else
+ {
+ Toolkit::PushButton handle( GetOwner() );
+
+ // Notifies the painter the button has been clicked.
+ GetPushButtonPainter( mPainter )->Released( handle );
+ GetPushButtonPainter( mPainter )->Clicked( handle );
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+
+ //Emit signal.
+ mReleasedSignal.Emit( handle );
+ mClickedSignal.Emit( handle );
+ }
+ }
+ }
+
+ void PushButton::OnTouchPointLeave()
+ {
+ if( ButtonDown == mState )
+ {
+ if( !mToggleButton )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+
+ // Notifies the painter the button has been released.
+ GetPushButtonPainter( mPainter )->Released( handle );
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+
+ //Emit signal.
+ mReleasedSignal.Emit( handle );
+ }
+ }
+ }
+
+ void PushButton::OnTouchPointInterrupted()
+ {
+ OnTouchPointLeave();
+ }
+
+ void PushButton::OnAnimationTimeSet( float animationTime )
+ {
+ GetPushButtonPainter( mPainter )->SetAnimationTime( animationTime );
+ }
+
+ float PushButton::OnAnimationTimeRequested() const
+ {
+ return GetPushButtonPainter( mPainter )->GetAnimationTime();
+ }
+
+ void PushButton::OnButtonStageDisconnection()
+ {
+ if( ButtonDown == mState )
+ {
+ if( !mToggleButton )
+ {
+ Toolkit::PushButton handle( GetOwner() );
+
+ // Notifies the painter the button has been released.
+ GetPushButtonPainter( mPainter )->Released( handle );
+
+ if( mAutoRepeating )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+ }
+ }
+ }
+
+ PushButton::PushButton()
+ : Button(),
+ mAutoRepeating( false ),
+ mInitialAutoRepeatingDelay( INITIAL_AUTOREPEATING_DELAY ),
+ mNextAutoRepeatingDelay( NEXT_AUTOREPEATING_DELAY ),
+ mToggleButton( false ),
+ mAutoRepeatingTimer(),
+ mToggled( false ),
+ mClickActionPerforming(false)
+ {
+ // Creates specific painter.
+ mPainter = PushButtonDefaultPainterPtr( new PushButtonDefaultPainter() );
+ }
+
+ PushButton::~PushButton()
+ {
+ if( mAutoRepeatingTimer )
+ {
+ mAutoRepeatingTimer.Reset();
+ }
+
+ mPainter = NULL;
+ }
+
+ void PushButton::SetUpTimer( float delay )
+ {
+ mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
+ mAutoRepeatingTimer.TickSignal().Connect( this, &PushButton::AutoRepeatingSlot );
+ mAutoRepeatingTimer.Start();
+ }
+
+ bool PushButton::AutoRepeatingSlot()
+ {
+ bool consumed = false;
+ if( !mDisabled )
+ {
+ // Restart the autorepeat timer.
+ SetUpTimer( mNextAutoRepeatingDelay );
+
+ Toolkit::PushButton handle( GetOwner() );
+
+ // Notifies the painter the button has been pressed.
+ GetPushButtonPainter( mPainter )->Pressed( handle );
+
+ //Emit signal.
+ consumed = mReleasedSignal.Emit( handle );
+ consumed |= mClickedSignal.Emit( handle );
+ consumed |= mPressedSignal.Emit( handle );
+ }
+
+ return consumed;
+ }
+
+ void PushButton::OnActivated()
+ {
+ // When the button is activated, it performs the click action
+ PropertyValueContainer attributes;
+ DoClickAction(attributes);
+ }
+
+ Vector3 PushButton::GetNaturalSize()
+ {
+ Vector3 size = Control::GetNaturalSize();
+
+ const bool widthIsZero = EqualsZero( size.width );
+ const bool heightIsZero = EqualsZero( size.height );
+
+ if( widthIsZero || heightIsZero )
+ {
+ // If background and background not scale9 try get size from that
+ ImageActor imageActor = FindImageActor( mButtonImage );
+ if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
+ {
+ Vector3 imageSize = RelayoutHelper::GetNaturalSize( imageActor );
+
+ if( widthIsZero )
+ {
+ size.width = imageSize.width;
+ }
+
+ if( heightIsZero )
+ {
+ size.height = imageSize.height;
+ }
+ }
+
+ ImageActor backgroundImageActor = FindImageActor( mBackgroundImage );
+ if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
+ {
+ Vector3 imageSize = RelayoutHelper::GetNaturalSize( backgroundImageActor );
+
+ if( widthIsZero )
+ {
+ size.width = std::max( size.width, imageSize.width );
+ }
+
+ if( heightIsZero )
+ {
+ size.height = std::max( size.height, imageSize.height );
+ }
+ }
+ }
+
+ return size;
+ }
+
+ void PushButton::DoClickAction(const PropertyValueContainer& attributes)
+ {
+ // Prevents the button signals from doing a recursive loop by sending an action
+ // and re-emitting the signals.
+ if(!mClickActionPerforming)
+ {
+ mClickActionPerforming = true;
+ OnButtonDown();
+ mState = ButtonDown;
+ OnButtonUp();
+ mClickActionPerforming = false;
+ }
+ }
+
+ bool PushButton::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
+ {
+ bool ret = false;
+
+ Dali::BaseHandle handle(object);
+
+ Toolkit::PushButton button = Toolkit::PushButton::DownCast(handle);
+
+ DALI_ASSERT_ALWAYS(button);
+
+ if(Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK == actionName)
+ {
+ GetImplementation(button).DoClickAction(attributes);
+ ret = true;
+ }
+
+ return ret;
+ }
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
-#include <dali/public-api/actors/text-actor.h>
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+
+ // CLASS HEADER
+ #include "radio-button-impl.h"
+
+ // EXTERNAL INCLUDES
- TextActor textActor = TextActor::DownCast( mLabel );
- if( textActor )
- {
- textActor.SetText( label );
- }
- else
- {
- Toolkit::TextView newTextView = Toolkit::TextView::New( label );
- SetLabel( newTextView );
- }
+ #include <dali/public-api/object/type-registry.h>
+ #include <dali/public-api/scripting/scripting.h>
+
+ using namespace Dali;
+ using namespace Dali::Toolkit::Internal;
+
+ namespace
+ {
+
+ BaseHandle Create()
+ {
+ return Toolkit::RadioButton::New();
+ }
+
+ TypeRegistration typeRegistration( typeid( Toolkit::RadioButton ), typeid( Toolkit::Button ), Create);
+
+ const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected.png";
+ const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected.png";
+
+ const Vector3 DISTANCE_BETWEEN_IMAGE_AND_LABEL(5.0f, 0.0f, 0.0f);
+ }
+
+ Dali::Toolkit::RadioButton RadioButton::New()
+ {
+ // Create the implementation, temporarily owned on stack
+ IntrusivePtr< RadioButton > internalRadioButton = new RadioButton();
+
+ // Pass ownership to CustomActor
+ Dali::Toolkit::RadioButton radioButton(*internalRadioButton);
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ internalRadioButton->Initialize();
+
+ return radioButton;
+ }
+
+ RadioButton::RadioButton()
+ : mSelected(false)
+ {
+ mUnselectedImage = Dali::Image::New( UNSELECTED_BUTTON_IMAGE_DIR );
+ mSelectedImage = Dali::Image::New( SELECTED_BUTTON_IMAGE_DIR );
+
+ mRadioIcon = Dali::ImageActor::New( mUnselectedImage );
+ }
+
+ RadioButton::~RadioButton()
+ {
+ }
+
+ void RadioButton::SetLabel(const std::string& label)
+ {
++ // TODO
+
+ RelayoutRequest();
+ }
+
+ void RadioButton::SetLabel(Actor label)
+ {
+ if( mLabel != label )
+ {
+ if( mLabel )
+ {
+ mRadioIcon.Remove( mLabel );
+ }
+
+ if( label )
+ {
+ label.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
+ label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ label.MoveBy( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ mRadioIcon.Add( label );
+ }
+
+ mLabel = label;
+
+ RelayoutRequest();
+ }
+ }
+
+ Actor RadioButton::GetLabel() const
+ {
+ return mLabel;
+ }
+
+ void RadioButton::SetSelected(bool selected)
+ {
+ if( mSelected != selected )
+ {
+ if( selected )
+ {
+ Actor parent = Self().GetParent();
+ if( parent )
+ {
+ for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
+ {
+ Dali::Toolkit::RadioButton rbChild = Dali::Toolkit::RadioButton::DownCast(parent.GetChildAt(i));
+
+ if( rbChild )
+ {
+ rbChild.SetSelected(false);
+ }
+ }
+ }
+
+ mSelected = true;
+ mRadioIcon.SetImage(mSelectedImage);
+ }
+ else
+ {
+ mSelected = false;
+ mRadioIcon.SetImage(mUnselectedImage);
+ }
+
+ // Raise state changed signal
+ Toolkit::RadioButton handle( GetOwner() );
+ mStateChangedSignal.Emit( handle, mSelected );
+
+ RelayoutRequest();
+ }
+ }
+
+ bool RadioButton::IsSelected()const
+ {
+ return mSelected;
+ }
+
+ void RadioButton::ToggleState()
+ {
+ SetSelected(!mSelected);
+ }
+
+ void RadioButton::OnRelayout( const Vector2& /*size*/, ActorSizeContainer& container )
+ {
+ Vector3 newSize( mRadioIcon.GetNaturalSize() );
+
+ if( mLabel )
+ {
+ // Offset the label from the radio button image
+ newSize.width += DISTANCE_BETWEEN_IMAGE_AND_LABEL.width;
+
+ // Find the size of the control using size negotiation
+ Vector3 actorNaturalSize( mLabel.GetNaturalSize() );
+ Control::Relayout( mLabel, Vector2( actorNaturalSize.width, actorNaturalSize.height ), container );
+
+ Vector3 actorSize( mLabel.GetSize() );
+ newSize.width += actorSize.width;
+ newSize.height = std::max( newSize.height, actorSize.height );
+ }
+
+ Self().SetSize( newSize );
+ }
+
+ void RadioButton::OnInitialize()
+ {
+ mRadioIcon.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ mRadioIcon.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ Self().Add( mRadioIcon );
+
+ RelayoutRequest();
+ }
+
+ void RadioButton::OnButtonUp()
+ {
+ // Don't allow selection on an already selected radio button
+ if( !mSelected )
+ {
+ ToggleState();
+ }
+ }
+
+ void RadioButton::SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value)
+ {
+ Toolkit::RadioButton radioButton = Toolkit::RadioButton::DownCast( Dali::BaseHandle( object ) );
+
+ if( radioButton )
+ {
+ RadioButton& radioButtonImpl( GetImplementation( radioButton ) );
+
+ if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED )
+ {
+ radioButtonImpl.SetSelected( value.Get< bool >( ) );
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR )
+ {
+ radioButtonImpl.SetLabel( Scripting::NewActor( value.Get< Property::Map >( ) ) );
+ }
+ }
+ }
+
+ Property::Value RadioButton::GetProperty(BaseObject* object, Property::Index propertyIndex)
+ {
+ Property::Value value;
+
+ Toolkit::RadioButton radioButton = Toolkit::RadioButton::DownCast( Dali::BaseHandle(object) );
+
+ if( radioButton )
+ {
+ RadioButton& radioButtonImpl( GetImplementation( radioButton ) );
+
+ if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED )
+ {
+ value = radioButtonImpl.mSelected;
+ }
+ else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR )
+ {
+ Property::Map map;
+ Scripting::CreatePropertyMap( radioButtonImpl.mLabel, map );
+ value = map;
+ }
+ }
+
+ return value;
+ }
--- /dev/null
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ #ifndef __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__
+ #define __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__
+
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // EXTERNAL INCLUDES
+ #include <dali/public-api/actors/image-actor.h>
+ #include <dali/public-api/common/dali-vector.h>
+
+ // INTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/buttons/radio-button.h>
+ #include "button-impl.h"
+
+ namespace Dali
+ {
+ namespace Toolkit
+ {
+ namespace Internal
+ {
+
+ /**
+ * RadioButton implementation class.
+ *
+ * \sa Dali::Toolkit::RadioButton
+ */
+ class RadioButton: public Button
+ {
+ public:
+
+ /**
+ * Create a new RadioButton.
+ *
+ * @return A smart-pointer to the newly allocated PushButton.
+ */
+ static Dali::Toolkit::RadioButton New();
+
+ /**
+ * Construct a new PushButton.
+ */
+ RadioButton();
+
+ /**
+ * Construct a new PushButton with label.
+ */
+ RadioButton(const std::string& label);
+
+ /**
+ * Construct a new PushButton with label.
+ */
+ RadioButton(Actor label);
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~RadioButton();
+
+ /**
+ * @copydoc Dali::Toolkit::RadioButton::SetLabel(const std::string& label)
+ */
+ void SetLabel(const std::string& label);
+
+ /**
+ * @copydoc Dali::Toolkit::RadioButton::SetLabel(Actor label)
+ */
+ void SetLabel(Actor label);
+
+ /**
+ * @copydoc Dali::Toolkit::RadioButton::GetLabel()
+ */
+ Actor GetLabel() const;
+
+ /**
+ * @copydoc Dali::Toolkit::RadioButton::SetSelected(bool selected)
+ */
+ void SetSelected(bool selected);
+
+ /**
+ * @copydoc Dali::Toolkit::RadioButton::IsSelected()
+ */
+ bool IsSelected()const;
+
+ /**
+ * @copydoc Dali::Toolkit::RadioButton::ToggleState()
+ */
+ void ToggleState();
+
+ /**
+ * @copydoc Dali::Toolkit::Control::OnRelayout()
+ */
+ virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+
+ public:
+ // Properties
+
+ /**
+ * @copydoc Button::SetProperty
+ */
+ static void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value);
+
+ /**
+ * @copydoc Button::GetProperty
+ */
+ static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
+
+ protected: // From Control
+
+ /**
+ * Sets the relative position of image and label.
+ */
+ virtual void OnInitialize();
+
+ protected: // From Button
+ /**
+ * Change button state when the button is pressed.
+ */
+ virtual void OnButtonUp();
+
+ private:
+
+ // Undefined
+ RadioButton(const RadioButton& origin);
+
+ // Undefined
+ RadioButton& operator=(const RadioButton& origin);
+
+ Image mUnselectedImage; ///< Stores the unselected image
+ Image mSelectedImage; ///< Stores the selected image
+ ImageActor mRadioIcon; ///< Stores the current image
+ Actor mLabel; ///< Stores the button label
+ bool mSelected; ///< Stores the selected state
+ } ;
+
+ } // namespace Internal
+
+ // Helpers for public-api forwarding methods
+
+ inline Toolkit::Internal::RadioButton& GetImplementation(Toolkit::RadioButton& button)
+ {
+ DALI_ASSERT_ALWAYS(button);
+
+ Dali::RefObject& handle = button.GetImplementation();
+
+ return static_cast<Toolkit::Internal::RadioButton&> (handle);
+ }
+
+ inline const Toolkit::Internal::RadioButton& GetImplementation(const Toolkit::RadioButton& button)
+ {
+ DALI_ASSERT_ALWAYS(button);
+
+ const Dali::RefObject& handle = button.GetImplementation();
+
+ return static_cast<const Toolkit::Internal::RadioButton&> (handle);
+ }
+
+ } // namespace Toolkit
+ } // namespace Dali
+
+ #endif // __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__
--- /dev/null
-
- mTitle = Toolkit::TextView::New();
- mTitle.SetTextAlignment( Toolkit::Alignment::HorizontalLeft );
- mTitle.SetWidthExceedPolicy(Toolkit::TextView::ShrinkToFit);
- mSubTitle = Toolkit::TextView::New();
- mSubTitle.SetTextAlignment( Toolkit::Alignment::HorizontalLeft );
- mSubTitle.SetWidthExceedPolicy(Toolkit::TextView::ShrinkToFit);
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "navigation-title-bar.h"
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ //ToDo: use const variables instead of magic numbers
+
+ NavigationTitleBar::NavigationTitleBar(NavigationControl& naviControl,
+ Toolkit::NaviTitleBarStyle titleBarStylePortrait,
+ Toolkit::NaviTitleBarStyle titleBarStyleLandscape )
+ : NavigationBar(naviControl, titleBarStylePortrait, titleBarStyleLandscape ),
+ mStylePortrait( titleBarStylePortrait ),
+ mStyleLandscape( titleBarStyleLandscape ),
+ mCurrentStyle( &mStylePortrait )
+ {
+ // title bar is located at the top of the frame
+ mLayout.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
+ mLayout.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
+ if(mBackground)
+ {
+ mBackground.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
+ mBackground.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
+ }
+
+ // button layout: three rows, controls will be put in the middle row, the top and bottom rows are just for margins
+ mButtonLayout = Toolkit::TableView::New(3, 1);
+ // title layout: fours rows, the top and bottom rows are just for margins
+ // if subtitle exists, title in the second row and subtitle in the third row
+ // if no subtitle, title will occupy both second and third row
+ mTitleLayout= Toolkit::TableView::New( 4,1 );
+ // title icon layout: the top row, the bottom row and the left column are all for margins
+ mTitleIconLayout= Toolkit::TableView::New( 3,2 );
+ SetFixedSizes();
- // add title and subtitle(if exist)
- mTitle.SetText( page.GetTitle() );
- mTitle.SetStyleToCurrentText(mCurrentStyle->titleTextStyle);
- if( page.GetSubTitle().empty() ) //display title
- {
- mTitleLayout.SetFixedHeight( 1,mCurrentStyle->titleHeightWithoutSubtitle - mCurrentStyle->subtitleHeight );
- mTitleLayout.AddChild( mTitle, Toolkit::TableView::CellPosition(1,0,2,1) );
- }
- else //display title and subtitle
- {
- mTitleLayout.SetFixedHeight( 1, mCurrentStyle->titleHeightWithSubtitle );
- mTitleLayout.AddChild( mTitle, Toolkit::TableView::CellPosition(1,0) );
- mSubTitle.SetText( page.GetSubTitle() );
- mSubTitle.SetStyleToCurrentText(mCurrentStyle->subtitleTextStyle);
- mTitleLayout.AddChild( mSubTitle, Toolkit::TableView::CellPosition(2,0) );
- }
-
+ }
+
+ void NavigationTitleBar::Update( Toolkit::Page page )
+ {
+ const std::vector<Actor>& controls = page.GetControlsOnTitleBar();
+
+ // if there is no control to place on the bar ano no title is set, hide the bar
+ if(controls.empty() && page.GetTitle().empty())
+ {
+ mVisible = false;
+ mLayout.SetVisible(false);
+ mBackground.SetVisible(false);
+ return;
+ }
+
+ if(mLayout.GetColumns() == 4)// | leftMargin | titleLayout(may have icon and subtitle) | buttonLayout | rightMargin |
+ {
+ //remove buttonLayout
+ mLayout.DeleteColumn(2);
+ }
+ // remove titleLayout
+ mLayout.RemoveChildAt( Toolkit::TableView::CellPosition(0,1) );
+ //Remove the controls in the buttonLayout
+ mButtonLayout.Resize(3,1);
+ //remove titleIcon
+ if(mTitleLayout.GetColumns() == 2)
+ {
+ mTitleLayout.DeleteColumn( 0 );
+ }
+ // remove title and subtitle
+ mTitleLayout.RemoveChildAt( Toolkit::TableView::CellPosition(2,0) );
+ mTitleLayout.RemoveChildAt( Toolkit::TableView::CellPosition(1,0) );
+
+ // add controls at the right part of the bar(if exist)
+ if(!controls.empty())
+ {
+ int numControls = controls.size();
+
+ for( int index = 0; index < numControls; index++)
+ {
+ mButtonLayout.AddChild( controls[index], Toolkit::TableView::CellPosition(1, 2*index + 1) );
+ mButtonLayout.SetFixedWidth (2*index, mCurrentStyle->gapBetweenButtons);
+ mButtonLayout.SetFixedWidth (2*index+1, mCurrentStyle->buttonSize);
+ }
+
+ mLayout.InsertColumn(2);
+ mLayout.SetFixedWidth(2, numControls * ( mCurrentStyle->buttonSize + mCurrentStyle->gapBetweenButtons) );
+ mLayout.AddChild(mButtonLayout, Toolkit::TableView::CellPosition(0,2));
+ }
+
+ // insert title icon to the left of the title(if exist)
+ if( page.GetTitleIcon() )
+ {
+ mTitleIconLayout.RemoveChildAt(Toolkit::TableView::CellPosition(1,0) );
+ mTitleIconLayout.AddChild( page.GetTitleIcon(), Toolkit::TableView::CellPosition(1,0) );
+ mTitleLayout.InsertColumn( 0 );
+ mTitleLayout.SetFixedWidth( 0, mCurrentStyle->titleLeftMargin + mCurrentStyle->titleIconSize);
+ mTitleLayout.AddChild( mTitleIconLayout, Toolkit::TableView::CellPosition(1,0,2,1) );
+ }
+
+ mLayout.AddChild( mTitleLayout, Toolkit::TableView::CellPosition(0,1) );
+
+ mVisible = true;
+ mLayout.SetVisible(true);
+ mBackground.SetVisible(true);
+ }
+
+ void NavigationTitleBar::OrientationUpdate( bool isPortrait )
+ {
+ mCurrentStyle = isPortrait ? &mStylePortrait : &mStyleLandscape;
+ SetFixedSizes();
+ Update( mCurrentItem );
+ }
+
+ void NavigationTitleBar::SetFixedSizes()
+ {
+ mLayout.SetFixedWidth(0, mCurrentStyle->titleLeftMargin);
+ mLayout.SetFixedWidth(2, mCurrentStyle->buttonRightMargin);
+
+ mButtonLayout.SetFixedHeight(2, mCurrentStyle->buttonBottomMargin);
+ mButtonLayout.SetFixedHeight(1, mCurrentStyle->buttonSize);
+
+ mTitleLayout.SetFixedHeight( 3,mCurrentStyle->titleBottomMargin );
+ mTitleLayout.SetFixedHeight( 2,mCurrentStyle->subtitleHeight );
+
+ mTitleIconLayout.SetFixedWidth( 0, mCurrentStyle->titleIconSize );
+ mTitleIconLayout.SetFixedHeight( 1, mCurrentStyle->titleIconSize );
+ }
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ #ifndef __DALI_TOOLKIT_INTERNAL_NAVIGATION_TITLE_BAR_H__
+ #define __DALI_TOOLKIT_INTERNAL_NAVIGATION_TITLE_BAR_H__
+
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <dali-toolkit/public-api/controls/table-view/table-view.h>
- Toolkit::TextView mTitle;
- Toolkit::TextView mSubTitle;
-
+ #include <dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.h>
+ #include <dali-toolkit/internal/controls/navigation-frame/navigation-bar.h>
+ #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ /**
+ * The title bar locates in the top of the frame where title, subtitle, title icon and other controls could be placed.
+ * The title bar contains two groups: the left group includes title icon, title and subtitle (subtitle and title icon are not must);
+ * while the right group can have multiple controls placed on, and it is also fine to have no control on it.
+ * If the current NavigationOtem provides no control for the bar at all and also has not set a title, the bar is hidden.
+ * +----------------------------------------+
+ * | +-+ Title +-+ +-+ |
+ * | +-+ Subtitle +-+ +-+ |
+ * +----------------------------------------+
+ */
+ class NavigationTitleBar : public NavigationBar
+ {
+ public:
+
+ NavigationTitleBar(NavigationControl& naviControl,
+ Toolkit::NaviTitleBarStyle titleBarStylePortrait,
+ Toolkit::NaviTitleBarStyle titleBarStyleLandscape );
+
+ protected:
+
+ /**
+ * @copydoc Toolkit::Internal::NavigationBar::Update
+ */
+ void Update( Toolkit::Page page );
+
+ /**
+ * @copydoc Toolkit::Internal::NavigationBar::OrientationUpdate
+ */
+ void OrientationUpdate( bool isPortrait );
+
+ private:
+ /**
+ * Set the fixed width and height to the cells of the layout
+ * These sizes need to be updated when the orientation is changing.
+ */
+ void SetFixedSizes();
+
+ private:
+
+ Toolkit::NaviTitleBarStyle mStylePortrait;
+ Toolkit::NaviTitleBarStyle mStyleLandscape;
+ const Toolkit::NaviTitleBarStyle* mCurrentStyle;
+
+ Toolkit::TableView mButtonLayout;
+ Toolkit::TableView mTitleLayout;
+ Toolkit::TableView mTitleIconLayout;
+
+ };
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
+
+
+ #endif /* __DALI_TOOLKIT_INTERNAL_NAVIGATION_TITLE_BAR_H__ */
--- /dev/null
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ #ifndef __DALI_TOOLKIT_INTERNAL_NAVIGATION_TOOL_BAR_H__
+ #define __DALI_TOOLKIT_INTERNAL_NAVIGATION_TOOL_BAR_H__
+
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <dali-toolkit/public-api/controls/table-view/table-view.h>
+ #include <dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.h>
+ #include <dali-toolkit/internal/controls/navigation-frame/navigation-bar.h>
+ #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ /**
+ * The tool bar locates in the bottom of the frame where other controls (such as PushButton ) could be placed.
+ * Controls could be added into three groups: HorizontalLeft, HorizontalCenter or HorizontalRight.
+ * The left and right groups can only have one control maximum each, while the central group can have multiple controls.
+ * It is also fine to have no control in each group.
+ * If the current NavigationOtem provides no control for the bar at all, the bar is hidden.
+ * +----------------------------------------+
+ * | +-+ +-----+ +-----+ +-+ |
+ * | +-+ +-----+ +-----+ +-+ |
+ * +----------------------------------------+
+ */
+ class NavigationToolBar : public NavigationBar
+ {
+ public:
+
+ NavigationToolBar(NavigationControl& naviControl,
+ Toolkit::NaviToolBarStyle toolBarStylePortrait,
+ Toolkit::NaviToolBarStyle toolBarStyleLandscape );
+
+ protected:
+
+ /**
+ * @copydoc Toolkit::Internal::NavigationBar::Update
+ */
+ void Update( Toolkit::Page page );
+
+ /**
+ * @copydoc Toolkit::Internal::NavigationBar::OrientationUpdate
+ */
+ void OrientationUpdate( bool isPortrait );
+
+ private:
+
+ /**
+ * Set a control onto the navigation tool bar when the page is on the top.
+ * @param[in] control The control on the navigation tool bar.
+ * @param[in] alignment The position of the control, can be HorizontalLeft/HorizontalRight/HorizontalCenter.
+ */
+ void AddControl(Actor actor, Toolkit::Alignment::Type alignment);
+
+ /**
+ * Set the fixed width and height to the cells of the layout
+ * These sizes need to be updated when the orientation is changing.
+ */
+ void SetFixedSizes();
+
+ private:
+
+ Toolkit::NaviToolBarStyle mStylePortrait;
+ Toolkit::NaviToolBarStyle mStyleLandscape;
+ const Toolkit::NaviToolBarStyle* mCurrentStyle;
+
+ Toolkit::TableView mLeftLayout;
+ Toolkit::TableView mRightLayout;
+ Toolkit::TableView mCentralLayout;
+
+ int mNumCentralActor;
+ };
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
+
+ #endif /* __DALI_TOOLKIT_INTERNAL_NAVIGATION_TOOL_BAR_H__ */
--- /dev/null
- Toolkit::TextView titleActor = Toolkit::TextView::New();
- titleActor.SetText( text );
- titleActor.SetColor( Color::BLACK );
- titleActor.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- titleActor.SetWidthExceedPolicy( Toolkit::TextView::Split );
- titleActor.SetLineJustification( Toolkit::TextView::Center );
-
- SetTitle( titleActor );
-}
-
-void Popup::SetTitle( Toolkit::TextView titleActor )
-{
- // Replaces the current title actor.
- if( mTitle && mPopupBg )
- {
- mPopupBg.Remove( mTitle );
- }
- mTitle = titleActor;
-
- mPopupBg.Add( mTitle );
-
- RelayoutRequest();
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // CLASS HEADER
+ #include <dali-toolkit/internal/controls/popup/popup-impl.h>
+
+ // EXTERNAL INCLUDES
+ #include <dali/public-api/adaptor-framework/key.h>
+ #include <dali/public-api/adaptor-framework/physical-keyboard.h>
+ #include <dali/public-api/animation/constraints.h>
+ #include <dali/public-api/common/stage.h>
+ #include <dali/public-api/events/key-event.h>
+ #include <dali/public-api/events/touch-event.h>
+ #include <dali/public-api/object/type-registry.h>
+ #include <dali/integration-api/debug.h>
+
+ // INTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/buttons/button.h>
+ #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
+ #include <dali-toolkit/public-api/controls/control-impl.h>
+ #include <dali-toolkit/internal/controls/relayout-helper.h>
+ #include <dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h>
+ #include <dali-toolkit/public-api/focus-manager/focus-manager.h>
+
+ using namespace Dali;
+
+ namespace
+ {
+ const float CONTENT_DEPTH = 1.0f; ///< 3D Effect of buttons/title etc. appearing off the popup.
+ const float POPUP_ANIMATION_DURATION = 0.5f; ///< Duration of hide/show animations
+ const float BACKING_DEPTH = -1.0f; ///< Depth of backing (positioned just behind dialog, so dialog catches hit events first)
+
+ const float POPUP_WIDTH = 720.0f; ///< Width of Popup
+ const float POPUP_OUT_MARGIN_WIDTH = 16.f; ///< Space between the screen edge and the popup edge in the horizontal dimension.
+ const float POPUP_OUT_MARGIN_HEIGHT = 36.f; ///< Space between the screen edge and the popup edge in the vertical dimension.
+ const float POPUP_TITLE_WIDTH = 648.0f; ///<Width of Popup Title
+ const float POPUP_BUTTON_BG_HEIGHT = 96.f; ///< Height of Button Background.
+ const Vector3 DEFAULT_DIALOG_SIZE = Vector3(POPUP_TITLE_WIDTH/POPUP_WIDTH, 0.5f, 0.0f);
+ const Vector3 DEFAULT_BOTTOM_SIZE = Vector3(1.0f, 0.2f, 0.0f);
+
+ const char* const PROPERTY_TITLE = "title";
+ const char* const PROPERTY_STATE = "state";
+
+ /**
+ * The background size should be at least as big as the Dialog.
+ * In some cases a background may have graphics which are visible
+ * outside of the Dialog, e.g. A Shadow. For this we need to alter
+ * the size of Background.
+ *
+ * @param[in] outerBorder The border to extend beyond parent's Size.
+ * @param[in] parentSize The parent's size
+ */
+ Vector3 BackgroundSize(const Vector4& outerBoarder, const Vector3& parentSize)
+ {
+ Vector3 size( parentSize );
+ size.width += outerBoarder.x + outerBoarder.y;
+ size.height += outerBoarder.z + outerBoarder.w;
+
+ return size;
+ }
+
+ /**
+ * sets button area size to parent's size plus a border.
+ *
+ * @param[in] outerBorder The border to extend beyond parent's Size.
+ * @param[in] parentSize The parent's size
+ */
+ Vector3 ButtonAreaSize( const Vector4& outBoarder, const Vector3& parentSize )
+ {
+ Vector3 size( parentSize );
+ size.width += outBoarder.x + outBoarder.y;
+ size.width -= (POPUP_OUT_MARGIN_WIDTH + POPUP_OUT_MARGIN_WIDTH);
+ size.height = POPUP_BUTTON_BG_HEIGHT;
+
+ return size;
+ }
+
+ } // unnamed namespace
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ namespace
+ {
+
+ BaseHandle Create()
+ {
+ return Toolkit::Popup::New();
+ }
+
+ TypeRegistration typeRegistration( typeid(Toolkit::Popup), typeid(Toolkit::Control), Create );
+
+ SignalConnectorType signalConnector1( typeRegistration, Toolkit::Popup::SIGNAL_TOUCHED_OUTSIDE, &Popup::DoConnectSignal );
+ SignalConnectorType signalConnector2( typeRegistration, Toolkit::Popup::SIGNAL_HIDDEN, &Popup::DoConnectSignal );
+
+
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ // Popup
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+
+ Dali::Toolkit::Popup Popup::New()
+ {
+ PopupStylePtr style = PopupStyleDefault::New();
+
+ // Create the implementation
+ PopupPtr popup(new Popup(*style));
+
+ // Pass ownership to CustomActor via derived handle
+ Dali::Toolkit::Popup handle(*popup);
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ popup->Initialize();
+
+ return handle;
+ }
+
+ Popup::Popup(PopupStyle& style)
+ : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mShowing(false),
+ mState(Toolkit::Popup::POPUP_NONE), // Initially, the popup state should not be set, it's set in OnInitialize
+ mAlterAddedChild(false),
+ mPopupStyle(PopupStylePtr(&style)),
+ mPropertyTitle(Property::INVALID_INDEX),
+ mPropertyState(Property::INVALID_INDEX)
+ {
+ SetKeyboardNavigationSupport( true );
+ }
+
+ void Popup::OnInitialize()
+ {
+ Actor self = Self();
+ self.SetSensitive(false);
+
+ // Create Layer
+ mLayer = Layer::New();
+ mLayer.SetParentOrigin(ParentOrigin::CENTER);
+ mLayer.SetAnchorPoint(AnchorPoint::CENTER);
+ mLayer.RaiseToTop();
+ self.Add(mLayer);
+
+ mPopupBg = Actor::New();
+ mPopupBg.SetParentOrigin(ParentOrigin::CENTER);
+ mPopupBg.SetAnchorPoint(AnchorPoint::CENTER);
+ mLayer.Add(mPopupBg);
+
+ // Any content after this point which is added to Self() will be reparented to
+ // mContent.
+ mAlterAddedChild = true;
+
+ // Add Backing (Dim effect)
+ CreateBacking();
+
+ // Add Dialog ( background image, title, content container, button container and tail )
+ CreateDialog();
+
+ // Default content.
+ ShowTail(ParentOrigin::BOTTOM_CENTER);
+
+ // Hide content by default.
+ SetState( Toolkit::Popup::POPUP_HIDE, 0.0f );
+
+ mPropertyTitle = self.RegisterProperty( PROPERTY_TITLE, "", Property::READ_WRITE );
+ mPropertyState = self.RegisterProperty( PROPERTY_STATE, "POPUP_HIDE", Property::READ_WRITE );
+
+ // Make self as keyboard focusable and focus group
+ self.SetKeyboardFocusable(true);
+ SetAsKeyboardFocusGroup(true);
+ }
+
+ void Popup::OnPropertySet( Property::Index index, Property::Value propertyValue )
+ {
+ if( index == mPropertyTitle )
+ {
+ SetTitle(propertyValue.Get<std::string>());
+ }
+ else if ( index == mPropertyState )
+ {
+ std::string value( propertyValue.Get<std::string>() );
+ if(value == "POPUP_SHOW")
+ {
+ SetState( Toolkit::Popup::POPUP_SHOW, 0.0f );
+ }
+ else if( value == "POPUP_HIDE")
+ {
+ SetState( Toolkit::Popup::POPUP_HIDE, 0.0f );
+ }
+ }
+ }
+
+ Popup::~Popup()
+ {
+ }
+
+ size_t Popup::GetButtonCount() const
+ {
+ return mButtons.size();
+ }
+
+ void Popup::SetBackgroundImage( Actor image )
+ {
+ // Removes any previous background.
+ if( mBackgroundImage && mPopupBg )
+ {
+ mPopupBg.Remove( mBackgroundImage );
+ }
+
+ // Adds new background to the dialog.
+ mBackgroundImage = image;
+
+ // OnDialogTouched only consume the event. It prevents the touch event to be caught by the backing.
+ mBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
+
+ mPopupBg.Add( mBackgroundImage );
+ }
+
+ void Popup::SetButtonAreaImage( Actor image )
+ {
+ // Removes any previous area image.
+ if( mButtonAreaImage && mPopupBg )
+ {
+ mPopupBg.Remove( mButtonAreaImage );
+ }
+
+ // Adds new area image to the dialog.
+ mButtonAreaImage = image;
+
+ // OnDialogTouched only consume the event. It prevents the touch event to be caught by the backing.
+ mButtonAreaImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
+
+ mPopupBg.Add( mButtonAreaImage );
+ }
+
+ void Popup::SetTitle( const std::string& text )
+ {
-Toolkit::TextView Popup::GetTitle() const
+ }
+
- return mTitle;
++const std::string& Popup::GetTitle() const
+ {
- if( mTitle )
- {
- Vector2 titleSize;
- titleSize.width = popupSize.width;
- titleSize.height = mTitle.GetHeightForWidth( titleSize.width );
-
- // As the default size policy for text-view is Fixed & Fixed, a size needs to be set.
- // Otherwise size-negotiation algorithm uses the GetNaturalSize() with doesn't take
- // into account the multiline and exceed policies, giving as result a wrong size.
- mTitle.SetSize( titleSize );
- Relayout( mTitle, titleSize, container );
-
- mTitle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mTitle.SetParentOrigin( ParentOrigin::TOP_CENTER );
- mTitle.SetPosition( positionOffset );
-
- positionOffset.y += titleSize.height + mPopupStyle->margin;
- }
++ static std::string temp("");
++ return temp;
+ }
+
+ void Popup::AddButton( Toolkit::Button button )
+ {
+ mButtons.push_back( button );
+ mBottomBg.Add( button );
+
+ RelayoutRequest();
+ }
+
+ void Popup::SetState( Toolkit::Popup::PopupState state )
+ {
+ SetState( state, POPUP_ANIMATION_DURATION );
+ }
+
+ void Popup::SetState( Toolkit::Popup::PopupState state, float duration )
+ {
+ // default animation behaviour.
+ HandleStateChange(state, duration);
+ }
+
+ Toolkit::Popup::PopupState Popup::GetState() const
+ {
+ return mState;
+ }
+
+ void Popup::ShowTail(const Vector3& position)
+ {
+ // Replaces the tail actor.
+ if(mTailImage && mTailImage.GetParent())
+ {
+ mTailImage.GetParent().Remove( mTailImage );
+ mTailImage.Reset();
+ }
+
+ std::string image = "";
+
+ // depending on position of tail around ParentOrigin, a different tail image is used...
+ if(position.y < Math::MACHINE_EPSILON_1)
+ {
+ image = mPopupStyle->tailUpImage;
+ }
+ else if(position.y > 1.0f - Math::MACHINE_EPSILON_1)
+ {
+ image = mPopupStyle->tailDownImage;
+ }
+ else if(position.x < Math::MACHINE_EPSILON_1)
+ {
+ image = mPopupStyle->tailLeftImage;
+ }
+ else if(position.x > 1.0f - Math::MACHINE_EPSILON_1)
+ {
+ image = mPopupStyle->tailRightImage;
+ }
+
+ if(image != "")
+ {
+ Image tail = Image::New( image );
+ mTailImage = ImageActor::New(tail);
+ const Vector3 anchorPoint = AnchorPoint::FRONT_BOTTOM_RIGHT - position;
+
+ mTailImage.SetParentOrigin(position);
+ mTailImage.SetAnchorPoint(anchorPoint);
+
+ mBottomBg.Add(mTailImage);
+ }
+ }
+
+ void Popup::HideTail()
+ {
+ ShowTail(ParentOrigin::CENTER);
+ }
+
+ void Popup::SetStyle(PopupStyle& style)
+ {
+ mPopupStyle = PopupStylePtr(&style);
+ // update //
+ }
+
+ PopupStylePtr Popup::GetStyle() const
+ {
+ return mPopupStyle;
+ }
+
+ void Popup::SetDefaultBackgroundImage()
+ {
+ Image bg = Image::New( mPopupStyle->backgroundImage );
+ ImageActor bgImage = ImageActor::New( bg );
+ bgImage.SetStyle( ImageActor::STYLE_NINE_PATCH );
+ bgImage.SetNinePatchBorder( mPopupStyle->backgroundScale9Border );
+
+ Image buttonBg = Image::New( mPopupStyle->buttonAreaImage );
+ ImageActor buttonBgImage = ImageActor::New( buttonBg );
+ buttonBgImage.SetStyle( ImageActor::STYLE_NINE_PATCH );
+ buttonBgImage.SetNinePatchBorder( mPopupStyle->buttonArea9PatchBorder );
+
+ SetBackgroundImage( bgImage );
+ SetButtonAreaImage( buttonBgImage );
+ }
+
+ void Popup::CreateBacking()
+ {
+ mBacking = Dali::Toolkit::CreateSolidColorActor( mPopupStyle->backingColor );
+
+ mBacking.SetPositionInheritanceMode(DONT_INHERIT_POSITION);
+ mBacking.SetSensitive(true);
+
+ mLayer.Add(mBacking);
+ mBacking.SetOpacity(0.0f);
+ mBacking.SetPosition(0.0f, 0.0f, BACKING_DEPTH);
+ mBacking.TouchedSignal().Connect( this, &Popup::OnBackingTouched );
+ mBacking.MouseWheelEventSignal().Connect(this, &Popup::OnBackingMouseWheelEvent);
+ }
+
+ void Popup::CreateDialog()
+ {
+ // Adds default background image.
+ SetDefaultBackgroundImage();
+
+ // Adds bottom background
+ mBottomBg = Actor::New();
+ mPopupBg.Add( mBottomBg );
+ }
+
+ void Popup::HandleStateChange( Toolkit::Popup::PopupState state, float duration )
+ {
+ const Vector2& stageSize( Stage::GetCurrent().GetSize() );
+
+ Vector3 targetSize;
+ float targetBackingAlpha;
+ Vector3 targetBackingSize;
+
+ if(mState == state)
+ {
+ return;
+ }
+ mState = state;
+ switch(state)
+ {
+ case Toolkit::Popup::POPUP_HIDE:
+ {
+ targetSize = Vector3(0.0f, 0.0f, 1.0f);
+ targetBackingAlpha = 0.0f;
+ targetBackingSize = Vector3(0.0f, 0.0f, 1.0f);
+ mShowing = false;
+ ClearKeyInputFocus();
+
+ // Retore the keyboard focus when popup is hidden
+ if(mPreviousFocusedActor && mPreviousFocusedActor.IsKeyboardFocusable() )
+ {
+ Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
+ if( keyboardFocusManager )
+ {
+ keyboardFocusManager.SetCurrentFocusActor(mPreviousFocusedActor);
+ }
+ }
+
+ break;
+ }
+
+ case Toolkit::Popup::POPUP_SHOW:
+ default:
+ {
+ targetSize = Vector3(1.0f, 1.0f, 1.0f);
+ targetBackingAlpha = 1.0f;
+ float length = (stageSize.width > stageSize.height) ? stageSize.width : stageSize.height;
+ targetBackingSize = Vector3( length, length, 1.0f );
+ mShowing = true;
+
+ // Add contents to stage for showing.
+ if( !mLayer.GetParent() )
+ {
+ mAlterAddedChild = false;
+ Self().Add(mLayer);
+ mAlterAddedChild = true;
+ }
+ Self().SetSensitive(true);
+ SetKeyInputFocus();
+
+ // Handle the keyboard focus when popup is shown
+ Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
+ if( keyboardFocusManager )
+ {
+ mPreviousFocusedActor = keyboardFocusManager.GetCurrentFocusActor();
+
+ if( mContent && mContent.IsKeyboardFocusable() )
+ {
+ // If content is focusable, move the focus to content
+ keyboardFocusManager.SetCurrentFocusActor(mContent);
+ }
+ else if( !mButtons.empty() )
+ {
+ // Otherwise, movethe focus to the first button
+ keyboardFocusManager.SetCurrentFocusActor(mButtons[0]);
+ }
+ else
+ {
+ DALI_LOG_WARNING("There is no focusable in popup\n");
+ }
+ }
+ break;
+ }
+ }
+
+ mBacking.SetSize( targetBackingSize );
+
+ if(duration > Math::MACHINE_EPSILON_1)
+ {
+ if ( mAnimation )
+ {
+ mAnimation.Stop();
+ mAnimation.Clear();
+ mAnimation.Reset();
+ }
+ mAnimation = Animation::New(duration);
+
+ if(mShowing)
+ {
+ mAnimation.AnimateTo( Property(mBacking, Actor::COLOR_ALPHA), targetBackingAlpha, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
+ mAnimation.AnimateTo( Property(mPopupBg, Actor::SCALE), targetSize, AlphaFunctions::EaseInOut, TimePeriod(duration * 0.5f, duration * 0.5f) );
+ }
+ else
+ {
+ mAnimation.AnimateTo( Property(mBacking, Actor::COLOR_ALPHA), targetBackingAlpha, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
+ mAnimation.AnimateTo( Property(mPopupBg, Actor::SCALE), targetSize, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
+ }
+ mAnimation.Play();
+ mAnimation.FinishedSignal().Connect(this, &Popup::OnStateAnimationFinished);
+ }
+ else
+ {
+ mBacking.SetOpacity( targetBackingAlpha );
+ mPopupBg.SetScale( targetSize );
+
+ HandleStateChangeComplete();
+ }
+ }
+
+ void Popup::HandleStateChangeComplete()
+ {
+ // Remove contents from stage if completely hidden.
+ if( (mState == Toolkit::Popup::POPUP_HIDE) && (mLayer.GetParent()) )
+ {
+ Self().Remove(mLayer);
+ Self().SetSensitive( false );
+
+ // Guard against destruction during signal emission
+ Toolkit::Popup handle( GetOwner() );
+ mHiddenSignal.Emit();
+ }
+ }
+
+ Toolkit::Popup::TouchedOutsideSignalType& Popup::OutsideTouchedSignal()
+ {
+ return mTouchedOutsideSignal;
+ }
+
+ Toolkit::Popup::HiddenSignalType& Popup::HiddenSignal()
+ {
+ return mHiddenSignal;
+ }
+
+ bool Popup::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+ {
+ Dali::BaseHandle handle( object );
+
+ bool connected( true );
+ Toolkit::Popup popup = Toolkit::Popup::DownCast(handle);
+
+ if( Dali::Toolkit::Popup::SIGNAL_TOUCHED_OUTSIDE == signalName )
+ {
+ popup.OutsideTouchedSignal().Connect( tracker, functor );
+ }
+ else if( Dali::Toolkit::Popup::SIGNAL_HIDDEN == signalName )
+ {
+ popup.HiddenSignal().Connect( tracker, functor );
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+ }
+
+ void Popup::OnStateAnimationFinished( Animation& source )
+ {
+ HandleStateChangeComplete();
+ }
+
+ bool Popup::OnBackingTouched(Actor actor, const TouchEvent& event)
+ {
+ if(event.GetPointCount()>0)
+ {
+ const TouchPoint& point = event.GetPoint(0);
+
+ if(point.state == TouchPoint::Down)
+ {
+ // Guard against destruction during signal emission
+ Toolkit::Popup handle( GetOwner() );
+
+ mTouchedOutsideSignal.Emit();
+ }
+ }
+
+ return true;
+ }
+
+ bool Popup::OnBackingMouseWheelEvent(Actor actor, const MouseWheelEvent& event)
+ {
+ // consume mouse wheel event in dimmed backing actor
+ return true;
+ }
+
+ bool Popup::OnDialogTouched(Actor actor, const TouchEvent& event)
+ {
+ // consume event (stops backing actor receiving touch events)
+ return true;
+ }
+
+ void Popup::OnControlChildAdd( Actor& child )
+ {
+ // reparent any children added by user to the body layer.
+ if( mAlterAddedChild )
+ {
+ // Removes previously added content.
+ if( mContent )
+ {
+ mPopupBg.Remove( mContent );
+ }
+
+ // Reparent new content.
+ Self().Remove( child );
+
+ // keep a handle to the new content.
+ mContent = child;
+
+ mPopupBg.Add( mContent );
+ }
+ }
+
+ void Popup::OnControlSizeSet( const Vector3& targetSize )
+ {
+ mLayer.SetSize( targetSize );
+ mPopupBg.SetSize( targetSize );
+
+ const Vector4 outerBorder = mPopupStyle->backgroundOuterBorder;
+ if( mBackgroundImage )
+ {
+ mBackgroundImage.SetSize( BackgroundSize( outerBorder,targetSize ) );
+ }
+ if( mButtonAreaImage )
+ {
+ mButtonAreaImage.SetSize( ButtonAreaSize( outerBorder, targetSize ) );
+ }
+
+ }
+
+ void Popup::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+ {
+ // Set the popup size
+ Vector2 popupSize;
+ popupSize.width = size.width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
+ popupSize.height = size.height - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
+
+ // Update sizes of all popup's components.
+
+ // Relayout background image.
+ // Adjust background position and size relative to parent to cater to outer Border.
+ // Some backgrounds are intended to over-spill. That is some content
+ // should appear outside the Dialog on all sides i.e. Shadows, glow effects.
+ const Vector4 outerBorder = mPopupStyle->backgroundOuterBorder;
+
+ if( mBackgroundImage )
+ {
+ mBackgroundImage.SetSize(BackgroundSize(outerBorder, Vector3(size)));
+ mBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mBackgroundImage.SetPosition( -outerBorder.x, -outerBorder.y, 0.0f );
+ }
+
+ if( mPopupBg && mButtonAreaImage )
+ {
+ // If there are no buttons, button background is also removed.
+ if ( mButtons.size() == 0 )
+ {
+ mPopupBg.Remove( mButtonAreaImage );
+ }
+ else
+ {
+ mButtonAreaImage.SetSize( ButtonAreaSize(outerBorder, Vector3(size)) );
+ mButtonAreaImage.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+ mButtonAreaImage.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ mButtonAreaImage.SetY( -outerBorder.z - POPUP_OUT_MARGIN_HEIGHT );
+
+ mPopupBg.Add( mButtonAreaImage );
+ }
+ }
+
+ // Relayout title
+ Vector3 positionOffset( 0.0f, mPopupStyle->margin + POPUP_OUT_MARGIN_WIDTH, CONTENT_DEPTH );
- if ( mTitle )
- {
- Vector3 titleNaturalSize = mTitle.GetImplementation().GetNaturalSize();
- // Buffer to avoid errors. The width of the popup could potentially be the width of the title text.
- // It was observed in this case that text wrapping was then inconsistent when seen on device
- const float titleBuffer = 0.5f;
- titleNaturalSize.width += titleBuffer;
-
- // As TextView GetNaturalSize does not take wrapping into account, limit the width
- // to that of the stage
- if( titleNaturalSize.width >= maxWidth)
- {
- naturalSize.width = maxWidth;
- naturalSize.height = mTitle.GetImplementation().GetHeightForWidth( naturalSize.width );
- }
- else
- {
- naturalSize += titleNaturalSize;
- }
-
- naturalSize.height += mPopupStyle->margin;
- }
-
++ // TODO
+
+ // Relayout content
+ if( mContent )
+ {
+ // If the content width is greater than popup width then scale it down/wrap text as needed
+ Vector2 contentSize( RelayoutHelper::GetNaturalSize( mContent ) );
+ if( contentSize.width > popupSize.width )
+ {
+ contentSize.width = popupSize.width;
+ contentSize.height = RelayoutHelper::GetHeightForWidth( mContent, contentSize.width );
+ }
+
+ mContent.SetSize( contentSize );
+ Relayout( mContent, contentSize, container );
+
+ mContent.SetParentOrigin(ParentOrigin::TOP_CENTER);
+ mContent.SetAnchorPoint(AnchorPoint::TOP_CENTER);
+
+ mContent.SetPosition( positionOffset );
+
+ positionOffset.y += contentSize.height + mPopupStyle->margin;
+ }
+
+ // Relayout Button Area
+ if( mBottomBg )
+ {
+ mBottomBg.SetSize( popupSize.width, mPopupStyle->bottomSize.height );
+
+ mBottomBg.SetParentOrigin(ParentOrigin::TOP_CENTER);
+ mBottomBg.SetAnchorPoint(AnchorPoint::TOP_CENTER);
+
+ mBottomBg.SetPosition( positionOffset );
+ }
+
+ // Relayout All buttons
+ if ( !mButtons.empty() )
+ {
+ // All buttons should be the same size and fill the button area. The button spacing needs to be accounted for as well.
+ Vector2 buttonSize( ( ( popupSize.width - mPopupStyle->buttonSpacing * ( mButtons.size() - 1 ) ) / mButtons.size() ),
+ mPopupStyle->bottomSize.height - mPopupStyle->margin );
+
+ Vector3 buttonPosition;
+
+ for ( ActorIter iter = mButtons.begin(), endIter = mButtons.end();
+ iter != endIter;
+ ++iter, buttonPosition.x += mPopupStyle->buttonSpacing + buttonSize.width )
+ {
+ iter->SetPosition( buttonPosition );
+
+ // If there is only one button, it needs to be laid out on center.
+ if ( mButtons.size() == 1 )
+ {
+ iter->SetAnchorPoint( AnchorPoint::CENTER );
+ iter->SetParentOrigin( ParentOrigin::CENTER );
+ }
+ else
+ {
+ iter->SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ iter->SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ }
+
+ Relayout( *iter, buttonSize, container );
+ }
+ }
+
+ if( mShowing && mBacking )
+ {
+ Vector2 stageSize = Stage::GetCurrent().GetSize();
+ float length = (stageSize.width > stageSize.height) ? stageSize.width : stageSize.height;
+ Vector3 targetBackingSize = Vector3( length, length, 1.0f );
+
+ mBacking.SetSize( targetBackingSize );
+ }
+ }
+
+ bool Popup::OnKeyEvent(const KeyEvent& event)
+ {
+ bool consumed = false;
+
+ if(event.state == KeyEvent::Down)
+ {
+ if (event.keyCode == Dali::DALI_KEY_ESCAPE || event.keyCode == Dali::DALI_KEY_BACK)
+ {
+ SetState(Toolkit::Popup::POPUP_HIDE);
+ consumed = true;
+ }
+ }
+
+ return consumed;
+ }
+
+ Vector3 Popup::GetNaturalSize()
+ {
+ float margin = 2.0f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
+ const float maxWidth = Stage::GetCurrent().GetSize().width - margin;
+
+ Vector3 naturalSize( 0.0f, 0.0f, 0.0f );
+
- if ( mTitle )
- {
- height += mTitle.GetImplementation().GetHeightForWidth( popupWidth );
- height += mPopupStyle->margin;
- }
-
+ if( mContent )
+ {
+ Vector3 contentSize = RelayoutHelper::GetNaturalSize( mContent );
+ // Choose the biggest width
+ naturalSize.width = std::max( naturalSize.width, contentSize.width );
+ if( naturalSize.width > maxWidth )
+ {
+ naturalSize.width = maxWidth;
+ contentSize.height = RelayoutHelper::GetHeightForWidth( mContent, maxWidth );
+ }
+ naturalSize.height += contentSize.height + mPopupStyle->margin;
+ }
+
+ if( !mButtons.empty() )
+ {
+ naturalSize.height += mPopupStyle->bottomSize.height;
+ }
+
+ // Add the margins
+ naturalSize.width += margin;
+ naturalSize.height += margin;
+
+ return naturalSize;
+ }
+
+ float Popup::GetHeightForWidth( float width )
+ {
+ float height( 0.0f );
+ float popupWidth( width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin ) );
+
+ if( mContent )
+ {
+ height += RelayoutHelper::GetHeightForWidth( mContent, popupWidth ) + mPopupStyle->margin;
+ }
+
+ if( !mButtons.empty() )
+ {
+ height += mPopupStyle->bottomSize.height;
+ }
+
+ // Add the margins
+ float margin( 2.0f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin ) );
+ height += margin;
+
+ return height;
+ }
+
+ float Popup::GetWidthForHeight( float height )
+ {
+ return GetNaturalSize().width;
+ }
+
+ Actor Popup::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
+ {
+ Actor nextFocusableActor( currentFocusedActor );
+
+ // TODO: Needs to be optimised
+
+ if ( !currentFocusedActor || ( currentFocusedActor && KeyboardFocusManager::Get().GetFocusGroup(currentFocusedActor) != Self() ) )
+ {
+ // The current focused actor is not within popup
+ if( mContent && mContent.IsKeyboardFocusable() )
+ {
+ // If content is focusable, move the focus to content
+ nextFocusableActor = mContent;
+ }
+ else if( !mButtons.empty() )
+ {
+ // Otherwise, movethe focus to the first button
+ nextFocusableActor = mButtons[0];
+ }
+ }
+ else
+ {
+ // Rebuild the focus chain because button or content can be added or removed dynamically
+ ActorContainer focusableActors;
+ if( mContent && mContent.IsKeyboardFocusable() )
+ {
+ focusableActors.push_back(mContent);
+ }
+
+ for(unsigned int i = 0; i < mButtons.size(); i++)
+ {
+ if( mButtons[i] && mButtons[i].IsKeyboardFocusable() )
+ {
+ focusableActors.push_back(mButtons[i]);
+ }
+ }
+
+ for ( ActorContainer::iterator iter = focusableActors.begin(), end = focusableActors.end(); iter != end; ++iter )
+ {
+ if ( currentFocusedActor == *iter )
+ {
+ switch ( direction )
+ {
+ case Toolkit::Control::Left:
+ {
+ if ( iter == focusableActors.begin() )
+ {
+ nextFocusableActor = *( focusableActors.end() - 1 );
+ }
+ else
+ {
+ nextFocusableActor = *( iter - 1 );
+ }
+ break;
+ }
+ case Toolkit::Control::Right:
+ {
+ if ( iter == focusableActors.end() - 1 )
+ {
+ nextFocusableActor = *( focusableActors.begin() );
+ }
+ else
+ {
+ nextFocusableActor = *( iter + 1 );
+ }
+ break;
+ }
+
+ case Toolkit::Control::Up:
+ {
+ if ( *iter == mContent )
+ {
+ nextFocusableActor = *( focusableActors.end() - 1 );
+ }
+ else
+ {
+ if ( mContent && mContent.IsKeyboardFocusable() )
+ {
+ nextFocusableActor = mContent;
+ }
+ else
+ {
+ if ( iter == focusableActors.begin() )
+ {
+ nextFocusableActor = *( focusableActors.end() - 1 );
+ }
+ else
+ {
+ nextFocusableActor = *( iter - 1 );
+ }
+ }
+ }
+ break;
+ }
+
+ case Toolkit::Control::Down:
+ {
+ if ( mContent && mContent.IsKeyboardFocusable() )
+ {
+ nextFocusableActor = mContent;
+ }
+ else
+ {
+ if ( iter == focusableActors.end() - 1 )
+ {
+ nextFocusableActor = *( focusableActors.begin() );
+ }
+ else
+ {
+ nextFocusableActor = *( iter + 1 );
+ }
+ }
+
+ if ( *iter == mContent && !mButtons.empty() )
+ {
+ nextFocusableActor = mButtons[0];
+ }
+ break;
+ }
+ }
+
+ if(!nextFocusableActor)
+ {
+ DALI_LOG_WARNING("Can not decide next focusable actor\n");
+ }
+
+ break;
+ }
+ }
+ }
+
+ return nextFocusableActor;
+ }
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
- /**
- * @copydoc Toolkit::Popup::SetTitle( TextView titleActor )
- */
- void SetTitle( Toolkit::TextView titleActor );
-
+ #ifndef __DALI_TOOLKIT_INTERNAL_POPUP_H__
+ #define __DALI_TOOLKIT_INTERNAL_POPUP_H__
+
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // EXTERNAL INCLUDES
+ #include <dali/public-api/actors/image-actor.h>
+ #include <dali/public-api/actors/layer.h>
+ #include <dali/public-api/animation/animation.h>
+
+ // INTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/control-impl.h>
+ #include <dali-toolkit/public-api/controls/popup/popup.h>
+ #include <dali-toolkit/internal/controls/popup/popup-style-impl.h>
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ class Button;
+
+ namespace Internal
+ {
+
+ class Popup;
+ class PopupStyle;
+
+ typedef IntrusivePtr<Popup> PopupPtr;
+ typedef IntrusivePtr<PopupStyle> PopupStylePtr;
+
+ /**
+ * @copydoc Toolkit::Popup
+ */
+ class Popup : public Control
+ {
+ public:
+
+ /**
+ * Create a new Popup.
+ * @return A public handle to the newly allocated Popup.
+ */
+ static Dali::Toolkit::Popup New();
+
+ public:
+
+ /**
+ * Returns number of buttons added to Popup
+ *
+ * @return Number of buttons
+ */
+ size_t GetButtonCount() const;
+
+ /**
+ * @copydoc Toolkit::Popup::SetBackgroundImage
+ */
+ void SetBackgroundImage( Actor image );
+
+ /**
+ * @copydoc Toolkit::Popup::SetButtonAreaImage
+ */
+ void SetButtonAreaImage( Actor image );
+
+ /**
+ * @copydoc Toolkit::Popup::SetTitle( const std::string& text );
+ */
+ void SetTitle( const std::string& text );
+
- Toolkit::TextView GetTitle() const;
+ /**
+ * @copydoc Toolkit::Popup::GetTitle
+ */
- Toolkit::TextView mTitle; ///< Stores the text title.
++ const std::string& GetTitle() const;
+
+ /**
+ * @copydoc Toolkit::Popup::AddButton
+ */
+ void AddButton( Toolkit::Button button );
+
+ /**
+ * @copydoc Toolkit::Popup::SetState( PopupState state )
+ */
+ void SetState( Toolkit::Popup::PopupState state );
+
+ /**
+ * @copydoc Toolkit::Popup::SetState( PopupState state, float duration )
+ */
+ void SetState( Toolkit::Popup::PopupState state, float duration );
+
+ /**
+ * @copydoc Toolkit::Popup::GetState( )
+ */
+ Toolkit::Popup::PopupState GetState() const;
+
+ /**
+ * @copydoc Toolkit::Popup::ShowTail
+ */
+ void ShowTail(const Vector3& position);
+
+ /**
+ * @copydoc Toolkit::Popup::HideTail
+ */
+ void HideTail();
+
+
+ /**
+ * Sets the style of the popup
+ * @param[in] style The style of the popup
+ */
+ void SetStyle(PopupStyle& style);
+
+ /**
+ * Gets the style of the popup
+ * @return style of the popup
+ */
+ PopupStylePtr GetStyle() const;
+
+ protected:
+
+ /**
+ * Construct a new Popup.
+ * @param[in] style of the popup
+ */
+ Popup(PopupStyle& style);
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~Popup();
+
+ private:
+
+ /**
+ * Creates and applies the default background image.
+ */
+ void SetDefaultBackgroundImage();
+
+ /**
+ * Create Dim Backing
+ * (covers all content behind the dialog)
+ */
+ void CreateBacking();
+
+ /**
+ * Create Dialog
+ * (dialog content resides inside this - buttons, title etc.)
+ */
+ void CreateDialog();
+
+ /**
+ * Animate Popup by scaling uniformally from 0 to 100% and vice versa (default behaviour)
+ * @param[in] state The desired state to change into.
+ * @param[in] duration The time for this animation to take.
+ */
+ void HandleStateChange( Toolkit::Popup::PopupState state, float duration );
+
+ /**
+ * Invoked once StateChange has completed.
+ */
+ void HandleStateChangeComplete();
+
+ public: // Signals
+
+ /**
+ * @copydoc Dali::Toolkit::Popup::OutsideTouchedSignal()
+ */
+ Toolkit::Popup::TouchedOutsideSignalType& OutsideTouchedSignal();
+
+ /**
+ * @copydoc Dali::Toolkit::Popup::HiddenSignal()
+ */
+ Toolkit::Popup::HiddenSignalType& HiddenSignal();
+
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+
+ private:
+
+ /**
+ * Signal occurs when the State animation (transition from hide<->show) finishes
+ * @param[in] source The animation that just finished.
+ */
+ void OnStateAnimationFinished( Animation& source );
+
+ /**
+ * Signal occurs when the dimmed backing for the Popup is touched.
+ * @param[in] actor The Actor Touched
+ * @param[in] event The Touch Event.
+ * @return Whether to consume event or not.
+ */
+ bool OnBackingTouched(Actor actor, const TouchEvent& event);
+
+ /**
+ * Signal occurs when the mouse wheel event is occured on dimmed backing for the Popup.
+ * @param[in] actor The Actor got mouse wheel
+ * @param[in] event The Mouse Wheel Event.
+ * @return Whether to consume event or not.
+ */
+ bool OnBackingMouseWheelEvent(Actor actor, const MouseWheelEvent& event);
+
+ /**
+ * Signal occurs when the dialog has been touched.
+ * @param[in] actor The Actor Touched
+ * @param[in] event The Touch Event.
+ * @return Whether to consume event or not.
+ */
+ bool OnDialogTouched(Actor actor, const TouchEvent& event);
+
+ /**
+ * @copydoc Toolkit::Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * @copydoc Dali::CustomActorImpl::OnPropertySet()
+ */
+ virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
+
+ /**
+ * From Control; called after a child has been added to the owning actor.
+ * @param[in] child The child which has been added.
+ */
+ virtual void OnControlChildAdd( Actor& child );
+
+ /**
+ * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& size )
+ */
+ virtual void OnControlSizeSet( const Vector3& size );
+
+ /**
+ * @copydoc Control::OnRelayOut()
+ */
+ virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+
+ /**
+ * @copydoc Control::OnKeyEvent()
+ */
+ virtual bool OnKeyEvent(const KeyEvent& event);
+
+ /**
+ * @copydoc Control::GetNaturalSize()
+ */
+ virtual Vector3 GetNaturalSize();
+
+ /**
+ * @copydoc Control::GetHeightForWidth()
+ */
+ float GetHeightForWidth( float width );
+
+ /**
+ * @copydoc Control::GetWidthForHeight()
+ */
+ float GetWidthForHeight( float height );
+
+ /**
+ * @copydoc Control::GetNextKeyboardFocusableActor()
+ */
+ Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
+
+ private:
+
+ // Undefined
+ Popup(const Popup&);
+
+ // Undefined
+ Popup& operator=(const Popup& rhs);
+
+ private:
+
+ struct LayoutInfo
+ {
+ Vector3 mTitleSize;
+ Vector3 mContentSize;
+ Vector3 mButtonBgSize;
+ std::vector<Vector3> mButtonSize;
+ };
+
+ private:
+
+ bool mShowing; ///< Popup is showing or not
+
+ Layer mLayer; ///< Popup Layer (i.e. Dim backing and PopupBg reside in this)
+ Actor mPopupBg; ///< Popup Background (i.e. dialog reside in this)
+ ImageActor mBacking; ///< Backing actor (dim effect)
+
+ Actor mPreviousFocusedActor; ///< Store the previous focused actor to restore the focus when popup hide
+
+ Actor mBackgroundImage; ///< Stores the background image.
+ Actor mButtonAreaImage; ///< Stores the button background image.
+ Actor mContent; ///< Stores popup's content.
+ Actor mBottomBg; ///< bottom button bar background. ImageActor is replaced with Actor due to hidden image.
+ Actor mTailImage; ///< Stores the tail image
+
+ ActorContainer mButtons; ///< Keeps track of the buttons added to this popup.
+ Toolkit::Popup::PopupState mState; ///< Popup current state.
+ Animation mAnimation; ///< The animation instance managing state changing.
+ bool mAlterAddedChild; ///< Flag used to control whether children are reparented or not.
+ PopupStylePtr mPopupStyle; ///< The style to be used for this popup.
+
+ LayoutInfo mLayoutInfo; ///< Stores sizes of all popup components.
+
+ Toolkit::Popup::TouchedOutsideSignalType mTouchedOutsideSignal;
+ Toolkit::Popup::HiddenSignalType mHiddenSignal;
+
+ Property::Index mPropertyTitle; ///< Property index for Title.
+ Property::Index mPropertyState; ///< Property index for popup state.
+ };
+
+ } // namespace Internal
+
+ // Helpers for public-api forwarding methods
+
+ inline Toolkit::Internal::Popup& GetImpl(Toolkit::Popup& pub)
+ {
+ DALI_ASSERT_ALWAYS(pub);
+
+ Dali::RefObject& handle = pub.GetImplementation();
+
+ return static_cast<Toolkit::Internal::Popup&>(handle);
+ }
+
+ inline const Toolkit::Internal::Popup& GetImpl(const Toolkit::Popup& pub)
+ {
+ DALI_ASSERT_ALWAYS(pub);
+
+ const Dali::RefObject& handle = pub.GetImplementation();
+
+ return static_cast<const Toolkit::Internal::Popup&>(handle);
+ }
+
+ } // namespace Toolkit
+
+ } // namespace Dali
+
+ #endif // __DALI_TOOLKIT_INTERNAL_POPUP_H__
--- /dev/null
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
-
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 HEADER
+
+ #include "relayout-controller-impl.h"
+
+ // EXTERNAL INCLUDES
+ #include <dali/public-api/actors/layer.h>
+ #include <dali/public-api/common/stage.h>
+ #include <dali/integration-api/debug.h>
+
+ #if defined(DEBUG_ENABLED)
+ #include <sstream>
+ #endif // defined(DEBUG_ENABLED)
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ namespace
+ {
+ #if defined(DEBUG_ENABLED)
+
+ Integration::Log::Filter* gLogFilter( Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_RELAYOUT_CONTROLLER") );
+
+ /**
+ * Prints out all the children of the given actor when debug is enabled.
+ *
+ * @param[in] actor The actor whose children to print.
+ * @param[in] level The number of " | " to put in front of the children.
+ */
+ void PrintChildren( Actor actor, int level )
+ {
+ std::ostringstream output;
+
+ for ( int t = 0; t < level; ++t )
+ {
+ output << " | ";
+ }
+
+ output << actor.GetTypeName();
+
+ output << " - Pos: " << actor.GetCurrentPosition() << " Size: " << actor.GetCurrentSize() << ",";
+
+ output << " (" << actor.GetObjectPtr() << ")" << std::endl;
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, output.str().c_str() );
+
+ ++level;
+ unsigned int numChildren = actor.GetChildCount();
+ for( unsigned int i=0; i<numChildren; ++i )
+ {
+ PrintChildren( actor.GetChildAt(i), level );
+ }
+ --level;
+ }
+
+ /**
+ * Prints the entire hierarchy of the scene.
+ */
+ void PrintHierarchy()
+ {
+ if ( gLogFilter->IsEnabledFor( Debug::Verbose ) )
+ {
+ PrintChildren( Stage().GetCurrent().GetRootLayer(), 0 );
+ }
+ }
+
+ #define PRINT_HIERARCHY PrintHierarchy()
+
+ #else // defined(DEBUG_ENABLED)
+
+ #define PRINT_HIERARCHY
+
+ #endif // defined(DEBUG_ENABLED)
+
+ /**
+ * Sets the target to source if the individual elements of source are NOT zero.
+ *
+ * @param[out] target The Vector2 elements to set if the source Vector2 elements are not 0.
+ * @param[in] source The Vector2 elements that are to be set to the target Vector2.
+ */
+ void SetIfNotZero( Vector2& target, const Vector2& source )
+ {
+ // Only set the width if it is non zero.
+ if ( !EqualsZero( source.width ) )
+ {
+ target.width = source.width;
+ }
+
+ // Only set the height if it is non zero.
+ if ( !EqualsZero( source.height ) )
+ {
+ target.height = source.height;
+ }
+ }
+
+ /**
+ * Finds controls in the hierarchy of actor. It descends the tree if the actor has more Actors.
+ * If it is a control, it no longer descends the tree.
+ *
+ * @param[in] actor The actor in which controls should be found.
+ * @param[in] size The size that this actor and its children should be.
+ */
+ void FindControls( Actor actor, ControlStack& controls, Vector2 size )
+ {
+ Toolkit::Control control( Toolkit::Control::DownCast( actor ) );
+ if( control )
+ {
+ // If the control size has been set by the application / control, then we should try and honour that.
+ Vector2 controlSetSize( control.GetImplementation().GetSizeSet() );
+
+ // Only set the width and height if they are non zero.
+ SetIfNotZero( size, controlSetSize );
+
+ controls.push_back( ControlSizePair( control, size ) );
+ }
+ else
+ {
+ unsigned int numChildren = actor.GetChildCount();
+ for( unsigned int i=numChildren; i>0; --i )
+ {
+ FindControls( actor.GetChildAt(i-1), controls, size );
+ }
+ }
+ }
+
+ /**
+ * Pushes the controls in the container, to the stack.
+ *
+ * @param[in,out] controlStack The stack to push controls to.
+ * @param[in] container The container to push controls from.
+ */
+ void PushToStack( ControlStack& controlStack, const ActorSizeContainer& container )
+ {
+ for ( ActorSizeContainer::const_reverse_iterator iter = container.rbegin(), endIter = container.rend(); iter != endIter; ++iter )
+ {
+ FindControls( iter->first, controlStack, iter->second );
+ }
+ }
+
+ } // unnamed namespace
+
+ RelayoutControllerImpl::RelayoutControllerImpl( bool& relayoutFlag )
+ : mRelayoutFlag( relayoutFlag ),
+ mRelayoutConnection( false )
+ {
+ // make space for 32 controls to avoid having to copy construct a lot in the beginning
+ mControlStack.reserve( 32 );
+ mSizecontainer.reserve( 32 );
+ }
+
+ RelayoutControllerImpl::~RelayoutControllerImpl()
+ {
+ }
+
+ void RelayoutControllerImpl::Request()
+ {
+ //TODO use Relayout Request to set up logic to optimize relayout of the actors/controls in the scene
+
+ if( !mRelayoutConnection )
+ {
+ Stage stage = Stage::GetCurrent();
+ stage.EventProcessingFinishedSignal().Connect( this, &RelayoutControllerImpl::Relayout );
+ mRelayoutConnection = true;
+ }
+ }
+
+ void RelayoutControllerImpl::Relayout()
+ {
+ // only do something when requested
+ if( mRelayoutFlag )
+ {
+ // clear the flag as we're now doing the relayout
+ mRelayoutFlag = false;
+ PRINT_HIERARCHY;
+
+ mControlStack.clear(); // we do not release memory, just empty the container
+
+ // 1. Finds all top-level controls from the root actor and allocate them the size of the stage
+ // These controls are paired with the stage size and added to the stack.
+ FindControls( Stage().GetCurrent().GetRootLayer(), mControlStack, Stage::GetCurrent().GetSize() );
+
+ // 2. Iterate through the stack until it's empty.
+ while ( !mControlStack.empty() )
+ {
+ ControlSizePair pair ( mControlStack.back() );
+ Toolkit::Control control ( pair.first );
+ Vector2 size ( pair.second );
+ mControlStack.pop_back();
+
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Allocating %p (%.2f, %.2f)\n", control.GetObjectPtr(), size.width, size.height );
+
+ mSizecontainer.clear();
+ // 3. Negotiate the size with the current control. Pass it an empty container which the control
+ // has to fill with all the actors it has not done any size negotiation for.
+ control.GetImplementation().NegotiateSize( size, mSizecontainer );
+
+ // 4. Push the controls from the actors in the container to the stack.
+ PushToStack( mControlStack, mSizecontainer );
+ }
+ }
+ // should not disconnect the signal as that causes some control size negotiations to not work correctly
+ // this algorithm needs more optimization as well
+ }
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
-#include "dali-toolkit/public-api/controls/text-view/text-view.h"
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 HEADER
+
+ #include "relayout-controller.h"
+ #include "relayout-controller-impl.h"
+
+ // EXTERNAL INCLUDES
+ #include <stack>
+ #include <sstream>
+ #include <dali/public-api/adaptor-framework/singleton-service.h>
+ #include <dali/integration-api/debug.h>
+
+ // INTERNAL INCLUDES
+
+ #include "dali-toolkit/public-api/controls/control.h"
+ #include "dali-toolkit/public-api/controls/control-impl.h"
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ namespace
+ {
+ // Flag to avoid doing more than one request per frame
+ // getting the singleton handle can be expensive as it requires calling to adaptor, dynamic cast etc
+ // and it can get called 100 times per frame easily in startup and new view initialization
+ bool gRelayoutRequestPending = false;
+ }
+
+ RelayoutController::RelayoutController()
+ {
+
+ }
+
+ RelayoutController::~RelayoutController()
+ {
+
+ }
+
+ void RelayoutController::Request()
+ {
+ // are we already going to do it this frame
+ if( !gRelayoutRequestPending )
+ {
+ RelayoutController controller;
+
+ // Check whether the RelayoutController is already created
+ SingletonService singletonService( SingletonService::Get() );
+ if ( singletonService )
+ {
+ Dali::BaseHandle handle = singletonService.GetSingleton(typeid(RelayoutController));
+
+ if(handle)
+ {
+ // If so, downcast the handle of singleton to RelayoutController
+ controller = RelayoutController(dynamic_cast<Internal::RelayoutControllerImpl*>(handle.GetObjectPtr()));
+ }
+
+ if(!controller)
+ {
+ // If not, create the RelayoutController and register it as a singleton
+ controller = RelayoutController( new Internal::RelayoutControllerImpl(gRelayoutRequestPending) );
+ singletonService.Register( typeid(controller), controller );
+ }
+
+ GetImpl(controller).Request();
+ gRelayoutRequestPending = true;
+ }
+ }
+ }
+
+ RelayoutController::RelayoutController(Internal::RelayoutControllerImpl *impl)
+ : BaseHandle(impl)
+ {
+ }
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
+
--- /dev/null
-#include <dali/public-api/actors/text-actor.h>
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // CLASS HEADER
+ #include "relayout-helper.h"
+
+ // EXTERNAL INCLUDES
+ #include <dali/public-api/actors/image-actor.h>
- else
- {
- // Get natural size for TextActor.
- TextActor textActor = TextActor::DownCast( actor );
- if( textActor )
- {
- Font font = textActor.GetFont();
- if( !font )
- {
- font = Font::New();
- }
- size = font.MeasureText( textActor.GetText() );
- size.depth = depth;
- }
- }
+
+ // INTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/control.h>
+
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal
+ {
+
+ namespace RelayoutHelper
+ {
+
+ Vector3 GetNaturalSize( Actor actor )
+ {
+ Vector3 size( 0.0f, 0.0f, 0.0f );
+
+ Toolkit::Control control = Toolkit::Control::DownCast( actor );
+ if( control )
+ {
+ size = control.GetNaturalSize();
+ }
+ else
+ {
+ size = actor.GetCurrentSize();
+ const float depth = size.depth;
+
+ // Get natural size for ImageActor.
+ // TODO: currently it doesn't work as expected.
+ ImageActor imageActor = ImageActor::DownCast( actor );
+ if( ( imageActor ) && ( imageActor.GetImage() ) )
+ {
+ Image image = imageActor.GetImage();
+ size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), depth );
+ }
- TextActor textActor = TextActor::DownCast( actor );
- if( textActor )
- {
- Font font = textActor.GetFont();
- if( !font )
- {
- font = Font::New();
- }
- size = font.MeasureText( textActor.GetText() );
-
- constrainSize = true;
- }
- else
- {
- size = actor.GetCurrentSize();
- }
+ }
+
+ return size;
+ }
+
+ float GetHeightForWidth( Actor actor, float width )
+ {
+ float height = 0.0f;
+
+ Toolkit::Control control = Toolkit::Control::DownCast( actor );
+ if( control )
+ {
+ height = control.GetHeightForWidth( width );
+ }
+ else
+ {
+ bool constrainSize = false;
+ Vector3 size( 0.0f, 0.0f, 0.0f );
+
+ ImageActor imageActor = ImageActor::DownCast( actor );
+ if( ( imageActor ) && ( imageActor.GetImage() ) )
+ {
+ Image image = imageActor.GetImage();
+ size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), 0.0f );
+
+ constrainSize = true;
+ }
+ else
+ {
++ size = actor.GetCurrentSize();
+ }
+
+ // Scale the actor
+ float scaleRatio = width / size.width;
+ if( constrainSize )
+ {
+ // Allow the scale to decrease if greater than input width but not increase if less than input width
+ if( scaleRatio > 1.0f )
+ {
+ scaleRatio = 1.0f;
+ }
+ }
+
+ height = size.height * scaleRatio;
+ }
+
+ return height;
+ }
+
+ } // namespace RelayoutHelper
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
-
- if( mHandleValueTextView )
- {
- std::stringstream ss;
- ss.precision( GetValuePrecision() );
- ss << std::fixed << clampledValue;
- mHandleValueTextView.SetText( ss.str() );
- }
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // CLASS HEADER
+ #include <dali-toolkit/internal/controls/slider/slider-impl.h>
+
+ // EXTERNAL INCLUDES
+ #include <dali/public-api/events/touch-event.h>
+ #include <dali/public-api/object/type-registry.h>
+
+ // EXTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/control-impl.h>
+
+ #include <sstream>
+
+ using namespace Dali;
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ // Properties
+ const Property::Index Slider::LOWER_BOUND_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX;
+ const Property::Index Slider::UPPER_BOUND_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 1;
+
+ const Property::Index Slider::VALUE_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 2;
+ const Property::Index Slider::HIT_REGION_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 3;
+ const Property::Index Slider::BACKING_REGION_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 4;
+ const Property::Index Slider::HANDLE_REGION_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 5;
+
+ const Property::Index Slider::BACKING_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 6;
+ const Property::Index Slider::HANDLE_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 7;
+ const Property::Index Slider::PROGRESS_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 8;
+ const Property::Index Slider::POPUP_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 9;
+ const Property::Index Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 10;
+
+ const Property::Index Slider::DISABLE_COLOR_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 11;
+ const Property::Index Slider::POPUP_TEXT_COLOR_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 12;
+
+ const Property::Index Slider::VALUE_PRECISION_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 13;
+
+ const Property::Index Slider::SHOW_POPUP_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 14;
+ const Property::Index Slider::SHOW_VALUE_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 15;
+
+ const Property::Index Slider::ENABLED_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 16;
+
+ const Property::Index Slider::MARKS_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 17;
+ const Property::Index Slider::SNAP_TO_MARKS_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 18;
+ const Property::Index Slider::MARK_TOLERANCE_PROPERTY = Internal::Slider::SLIDER_PROPERTY_START_INDEX + 19;
+
+ namespace Internal
+ {
+
+ namespace
+ {
+ const float BACKING_Z = -0.1f;
+ const float PROGRESS_Z = 0.1f;
+ const float HANDLE_Z = 1.0f;
+ const float VALUE_TEXT_INCREMENT = 0.01f;
+ const float HANDLE_VALUE_DISPLAY_TEXT_Z = HANDLE_Z + VALUE_TEXT_INCREMENT;
+ const float VALUE_DISPLAY_TEXT_Z = VALUE_TEXT_INCREMENT + VALUE_TEXT_INCREMENT; // Put above HANDLE_VALUE_DISPLAY_TEXT_Z (parented to handle)
+
+ const float MARK_SNAP_TOLERANCE = 0.05f; // 5% of slider width
+
+ const int VALUE_VIEW_SHOW_DURATION = 1000; // millisec
+ const int VALUE_VIEW_SHOW_DURATION_LONG = 2000; // millisec
+
+ const float VALUE_VERTICAL_OFFSET = 48.0f;
+
+ const float DEFAULT_WIDTH = 0.0f;
+ const float DEFAULT_HEIGHT = 27.0f;
+ const float DEFAULT_HIT_HEIGHT = 72.0f;
+ const float DEFAULT_HANDLE_HEIGHT = DEFAULT_HIT_HEIGHT;
+
+ const char* SKINNED_BACKING_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin.9.png";
+ const char* SKINNED_HANDLE_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin-handle.png";;
+ const char* SKINNED_PROGRESS_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin-progress.9.png";
+ const char* SKINNED_POPUP_IMAGE_NAME = DALI_IMAGE_DIR "slider-popup.9.png";
+ const char* SKINNED_POPUP_ARROW_IMAGE_NAME = DALI_IMAGE_DIR "slider-popup-arrow.png";
+
+ const Vector2 DEFAULT_HIT_REGION( DEFAULT_WIDTH, DEFAULT_HIT_HEIGHT );
+ const Vector2 DEFAULT_BACKING_REGION( DEFAULT_WIDTH, DEFAULT_HEIGHT );
+ const Vector2 DEFAULT_HANDLE_REGION( DEFAULT_HANDLE_HEIGHT, DEFAULT_HANDLE_HEIGHT );
+
+ const Vector4 DEFAULT_DISABLE_COLOR( 0.5f, 0.5f, 0.5f, 1.0f );
+ const Vector4 DEFAULT_POPUP_TEXT_COLOR( 0.5f, 0.5f, 0.5f, 1.0f );
+
+ const float VALUE_POPUP_MARGIN = 10.0f;
+ const float VALUE_POPUP_HEIGHT = 81.0f;
+ const float VALUE_POPUP_MIN_WIDTH = 54.0f;
+ const Vector2 VALUE_POPUP_ARROW_SIZE( 18.0f, 18.0f );
+
+ const float DEFAULT_LOWER_BOUND = 0.0f;
+ const float DEFAULT_UPPER_BOUND = 1.0f;
+ const float DEFAULT_VALUE = 0.0f;
+ const int DEFAULT_VALUE_PRECISION = 0;
+ const bool DEFAULT_SHOW_POPUP = false;
+ const bool DEFAULT_SHOW_VALUE = true;
+ const bool DEFAULT_ENABLED = true;
+ const bool DEFAULT_SNAP_TO_MARKS = false;
+
+ BaseHandle Create()
+ {
+ return Dali::Toolkit::Slider::New();
+ }
+
+ TypeRegistration typeRegistration( typeid(Dali::Toolkit::Slider), typeid(Dali::Toolkit::Control), Create );
+
+ SignalConnectorType signalConnector1( typeRegistration, Toolkit::Slider::SIGNAL_VALUE_CHANGED, &Toolkit::Internal::Slider::DoConnectSignal );
+ SignalConnectorType signalConnector2( typeRegistration, Toolkit::Slider::SIGNAL_MARK, &Toolkit::Internal::Slider::DoConnectSignal );
+
+ PropertyRegistration property1( typeRegistration, "lower-bound", Toolkit::Slider::LOWER_BOUND_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property2( typeRegistration, "upper-bound", Toolkit::Slider::UPPER_BOUND_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property3( typeRegistration, "value", Toolkit::Slider::VALUE_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
+
+ PropertyRegistration property4( typeRegistration, "hit-region", Toolkit::Slider::HIT_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property5( typeRegistration, "backing-region", Toolkit::Slider::BACKING_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property6( typeRegistration, "handle-region", Toolkit::Slider::HANDLE_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty );
+
+ PropertyRegistration property7( typeRegistration, "backing-image-name", Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property8( typeRegistration, "handle-image-name", Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property9( typeRegistration, "progress-image-name", Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property10( typeRegistration, "popup-image-name", Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property11( typeRegistration, "popup-arrow-image-name", Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty );
+
+ PropertyRegistration property12( typeRegistration, "disable-color", Toolkit::Slider::DISABLE_COLOR_PROPERTY, Property::VECTOR4, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property13( typeRegistration, "popup-text-color", Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY, Property::VECTOR4, &Slider::SetProperty, &Slider::GetProperty );
+
+ PropertyRegistration property14( typeRegistration, "value-precision", Toolkit::Slider::VALUE_PRECISION_PROPERTY, Property::INTEGER, &Slider::SetProperty, &Slider::GetProperty );
+
+ PropertyRegistration property15( typeRegistration, "show-popup", Toolkit::Slider::SHOW_POPUP_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property16( typeRegistration, "show-value", Toolkit::Slider::SHOW_VALUE_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty );
+
+ PropertyRegistration property17( typeRegistration, "enabled", Toolkit::Slider::ENABLED_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty );
+
+ PropertyRegistration property18( typeRegistration, "marks", Toolkit::Slider::MARKS_PROPERTY, Property::ARRAY, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property19( typeRegistration, "snap-to-marks", Toolkit::Slider::SNAP_TO_MARKS_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty );
+ PropertyRegistration property20( typeRegistration, "mark-tolerance", Toolkit::Slider::MARK_TOLERANCE_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty );
+
+ } // namespace
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ // Slider
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+
+ Dali::Toolkit::Slider Slider::New()
+ {
+ // Create the implementation
+ SliderPtr slider( new Slider() );
+
+ // Pass ownership to CustomActor via derived handle
+ Dali::Toolkit::Slider handle( *slider );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ slider->Initialize();
+
+ return handle;
+ }
+
+ Slider::Slider()
+ : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+ mState( NORMAL ),
+ mDisableColor( 0.0f, 0.0f, 0.0f, 0.0f ),
+ mPopupTextColor( 0.0f, 0.0f, 0.0f, 0.0f ),
+ mHitRegion( 0.0f, 0.0f ),
+ mBackingRegion( 0.0f, 0.0f ),
+ mHandleRegionSize( 0.0f, 0.0f ),
+ mLowerBound( 0.0f ),
+ mUpperBound( 0.0f ),
+ mValue( 0.0f ),
+ mMarkTolerance( 0.0f ),
+ mValuePrecision( 0 ),
+ mShowPopup( false ),
+ mShowValue( false ),
+ mSnapToMarks( false )
+ {
+ }
+
+ Slider::~Slider()
+ {
+ }
+
+ void Slider::OnInitialize()
+ {
+ // Setup
+ CreateChildren();
+
+ // Properties
+ Actor self = Self();
+
+ SetHitRegion( DEFAULT_HIT_REGION );
+ SetBackingRegion( DEFAULT_BACKING_REGION );
+ SetHandleRegion( DEFAULT_HANDLE_REGION );
+
+ SetBackingImageName( SKINNED_BACKING_IMAGE_NAME );
+ SetHandleImageName( SKINNED_HANDLE_IMAGE_NAME );
+ SetProgressImageName( SKINNED_PROGRESS_IMAGE_NAME );
+ SetPopupImageName( SKINNED_POPUP_IMAGE_NAME );
+ SetPopupArrowImageName( SKINNED_POPUP_ARROW_IMAGE_NAME );
+
+ SetPopupTextColor( DEFAULT_POPUP_TEXT_COLOR );
+
+ SetShowPopup( DEFAULT_SHOW_POPUP );
+ SetShowValue( DEFAULT_SHOW_VALUE );
+
+ SetEnabled( DEFAULT_ENABLED );
+ SetDisableColor( DEFAULT_DISABLE_COLOR );
+
+ SetSnapToMarks( DEFAULT_SNAP_TO_MARKS );
+ SetMarkTolerance( MARK_SNAP_TOLERANCE );
+
+ SetLowerBound( DEFAULT_LOWER_BOUND );
+ SetUpperBound( DEFAULT_UPPER_BOUND );
+ UpdateSkin();
+ SetValuePrecision( DEFAULT_VALUE_PRECISION );
+ mValue = DEFAULT_VALUE;
+ DisplayValue( mValue, false ); // Run this last to display the correct value
+
+ // Size the Slider actor to a default
+ self.SetSize( DEFAULT_HIT_REGION.x, DEFAULT_HIT_REGION.y );
+ }
+
+ void Slider::OnControlSizeSet( const Vector3& size )
+ {
+ // Factor in handle overshoot into size of backing
+ SetHitRegion( Vector2( size.x, GetHitRegion().y ) );
+ SetBackingRegion( Vector2( size.x - GetHandleRegion().x, GetBackingRegion().y ) );
+ }
+
+ bool Slider::OnTouchEvent(Actor actor, const TouchEvent& event)
+ {
+ if( mState != DISABLED )
+ {
+ TouchPoint::State touchState = event.GetPoint(0).state;
+
+ if( touchState == TouchPoint::Down )
+ {
+ mState = PRESSED;
+
+ float percentage = MapPercentage( event.GetPoint(0).local );
+ float value = MapBounds( ( GetSnapToMarks() ) ? SnapToMark( percentage ) : MarkFilter( percentage ), GetLowerBound(), GetUpperBound() );
+ SetValue( value );
+ DisplayPopup( value );
+ }
+ else if( touchState == TouchPoint::Up)
+ {
+ if( mState == PRESSED )
+ {
+ mState = NORMAL;
+ mSlidingFinishedSignal.Emit( Toolkit::Slider::DownCast( Self() ), GetValue() );
+ }
+ }
+ }
+
+ return true;
+ }
+
+ void Slider::OnPan( Actor actor, const PanGesture& gesture )
+ {
+ // gesture.position is in local actor coordinates
+ if( mState != DISABLED )
+ {
+ switch( gesture.state )
+ {
+ case Gesture::Continuing:
+ {
+ if( mState == PRESSED )
+ {
+ float value = MapBounds( MarkFilter ( MapPercentage( gesture.position ) ), GetLowerBound(), GetUpperBound() );
+ SetValue( value );
+ DisplayPopup( value );
+ }
+ break;
+ }
+ case Gesture::Finished:
+ {
+ if( mState == PRESSED )
+ {
+ if( GetSnapToMarks() )
+ {
+ float value = MapBounds( SnapToMark( MapPercentage( gesture.position ) ), GetLowerBound(), GetUpperBound() );
+ SetValue( value );
+ DisplayPopup( value );
+ }
+ mSlidingFinishedSignal.Emit( Toolkit::Slider::DownCast( Self() ), GetValue() );
+ }
+
+ mState = NORMAL;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ float Slider::HitSpaceToDomain( float x )
+ {
+ float halfRegionWidth = GetHitRegion().x * 0.5f;
+ float halfDomainWidth = ( mDomain.to.x - mDomain.from.x ) * 0.5f;
+ float endDiff = halfRegionWidth - halfDomainWidth;
+
+ return x - endDiff;
+ }
+
+ float Slider::MapPercentage( const Vector2& point )
+ {
+ return Clamp( ( HitSpaceToDomain( point.x ) - mDomain.from.x ) / ( mDomain.to.x - mDomain.from.x ), 0.0f, 1.0f );
+ }
+
+ float Slider::MapValuePercentage( float value )
+ {
+ return ( value - GetLowerBound() ) / ( GetUpperBound() - GetLowerBound() );
+ }
+
+ float Slider::MapBounds( float percent, float lowerBound, float upperBound )
+ {
+ return lowerBound + percent * ( upperBound - lowerBound );
+ }
+
+ Slider::Domain Slider::CalcDomain( const Vector2& currentSize )
+ {
+ return Domain( Vector2( 0.0f, 0.0f ), currentSize );
+ }
+
+ void Slider::DisplayValue( float value, bool raiseSignals )
+ {
+ float clampledValue = Clamp( value, GetLowerBound(), GetUpperBound() );
+
+ float percent = MapValuePercentage( clampledValue );
+
+ float x = mDomain.from.x + percent * ( mDomain.to.x - mDomain.from.x );
+
+ mHandle.SetPosition( x, 0.0f, HANDLE_Z );
+
+ // Progress bar
+ if( mProgress )
+ {
+ if( clampledValue > 0.0f )
+ {
+ mProgress.SetVisible( true ); // Deliberately set this in case multiple SetValues are fired at once
+ mProgress.SetSize( x, GetBackingRegion().y );
+ }
+ else
+ {
+ mProgress.SetVisible( false );
+ }
+ }
+
+ // Signals
+ if( raiseSignals )
+ {
+ Toolkit::Slider self = Toolkit::Slider::DownCast( Self() );
+ mValueChangedSignal.Emit( self, clampledValue );
+
+ int markIndex;
+ if( MarkReached( percent, markIndex ) )
+ {
+ mMarkSignal.Emit( self, markIndex );
+ }
+ }
-Toolkit::TextView Slider::CreatePopupText()
-{
- Toolkit::TextView textView = Toolkit::TextView::New();
- textView.SetParentOrigin( ParentOrigin::CENTER );
- textView.SetAnchorPoint( AnchorPoint::CENTER );
- textView.SetSizePolicy( Toolkit::Control::Flexible, Toolkit::Control::Flexible );
- textView.SetZ( VALUE_DISPLAY_TEXT_Z );
- return textView;
-}
+ }
+
+ void Slider::SetMarks( const MarkList& marks )
+ {
+ float value;
+ for( MarkList::const_iterator it = marks.begin(), itEnd = marks.end(); it != itEnd; ++it )
+ {
+ const Property::Value& propertyValue = *it;
+ propertyValue.Get( value );
+
+ mMarks.push_back( value );
+ }
+ }
+
+ const Slider::MarkList& Slider::GetMarks() const
+ {
+ return mMarks;
+ }
+
+ void Slider::SetSnapToMarks( bool snap )
+ {
+ mSnapToMarks = snap;
+ }
+
+ bool Slider::GetSnapToMarks() const
+ {
+ return mSnapToMarks;
+ }
+
+ Actor Slider::CreateHitRegion()
+ {
+ Actor hitRegion = Actor::New();
+ hitRegion.SetParentOrigin( ParentOrigin::CENTER );
+ hitRegion.SetAnchorPoint( AnchorPoint::CENTER );
+ hitRegion.TouchedSignal().Connect( this, &Slider::OnTouchEvent );
+
+ return hitRegion;
+ }
+
+ ImageActor Slider::CreateBacking()
+ {
+ ImageActor backing = ImageActor::New();
+ backing.SetParentOrigin( ParentOrigin::CENTER );
+ backing.SetAnchorPoint( AnchorPoint::CENTER );
+ backing.SetZ( BACKING_Z );
+
+ return backing;
+ }
+
+ void Slider::SetBackingImageName( const std::string& imageName )
+ {
+ if( mBacking && imageName != String::EMPTY )
+ {
+ Image image = Image::New( imageName );
+ mBacking.SetImage( image );
+ }
+ }
+
+ std::string Slider::GetBackingImageName()
+ {
+ if( mBacking )
+ {
+ return mBacking.GetImage().GetFilename();
+ }
+
+ return std::string( "" );
+ }
+
+ ImageActor Slider::CreateProgress()
+ {
+ ImageActor progress = ImageActor::New();
+ progress.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ progress.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+ progress.SetZ( PROGRESS_Z );
+
+ return progress;
+ }
+
+ void Slider::SetProgressImageName( const std::string& imageName )
+ {
+ if( mProgress && imageName != String::EMPTY )
+ {
+ Image image = Image::New( imageName );
+ mProgress.SetImage( image );
+ }
+ }
+
+ std::string Slider::GetProgressImageName()
+ {
+ if( mProgress )
+ {
+ return mProgress.GetImage().GetFilename();
+ }
+
+ return std::string( "" );
+ }
+
+ void Slider::SetPopupImageName( const std::string& imageName )
+ {
+ mPopupImageName = imageName;
+ }
+
+ std::string Slider::GetPopupImageName()
+ {
+ return mPopupImageName;
+ }
+
+ void Slider::CreatePopupImage( const std::string& imageName )
+ {
+ if( mPopup && imageName != String::EMPTY )
+ {
+ Image image = Image::New( imageName );
+ mPopup.SetImage( image );
+ }
+ }
+
+ void Slider::SetPopupArrowImageName( const std::string& imageName )
+ {
+ mPopupArrowImageName = imageName;
+ }
+
+ std::string Slider::GetPopupArrowImageName()
+ {
+ return mPopupArrowImageName;
+ }
+
+ void Slider::CreatePopupArrowImage( const std::string& imageName )
+ {
+ if( mPopupArrow && imageName != String::EMPTY )
+ {
+ Image image = Image::New( imageName );
+ mPopupArrow.SetImage( image );
+ }
+ }
+
+ void Slider::ResizeProgressRegion( const Vector2& region )
+ {
+ if( mProgress )
+ {
+ mProgress.SetSize( region );
+ }
+ }
+
+ ImageActor Slider::CreateHandle()
+ {
+ ImageActor handle = ImageActor::New();
+ handle.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ handle.SetAnchorPoint( AnchorPoint::CENTER );
+ handle.SetZ( HANDLE_Z );
+
+ return handle;
+ }
+
+ ImageActor Slider::CreatePopupArrow()
+ {
+ ImageActor arrow = ImageActor::New();
+ arrow.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ arrow.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+ arrow.SetZ( HANDLE_Z );
+
+ return arrow;
+ }
+
- mValueTextView = CreatePopupText();
- popup.Add( mValueTextView );
-
++//Toolkit::TextView Slider::CreatePopupText()
++//{
++//}
+
+ ImageActor Slider::CreatePopup()
+ {
+ ImageActor popup = ImageActor::New();
+ popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+
- if( mHandle && !mHandleValueTextView )
- {
- mHandleValueTextView = Toolkit::TextView::New();
- mHandleValueTextView.SetParentOrigin( ParentOrigin::CENTER );
- mHandleValueTextView.SetAnchorPoint( AnchorPoint::CENTER );
- mHandleValueTextView.SetSize( GetHandleRegion() );
- mHandleValueTextView.SetZ( HANDLE_VALUE_DISPLAY_TEXT_Z );
- mHandle.Add( mHandleValueTextView );
- }
+ return popup;
+ }
+
+ void Slider::SetHandleImageName( const std::string& imageName )
+ {
+ if( mHandle && imageName != String::EMPTY )
+ {
+ Image image = Image::New( imageName );
+ mHandle.SetImage( image );
+ }
+ }
+
+ std::string Slider::GetHandleImageName()
+ {
+ if( mHandle )
+ {
+ return mHandle.GetImage().GetFilename();
+ }
+
+ return std::string( "" );
+ }
+
+ void Slider::ResizeHandleRegion( const Vector2& region )
+ {
+ if( mHandle )
+ {
+ mHandle.SetSize( region );
+ }
+ }
+
+ void Slider::CreateHandleValueDisplay()
+ {
- if(mHandleValueTextView)
- {
- mHandleValueTextView.Unparent();
- mHandleValueTextView.Reset();
- }
+ }
+
+ void Slider::DestroyHandleValueDisplay()
+ {
- // Value displayDoConnectSignal
- if( mValueTextView )
- {
- std::stringstream ss;
- ss.precision( GetValuePrecision() );
- ss << std::fixed << value;
- mValueTextView.SetText( ss.str() );
- TextStyle style;
- style.SetTextColor( GetPopupTextColor() );
- mValueTextView.SetStyleToCurrentText( style, TextStyle::COLOR);
-
- if( mValueDisplay )
- {
- Font font = Font::New();
- float popupWidth = font.MeasureText( ss.str() ).x + VALUE_POPUP_MARGIN * 2.0f;
- if( popupWidth < VALUE_POPUP_MIN_WIDTH )
- {
- popupWidth = VALUE_POPUP_MIN_WIDTH;
- }
-
- mPopup.SetSize( popupWidth, VALUE_POPUP_HEIGHT );
- mValueDisplay.SetVisible( true );
-
- mValueTimer.SetInterval( VALUE_VIEW_SHOW_DURATION );
- }
- }
+ }
+
+ void Slider::SetPopupTextColor( const Vector4& color )
+ {
+ mPopupTextColor = color;
+ }
+
+ Actor Slider::CreateValueDisplay()
+ {
+ Actor popup = Actor::New();
+ popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
+ popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+
+ mPopupArrow = CreatePopupArrow();
+ popup.Add( mPopupArrow );
+
+ mPopup = CreatePopup();
+ mPopup.SetSize( 0.0f, VALUE_POPUP_HEIGHT );
+ mPopupArrow.Add( mPopup );
+
+ return popup;
+ }
+
+ Toolkit::Slider::ValueChangedSignalType& Slider::ValueChangedSignal()
+ {
+ return mValueChangedSignal;
+ }
+
+ Toolkit::Slider::ValueChangedSignalType& Slider::SlidingFinishedSignal()
+ {
+ return mSlidingFinishedSignal;
+ }
+
+ Toolkit::Slider::MarkSignalType& Slider::MarkSignal()
+ {
+ return mMarkSignal;
+ }
+
+ void Slider::UpdateSkin()
+ {
+ switch( mState )
+ {
+ case NORMAL:
+ {
+ mBacking.SetColor( Color::WHITE );
+ mHandle.SetColor( Color::WHITE );
+ mProgress.SetColor( Color::WHITE );
+ break;
+ }
+ case DISABLED:
+ {
+ Vector4 disableColor = GetDisableColor();
+ mBacking.SetColor( disableColor );
+ mHandle.SetColor( disableColor );
+ mProgress.SetColor( disableColor );
+ break;
+ }
+ case PRESSED:
+ {
+ break;
+ }
+ case FOCUSED:
+ {
+ break;
+ }
+ }
+ }
+
+ void Slider::CreateChildren()
+ {
+ Actor self = Self();
+
+ // Hit region
+ mHitArea = CreateHitRegion();
+ mPanDetector = PanGestureDetector::New();
+ mPanDetector.Attach( mHitArea );
+ mPanDetector.DetectedSignal().Connect( this, &Slider::OnPan );
+ self.Add( mHitArea );
+
+ // Background
+ mBacking = CreateBacking();
+ self.Add( mBacking );
+
+ // Progress bar
+ mProgress = CreateProgress();
+ mBacking.Add( mProgress );
+
+ // Handle
+ mHandle = CreateHandle();
+ mBacking.Add( mHandle );
+ }
+
+ void Slider::SetHitRegion( const Vector2& size )
+ {
+ mHitRegion = size;
+
+ if( mHitArea )
+ {
+ mHitArea.SetSize( mHitRegion );
+ }
+ }
+
+ const Vector2& Slider::GetHitRegion() const
+ {
+ return mHitRegion;
+ }
+
+ void Slider::AddPopup()
+ {
+ if( !mValueDisplay )
+ {
+ mValueDisplay = CreateValueDisplay();
+ mValueDisplay.SetVisible( false );
+ mHandle.Add( mValueDisplay );
+
+ CreatePopupImage( GetPopupImageName() );
+ CreatePopupArrowImage( GetPopupArrowImageName() );
+
+ mValueTimer = Timer::New( VALUE_VIEW_SHOW_DURATION );
+ mValueTimer.TickSignal().Connect( this, &Slider::HideValueView );
+ }
+ }
+
+ void Slider::RemovePopup()
+ {
+ if( mValueDisplay )
+ {
+ mPopup.Unparent();
+ mPopup.Reset();
+
+ mPopupArrow.Unparent();
+ mPopupArrow.Reset();
+
+ mValueDisplay.Unparent();
+ mValueDisplay.Reset();
+
+ mValueTimer.TickSignal().Disconnect( this, &Slider::HideValueView );
+ mValueTimer.Reset();
+ }
+ }
+
+
+ float Slider::MarkFilter( float value )
+ {
+ const float MARK_TOLERANCE = GetMarkTolerance();
+
+ float mark;
+ for( MarkList::iterator it = mMarks.begin(), itEnd = mMarks.end(); it != itEnd; ++it )
+ {
+ const Property::Value& propertyValue = *it;
+ propertyValue.Get( mark );
+ mark = MapValuePercentage( mark );
+
+ // If close to a mark, return the mark
+ if( fabsf( mark - value ) < MARK_TOLERANCE )
+ {
+ return mark;
+ }
+ }
+
+ return value;
+ }
+
+ float Slider::SnapToMark( float value )
+ {
+ float closestMark = value;
+ float closestDist = std::numeric_limits<float>::max();
+
+ float mark;
+ for( MarkList::iterator it = mMarks.begin(), itEnd = mMarks.end(); it != itEnd; ++it )
+ {
+ const Property::Value& propertyValue = *it;
+ propertyValue.Get( mark );
+ mark = MapValuePercentage( mark );
+
+ float dist = fabsf( mark - value );
+ if( dist < closestDist )
+ {
+ closestDist = dist;
+ closestMark = mark;
+ }
+ }
+
+ return closestMark;
+ }
+
+ bool Slider::MarkReached( float value, int& outIndex )
+ {
+ const float MARK_TOLERANCE = GetMarkTolerance();
+
+ // Binary search
+ int head = 0,
+ tail = mMarks.size() - 1;
+ int current;
+ float mark;
+
+ while( head <= tail )
+ {
+ current = head + ( tail - head ) / 2;
+
+ const Property::Value& propertyValue = mMarks[ current ];
+ propertyValue.Get( mark );
+ mark = MapValuePercentage( mark );
+
+ if( fabsf( mark - value ) < MARK_TOLERANCE )
+ {
+ outIndex = current;
+ return true;
+ }
+ else
+ {
+ if( value < mark )
+ {
+ tail = current - 1;
+ }
+ else
+ {
+ head = current + 1;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ bool Slider::HideValueView()
+ {
+ if( mValueDisplay )
+ {
+ mValueDisplay.SetVisible( false );
+ }
+
+ return false;
+ }
+
+ void Slider::SetLowerBound( float bound )
+ {
+ mLowerBound = bound;
+ DisplayValue( GetValue(), false );
+ }
+
+ float Slider::GetLowerBound() const
+ {
+ return mLowerBound;
+ }
+
+ void Slider::SetUpperBound( float bound )
+ {
+ mUpperBound = bound;
+ DisplayValue( GetValue(), false );
+ }
+
+ float Slider::GetUpperBound() const
+ {
+ return mUpperBound;
+ }
+
+ void Slider::SetValue( float value )
+ {
+ mValue = value;
+ DisplayValue( mValue, true );
+ }
+
+ float Slider::GetValue() const
+ {
+ return mValue;
+ }
+
+ void Slider::SetBackingRegion( const Vector2& region )
+ {
+ mBackingRegion = region;
+
+ if( mBacking )
+ {
+ mBacking.SetSize( mBackingRegion );
+ }
+
+ ResizeProgressRegion( Vector2( 0.0f, mBackingRegion.y ) );
+
+ mDomain = CalcDomain( mBackingRegion );
+
+ DisplayValue( GetValue(), false ); // Set the progress bar to correct width
+ }
+
+ const Vector2& Slider::GetBackingRegion() const
+ {
+ return mBackingRegion;
+ }
+
+ void Slider::SetHandleRegion( const Vector2& region )
+ {
+ mHandleRegionSize = region;
+
+ ResizeHandleRegion( mHandleRegionSize );
+
+ Vector2 hitRegion = GetHitRegion();
+ hitRegion.x += mHandleRegionSize.x;
+ SetHitRegion( hitRegion );
+ }
+
+ const Vector2& Slider::GetHandleRegion() const
+ {
+ return mHandleRegionSize;
+ }
+
+ void Slider::SetDisableColor( const Vector4& color )
+ {
+ mDisableColor = color;
+
+ UpdateSkin();
+ }
+
+ Vector4 Slider::GetDisableColor() const
+ {
+ return mDisableColor;
+ }
+
+ Vector4 Slider::GetPopupTextColor() const
+ {
+ return mPopupTextColor;
+ }
+
+ void Slider::SetValuePrecision( int precision )
+ {
+ mValuePrecision = precision;
+ }
+
+ int Slider::GetValuePrecision() const
+ {
+ return mValuePrecision;
+ }
+
+ void Slider::SetShowPopup( bool showPopup )
+ {
+ mShowPopup = showPopup;
+
+ // Value display
+ if( mShowPopup )
+ {
+ AddPopup();
+ }
+ else
+ {
+ RemovePopup();
+ }
+ }
+
+ bool Slider::GetShowPopup() const
+ {
+ return mShowPopup;
+ }
+
+ void Slider::SetShowValue( bool showValue )
+ {
+ mShowValue = showValue;
+
+ if( mShowValue )
+ {
+ CreateHandleValueDisplay();
+ }
+ else
+ {
+ DestroyHandleValueDisplay();
+ }
+ }
+
+ bool Slider::GetShowValue() const
+ {
+ return mShowValue;
+ }
+
+ void Slider::SetEnabled( bool enabled )
+ {
+ if( enabled )
+ {
+ mState = NORMAL;
+ }
+ else
+ {
+ mState = DISABLED;
+ }
+
+ UpdateSkin();
+ }
+
+ bool Slider::IsEnabled() const
+ {
+ return mState != DISABLED;
+ }
+
+ void Slider::SetMarkTolerance( float tolerance )
+ {
+ mMarkTolerance = tolerance;
+ }
+
+ float Slider::GetMarkTolerance() const
+ {
+ return mMarkTolerance;
+ }
+
+ // static class method to support script connecting signals
+
+ bool Slider::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+ {
+ Dali::BaseHandle handle( object );
+
+ bool connected = true;
+ Toolkit::Slider slider = Toolkit::Slider::DownCast( handle );
+
+ if( signalName == Dali::Toolkit::Slider::SIGNAL_VALUE_CHANGED )
+ {
+ slider.ValueChangedSignal().Connect( tracker, functor );
+ }
+ else if( signalName == Dali::Toolkit::Slider::SIGNAL_MARK )
+ {
+ slider.MarkSignal().Connect( tracker, functor );
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+ }
+
+ void Slider::DisplayPopup( float value )
+ {
+ }
+
+ void Slider::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
+ {
+ Toolkit::Slider slider = Toolkit::Slider::DownCast( Dali::BaseHandle( object ) );
+
+ if ( slider )
+ {
+ Slider& sliderImpl( GetImpl( slider ) );
+
+ switch ( propertyIndex )
+ {
+ case Toolkit::Slider::LOWER_BOUND_PROPERTY:
+ {
+ sliderImpl.SetLowerBound( value.Get< float >() );
+ break;
+ }
+
+ case Toolkit::Slider::UPPER_BOUND_PROPERTY:
+ {
+ sliderImpl.SetUpperBound( value.Get< float >() );
+ break;
+ }
+
+ case Toolkit::Slider::VALUE_PROPERTY:
+ {
+ sliderImpl.SetValue( value.Get< float >() );
+ break;
+ }
+
+ case Toolkit::Slider::HIT_REGION_PROPERTY:
+ {
+ sliderImpl.SetHitRegion( value.Get< Vector2 >() );
+ break;
+ }
+
+ case Toolkit::Slider::BACKING_REGION_PROPERTY:
+ {
+ sliderImpl.SetBackingRegion( value.Get< Vector2 >() );
+ break;
+ }
+
+ case Toolkit::Slider::HANDLE_REGION_PROPERTY:
+ {
+ sliderImpl.SetHandleRegion( value.Get< Vector2 >() );
+ break;
+ }
+
+ case Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY:
+ {
+ sliderImpl.SetBackingImageName( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY:
+ {
+ sliderImpl.SetHandleImageName( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY:
+ {
+ sliderImpl.SetProgressImageName( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY:
+ {
+ sliderImpl.SetPopupImageName( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY:
+ {
+ sliderImpl.SetPopupArrowImageName( value.Get< std::string >() );
+ break;
+ }
+
+ case Toolkit::Slider::DISABLE_COLOR_PROPERTY:
+ {
+ sliderImpl.SetDisableColor( value.Get< Vector4 >() );
+ break;
+ }
+
+ case Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY:
+ {
+ sliderImpl.SetPopupTextColor( value.Get< Vector4 >() );
+ break;
+ }
+
+ case Toolkit::Slider::VALUE_PRECISION_PROPERTY:
+ {
+ sliderImpl.SetValuePrecision( value.Get< int >() );
+ break;
+ }
+
+ case Toolkit::Slider::SHOW_POPUP_PROPERTY:
+ {
+ sliderImpl.SetShowPopup( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Slider::SHOW_VALUE_PROPERTY:
+ {
+ sliderImpl.SetShowValue( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Slider::ENABLED_PROPERTY:
+ {
+ sliderImpl.SetEnabled( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Slider::MARKS_PROPERTY:
+ {
+ sliderImpl.SetMarks( value.Get< Property::Array >() );
+ break;
+ }
+
+ case Toolkit::Slider::SNAP_TO_MARKS_PROPERTY:
+ {
+ sliderImpl.SetSnapToMarks( value.Get< bool >() );
+ break;
+ }
+
+ case Toolkit::Slider::MARK_TOLERANCE_PROPERTY:
+ {
+ sliderImpl.SetMarkTolerance( value.Get< float >() );
+ break;
+ }
+ }
+ }
+ }
+
+ Property::Value Slider::GetProperty( BaseObject* object, Property::Index propertyIndex )
+ {
+ Property::Value value;
+
+ Toolkit::Slider slider = Toolkit::Slider::DownCast( Dali::BaseHandle( object ) );
+
+ if ( slider )
+ {
+ Slider& sliderImpl( GetImpl( slider ) );
+
+ switch ( propertyIndex )
+ {
+ case Toolkit::Slider::LOWER_BOUND_PROPERTY:
+ {
+ value = sliderImpl.GetLowerBound();
+ break;
+ }
+
+ case Toolkit::Slider::UPPER_BOUND_PROPERTY:
+ {
+ value = sliderImpl.GetUpperBound();
+ break;
+ }
+
+ case Toolkit::Slider::VALUE_PROPERTY:
+ {
+ value = sliderImpl.GetValue();
+ break;
+ }
+
+ case Toolkit::Slider::HIT_REGION_PROPERTY:
+ {
+ value = sliderImpl.GetHitRegion();
+ break;
+ }
+
+ case Toolkit::Slider::BACKING_REGION_PROPERTY:
+ {
+ value = sliderImpl.GetBackingRegion();
+ break;
+ }
+
+ case Toolkit::Slider::HANDLE_REGION_PROPERTY:
+ {
+ value = sliderImpl.GetHandleRegion();
+ break;
+ }
+
+ case Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY:
+ {
+ value = sliderImpl.GetBackingImageName();
+ break;
+ }
+
+ case Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY:
+ {
+ value = sliderImpl.GetHandleImageName();
+ break;
+ }
+
+ case Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY:
+ {
+ value = sliderImpl.GetProgressImageName();
+ break;
+ }
+
+ case Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY:
+ {
+ value = sliderImpl.GetPopupImageName();
+ break;
+ }
+
+ case Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY:
+ {
+ value = sliderImpl.GetPopupArrowImageName();
+ break;
+ }
+
+ case Toolkit::Slider::DISABLE_COLOR_PROPERTY:
+ {
+ value = sliderImpl.GetDisableColor();
+ break;
+ }
+
+ case Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY:
+ {
+ value = sliderImpl.GetPopupTextColor();
+ break;
+ }
+
+ case Toolkit::Slider::VALUE_PRECISION_PROPERTY:
+ {
+ value = sliderImpl.GetValuePrecision();
+ break;
+ }
+
+ case Toolkit::Slider::SHOW_POPUP_PROPERTY:
+ {
+ value = sliderImpl.GetShowPopup();
+ break;
+ }
+
+ case Toolkit::Slider::SHOW_VALUE_PROPERTY:
+ {
+ value = sliderImpl.GetShowValue();
+ break;
+ }
+
+ case Toolkit::Slider::ENABLED_PROPERTY:
+ {
+ value = sliderImpl.IsEnabled();
+ break;
+ }
+
+ case Toolkit::Slider::MARKS_PROPERTY:
+ {
+ // TODO: Need to be able to return a PropertyArray
+ // value = sliderImpl.GetMarks();
+ break;
+ }
+
+ case Toolkit::Slider::SNAP_TO_MARKS_PROPERTY:
+ {
+ value = sliderImpl.GetSnapToMarks();
+ break;
+ }
+
+ case Toolkit::Slider::MARK_TOLERANCE_PROPERTY:
+ {
+ value = sliderImpl.GetMarkTolerance();
+ break;
+ }
+ }
+ }
+
+ return value;
+ }
+
+ } // namespace Internal
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ #ifndef __DALI_TOOLKIT_INTERNAL_SLIDER_H__
+ #define __DALI_TOOLKIT_INTERNAL_SLIDER_H__
+
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // EXTERNAL INCLUDES
+ #include <dali/public-api/actors/image-actor.h>
+ #include <dali/public-api/adaptor-framework/timer.h>
+
+ // INTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/control-impl.h>
+ #include <dali-toolkit/public-api/controls/slider/slider.h>
- Toolkit::TextView CreatePopupText();
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ class Button;
+
+ namespace Internal
+ {
+
+ class Slider;
+
+ typedef Dali::IntrusivePtr< Slider > SliderPtr;
+
+ /**
+ * @copydoc Toolkit::Slider
+ */
+ class Slider : public Control
+ {
+ public:
+
+ // Properties
+ enum
+ {
+ SLIDER_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+ SLIDER_PROPERTY_END_INDEX = SLIDER_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
+ };
+
+ typedef Property::Array MarkList;
+
+ /**
+ * Create a new Slider.
+ *
+ * @return A public handle to the newly allocated Slider.
+ */
+ static Dali::Toolkit::Slider New();
+
+ public:
+
+ // Properties
+
+ /**
+ * Set marks from a list
+ *
+ * @param[in] marks The list of marks to set
+ */
+ void SetMarks( const MarkList& marks );
+
+ /**
+ * Get the list of marks
+ *
+ * @return The marks list
+ */
+ const MarkList& GetMarks() const;
+
+ /**
+ * Set if should snap to marks or not
+ *
+ * @param[in] snap Flag to snap to marks or not
+ */
+ void SetSnapToMarks( bool snap );
+
+ /**
+ * Return if snap to marks is set or not
+ *
+ * @return If snap to marks is set
+ */
+ bool GetSnapToMarks() const;
+
+ /**
+ * Set the value of the slider
+ *
+ * @param[in] value The value to set. Will be clamped to [lowerBound .. upperBound]
+ */
+ void SetValue( float value );
+
+ /**
+ * Get the value of the slider
+ *
+ * @return The current value of the slider
+ */
+ float GetValue() const;
+
+ /**
+ * Set hit region
+ *
+ * @param[in] region The hit region
+ */
+ void SetHitRegion( const Vector2& region );
+
+ /**
+ * Get hit region
+ *
+ * @return The hit region
+ */
+ const Vector2& GetHitRegion() const;
+
+ /**
+ * Set backing region
+ *
+ * @param[in] region The backing region
+ */
+ void SetBackingRegion( const Vector2& region );
+
+ /**
+ * Get backing region
+ *
+ * @return The backing region
+ */
+ const Vector2& GetBackingRegion() const;
+
+ /**
+ * @brief Set the disable color.
+ *
+ * @param[in] color The disable color.
+ */
+ void SetDisableColor( const Vector4& color );
+
+ /**
+ * @brief Get disable color
+ *
+ * @return The disable color
+ */
+ Vector4 GetDisableColor() const;
+
+ /**
+ * Get popup text color
+ *
+ * @return The popup text color
+ */
+ Vector4 GetPopupTextColor() const;
+
+ /**
+ * Set the value precision to be used for numbers in the slider
+ *
+ * @param[in] precision The number of decimal places to use for printing numbers
+ */
+ void SetValuePrecision( int precision );
+
+ /**
+ * Get value precision
+ *
+ * @return The value precision
+ */
+ int GetValuePrecision() const;
+
+ /**
+ * Show the popup
+ *
+ * @param[in] showPopup The show popup flag
+ */
+ void SetShowPopup( bool showPopup );
+
+ /**
+ * Get show value in popup
+ *
+ * @return The show value flag
+ */
+ bool GetShowPopup() const;
+
+ /**
+ * Set show value on handle
+ *
+ * @param[in] showValue The show value flag
+ */
+ void SetShowValue( bool showValue );
+
+ /**
+ * Get show value on handle
+ *
+ * @return The show value flag
+ */
+ bool GetShowValue() const;
+
+ /**
+ * Set enabled
+ *
+ * param[in] enabled Set the enabled flag
+ */
+ void SetEnabled( bool enabled );
+
+ /**
+ * Return if enabled or not
+ *
+ * @return If enabled
+ */
+ bool IsEnabled() const;
+
+ /**
+ * @brief Set the mark tolerance
+ *
+ * The tolerance is the percentage of the slider width for which snapping to
+ * marks occurs
+ *
+ * @param[in] tolerance The percentage of width for which to snap
+ */
+ void SetMarkTolerance( float tolerance );
+
+ /**
+ * Return the mark tolerance
+ *
+ * @return The tolerance set for snapping to marks
+ */
+ float GetMarkTolerance() const;
+
+ public:
+ //Signals
+
+ /**
+ * @copydoc Toolkit::Slider::ValueChangedSignal()
+ */
+ Toolkit::Slider::ValueChangedSignalType& ValueChangedSignal();
+
+ /**
+ * copydoc Toolkit::Slider::SlidingFinishedSignal()
+ */
+ Toolkit::Slider::ValueChangedSignalType& SlidingFinishedSignal();
+
+ /**
+ * @copydoc Toolkit::Slider::MarkSignal()
+ */
+ Toolkit::Slider::MarkSignalType& MarkSignal();
+
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName,
+ FunctorDelegate* functor );
+
+ // Properties
+
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+
+ protected:
+
+ /**
+ * Construct a new Slider.
+ */
+ Slider();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~Slider();
+
+ /**
+ * @copydoc Control::OnControlSizeSet( const Vector3& size )
+ */
+ virtual void OnControlSizeSet( const Vector3& size );
+
+ private:
+
+ /**
+ * Domain is a from/to pair
+ */
+ struct Domain
+ {
+ Vector2 from;
+ Vector2 to;
+
+ Domain()
+ {
+ }
+ Domain( Vector2 fromVal, Vector2 toVal )
+ : from( fromVal ), to( toVal )
+ {
+ }
+ };
+
+ /**
+ * Slider states
+ */
+ enum SliderState
+ {
+ NORMAL,
+ DISABLED,
+ PRESSED,
+ FOCUSED
+ };
+
+ private:
+
+ /**
+ * @copydoc Toolkit::Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * Hit region touch event
+ *
+ * @param[in] actor The actor the event is raised for
+ * @param[in] event The touch event info
+ * @return If the event is handled or not
+ */
+ bool OnTouchEvent( Actor actor, const TouchEvent& event );
+
+ /**
+ * Pan gesture event
+ *
+ * @param[in] actor The actor the event is raised for
+ * @param[in] gesture The pan event info
+ */
+ void OnPan( Actor actor, const PanGesture& gesture );
+
+ /**
+ * Map a position onto a domain and return the result as a percentage
+ *
+ * @param[in] point The point to map onto the domain
+ * @return The result as a percentage [0..1]
+ */
+ float MapPercentage( const Vector2& point );
+
+ /**
+ * Map a value in the range to a percentage
+ *
+ * @param[in] point The value in range [lowerBound..upperBound]
+ * @return The result as a percentage [0..1]
+ */
+ float MapValuePercentage( float value );
+
+ /**
+ * Convert a point in local hit space into domain space
+ *
+ * @param[in] x The x position to convert
+ * @return The x position in domain space
+ */
+ float HitSpaceToDomain( float x );
+
+ /**
+ * Map a percentage onto the slider's bounds
+ *
+ * @param[in] percent The current value of slider in percent
+ * @param[in] lowerBound The lower bound to map onto
+ * @param[in] upperBound The upper bound to map onto
+ * @return The value of percent mapped from lowerBound to upperBound
+ */
+ float MapBounds( float percent, float lowerBound, float upperBound );
+
+ /**
+ * Get the range of the valid values the slider handle can move between
+ *
+ * @param[in] currentSize The current size of the slider
+ * @return The range as a domain pair
+ */
+ Domain CalcDomain( const Vector2& currentSize );
+
+ /**
+ * Create the hit region
+ *
+ * @return The hit region actor
+ */
+ Actor CreateHitRegion();
+
+ /**
+ * Create the backing for the slider
+ *
+ * @return The backing actor
+ */
+ ImageActor CreateBacking();
+
+ /**
+ * Create the progress backing for the slider
+ *
+ * @return The backing actor
+ */
+ ImageActor CreateProgress();
+
+ /**
+ * Create the handle for the slider
+ *
+ * @return The created image handle
+ */
+ ImageActor CreateHandle();
+
+ /**
+ * Create the popup arrow
+ *
+ * @return The created image handle
+ */
+ ImageActor CreatePopupArrow();
+
+ /**
+ * Create the popup
+ *
+ * @return The created image handle
+ */
+ ImageActor CreatePopup();
+
+ /**
+ * Create the textview for the popup
+ *
+ * @return The textview created for the popup
+ */
- Toolkit::TextView mValueTextView; //< The text value in popup
- Toolkit::TextView mHandleValueTextView; ///< The text value on handle
++ //Toolkit::TextView CreatePopupText();
+
+ /**
+ * Create the value display for the slider
+ *
+ * @return The created root actor of the display
+ */
+ Actor CreateValueDisplay();
+
+ /**
+ * Set the skin based on the current state
+ */
+ void UpdateSkin();
+
+ /**
+ * Create all the children
+ */
+ void CreateChildren();
+
+ /**
+ * Create value popup
+ */
+ void AddPopup();
+
+ /**
+ * Remove value popup
+ */
+ void RemovePopup();
+
+ /**
+ * Display the popup for a set duration with the given value
+ *
+ * @param[in] value The value to display in the popup
+ */
+ void DisplayPopup( float value );
+
+ /**
+ * If there are marks present, filter the incoming percent based on snapping to any nearby marks
+ *
+ * @param[in] value The incoming value on the slider to filter
+ * @return The filtered percentage snapped to any nearby marks
+ */
+ float MarkFilter( float value );
+
+ /**
+ * If there are marks present, snap the incoming percent to the nearest mark
+ *
+ * @param[in] value The incoming value on the slider to snap
+ * @return The filtered percentage snapped to the nearest mark
+ */
+ float SnapToMark( float value );
+
+ /**
+ * Search for if a mark has been reached
+ *
+ * @param[in] value The value to search against
+ * @param[out] outIndex The index of the mark if found
+ * @return If a mark has been found to match percent
+ */
+ bool MarkReached( float value, int& outIndex );
+
+ /**
+ * Handler for when the value view needs to be hidden
+ *
+ * @return If handled or not
+ */
+ bool HideValueView();
+
+ /**
+ * Set value choosing whether to fire signals or not
+ *
+ * @paramp[in] value The value to set
+ * @param[in] raiseSignals Configure signals to be raised or not.
+ */
+ void DisplayValue( float value, bool raiseSignals );
+
+ /**
+ * Create the image for the backing
+ *
+ * @param[in] imageName The name of the image to load and set
+ */
+ void SetBackingImageName( const std::string& imageName );
+
+ /**
+ * @brief Return the backing image file name.
+ *
+ * @return The backing image file name.
+ */
+ std::string GetBackingImageName();
+
+ /**
+ * Create the image for the progress bar
+ *
+ * @param[in] imageName The name of the image to load and set
+ */
+ void SetProgressImageName( const std::string& imageName );
+
+ /**
+ * @brief Return the progress image name.
+ *
+ * @return The progress image name if it exists.
+ */
+ std::string GetProgressImageName();
+
+ /**
+ * @brief Create the image for the popup
+ *
+ * @param[in] imageName The name of the image to load and set
+ */
+ void CreatePopupImage( const std::string& imageName );
+
+ /**
+ * @brief Set the popup name
+ *
+ * @param[in] imageName The name of the image to set
+ */
+ void SetPopupImageName( const std::string& imageName );
+
+ /**
+ * @brief Return the popup image name.
+ *
+ * @return The name of the popup image if it exists.
+ */
+ std::string GetPopupImageName();
+
+ /**
+ * @brief Set the popup arrow image name
+ *
+ * @param[in] imageName The name of the image to set
+ */
+ void SetPopupArrowImageName( const std::string& imageName );
+
+ /**
+ * @brief Return the popup arrow image name.
+ *
+ * @return The name of the popup image if it exists.
+ */
+ std::string GetPopupArrowImageName();
+
+ /**
+ * Create the image for the popup arrow
+ *
+ * @param[in] imageName The name of the image to load and set
+ */
+ void CreatePopupArrowImage( const std::string& imageName );
+
+ /**
+ * Set the size of the progress bar region
+ *
+ * @param[in] region The size of the region to set
+ */
+ void ResizeProgressRegion( const Vector2& region );
+
+ /**
+ * Create the image for the handle
+ *
+ * @param[in] imageName The name of the image to load and set
+ */
+ void SetHandleImageName( const std::string& imageName );
+
+ /**
+ * @brief Return the handle image name.
+ *
+ * @return The name of the image handle if it exists.
+ */
+ std::string GetHandleImageName();
+
+ /**
+ * Set the size of the handle region
+ *
+ * @param[in] region The size of the region to set
+ */
+ void ResizeHandleRegion( const Vector2& region );
+
+ /**
+ * Create and display the value on the handle
+ */
+ void CreateHandleValueDisplay();
+
+ /**
+ * Remove and destroy the handle value display
+ */
+ void DestroyHandleValueDisplay();
+
+ /**
+ * Update the color of the popup text
+ *
+ * @param[in] color The new color
+ */
+ void SetPopupTextColor( const Vector4& color );
+
+ /**
+ * Set handle region
+ *
+ * @param[in] region The handle region
+ */
+ void SetHandleRegion( const Vector2& region );
+
+ /**
+ * Get handle region
+ *
+ * @return The handle region
+ */
+ const Vector2& GetHandleRegion() const;
+
+ /**
+ * Set the lower bound of the slider's value
+ *
+ * @param[in] bound The value to set for the lower bound
+ */
+ void SetLowerBound( float bound );
+
+ /**
+ * Get the lower bound of the slider's value
+ *
+ * @return The lower bound value
+ */
+ float GetLowerBound() const;
+
+ /**
+ * Set the upper bound of the slider's value
+ *
+ * @param[in] bound The value to set for the upper bound
+ */
+ void SetUpperBound( float bound );
+
+ /**
+ * Get the upper bound of the slider's value
+ *
+ * @return The upper bound value
+ */
+ float GetUpperBound() const;
+
+ private:
+
+ // Undefined
+ Slider( const Slider& );
+
+ // Undefined
+ Slider& operator=( const Slider& rhs );
+
+ private:
+
+ Domain mDomain; ///< Current domain of the handle
+
+ Actor mHitArea; ///< The input handler
+ ImageActor mBacking; ///< Backing image
+ ImageActor mHandle; ///< Slider handle
+ ImageActor mProgress; ///< Progress backing
+ Actor mValueDisplay; ///< Display of the value
+ ImageActor mPopup; ///< Popup backing
+ ImageActor mPopupArrow; ///< Popup arrow backing
+
+ Vector2 mHandleLastTouchPoint; ///< The last touch point for the handle
+ Timer mValueTimer; ///< Timer used to hide value view
+
+ Toolkit::Slider::ValueChangedSignalType mValueChangedSignal; ///< Signal emitted when the value is changed
+ Toolkit::Slider::ValueChangedSignalType mSlidingFinishedSignal; ///< Signal emitted when a sliding is finished
+ Toolkit::Slider::MarkSignalType mMarkSignal; ///< Signal emitted when a mark is reached
+
+ SliderState mState; ///< The state of the slider
+
+ PanGestureDetector mPanDetector; ///< Hit region pan detector
+
+ MarkList mMarks; ///< List of discreet marks
+
+ std::string mPopupImageName; ///< Image name for popup image
+ std::string mPopupArrowImageName; ///< Image name for popup arrow
+
+ Vector4 mDisableColor; ///< The color to tint the slider when disabled
+ Vector4 mPopupTextColor; ///< The color of the popup text
+
+ Vector2 mHitRegion; ///< Size of hit region
+ Vector2 mBackingRegion; ///< Size of backing region
+ Vector2 mHandleRegionSize; ///< Size of the handle region
+
+ float mLowerBound; ///< Lower bound on value
+ float mUpperBound; ///< Upper bound on value
+ float mValue; ///< Current value of slider
+
+ float mMarkTolerance; ///< Tolerance in percentage of slider width for which to snap to marks
+
+ int mValuePrecision; ///< The precision to use for outputting the value
+
+ bool mShowPopup : 1, ///< Show the popup or not
+ mShowValue : 1, ///< Whether to display the value number or not on the handle
+ mSnapToMarks : 1; ///< Turn on or off snapping to marks
+ };
+
+ } // namespace Internal
+
+ // Helpers for public-api forwarding methods
+
+ inline Toolkit::Internal::Slider& GetImpl( Toolkit::Slider& pub )
+ {
+ DALI_ASSERT_ALWAYS( pub );
+
+ Dali::RefObject& handle = pub.GetImplementation();
+
+ return static_cast< Toolkit::Internal::Slider& >( handle );
+ }
+
+ inline const Toolkit::Internal::Slider& GetImpl( const Toolkit::Slider& pub )
+ {
+ DALI_ASSERT_ALWAYS( pub );
+
+ const Dali::RefObject& handle = pub.GetImplementation();
+
+ return static_cast< const Toolkit::Internal::Slider& >( handle );
+ }
+
+ } // namespace Toolkit
+
+ } // namespace Dali
+
+ #endif // __DALI_TOOLKIT_INTERNAL_SLIDER_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/object/type-registry.h>
++#include <dali/integration-api/debug.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/layouts/layout-engine.h>
++#include <dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.h> // TODO - Get from RendererFactory
++
++using Dali::Toolkit::Text::LayoutEngine;
++
++namespace
++{
++
++} // namespace
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++const Property::Index TextLabel::PROPERTY_TEXT( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX );
++const Property::Index TextLabel::PROPERTY_MULTI_LINE( Internal::TextLabel::TEXTLABEL_PROPERTY_START_INDEX + 1 );
++
++namespace Internal
++{
++
++namespace
++{
++
++// Type registration
++BaseHandle Create()
++{
++ return Toolkit::TextLabel::New();
++}
++
++TypeRegistration mType( typeid(Toolkit::TextLabel), typeid(Toolkit::Control), Create );
++
++PropertyRegistration property1( mType, "text", Toolkit::TextLabel::PROPERTY_TEXT, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty );
++PropertyRegistration property2( mType, "multi-line", Toolkit::TextLabel::PROPERTY_MULTI_LINE, Property::STRING, &TextLabel::SetProperty, &TextLabel::GetProperty );
++
++} // namespace
++
++Toolkit::TextLabel TextLabel::New()
++{
++ // Create the implementation, temporarily owned by this handle on stack
++ IntrusivePtr< TextLabel > impl = new TextLabel();
++
++ // Pass ownership to CustomActor handle
++ Toolkit::TextLabel handle( *impl );
++
++ // Second-phase init of the implementation
++ // This can only be done after the CustomActor connection has been made...
++ impl->Initialize();
++
++ return handle;
++}
++
++void TextLabel::SetRenderer( Text::RendererPtr renderer )
++{
++ mRenderer = renderer;
++}
++
++void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
++{
++ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
++
++ if( label )
++ {
++ TextLabel& labelImpl( GetImpl( label ) );
++ switch( index )
++ {
++ case Toolkit::TextLabel::PROPERTY_TEXT:
++ {
++ labelImpl.SetText( value.Get< std::string >() );
++ break;
++ }
++ case Toolkit::TextLabel::PROPERTY_MULTI_LINE:
++ {
++ labelImpl.SetMultiLine( value.Get< bool >() );
++ break;
++ }
++ }
++ }
++}
++
++Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index index )
++{
++ Property::Value value;
++
++ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( Dali::BaseHandle( object ) );
++
++ if( label )
++ {
++ switch( index )
++ {
++ case Toolkit::TextLabel::PROPERTY_TEXT:
++ {
++ DALI_LOG_WARNING( "UTF-8 text representation was discarded\n" );
++ break;
++ }
++ }
++ }
++
++ return value;
++}
++
++void TextLabel::OnInitialize()
++{
++ mController = Text::Controller::New();
++}
++
++void TextLabel::OnRelayout( const Vector2& size, ActorSizeContainer& container )
++{
++ if( mController->Relayout( size ) )
++ {
++ if( !mRenderer )
++ {
++ // TODO - Get from RendererFactory
++ mRenderer = Dali::Toolkit::Text::BasicRenderer::New();
++ }
++
++ if( mRenderer )
++ {
++ Actor renderableActor = mRenderer->Render( mController->GetView() );
++
++ if( renderableActor )
++ {
++ Self().Add( renderableActor );
++ }
++ }
++ }
++}
++
++void TextLabel::SetText( const std::string& text )
++{
++ if( mController )
++ {
++ // The Controller updates the View for the renderer
++ mController->SetText( text );
++ }
++}
++
++void TextLabel::SetMultiLine( bool multiLine )
++{
++ if( mController )
++ {
++ if( multiLine )
++ {
++ mController->GetLayoutEngine().SetLayout( LayoutEngine::MULTI_LINE_BOX );
++ }
++ else
++ {
++ mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
++ }
++ }
++}
++
++TextLabel::TextLabel()
++: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) )
++{
++}
++
++TextLabel::~TextLabel()
++{
++}
++
++} // namespace Internal
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
++#define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/controls/control-impl.h>
++#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
++#include <dali-toolkit/public-api/text/text-controller.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Internal
++{
++
++/**
++ * @brief A control which renders a short text string.
++ */
++class TextLabel : public Control
++{
++public:
++
++ // Properties
++ enum
++ {
++ TEXTLABEL_PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
++ TEXTLABEL_PROPERTY_END_INDEX = TEXTLABEL_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
++ };
++
++ /**
++ * @copydoc Dali::Toollkit::TextLabel::New()
++ */
++ static Toolkit::TextLabel New();
++
++ /**
++ * @copydoc Dali::Toollkit::TextLabel::SetRenderer()
++ */
++ void SetRenderer( Text::RendererPtr renderer );
++
++ // Properties
++
++ /**
++ * Called when a property of an object of this type is set.
++ * @param[in] object The object whose property is set.
++ * @param[in] index The property index.
++ * @param[in] value The new property value.
++ */
++ static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
++
++ /**
++ * Called to retrieve a property of an object of this type.
++ * @param[in] object The object whose property is to be retrieved.
++ * @param[in] index The property index.
++ * @return The current value of the property.
++ */
++ static Property::Value GetProperty( BaseObject* object, Property::Index index );
++
++private: // From Control
++
++ /**
++ * @copydoc Control::OnInitialize()
++ */
++ virtual void OnInitialize();
++
++ /**
++ * @copydoc Control::OnInitialize()
++ */
++ virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
++
++private: // Implementation
++
++ /**
++ * Helper for SetProperty.
++ * @param[in] text The new "text" property value.
++ */
++ void SetText( const std::string& text );
++
++ /**
++ * Helper for SetProperty.
++ * @param[in] multiLine The new "multi-line" property value.
++ */
++ void SetMultiLine( bool multiLine );
++
++ /**
++ * Construct a new TextLabel.
++ */
++ TextLabel();
++
++ /**
++ * A reference counted object may only be deleted by calling Unreference()
++ */
++ virtual ~TextLabel();
++
++private:
++
++ // Undefined copy constructor and assignment operators
++ TextLabel(const TextLabel&);
++ TextLabel& operator=(const TextLabel& rhs);
++
++private: // Data
++
++ Text::ControllerPtr mController;
++ Text::RendererPtr mRenderer;
++};
++
++} // namespace Internal
++
++// Helpers for public-api forwarding methods
++
++inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
++{
++ DALI_ASSERT_ALWAYS(textLabel);
++
++ Dali::RefObject& handle = textLabel.GetImplementation();
++
++ return static_cast<Toolkit::Internal::TextLabel&>(handle);
++}
++
++inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
++{
++ DALI_ASSERT_ALWAYS(textLabel);
++
++ const Dali::RefObject& handle = textLabel.GetImplementation();
++
++ return static_cast<const Toolkit::Internal::TextLabel&>(handle);
++}
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
--- /dev/null
- $(toolkit_src_dir)/controls/text-input/text-input-decorator-impl.cpp \
- $(toolkit_src_dir)/controls/text-input/text-input-handles-impl.cpp \
- $(toolkit_src_dir)/controls/text-input/text-input-impl.cpp \
- $(toolkit_src_dir)/controls/text-input/text-input-popup-impl.cpp \
- $(toolkit_src_dir)/controls/text-input/text-input-text-highlight-impl.cpp \
- $(toolkit_src_dir)/controls/text-view/relayout-utilities.cpp \
- $(toolkit_src_dir)/controls/text-view/split-by-char-policies.cpp \
- $(toolkit_src_dir)/controls/text-view/split-by-new-line-char-policies.cpp \
- $(toolkit_src_dir)/controls/text-view/split-by-word-policies.cpp \
- $(toolkit_src_dir)/controls/text-view/text-actor-cache.cpp \
- $(toolkit_src_dir)/controls/text-view/text-processor-bidirectional-info.cpp \
- $(toolkit_src_dir)/controls/text-view/text-processor.cpp \
- $(toolkit_src_dir)/controls/text-view/text-view-character-processor.cpp \
- $(toolkit_src_dir)/controls/text-view/text-view-impl.cpp \
- $(toolkit_src_dir)/controls/text-view/text-view-paragraph-processor.cpp \
- $(toolkit_src_dir)/controls/text-view/text-view-processor-dbg.cpp \
- $(toolkit_src_dir)/controls/text-view/text-view-processor-helper-functions.cpp \
- $(toolkit_src_dir)/controls/text-view/text-view-processor.cpp \
- $(toolkit_src_dir)/controls/text-view/text-view-word-processor.cpp \
+ # Add local source files here
+
+ toolkit_src_files = \
+ $(toolkit_src_dir)/builder/builder-actor.cpp \
+ $(toolkit_src_dir)/builder/builder-animations.cpp \
+ $(toolkit_src_dir)/builder/builder-impl.cpp \
+ $(toolkit_src_dir)/builder/builder-set-property.cpp \
+ $(toolkit_src_dir)/builder/builder-signals.cpp \
+ $(toolkit_src_dir)/builder/json-parser-state.cpp \
+ $(toolkit_src_dir)/builder/json-parser-impl.cpp \
+ $(toolkit_src_dir)/builder/tree-node-manipulator.cpp \
+ $(toolkit_src_dir)/builder/replacement.cpp \
+ $(toolkit_src_dir)/controls/alignment/alignment-impl.cpp \
+ $(toolkit_src_dir)/controls/bloom-view/bloom-view-impl.cpp \
+ $(toolkit_src_dir)/controls/bubble-effect/bubble-emitter-impl.cpp \
+ $(toolkit_src_dir)/controls/buttons/button-impl.cpp \
+ $(toolkit_src_dir)/controls/buttons/check-box-button-default-painter-impl.cpp \
+ $(toolkit_src_dir)/controls/buttons/check-box-button-impl.cpp \
+ $(toolkit_src_dir)/controls/buttons/push-button-default-painter-impl.cpp \
+ $(toolkit_src_dir)/controls/buttons/push-button-impl.cpp \
+ $(toolkit_src_dir)/controls/buttons/radio-button-impl.cpp \
+ $(toolkit_src_dir)/controls/cluster/cluster-impl.cpp \
+ $(toolkit_src_dir)/controls/cluster/cluster-style-impl.cpp \
+ $(toolkit_src_dir)/controls/effects-view/effects-view-impl.cpp \
+ $(toolkit_src_dir)/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp \
+ $(toolkit_src_dir)/controls/image-view/masked-image-view-impl.cpp \
+ $(toolkit_src_dir)/controls/magnifier/magnifier-impl.cpp \
+ $(toolkit_src_dir)/controls/navigation-frame/navigation-bar.cpp \
+ $(toolkit_src_dir)/controls/navigation-frame/navigation-control-impl.cpp \
+ $(toolkit_src_dir)/controls/navigation-frame/navigation-title-bar.cpp \
+ $(toolkit_src_dir)/controls/navigation-frame/navigation-tool-bar.cpp \
+ $(toolkit_src_dir)/controls/navigation-frame/page-impl.cpp \
+ $(toolkit_src_dir)/controls/popup/popup-impl.cpp \
+ $(toolkit_src_dir)/controls/popup/popup-style-impl.cpp \
+ $(toolkit_src_dir)/controls/page-turn-view/page-turn-portrait-view-impl.cpp \
+ $(toolkit_src_dir)/controls/page-turn-view/page-turn-landscape-view-impl.cpp \
+ $(toolkit_src_dir)/controls/page-turn-view/page-turn-view-impl.cpp \
+ $(toolkit_src_dir)/controls/relayout-controller-impl.cpp \
+ $(toolkit_src_dir)/controls/relayout-controller.cpp \
+ $(toolkit_src_dir)/controls/relayout-helper.cpp \
+ $(toolkit_src_dir)/controls/scroll-bar/scroll-bar-impl.cpp \
+ $(toolkit_src_dir)/controls/scroll-component/scroll-bar-internal-impl.cpp \
+ $(toolkit_src_dir)/controls/scroll-component/scroll-bar-internal.cpp \
+ $(toolkit_src_dir)/controls/scrollable/bouncing-effect-actor.cpp \
+ $(toolkit_src_dir)/controls/scrollable/item-view/item-view-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scrollable-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-connector-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-base-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-effect-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-carousel-effect-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-cube-effect-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-depth-effect-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-helper-functions.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-page-carousel-effect-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-page-cube-effect-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-page-spiral-effect-impl.cpp \
+ $(toolkit_src_dir)/controls/scrollable/scroll-view/scroll-view-wobble-effect-impl.cpp \
+ $(toolkit_src_dir)/controls/shadow-view/shadow-view-impl.cpp \
+ $(toolkit_src_dir)/controls/slider/slider-impl.cpp \
+ $(toolkit_src_dir)/controls/super-blur-view/super-blur-view-impl.cpp \
+ $(toolkit_src_dir)/controls/table-view/table-view-impl.cpp \
++ $(toolkit_src_dir)/controls/text-controls/text-label-impl.cpp \
+ $(toolkit_src_dir)/controls/tool-bar/tool-bar-impl.cpp \
+ $(toolkit_src_dir)/controls/view/view-impl.cpp \
+ $(toolkit_src_dir)/focus-manager/focus-manager-impl.cpp \
+ $(toolkit_src_dir)/focus-manager/keyboard-focus-manager-impl.cpp \
+ $(toolkit_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp \
+ $(toolkit_src_dir)/filters/blur-two-pass-filter.cpp \
+ $(toolkit_src_dir)/filters/emboss-filter.cpp \
+ $(toolkit_src_dir)/filters/image-filter.cpp \
+ $(toolkit_src_dir)/filters/spread-filter.cpp \
+ $(toolkit_src_dir)/shader-effects/page-turn-effect-impl.cpp \
+ $(toolkit_src_dir)/shader-effects/water-effect-impl.cpp \
+ $(toolkit_src_dir)/styling/style-manager-impl.cpp \
++ $(toolkit_src_dir)/text/multi-language-support-impl.cpp \
+ $(toolkit_src_dir)/transition-effects/cube-transition-effect-impl.cpp \
+ $(toolkit_src_dir)/transition-effects/cube-transition-cross-effect-impl.cpp \
+ $(toolkit_src_dir)/transition-effects/cube-transition-fold-effect-impl.cpp \
+ $(toolkit_src_dir)/transition-effects/cube-transition-wave-effect-impl.cpp
+
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/internal/text/multi-language-support-impl.h>
++
++// INTERNAL INCLUDES
++#include <dali/public-api/adaptor-framework/singleton-service.h>
++#include <dali-toolkit/public-api/text/logical-model.h>
++#include <dali-toolkit/public-api/text/font-run.h>
++#include <dali-toolkit/public-api/text/script.h>
++#include <dali-toolkit/public-api/text/script-run.h>
++#include <dali/integration-api/debug.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++namespace Internal
++{
++
++/**
++ * @brief Retrieves the font Id from the font run for a given character's @p index.
++ *
++ * If the character's index exceeds the current font run it increases the iterator to get the next one.
++ *
++ * @param[in] index The character's index.
++ * @param[in,out] fontRunIt Iterator to the current font run.
++ * @param[in] fontRunEndIt Iterator to one after the last font run.
++ *
++ * @return The font id.
++ */
++FontId GetFontId( Length index,
++ Vector<FontRun>::ConstIterator& fontRunIt,
++ const Vector<FontRun>::ConstIterator& fontRunEndIt )
++{
++ FontId fontId = 0u;
++
++ if( fontRunIt != fontRunEndIt )
++ {
++ const FontRun& fontRun = *fontRunIt;
++
++ if( ( index >= fontRun.characterRun.characterIndex ) &&
++ ( index < fontRun.characterRun.characterIndex + fontRun.characterRun.numberOfCharacters ) )
++ {
++ fontId = fontRun.fontId;
++ }
++
++ if( index == fontRun.characterRun.characterIndex + fontRun.characterRun.numberOfCharacters )
++ {
++ // All the characters of the current run have been traversed. Get the next one for the next iteration.
++ ++fontRunIt;
++ }
++ }
++
++ return fontId;
++}
++
++/**
++ * @brief Retrieves the script Id from the script run for a given character's @p index.
++ *
++ * If the character's index exceeds the current script run it increases the iterator to get the next one.
++ *
++ * @param[in] index The character's index.
++ * @param[in,out] scriptRunIt Iterator to the current font run.
++ * @param[in] scriptRunEndIt Iterator to one after the last script run.
++ *
++ * @return The script.
++ */
++Script GetScript( Length index,
++ Vector<ScriptRun>::ConstIterator& scriptRunIt,
++ const Vector<ScriptRun>::ConstIterator& scriptRunEndIt )
++{
++ Script script = TextAbstraction::UNKNOWN;
++
++ if( scriptRunIt != scriptRunEndIt )
++ {
++ const ScriptRun& scriptRun = *scriptRunIt;
++
++ if( ( index >= scriptRun.characterRun.characterIndex ) &&
++ ( index < scriptRun.characterRun.characterIndex + scriptRun.characterRun.numberOfCharacters ) )
++ {
++ script = scriptRun.script;
++ }
++
++ if( index == scriptRun.characterRun.characterIndex + scriptRun.characterRun.numberOfCharacters )
++ {
++ // All the characters of the current run have been traversed. Get the next one for the next iteration.
++ ++scriptRunIt;
++ }
++ }
++
++ return script;
++}
++
++bool ValidateFontsPerScript::FindValidFont( FontId fontId ) const
++{
++ for( Vector<FontId>::ConstIterator it = mValidFonts.Begin(),
++ endIt = mValidFonts.End();
++ it != endIt;
++ ++it )
++ {
++ if( fontId == *it )
++ {
++ return true;
++ }
++ }
++
++ return false;
++}
++
++MultilanguageSupport::MultilanguageSupport()
++: mDefaultFontPerScriptCache(),
++ mValidFontsPerScriptCache()
++{
++ // Initializes the default font cache to zero (invalid font).
++ // Reserves space to cache the default fonts and access them with the script as an index.
++ mDefaultFontPerScriptCache.Resize( TextAbstraction::UNKNOWN, 0u );
++
++ // Initializes the valid fonts cache to NULL (no valid fonts).
++ // Reserves space to cache the valid fonts and access them with the script as an index.
++ mValidFontsPerScriptCache.Resize( TextAbstraction::UNKNOWN, NULL );
++}
++
++MultilanguageSupport::~MultilanguageSupport()
++{
++ // Destroy the valid fonts per script cache.
++
++ for( Vector<ValidateFontsPerScript*>::Iterator it = mValidFontsPerScriptCache.Begin(),
++ endIt = mValidFontsPerScriptCache.End();
++ it != endIt;
++ ++it )
++ {
++ delete *it;
++ }
++}
++
++Text::MultilanguageSupport MultilanguageSupport::Get()
++{
++ Text::MultilanguageSupport multilanguageSupportHandle;
++
++ SingletonService service( SingletonService::Get() );
++ if( service )
++ {
++ // Check whether the singleton is already created
++ Dali::BaseHandle handle = service.GetSingleton( typeid( Text::MultilanguageSupport ) );
++ if( handle )
++ {
++ // If so, downcast the handle
++ MultilanguageSupport* impl = dynamic_cast< Internal::MultilanguageSupport* >( handle.GetObjectPtr() );
++ multilanguageSupportHandle = Text::MultilanguageSupport( impl );
++ }
++ else // create and register the object
++ {
++ multilanguageSupportHandle = Text::MultilanguageSupport( new MultilanguageSupport );
++ service.Register( typeid( multilanguageSupportHandle ), multilanguageSupportHandle );
++ }
++ }
++
++ return multilanguageSupportHandle;
++}
++
++void MultilanguageSupport::SetScripts( LogicalModel& model )
++{
++ // 1) Retrieve the text from the model.
++ const Length numberOfCharacters = model.GetNumberOfCharacters();
++
++ if( 0u == numberOfCharacters )
++ {
++ // Nothing to do if there are no characters.
++ return;
++ }
++
++ Vector<Character> text;
++ text.Resize( numberOfCharacters );
++
++ model.GetText( 0u,
++ text.Begin(),
++ numberOfCharacters );
++
++ // 2) Traverse all characters and set the scripts.
++
++ // Stores the current script run.
++ ScriptRun currentScriptRun;
++ currentScriptRun.characterRun.characterIndex = 0u;
++ currentScriptRun.characterRun.numberOfCharacters = 0u;
++ currentScriptRun.script = TextAbstraction::UNKNOWN;
++
++ // Temporary stores the script runs.
++ std::vector<ScriptRun> scriptRuns;
++ scriptRuns.reserve( numberOfCharacters << 2u ); // To reduce the number of reallocations.
++
++ for( Vector<Character>::ConstIterator it = text.Begin(),
++ endIt = text.End();
++ it != endIt;
++ ++it )
++ {
++ const Character character = *it;
++
++ Script script = GetCharacterScript( character );
++
++ if( TextAbstraction::UNKNOWN == script )
++ {
++ script = TextAbstraction::LATIN;
++ DALI_ASSERT_DEBUG( !"MultilanguageSupport::SetScripts. Unkown script!" );
++ }
++
++ if( script != currentScriptRun.script )
++ {
++ // Current run needs to be stored and a new one initialized.
++
++ if( 0u != currentScriptRun.characterRun.numberOfCharacters )
++ {
++ // Store the script run.
++ scriptRuns.push_back( currentScriptRun );
++ }
++
++ // Initialize the new one.
++ currentScriptRun.characterRun.characterIndex = currentScriptRun.characterRun.characterIndex + currentScriptRun.characterRun.numberOfCharacters;
++ currentScriptRun.characterRun.numberOfCharacters = 0u;
++ currentScriptRun.script = script;
++ }
++
++ // Add one more character to the run.
++ ++currentScriptRun.characterRun.numberOfCharacters;
++ }
++
++ if( 0u != currentScriptRun.characterRun.numberOfCharacters )
++ {
++ // Store the last run.
++ scriptRuns.push_back( currentScriptRun );
++ }
++
++ // 3) Set the script runs into the model.
++
++ model.SetScripts( &scriptRuns[0u],
++ scriptRuns.size() );
++}
++
++void MultilanguageSupport::ValidateFonts( LogicalModel& model )
++{
++ // 1) Retrieve the text from the model.
++ const Length numberOfCharacters = model.GetNumberOfCharacters();
++
++ if( 0u == numberOfCharacters )
++ {
++ // Nothing to do if there are no characters.
++ return;
++ }
++
++ Vector<Character> text;
++ text.Resize( numberOfCharacters );
++
++ Character* textBuffer = text.Begin();
++ model.GetText( 0u,
++ textBuffer,
++ numberOfCharacters );
++
++ // 2) Retrieve any font previously set.
++
++ const Length numberOfFontRuns = model.GetNumberOfFontRuns( 0u, numberOfCharacters );
++
++ Vector<FontRun> fontRuns;
++ fontRuns.Reserve( numberOfFontRuns );
++
++ FontRun* fontRunsBuffer = fontRuns.Begin();
++ model.GetFontRuns( fontRunsBuffer,
++ 0u,
++ numberOfCharacters );
++
++ // 3) Retrieve the scripts from the model.
++
++ const Length numberOfScriptRuns = model.GetNumberOfScriptRuns( 0u, numberOfCharacters );
++
++ Vector<ScriptRun> scriptRuns;
++ scriptRuns.Reserve( numberOfScriptRuns );
++
++ ScriptRun* scriptRunsBuffer = scriptRuns.Begin();
++ model.GetScriptRuns( scriptRunsBuffer,
++ 0u,
++ numberOfCharacters );
++
++ // 4) Traverse the characters and validate/set the fonts.
++
++ // Get the caches.
++ FontId* defaultFontPerScriptCacheBuffer = mDefaultFontPerScriptCache.Begin();
++ ValidateFontsPerScript** validFontsPerScriptCacheBuffer = mValidFontsPerScriptCache.Begin();
++
++ // Stores the validated font runs.
++ Vector<FontRun> validatedFontRuns;
++ validatedFontRuns.Reserve( numberOfFontRuns );
++
++ // Initializes a validated font run.
++ FontRun currentFontRun;
++ currentFontRun.characterRun.characterIndex = 0u;
++ currentFontRun.characterRun.numberOfCharacters = 0u;
++ currentFontRun.fontId = 0u;
++ currentFontRun.isDefault = false;
++
++ // Get the font client.
++ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
++
++ // Iterators of the font and script runs.
++ Vector<FontRun>::ConstIterator fontRunIt = fontRuns.Begin();
++ Vector<FontRun>::ConstIterator fontRunEndIt = fontRuns.End();
++ Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
++ Vector<ScriptRun>::ConstIterator scriptRunEndIt = scriptRuns.End();
++
++ for( Length index = 0u; index < numberOfCharacters; ++index )
++ {
++ // Get the character.
++ const Character character = *( textBuffer + index );
++
++ // Get the font for the character.
++ FontId fontId = GetFontId( index,
++ fontRunIt,
++ fontRunEndIt );
++
++ // Get the script for the character.
++ Script script = GetScript( index,
++ scriptRunIt,
++ scriptRunEndIt );
++
++ if( TextAbstraction::UNKNOWN == script )
++ {
++ DALI_LOG_WARNING( "MultilanguageSupport::ValidateFonts. Unknown script!" );
++ script = TextAbstraction::LATIN;
++ }
++
++ // Whether the font being validated is a default one not set by the user.
++ const bool isDefault = ( 0u == fontId );
++
++ // The default font point size.
++ PointSize26Dot6 pointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
++
++ if( !isDefault )
++ {
++ // Validate if the font set by the user supports the character.
++
++ // Check first in the caches.
++
++ // The user may have set the default font. Check it. Otherwise check in the valid fonts cache.
++ if( fontId != *( defaultFontPerScriptCacheBuffer + script ) )
++ {
++ // Check in the valid fonts cache.
++ ValidateFontsPerScript* validateFontsPerScript = *( validFontsPerScriptCacheBuffer + script );
++ if( NULL != validateFontsPerScript )
++ {
++ if( !validateFontsPerScript->FindValidFont( fontId ) )
++ {
++ // Use the font client to validate the font.
++ const GlyphIndex glyphIndex = fontClient.GetGlyphIndex( fontId, character );
++
++ if( 0u == glyphIndex )
++ {
++ // Get the point size of the current font. It will be used to get a default font id.
++ pointSize = fontClient.GetPointSize( fontId );
++
++ // The font is not valid. Set to zero and a default one will be set.
++ fontId = 0u;
++ }
++ else
++ {
++ // Add the font to the valid font cache.
++ validateFontsPerScript->mValidFonts.PushBack( fontId );
++ }
++ }
++ }
++ else
++ {
++ // Use the font client to validate the font.
++ const GlyphIndex glyphIndex = fontClient.GetGlyphIndex( fontId, character );
++
++ if( 0u == glyphIndex )
++ {
++ // Get the point size of the current font. It will be used to get a default font id.
++ pointSize = fontClient.GetPointSize( fontId );
++
++ // The font is not valid. Set to zero and a default one will be set.
++ fontId = 0u;
++ }
++ else
++ {
++ // Add the font to the valid font cache.
++ validateFontsPerScript = new ValidateFontsPerScript();
++ *( validFontsPerScriptCacheBuffer + script ) = validateFontsPerScript;
++
++ validateFontsPerScript->mValidFonts.PushBack( fontId );
++ }
++ }
++ }
++ }
++
++ // The font has not been validated. Find a default one.
++ if( 0u == fontId )
++ {
++ // The character has no font assigned. Get a default one from the cache
++ fontId = *( defaultFontPerScriptCacheBuffer + script );
++
++ // If the cache has not a default font, get one from the font client.
++ if( 0u == fontId )
++ {
++ // Find a default font.
++ fontId = fontClient.FindDefaultFont( character, pointSize );
++
++ // Cache the font.
++ *( defaultFontPerScriptCacheBuffer + script ) = fontId;
++ }
++ }
++
++ // The font is now validated.
++
++ if( ( fontId != currentFontRun.fontId ) ||
++ ( isDefault != currentFontRun.isDefault ) )
++ {
++ // Current run needs to be stored and a new one initialized.
++
++ if( 0u != currentFontRun.characterRun.numberOfCharacters )
++ {
++ // Store the font run.
++ validatedFontRuns.PushBack( currentFontRun );
++ }
++
++ // Initialize the new one.
++ currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
++ currentFontRun.characterRun.numberOfCharacters = 0u;
++ currentFontRun.fontId = fontId;
++ currentFontRun.isDefault = isDefault;
++ }
++
++ // Add one more character to the run.
++ ++currentFontRun.characterRun.numberOfCharacters;
++ }
++
++ if( 0u != currentFontRun.characterRun.numberOfCharacters )
++ {
++ // Store the last run.
++ validatedFontRuns.PushBack( currentFontRun );
++ }
++
++ // 5) Sets the validated font runs to the model.
++ model.SetFonts( validatedFontRuns.Begin(),
++ validatedFontRuns.Count() );
++}
++
++} // namespace Internal
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__
++#define __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/multi-language-support.h>
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/object/base-object.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++namespace Internal
++{
++
++/**
++ * @brief Stores valid font ids per script.
++ */
++struct ValidateFontsPerScript
++{
++ /**
++ * Default constructor.
++ */
++ ValidateFontsPerScript()
++ : mValidFonts()
++ {}
++
++ /**
++ * Default destructor.
++ */
++ ~ValidateFontsPerScript()
++ {}
++
++ /**
++ * @brief Whether the given @p fontId is in the vector of valid fonts.
++ *
++ * @param[in] fontId The font id.
++ *
++ * @return @e true if the font is in the vector of valid fonts.
++ */
++ bool FindValidFont( FontId fontId ) const;
++
++ Vector<FontId> mValidFonts;
++};
++
++/**
++ * @brief Multi-language support implementation. @see Text::MultilanguageSupport.
++ */
++class MultilanguageSupport : public BaseObject
++{
++public:
++
++ /**
++ * Constructor
++ */
++ MultilanguageSupport();
++
++ /**
++ * Destructor
++ *
++ * This is non-virtual since derived Handle types must not contain data or virtual methods.
++ */
++ ~MultilanguageSupport();
++
++ /**
++ * @copydoc Dali::MultilanguageSupport::Get()
++ */
++ static Text::MultilanguageSupport Get();
++
++ /**
++ * @copydoc Dali::MultilanguageSupport::SetScripts()
++ */
++ void SetScripts( LogicalModel& model );
++
++ /**
++ * @copydoc Dali::MultilanguageSupport::ValidateFonts()
++ */
++ void ValidateFonts( LogicalModel& model );
++
++private:
++ Vector<FontId> mDefaultFontPerScriptCache; ///< Caches the default font for a script.
++ Vector<ValidateFontsPerScript*> mValidFontsPerScriptCache; ///< Caches valid fonts for a script.
++};
++
++} // namespace Internal
++
++inline static Internal::MultilanguageSupport& GetImplementation( MultilanguageSupport& multilanguageSupport )
++{
++ DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
++ BaseObject& handle = multilanguageSupport.GetBaseObject();
++ return static_cast<Internal::MultilanguageSupport&>( handle );
++}
++
++inline static const Internal::MultilanguageSupport& GetImplementation( const MultilanguageSupport& multilanguageSupport )
++{
++ DALI_ASSERT_ALWAYS( multilanguageSupport && "multi-language handle is empty" );
++ const BaseObject& handle = multilanguageSupport.GetBaseObject();
++ return static_cast<const Internal::MultilanguageSupport&>( handle );
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_IMPL_H__
--- /dev/null
- TextStyle titleTextStyle,
- TextStyle subtitleTextStyle,
+ #ifndef __DALI_TOOLKIT_NAVIGATION_BAR_STYLE_H__
+ #define __DALI_TOOLKIT_NAVIGATION_BAR_STYLE_H__
+
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ /**
+ * The basic information of a navigation bar style: background and size.
+ * All the style metrics for tool bar and title bar are in pixels referring to a bar width of 'referenceWidth'.
+ * To fit the bars into different window size, the NavigationControl scales the bar by the ratio of windowWidth and referenceWidth.
+ */
+ struct BasicNaviBarStyle
+ {
+ /**
+ * Constructor
+ */
+ BasicNaviBarStyle ( Actor background,
+ int referenceWidth,
+ int height )
+ : background( background ),
+ referenceWidth( referenceWidth ),
+ height( height )
+ {
+ }
+
+ Actor background; ///< bar background
+ int referenceWidth; ///< the width of the bar, this value also used to calculate the scale to fit the bar into windows of different sizes
+ int height; ///< the height of the bar
+ };
+
+ /**
+ * The tool bar locates in the bottom of the frame where other controls (such as PushButton ) could be placed.
+ * NaviToolBarStyle provides the tool bar layout style, which customize the position and size of the controls placed on it.
+ * Controls could be added into three groups: HorizontalLeft, HorizontalCenter or HorizontalRight.
+ * The left and right groups can only have one control maximum each, while the central group can have multiple controls.
+ * It is fine to have no control in every group.
+ * +----------------------------------------+
+ * | +-+ +-----+ +-----+ +-+ |
+ * | +-+ +-----+ +-----+ +-+ |
+ * +----------------------------------------+
+ */
+ struct NaviToolBarStyle : BasicNaviBarStyle
+ {
+ /**
+ * Constructor
+ */
+ NaviToolBarStyle ( Actor background,
+ int referenceWidth,
+ int height,
+ int centralMaximum,
+ int centralMinimum,
+ int centralButtonHeight,
+ int centralButtonGap,
+ int sideButtonSize,
+ int hotizontalMargin )
+ : BasicNaviBarStyle( background, referenceWidth, height),
+ centralMaximum( centralMaximum ), centralMinimum( centralMinimum ),
+ centralButtonHeight( centralButtonHeight ), centralButtonGap( centralButtonGap ),
+ sideButtonSize( sideButtonSize ), hotizontalMargin( hotizontalMargin )
+ {
+ }
+
+ int centralMaximum; ///< the maximum width of central button
+ int centralMinimum; ///< the minimum width of central button
+ int centralButtonHeight; ///< the height of the central button
+ int centralButtonGap; ///< the gap width between central buttons
+ int sideButtonSize; ///< the size of side buttons in the left and right groups: sideButtonSize*sideButtonSize
+ int hotizontalMargin; ///< the horizontal margin width
+ };
+
+ /**
+ * The title bar locates in the top of the frame where title, subtitle, title icon and other controls could be placed.
+ * NaviTitleBarStyle provides the title bar layout style,
+ * which customize the position and size of the components placed on it and the text style of the titles.
+ * The title bar contains two groups: the left group includes title icon, title and subtitle (subtitle and title icon are not must);
+ * while the right group can have multiple controls placed on, and it is also fine to have no control on it.
+ * +----------------------------------------+
+ * | +-+ Title +-+ +-+ |
+ * | +-+ Subtitle +-+ +-+ |
+ * +----------------------------------------+
+ */
+ struct NaviTitleBarStyle : BasicNaviBarStyle
+ {
+ /**
+ * Constructor
+ */
+ NaviTitleBarStyle( Actor background,
- titleTextStyle( titleTextStyle ), subtitleTextStyle( subtitleTextStyle ),
+ int referenceWidth,
+ int height,
+ int titleHeightWithoutSubtitle,
+ int titleHeightWithSubtitle,
+ int subtitleHeight,
+ int titleLeftMargin,
+ int titleBottomMargin,
+ int titleIconSize,
+ int buttonSize,
+ int buttonRightMargin,
+ int buttonBottomMargin,
+ int gapBetweenButtons )
+ : BasicNaviBarStyle( background, referenceWidth, height),
- TextStyle titleTextStyle; ///< the text style of the tile text
- TextStyle subtitleTextStyle; ///< the text style of the subtitle text
+ titleHeightWithoutSubtitle( titleHeightWithoutSubtitle ),
+ titleHeightWithSubtitle( titleHeightWithSubtitle ), subtitleHeight( subtitleHeight ),
+ titleLeftMargin( titleLeftMargin ), titleBottomMargin( titleBottomMargin ),
+ titleIconSize( titleIconSize ), buttonSize( buttonSize ),
+ buttonRightMargin( buttonRightMargin ), buttonBottomMargin( buttonBottomMargin ),
+ gapBetweenButtons( gapBetweenButtons )
+ {
+ }
+
+ int titleHeightWithoutSubtitle; ///< the height of the title when no subtitle exists
+ int titleHeightWithSubtitle; ///< the height of the title when there is subtitle below
+ int subtitleHeight; ///< the height of the subtitle
+ int titleLeftMargin; ///< the Margin between title and the left edge of the bar
+ int titleBottomMargin; ///< the Margin between title and the bottom edge of the bar
+ int titleIconSize; ///< the size of the title icon: titleIconSize*titleIconSize
+ int buttonSize; ///< the size of the buttons in the right group: buttonSize*buttonSize
+ int buttonRightMargin; ///< the Margin between the button and the right edge of the bar
+ int buttonBottomMargin; ///< the Margin between the button and the bottom edge of the bar
+ int gapBetweenButtons; ///< the gap width between buttons
+ };
+
+ } // namespace Toolkit
+ } // namespace Dali
+
+
+ #endif /* __DALI_TOOLKIT_NAVIGATION_BAR_STYLE_H__ */
--- /dev/null
-void Popup::SetTitle( TextView titleActor )
-{
- GetImpl(*this).SetTitle( titleActor );
-}
-
-TextView Popup::GetTitle() const
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <dali-toolkit/public-api/controls/popup/popup.h>
+ #include <dali-toolkit/internal/controls/popup/popup-impl.h>
+ #include <dali-toolkit/public-api/controls/buttons/button.h>
+
+ using namespace Dali;
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ // Popup
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+
+ const char* const Popup::SIGNAL_TOUCHED_OUTSIDE = "touched-outside";
+ const char* const Popup::SIGNAL_HIDDEN = "hidden";
+
+ Popup::Popup()
+ {
+ }
+
+ Popup::Popup( const Popup& handle )
+ : Control( handle )
+ {
+ }
+
+ Popup& Popup::operator=( const Popup& handle )
+ {
+ if( &handle != this )
+ {
+ Control::operator=( handle );
+ }
+ return *this;
+ }
+
+ Popup::Popup(Internal::Popup& implementation)
+ : Control(implementation)
+ {
+ }
+
+ Popup::Popup( Dali::Internal::CustomActor* internal )
+ : Control( internal )
+ {
+ VerifyCustomActorPointer<Internal::Popup>(internal);
+ }
+
+ Popup Popup::New()
+ {
+ return Internal::Popup::New();
+ }
+
+ Popup::~Popup()
+ {
+ }
+
+ Popup Popup::DownCast( BaseHandle handle )
+ {
+ return Control::DownCast<Popup, Internal::Popup>(handle);
+ }
+
+ void Popup::SetBackgroundImage( Actor image )
+ {
+ GetImpl(*this).SetBackgroundImage( image );
+ }
+
+ void Popup::SetTitle( const std::string& text )
+ {
+ GetImpl(*this).SetTitle( text );
+ }
+
++const std::string& Popup::GetTitle() const
+ {
+ return GetImpl(*this).GetTitle();
+ }
+
+ void Popup::AddButton( Button button )
+ {
+ GetImpl(*this).AddButton( button );
+ }
+
+ void Popup::SetState( PopupState state )
+ {
+ GetImpl(*this).SetState( state );
+ }
+
+ void Popup::SetState( PopupState state, float duration )
+ {
+ GetImpl(*this).SetState( state, duration );
+ }
+
+ Popup::PopupState Popup::GetState() const
+ {
+ return GetImpl(*this).GetState();
+ }
+
+ void Popup::Show()
+ {
+ GetImpl(*this).SetState( POPUP_SHOW );
+ }
+
+ void Popup::Hide()
+ {
+ GetImpl(*this).SetState( POPUP_HIDE );
+ }
+
+ void Popup::ShowTail(const Vector3& position)
+ {
+ GetImpl(*this).ShowTail( position );
+ }
+
+ void Popup::HideTail()
+ {
+ GetImpl(*this).HideTail();
+ }
+
+ Popup::TouchedOutsideSignalType& Popup::OutsideTouchedSignal()
+ {
+ return GetImpl(*this).OutsideTouchedSignal();
+ }
+
+ Popup::HiddenSignalType& Popup::HiddenSignal()
+ {
+ return GetImpl(*this).HiddenSignal();
+ }
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+ #ifndef __DALI_TOOLKIT_POPUP_H__
+ #define __DALI_TOOLKIT_POPUP_H__
+
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+ // INTERNAL INCLUDES
+ #include <dali-toolkit/public-api/controls/control.h>
- /**
- * @brief Sets a title for this Popup.
- *
- * @param[in] titleActor The TextView to appear as the heading for this Popup
- */
- void SetTitle( TextView titleActor );
-
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace Internal DALI_INTERNAL
+ {
+ class Popup;
+ }
+
+ class Button;
+
+ /**
+ * @brief Popup contains content that can come into focus when activated, and out of focus when deactivated.
+ *
+ * Content:
+ *
+ * The content within a popup consists of:
+ *
+ * 1. Title
+ * 2. Buttons
+ * 3. Background/Frame (i.e. Scale-9 image)
+ * 4. Custom Content (Actors)
+ *
+ * All of which are optional.
+ *
+ * States:
+ *
+ * A popup can be in a number of states:
+ *
+ * 1. HIDE (invisible)
+ * 2. SHOW (visible at normal size)
+ * 3. SHOW_MAXIMIZED (visible occupying full parent size)
+ * 4. Or custom defined.
+ *
+ * Transition Effects:
+ *
+ * A popup can use various custom transition effects, e.g.
+ * Alpha fade, Scaling transition, position/rotation, shader effects.
+ */
+ class DALI_IMPORT_API Popup : public Control
+ {
+
+ public:
+
+ //Signal Names
+ static const char* const SIGNAL_TOUCHED_OUTSIDE; ///< name "touched-outside"
+ static const char* const SIGNAL_HIDDEN; ///< name "hidden"
+
+ /**
+ * @brief Current popup state.
+ */
+ enum PopupState
+ {
+ POPUP_NONE, ///< Init status
+ POPUP_HIDE, ///< Hidden (not visible)
+ POPUP_SHOW, ///< Shown (visible in default size)
+ };
+
+ typedef Signal< void () > TouchedOutsideSignalType; ///< Touched outside signal type.
+ typedef Signal< void () > HiddenSignalType; ///< Hidden signal type.
+
+ /**
+ * @brief Signal emitted when user has touched outside of the Dialog.
+ */
+ TouchedOutsideSignalType& OutsideTouchedSignal();
+
+ /**
+ * @brief Signal emitted when popup has been hidden.
+ */
+ HiddenSignalType& HiddenSignal();
+
+ public:
+
+ /**
+ * @brief Creates an empty Popup handle.
+ */
+ Popup();
+
+ /**
+ * @brief Copy constructor.
+ *
+ * Creates another handle that points to the same real object
+ * @param[in] handle Handle to the copied object
+ */
+ Popup( const Popup& handle );
+
+ /**
+ * @brief Assignment operator.
+ *
+ * Changes this handle to point to another real object
+ * @param[in] handle Handle to the object
+ * @return A reference to this
+ */
+ Popup& operator=( const Popup& handle );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~Popup();
+
+ /**
+ * @brief Create the Poup control.
+ *
+ * @return A handle to the Popup control.
+ */
+ static Popup New();
+
+ /**
+ * @brief Downcast an Object handle to Popup.
+ *
+ * If handle points to a Popup the
+ * downcast produces valid handle. If not the returned handle is left uninitialized.
+ * @param[in] handle Handle to an object
+ * @return handle to a Popup or an uninitialized handle
+ */
+ static Popup DownCast( BaseHandle handle );
+
+ public:
+
+ /**
+ * @brief Sets the background image for this Popup.
+ *
+ * The background is resized (stretched according to scale settings),
+ * to the size of the Popup.
+ *
+ * @param[in] image The Background ImageActor to cover background
+ */
+ void SetBackgroundImage( Actor image );
+
+ /**
+ * @brief Sets a title for this Popup.
+ *
+ * By default a TextView is created with following settings: black color, split-by-word multi-line policy and split exceed policy.
+ *
+ * @param[in] text The text to appear as the heading for this Popup
+ */
+ void SetTitle( const std::string& text );
+
- * @return The TextView representing this popup is returned.
+ /**
+ * @brief Gets the text (TextView) for this Popup.
+ *
- TextView GetTitle() const;
++ * @return The text to appear as the heading for this Popup
+ */
++ const std::string& GetTitle() const;
+
+ /**
+ * @brief Adds a button to this Popup.
+ *
+ * Buttons are added to the bottom of the Popup and Centered.
+ *
+ * By default the first button added will have the focus, and the focus will
+ * shift to other buttons based on the sequence in which they are added to the popup.
+ *
+ * @param[in] button The button to be added to this Popup
+ */
+ void AddButton( Button button );
+
+ /**
+ * @brief Sets state of Popup, such as HIDE, and SHOW.
+ *
+ * The Popup will instantaneously jump to this state.
+ *
+ * @param[in] state The state of the popup
+ */
+ void SetState( PopupState state );
+
+ /**
+ * @brief Sets state of Popup, such as HIDE, and SHOW.
+ *
+ * The Popup will smoothly animate to this state.
+ *
+ * @param[in] state The state of the popup
+ * @param[in] duration The time to animate to this new state.
+ */
+ void SetState( PopupState state, float duration );
+
+ /**
+ * @brief Gets the state of the popup.
+ *
+ * @return The state of the popup.
+ */
+ PopupState GetState() const;
+
+ /**
+ * @brief Shows the popup.
+ *
+ * The Popup will animate to the SHOW state
+ */
+ void Show();
+
+ /**
+ * @brief Hides the popup.
+ *
+ * The Popup will animate to the HIDE state
+ */
+ void Hide();
+
+ /**
+ * @brief Shows the tail.
+ *
+ * The tail position is specified relative to it's Parent.
+ * To display at top center for instace, pass:
+ *
+ * ParentOrigin::TOP_CENTER
+ *
+ * @note The tail images are defined inside PopupStyle as
+ * tailUpImage, tailDownImage, tailLeftImage, and tailRightImage
+ *
+ * @param[in] position A position around the perimeter of the Parent.
+ */
+ void ShowTail(const Vector3& position);
+
+ /**
+ * @brief Hides the tail.
+ */
+ void HideTail();
+
+ public: // Not intended for application developers
+
+ /**
+ * @brief Creates a handle using the Toolkit::Internal implementation.
+ *
+ * @param[in] implementation The Control implementation.
+ */
+ DALI_INTERNAL Popup(Internal::Popup& implementation);
+
+ /**
+ * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
+ *
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ explicit DALI_INTERNAL Popup( Dali::Internal::CustomActor* internal );
+ };
+
+ } // namespace Toolkit
+
+ } // namespace Dali
+
+ #endif // __DALI_TOOLKIT_POPUP_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++const std::string TextLabel::TEXT_PROPERTY_NAME("text");
++const std::string TextLabel::MULTI_LINE_PROPERTY_NAME("multi-line");
++
++TextLabel TextLabel::New()
++{
++ return Internal::TextLabel::New();
++}
++
++TextLabel::TextLabel()
++{
++}
++
++TextLabel::TextLabel( const TextLabel& handle )
++: Control( handle )
++{
++}
++
++TextLabel& TextLabel::operator=( const TextLabel& handle )
++{
++ if( &handle != this )
++ {
++ Control::operator=( handle );
++ }
++ return *this;
++}
++
++TextLabel::~TextLabel()
++{
++}
++
++TextLabel TextLabel::DownCast( BaseHandle handle )
++{
++ return Control::DownCast<TextLabel, Internal::TextLabel>(handle);
++}
++
++void TextLabel::SetRenderer( Text::RendererPtr renderer )
++{
++ GetImpl(*this).SetRenderer( renderer );
++}
++
++TextLabel::TextLabel( Internal::TextLabel& implementation )
++: Control(implementation)
++{
++}
++
++TextLabel::TextLabel( Dali::Internal::CustomActor* internal )
++: Control( internal )
++{
++ VerifyCustomActorPointer<Internal::TextLabel>( internal );
++}
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_LABEL_H__
++#define __DALI_TOOLKIT_TEXT_LABEL_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/controls/control.h>
++#include <dali-toolkit/public-api/text/rendering/text-renderer.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Internal DALI_INTERNAL
++{
++class TextLabel;
++}
++
++/**
++ * @brief A control which renders a short text string.
++ */
++class DALI_IMPORT_API TextLabel : public Control
++{
++public:
++
++ // Property indices
++ static const Property::Index PROPERTY_TEXT; ///< name "text", type STRING
++ static const Property::Index PROPERTY_MULTI_LINE; ///< name "multi-line", type BOOLEAN
++
++ // Property names
++ static const std::string TEXT_PROPERTY_NAME; ///< Property, name "text", type STRING
++ static const std::string MULTI_LINE_PROPERTY_NAME; ///< Property, name "multi-line", type BOOLEAN
++
++ /**
++ * Create the TextLabel control.
++ * @return A handle to the TextLabel control.
++ */
++ static TextLabel New();
++
++ /**
++ * @brief Creates an empty handle.
++ */
++ TextLabel();
++
++ /**
++ * @brief Copy constructor.
++ *
++ * @param[in] handle The handle to copy from.
++ */
++ TextLabel( const TextLabel& handle );
++
++ /**
++ * @brief Assignment operator.
++ *
++ * @param[in] handle The handle to copy from.
++ * @return A reference to this.
++ */
++ TextLabel& operator=( const TextLabel& handle );
++
++ /**
++ * @brief Destructor
++ *
++ * This is non-virtual since derived Handle types must not contain data or virtual methods.
++ */
++ ~TextLabel();
++
++ /**
++ * @brief Downcast a handle to TextLabel.
++ *
++ * If the BaseHandle points is a TextLabel the downcast returns a valid handle.
++ * If not the returned handle is left empty.
++ *
++ * @param[in] handle Handle to an object
++ * @return handle to a TextLabel or an empty handle
++ */
++ static TextLabel DownCast( BaseHandle handle );
++
++ /**
++ * @brief Set the rendering back-end used by the TextLabel.
++ *
++ * @param[in] renderer The text renderer to use.
++ */
++ void SetRenderer( Text::RendererPtr renderer );
++
++public: // Not intended for application developers
++
++ /**
++ * @brief Creates a handle using the Toolkit::Internal implementation.
++ *
++ * @param[in] implementation The Control implementation.
++ */
++ DALI_INTERNAL TextLabel( Internal::TextLabel& implementation );
++
++ /**
++ * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
++ *
++ * @param[in] internal A pointer to the internal CustomActor.
++ */
++ explicit DALI_INTERNAL TextLabel( Dali::Internal::CustomActor* internal );
++};
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_LABEL_H__
--- /dev/null
- $(public_api_src_dir)/controls/text-input/text-input.cpp \
- $(public_api_src_dir)/controls/text-view/text-view.cpp \
+ # Add local source files here
+
+ public_api_src_files = \
+ $(public_api_src_dir)/builder/builder.cpp \
+ $(public_api_src_dir)/builder/json-parser.cpp \
+ $(public_api_src_dir)/builder/tree-node.cpp \
+ $(public_api_src_dir)/controls/control-impl.cpp \
+ $(public_api_src_dir)/controls/control.cpp \
+ $(public_api_src_dir)/controls/alignment/alignment.cpp \
+ $(public_api_src_dir)/controls/bubble-effect/bubble-emitter.cpp \
+ $(public_api_src_dir)/controls/buttons/button.cpp \
+ $(public_api_src_dir)/controls/buttons/check-box-button.cpp \
+ $(public_api_src_dir)/controls/buttons/push-button.cpp \
+ $(public_api_src_dir)/controls/buttons/radio-button.cpp \
+ $(public_api_src_dir)/controls/default-controls/check-button-factory.cpp \
+ $(public_api_src_dir)/controls/default-controls/push-button-factory.cpp \
+ $(public_api_src_dir)/controls/default-controls/solid-color-actor.cpp \
+ $(public_api_src_dir)/controls/navigation-frame/navigation-control.cpp \
+ $(public_api_src_dir)/controls/navigation-frame/page.cpp \
+ $(public_api_src_dir)/controls/magnifier/magnifier.cpp \
+ $(public_api_src_dir)/controls/page-turn-view/page-factory.cpp \
+ $(public_api_src_dir)/controls/page-turn-view/page-turn-landscape-view.cpp \
+ $(public_api_src_dir)/controls/page-turn-view/page-turn-portrait-view.cpp \
+ $(public_api_src_dir)/controls/page-turn-view/page-turn-view.cpp \
+ $(public_api_src_dir)/controls/popup/popup.cpp \
+ $(public_api_src_dir)/controls/scroll-bar/scroll-bar.cpp \
+ $(public_api_src_dir)/controls/scrollable/item-view/depth-layout.cpp \
+ $(public_api_src_dir)/controls/scrollable/item-view/grid-layout.cpp \
+ $(public_api_src_dir)/controls/scrollable/item-view/item-factory.cpp \
+ $(public_api_src_dir)/controls/scrollable/item-view/item-layout.cpp \
+ $(public_api_src_dir)/controls/scrollable/item-view/item-view.cpp \
+ $(public_api_src_dir)/controls/scrollable/item-view/navigation-layout.cpp \
+ $(public_api_src_dir)/controls/scrollable/item-view/roll-layout.cpp \
+ $(public_api_src_dir)/controls/scrollable/item-view/spiral-layout.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-carousel-effect.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-constraints.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-cube-effect.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-depth-effect.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-effect.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-carousel-effect.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-cube-effect.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-spiral-effect.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-wobble-effect.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-connector.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-component-impl.cpp \
+ $(public_api_src_dir)/controls/scrollable/scroll-component.cpp \
+ $(public_api_src_dir)/controls/scrollable/scrollable.cpp \
+ $(public_api_src_dir)/controls/shadow-view/shadow-view.cpp \
+ $(public_api_src_dir)/controls/slider/slider.cpp \
+ $(public_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \
+ $(public_api_src_dir)/controls/table-view/table-view.cpp \
- $(public_api_src_dir)/markup-processor/markup-processor.cpp \
++ $(public_api_src_dir)/controls/text-controls/text-label.cpp \
+ $(public_api_src_dir)/controls/tool-bar/tool-bar.cpp \
+ $(public_api_src_dir)/controls/bloom-view/bloom-view.cpp \
+ $(public_api_src_dir)/controls/cluster/cluster-style.cpp \
+ $(public_api_src_dir)/controls/cluster/cluster.cpp \
+ $(public_api_src_dir)/controls/effects-view/effects-view.cpp \
+ $(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.cpp \
+ $(public_api_src_dir)/controls/image-view/masked-image-view.cpp \
+ $(public_api_src_dir)/controls/view/view.cpp \
+ $(public_api_src_dir)/focus-manager/focus-manager.cpp \
+ $(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \
+ $(public_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
-public_api_markup_processor_header_files = \
- $(public_api_src_dir)/markup-processor/markup-processor.h
-
+ $(public_api_src_dir)/shader-effects/bubble-effect/bubble-effect.cpp \
+ $(public_api_src_dir)/shader-effects/bubble-effect/color-adjuster.cpp \
+ $(public_api_src_dir)/shader-effects/alpha-discard-effect.cpp \
+ $(public_api_src_dir)/shader-effects/bendy-effect.cpp \
+ $(public_api_src_dir)/shader-effects/blind-effect.cpp \
+ $(public_api_src_dir)/shader-effects/bouncing-effect.cpp \
+ $(public_api_src_dir)/shader-effects/carousel-effect.cpp \
+ $(public_api_src_dir)/shader-effects/displacement-effect.cpp \
+ $(public_api_src_dir)/shader-effects/dissolve-effect.cpp \
+ $(public_api_src_dir)/shader-effects/dissolve-local-effect.cpp \
+ $(public_api_src_dir)/shader-effects/distance-field-effect.cpp \
+ $(public_api_src_dir)/shader-effects/image-region-effect.cpp \
+ $(public_api_src_dir)/shader-effects/iris-effect.cpp \
+ $(public_api_src_dir)/shader-effects/mask-effect.cpp \
+ $(public_api_src_dir)/shader-effects/mirror-effect.cpp \
+ $(public_api_src_dir)/shader-effects/motion-blur-effect.cpp \
+ $(public_api_src_dir)/shader-effects/motion-stretch-effect.cpp \
+ $(public_api_src_dir)/shader-effects/nine-patch-mask-effect.cpp \
+ $(public_api_src_dir)/shader-effects/overlay-effect.cpp \
+ $(public_api_src_dir)/shader-effects/page-turn-book-spine-effect.cpp \
+ $(public_api_src_dir)/shader-effects/page-turn-effect.cpp \
+ $(public_api_src_dir)/shader-effects/ripple-effect.cpp \
+ $(public_api_src_dir)/shader-effects/ripple2d-effect.cpp \
+ $(public_api_src_dir)/shader-effects/shear-effect.cpp \
+ $(public_api_src_dir)/shader-effects/soft-button-effect.cpp \
+ $(public_api_src_dir)/shader-effects/spot-effect.cpp \
+ $(public_api_src_dir)/shader-effects/square-dissolve-effect.cpp \
+ $(public_api_src_dir)/shader-effects/swirl-effect.cpp \
+ $(public_api_src_dir)/shader-effects/water-effect.cpp \
+ $(public_api_src_dir)/styling/style-manager.cpp \
++ $(public_api_src_dir)/text/bidirectional-support.cpp \
++ $(public_api_src_dir)/text/character-set-conversion.cpp \
++ $(public_api_src_dir)/text/logical-model.cpp \
++ $(public_api_src_dir)/text/multi-language-support.cpp \
++ $(public_api_src_dir)/text/script.cpp \
++ $(public_api_src_dir)/text/segmentation.cpp \
++ $(public_api_src_dir)/text/text-controller.cpp \
++ $(public_api_src_dir)/text/text-view.cpp \
++ $(public_api_src_dir)/text/text-view-interface.cpp \
++ $(public_api_src_dir)/text/visual-model.cpp \
++ $(public_api_src_dir)/text/layouts/layout-engine.cpp \
++ $(public_api_src_dir)/text/rendering/text-renderer.cpp \
++ $(public_api_src_dir)/text/rendering/basic/text-basic-renderer.cpp \
++ $(public_api_src_dir)/text/rendering/shaders/text-basic-shader.cpp \
+ $(public_api_src_dir)/transition-effects/cube-transition-cross-effect.cpp \
+ $(public_api_src_dir)/transition-effects/cube-transition-effect.cpp \
+ $(public_api_src_dir)/transition-effects/cube-transition-fold-effect.cpp \
+ $(public_api_src_dir)/transition-effects/cube-transition-wave-effect.cpp \
+ $(public_api_src_dir)/dali-toolkit-version.cpp \
+ $(public_api_src_dir)/enums.cpp
+
+ # Add public header files here
+
+ public_api_header_files = \
+ $(public_api_src_dir)/dali-toolkit-version.h \
+ $(public_api_src_dir)/enums.h
+
+ public_api_builder_header_files = \
+ $(public_api_src_dir)/builder/builder.h \
+ $(public_api_src_dir)/builder/json-parser.h \
+ $(public_api_src_dir)/builder/tree-node.h
+
+ public_api_controls_header_files = \
+ $(public_api_src_dir)/controls/control-impl.h \
+ $(public_api_src_dir)/controls/control.h
+
+ public_api_alignment_header_files = \
+ $(public_api_src_dir)/controls/alignment/alignment.h
+
+ public_api_buttons_header_files = \
+ $(public_api_src_dir)/controls/buttons/button.h \
+ $(public_api_src_dir)/controls/buttons/check-box-button.h \
+ $(public_api_src_dir)/controls/buttons/push-button.h \
+ $(public_api_src_dir)/controls/buttons/radio-button.h
+
+ public_api_bloom_view_header_files = \
+ $(public_api_src_dir)/controls/bloom-view/bloom-view.h
+
+ public_api_bubble_emitter_header_files = \
+ $(public_api_src_dir)/controls/bubble-effect/bubble-emitter.h
+
+ public_api_cluster_header_files = \
+ $(public_api_src_dir)/controls/cluster/cluster-style.h \
+ $(public_api_src_dir)/controls/cluster/cluster.h
+
+ public_api_default_controls_header_files = \
+ $(public_api_src_dir)/controls/default-controls/check-button-factory.h \
+ $(public_api_src_dir)/controls/default-controls/push-button-factory.h \
+ $(public_api_src_dir)/controls/default-controls/solid-color-actor.h
+
+ public_api_effects_view_header_files = \
+ $(public_api_src_dir)/controls/effects-view/effects-view.h
+
+ public_api_gaussian_blur_view_header_files = \
+ $(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.h
+
+ public_api_image_view_header_files = \
+ $(public_api_src_dir)/controls/image-view/masked-image-view.h
+
+ public_api_item_view_header_files = \
+ $(public_api_src_dir)/controls/scrollable/item-view/depth-layout.h \
+ $(public_api_src_dir)/controls/scrollable/item-view/grid-layout.h \
+ $(public_api_src_dir)/controls/scrollable/item-view/item-factory.h \
+ $(public_api_src_dir)/controls/scrollable/item-view/item-layout.h \
+ $(public_api_src_dir)/controls/scrollable/item-view/item-view-declarations.h \
+ $(public_api_src_dir)/controls/scrollable/item-view/item-view.h \
+ $(public_api_src_dir)/controls/scrollable/item-view/navigation-layout.h \
+ $(public_api_src_dir)/controls/scrollable/item-view/roll-layout.h \
+ $(public_api_src_dir)/controls/scrollable/item-view/spiral-layout.h
+
+ public_api_magnifier_header_files = \
+ $(public_api_src_dir)/controls/magnifier/magnifier.h
+
+ public_api_page_turn_view_header_files = \
+ $(public_api_src_dir)/controls/page-turn-view/page-factory.h \
+ $(public_api_src_dir)/controls/page-turn-view/page-turn-landscape-view.h \
+ $(public_api_src_dir)/controls/page-turn-view/page-turn-portrait-view.h \
+ $(public_api_src_dir)/controls/page-turn-view/page-turn-view.h
+
+ public_api_popup_header_files = \
+ $(public_api_src_dir)/controls/popup/popup.h
+
+ public_api_scrollable_header_files = \
+ $(public_api_src_dir)/controls/scrollable/scroll-component-impl.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-component.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-connector.h \
+ $(public_api_src_dir)/controls/scrollable/scrollable.h
+
+ public_api_scroll_bar_header_files = \
+ $(public_api_src_dir)/controls/scroll-bar/scroll-bar.h
+
+ public_api_scroll_view_header_files = \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-carousel-effect.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-constraints.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-cube-effect.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-depth-effect.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-effect.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-carousel-effect.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-cube-effect.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-spiral-effect.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-wobble-effect.h \
+ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view.h
+
+ public_api_slider_header_files = \
+ $(public_api_src_dir)/controls/slider/slider.h
+
+ public_api_shadow_view_header_files = \
+ $(public_api_src_dir)/controls/shadow-view/shadow-view.h
+
+ public_api_super_blur_view_header_files = \
+ $(public_api_src_dir)/controls/super-blur-view/super-blur-view.h
+
+ public_api_table_view_header_files = \
+ $(public_api_src_dir)/controls/table-view/table-view.h
+
++public_api_text_controls_header_files = \
++ $(public_api_src_dir)/controls/text-controls/text-label.h
++
++public_api_text_header_files = \
++ $(public_api_src_dir)/text/bidirectional-line-info-run.h \
++ $(public_api_src_dir)/text/bidirectional-paragraph-info-run.h \
++ $(public_api_src_dir)/text/bidirectional-support.h \
++ $(public_api_src_dir)/text/character-run.h \
++ $(public_api_src_dir)/text/character-set-conversion.h \
++ $(public_api_src_dir)/text/font-run.h \
++ $(public_api_src_dir)/text/logical-model.h \
++ $(public_api_src_dir)/text/multi-language-support.h \
++ $(public_api_src_dir)/text/script.h \
++ $(public_api_src_dir)/text/script-run.h \
++ $(public_api_src_dir)/text/segmentation.h \
++ $(public_api_src_dir)/text/text-controller.h \
++ $(public_api_src_dir)/text/text-definitions.h \
++ $(public_api_src_dir)/text/text-view.h \
++ $(public_api_src_dir)/text/text-view-interface.h \
++ $(public_api_src_dir)/text/visual-model.h
++
++public_api_text_layouts_header_files = \
++ $(public_api_src_dir)/text/layouts/layout-engine.h
++
++public_api_text_rendering_header_files = \
++ $(public_api_src_dir)/text/rendering/text-renderer.h
++
++public_api_text_rendering_basic_header_files = \
++ $(public_api_src_dir)/text/rendering/basic/text-basic-renderer.h
++
++public_api_text_rendering_shaders_header_files = \
++ $(public_api_src_dir)/text/rendering/shaders/text-basic-shader.h
++
+ public_api_text_input_header_files = \
+ $(public_api_src_dir)/controls/text-input/text-input.h
+
+ public_api_text_view_header_files = \
+ $(public_api_src_dir)/controls/text-view/text-view.h
+
+ public_api_tool_bar_header_files = \
+ $(public_api_src_dir)/controls/tool-bar/tool-bar.h
+
+ public_api_navigation_frame_header_files = \
+ $(public_api_src_dir)/controls/navigation-frame/navigation-bar-style.h \
+ $(public_api_src_dir)/controls/navigation-frame/navigation-control.h \
+ $(public_api_src_dir)/controls/navigation-frame/page.h
+
+ public_api_view_header_files = \
+ $(public_api_src_dir)/controls/view/view.h
+
+ public_api_focus_manager_header_files = \
+ $(public_api_src_dir)/focus-manager/focus-manager.h \
+ $(public_api_src_dir)/focus-manager/keyboard-focus-manager.h \
+ $(public_api_src_dir)/focus-manager/keyinput-focus-manager.h
+
+ public_api_shader_effects_header_files = \
+ $(public_api_src_dir)/shader-effects/alpha-discard-effect.h \
+ $(public_api_src_dir)/shader-effects/bendy-effect.h \
+ $(public_api_src_dir)/shader-effects/blind-effect.h \
+ $(public_api_src_dir)/shader-effects/bouncing-effect.h \
+ $(public_api_src_dir)/shader-effects/carousel-effect.h \
+ $(public_api_src_dir)/shader-effects/displacement-effect.h \
+ $(public_api_src_dir)/shader-effects/dissolve-effect.h \
+ $(public_api_src_dir)/shader-effects/dissolve-local-effect.h \
+ $(public_api_src_dir)/shader-effects/distance-field-effect.h \
+ $(public_api_src_dir)/shader-effects/image-region-effect.h \
+ $(public_api_src_dir)/shader-effects/iris-effect.h \
+ $(public_api_src_dir)/shader-effects/mask-effect.h \
+ $(public_api_src_dir)/shader-effects/mirror-effect.h \
+ $(public_api_src_dir)/shader-effects/motion-blur-effect.h \
+ $(public_api_src_dir)/shader-effects/motion-stretch-effect.h \
+ $(public_api_src_dir)/shader-effects/nine-patch-mask-effect.h \
+ $(public_api_src_dir)/shader-effects/overlay-effect.h \
+ $(public_api_src_dir)/shader-effects/page-turn-book-spine-effect.h \
+ $(public_api_src_dir)/shader-effects/page-turn-effect.h \
+ $(public_api_src_dir)/shader-effects/ripple-effect.h \
+ $(public_api_src_dir)/shader-effects/ripple2d-effect.h \
+ $(public_api_src_dir)/shader-effects/shear-effect.h \
+ $(public_api_src_dir)/shader-effects/soft-button-effect.h \
+ $(public_api_src_dir)/shader-effects/spot-effect.h \
+ $(public_api_src_dir)/shader-effects/square-dissolve-effect.h \
+ $(public_api_src_dir)/shader-effects/swirl-effect.h \
+ $(public_api_src_dir)/shader-effects/water-effect.h
+
+ public_api_bubble_effect_header_files = \
+ $(public_api_src_dir)/shader-effects/bubble-effect/bubble-effect.h \
+ $(public_api_src_dir)/shader-effects/bubble-effect/color-adjuster.h
+
+ public_api_styling_header_files = \
+ $(public_api_src_dir)/styling/style-manager.h
+
+ public_api_transition_effects_header_files = \
+ $(public_api_src_dir)/transition-effects/cube-transition-effect.h \
+ $(public_api_src_dir)/transition-effects/cube-transition-cross-effect.h \
+ $(public_api_src_dir)/transition-effects/cube-transition-fold-effect.h \
+ $(public_api_src_dir)/transition-effects/cube-transition-wave-effect.h
+
--- /dev/null
- GeometryType( GEOMETRY_TYPE_IMAGE | GEOMETRY_TYPE_TEXT ),
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <dali-toolkit/public-api/shader-effects/carousel-effect.h>
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace
+ {
+
+ const std::string RADIUS_PROPERTY_NAME( "uRadius" );
+ const std::string ANGLE_PER_UNIT_PROPERTY_NAME( "uAnglePerUnit" );
+ const std::string CENTER_PROPERTY_NAME( "uCenter" );
+
+ } // namespace
+
+ CarouselEffect::CarouselEffect()
+ {
+ }
+
+ //Call the Parent copy constructor to add reference to the implementation for this object
+ CarouselEffect::CarouselEffect(ShaderEffect handle)
+ :ShaderEffect(handle)
+ {
+ }
+
+ CarouselEffect::~CarouselEffect()
+ {
+ }
+
+
+ CarouselEffect CarouselEffect::New()
+ {
+ // append the default version
+ std::string vertexShader(
+ "uniform float uRadius;\n"
+ "uniform mediump vec2 uCenter;\n"
+ "uniform mediump vec2 uAnglePerUnit;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " mediump vec4 world = uModelView * vec4(aPosition,1.0);\n"
+ " mediump vec2 d = (world.xy - uCenter) * uAnglePerUnit;\n"
+ " mediump float a = length(d);\n"
+ " mediump float cs = cos(radians(a));\n"
+ " world.z -= cs * uRadius;\n"
+ " gl_Position = uProjection * world;\n"
+ " \n"
+ " vTexCoord = aTexCoord;\n"
+ "}\n");
+
+ ShaderEffect shaderEffectCustom = ShaderEffect::New(vertexShader,
+ "",
++ GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER ));
+
+ // Pass ownership to CarouselEffect through overloaded constructor, So that it now has access to the
+ // Dali::ShaderEffect implementation
+ CarouselEffect handle( shaderEffectCustom );
+
+ handle.SetUniform( RADIUS_PROPERTY_NAME, 0.0f );
+ handle.SetUniform( CENTER_PROPERTY_NAME, Vector2( 0.0f, 0.0f ) );
+ handle.SetUniform( ANGLE_PER_UNIT_PROPERTY_NAME, Vector2( 0.0f, 0.0f ) );
+
+ return handle;
+ }
+
+ void CarouselEffect::SetRadius( float radius)
+ {
+ SetUniform( RADIUS_PROPERTY_NAME, radius );
+ }
+
+ void CarouselEffect::SetCenter( const Vector2& center )
+ {
+ SetUniform( CENTER_PROPERTY_NAME, center );
+ }
+
+ void CarouselEffect::SetAnglePerUnit( const Vector2& angle )
+ {
+ SetUniform( ANGLE_PER_UNIT_PROPERTY_NAME, angle );
+ }
+
+ const std::string& CarouselEffect::GetRadiusPropertyName() const
+ {
+ return RADIUS_PROPERTY_NAME;
+ }
+
+ const std::string& CarouselEffect::GetCenterPropertyName() const
+ {
+ return CENTER_PROPERTY_NAME;
+ }
+
+ const std::string& CarouselEffect::GetAnglePerUnitPropertyName() const
+ {
+ return ANGLE_PER_UNIT_PROPERTY_NAME;
+ }
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
- vertexShader, imageFragmentShader, vertexShader, "", GeometryHints(HINT_GRID) );
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <dali-toolkit/public-api/shader-effects/ripple-effect.h>
+
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace
+ {
+
+ const std::string AMPLITUDE_PROPERTY_NAME( "uAmplitude" );
+ const std::string CENTER_PROPERTY_NAME( "uCenter" );
+ const std::string TIME_PROPERTY_NAME( "uTime" );
+
+ } // namespace
+
+ RippleEffect::RippleEffect()
+ {
+ }
+
+ //Call the Parent copy constructor to add reference to the implementation for this object
+ RippleEffect::RippleEffect(ShaderEffect handle)
+ :ShaderEffect(handle)
+ {
+ }
+
+ RippleEffect::~RippleEffect()
+ {
+ }
+
+
+ RippleEffect RippleEffect::New()
+ {
+
+ std::string vertexShader(
+ "precision mediump float;\n"
+ "uniform mediump vec2 uCenter;\n"
+ "uniform mediump float uTime;\n"
+ "uniform mediump float uAmplitude;\n"
+ "uniform mediump float uLighting;\n"
+ "uniform mediump float uWaveLength;\n"
+ "varying mediump float vLight;\n"
+ "varying mediump float vShade;\n"
+ "void main()\n"
+ "{\n"
+ "float lighting = uAmplitude * 0.02;\n"
+ "float waveLength = uAmplitude * 0.0016;\n"
+ "vec4 world = uModelView * vec4(aPosition,1.0);\n"
+ "vec2 d = vec2(world.x - uCenter.x, world.y - uCenter.y);\n"
+ "float dist = length(d);\n"
+ "float amplitude = cos(uTime - dist*waveLength);\n"
+ "float slope = sin(uTime - dist*waveLength);\n"
+ "world.z += amplitude * uAmplitude;\n"
+ "gl_Position = uProjection * world;\n"
+ "vec2 lightDirection = vec2(-0.707,0.707);\n"
+ "float dot = 0.0;\n"
+ "if(dist > 0.0)\n"
+ "{\n"
+ " dot = dot(normalize(d),lightDirection) * lighting;\n"
+ "}\n"
+ "vShade = 1.0 - (dot * slope);\n"
+ "vLight = max(0.0, dot * -slope);\n"
+ "vTexCoord = aTexCoord;\n"
+ "}" );
+
+ // append the default version
+ std::string imageFragmentShader(
+ "precision mediump float;\n"
+ "varying mediump float vLight;\n"
+ "varying mediump float vShade;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(vShade,vShade,vShade,1.0) + vec4(vLight, vLight, vLight,0.0);\n"
+ "}" );
+
+ // Create the implementation, temporarily owned on stack
+ Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
++ vertexShader, imageFragmentShader, GeometryType(GEOMETRY_TYPE_IMAGE), GeometryHints(HINT_GRID) );
+
+ /* Pass ownership to RippleEffect through overloaded constructor, So that it now has access to the
+ Dali::ShaderEffect implementation */
+ Dali::Toolkit::RippleEffect handle( shaderEffect );
+
+ handle.SetUniform( AMPLITUDE_PROPERTY_NAME, 0.0f );
+ handle.SetUniform( CENTER_PROPERTY_NAME, Vector2(0.0f, 0.0f));
+ handle.SetUniform( TIME_PROPERTY_NAME, 0.0f );
+
+ return handle;
+ }
+
+ void RippleEffect::SetAmplitude(float amplitude)
+ {
+ SetUniform( AMPLITUDE_PROPERTY_NAME, amplitude );
+ }
+
+ void RippleEffect::SetCenter(const Vector2& center)
+ {
+ SetUniform( CENTER_PROPERTY_NAME, center );
+ }
+
+ void RippleEffect::SetTime(float time)
+ {
+ SetUniform( TIME_PROPERTY_NAME, time );
+ }
+
+ const std::string& RippleEffect::GetAmplitudePropertyName() const
+ {
+ return AMPLITUDE_PROPERTY_NAME;
+ }
+
+ const std::string& RippleEffect::GetCenterPropertyName() const
+ {
+ return CENTER_PROPERTY_NAME;
+ }
+
+ const std::string& RippleEffect::GetTimePropertyName() const
+ {
+ return TIME_PROPERTY_NAME;
+ }
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
- GeometryType( GEOMETRY_TYPE_IMAGE | GEOMETRY_TYPE_TEXT ),
+ /*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 <dali-toolkit/public-api/shader-effects/shear-effect.h>
+
+ namespace Dali
+ {
+
+ namespace Toolkit
+ {
+
+ namespace
+ {
+
+ const std::string CENTER_PROPERTY_NAME( "uCenter" );
+ const std::string ANGLE_X_AXIS_PROPERTY_NAME( "uAngleXAxis" );
+ const std::string ANGLE_Y_AXIS_PROPERTY_NAME( "uAngleYAxis" );
+
+ } // namespace
+
+ ShearEffect::ShearEffect()
+ {
+ }
+
+ //Call the Parent copy constructor to add reference to the implementation for this object
+ ShearEffect::ShearEffect(ShaderEffect handle)
+ :ShaderEffect(handle)
+ {
+ }
+
+ ShearEffect::~ShearEffect()
+ {
+ }
+
+
+ ShearEffect ShearEffect::New()
+ {
+ // append the default version
+ std::string vertexShader(
+ "uniform mediump vec2 uCenter;\n"
+ "uniform mediump float uAngleXAxis;\n"
+ "uniform mediump float uAngleYAxis;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ "mediump vec4 world = uModelView * vec4(aPosition,1.0);\n"
+ "\n"
+ "world.x = world.x + tan(radians(uAngleXAxis)) * (world.y - uCenter.y * world.w);\n"
+ "world.y = world.y + tan(radians(uAngleYAxis)) * (world.x - uCenter.x * world.w);\n"
+ "\n"
+ "gl_Position = uProjection * world;\n"
+ "\n"
+ "vTexCoord = aTexCoord;\n"
+ "}" );
+
+ // Create the implementation, temporarily owned on stack,
+ ShaderEffect shaderEffectCustom = Dali::ShaderEffect::New(
+ vertexShader,
+ "",
++ GeometryType( GEOMETRY_TYPE_IMAGE ),
+ GeometryHints( HINT_GRID ));
+
+ // Pass ownership to ShearEffect through overloaded constructor, So that it now has access to the
+ // Dali::ShaderEffect implementation
+ Dali::Toolkit::ShearEffect handle( shaderEffectCustom );
+
+ handle.SetUniform( CENTER_PROPERTY_NAME, Vector2(0.0f, 0.0f), COORDINATE_TYPE_VIEWPORT_POSITION );
+ handle.SetUniform( ANGLE_X_AXIS_PROPERTY_NAME, 0.0f);
+ handle.SetUniform( ANGLE_Y_AXIS_PROPERTY_NAME, 0.0f);
+
+ return handle;
+ }
+
+ void ShearEffect::SetCenter( const Vector2& center )
+ {
+ SetUniform( CENTER_PROPERTY_NAME, center, COORDINATE_TYPE_VIEWPORT_POSITION );
+ }
+
+ void ShearEffect::SetAngleXAxis( float angle )
+ {
+ SetUniform( ANGLE_X_AXIS_PROPERTY_NAME, angle );
+ };
+
+ void ShearEffect::SetAngleYAxis( float angle )
+ {
+ SetUniform( ANGLE_Y_AXIS_PROPERTY_NAME, angle );
+ };
+
+ const std::string& ShearEffect::GetCenterPropertyName() const
+ {
+ return CENTER_PROPERTY_NAME;
+ }
+
+ const std::string& ShearEffect::GetAngleXAxisPropertyName() const
+ {
+ return ANGLE_X_AXIS_PROPERTY_NAME;
+ }
+
+ const std::string& ShearEffect::GetAngleYAxisPropertyName() const
+ {
+ return ANGLE_Y_AXIS_PROPERTY_NAME;
+ }
+
+ } // namespace Toolkit
+
+ } // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_LINE_INFO_RUN_H__
++#define __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_LINE_INFO_RUN_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/character-run.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief BidirectionalLineInfoRun
++ */
++struct BidirectionalLineInfoRun
++{
++ CharacterRun characterRun; ///< The initial character index within the whole text and the number of characters of the run.
++ CharacterIndex* visualToLogicalMap; ///< Pointer to the visual to logical map table.
++ CharacterIndex* logicalToVisualMap; ///< Pointer to the logical to visual map table.
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_LINE_INFO_RUN_H__
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_PARAGRAPH_INFO_RUN_H__
++#define __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_PARAGRAPH_INFO_RUN_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/character-run.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief BidirectionalParagraphInfoRun
++ *
++ * In terms of the bidirectional algorithm, a 'paragraph' is understood as a run of characters between Paragraph Separators or appropriate Newline Functions.
++ * A 'paragraph' may also be determined by higher-level protocols like a mark-up tag.
++ */
++struct BidirectionalParagraphInfoRun
++{
++ CharacterRun characterRun; ///< The initial character index within the whole text and the number of characters of the run.
++ BidiInfoIndex bidirectionalInfoIndex; ///< Index to the table with the bidirectional info per paragraph.
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_PARAGRAPH_INFO_RUN_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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 HEADER
++#include <dali-toolkit/public-api/text/bidirectional-support.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++void SetBidirectionalInfo( LogicalModel& model )
++{
++}
++
++void ReorderLines( LogicalModel& logicalModel,
++ const VisualModel& visualModel )
++{
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_SUPPORT_H__
++#define __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_SUPPORT_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++class LogicalModel;
++class VisualModel;
++
++/**
++ * Sets the bidirectional info into the logical model.
++ *
++ * Any bidirectional info previously set is removed.
++ *
++ * @pre The @p model needs to have a text set.
++ * @pre The @p model needs to have the line break info set.
++ *
++ * @param[in,out] model The text's logical model.
++ */
++void SetBidirectionalInfo( LogicalModel& model );
++
++/**
++ * Sets the visual to logical and logical to visual map tables.
++ *
++ * Any map tables previously set are removed.
++ *
++ * @pre The @p logicalModel needs to have a text set.
++ * @pre The @p logicalModel needs to have the line break info set.
++ * @pre The @p visualModel needs to have the laid-out lines info set.
++ *
++ * @param[in,out] logicalModel The text's logical model.
++ * @param[in] visualModel The text's visual model.
++ */
++void ReorderLines( LogicalModel& logicalModel,
++ const VisualModel& visualModel );
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_BIDIRECTIONAL_SUPPORT_H__
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_CHARACTER_RUN_H__
++#define __DALI_TOOLKIT_TEXT_CHARACTER_RUN_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief A run of consecutive characters.
++ */
++struct CharacterRun
++{
++ CharacterIndex characterIndex; ///< Index to the first character.
++ Length numberOfCharacters; ///< Number of characters in the run.
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_CHARACTER_RUN_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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 HEADER
++#include <dali-toolkit/public-api/text/character-set-conversion.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace
++{
++ const static uint8_t U1 = 1u;
++ const static uint8_t U2 = 2u;
++ const static uint8_t U3 = 3u;
++ const static uint8_t U4 = 4u;
++ const static uint8_t U0 = 0u;
++ const static uint8_t UTF8_LENGTH[256] = {
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, // lead byte = 0xxx xxxx (U+0000 - U+007F + some extended ascii characters)
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, U1, U1, U1, U1, U1, U1, U1, U1, //
++ U1, U1, //
++
++ U2, U2, U2, U2, U2, U2, U2, U2, U2, U2, //
++ U2, U2, U2, U2, U2, U2, U2, U2, U2, U2, // lead byte = 110x xxxx (U+0080 - U+07FF)
++ U2, U2, U2, U2, U2, U2, U2, U2, U2, U2, //
++ U2, U2, //
++
++ U3, U3, U3, U3, U3, U3, U3, U3, U3, U3, // lead byte = 1110 xxxx (U+0800 - U+FFFF)
++ U3, U3, U3, U3, U3, U3, //
++
++ U4, U4, U4, U4, U4, U4, U4, U4, // lead byte = 1111 0xxx (U+10000 - U+1FFFFF)
++
++ U0, U0, U0, U0, // Non valid.
++ U0, U0, U0, U0, // Non valid.
++ };
++} // namespace
++
++uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length )
++{
++ uint32_t numberOfCharacters = 0u;
++
++ const uint8_t* begin = utf8;
++ const uint8_t* end = utf8 + length;
++
++ for( ; begin < end ; begin += UTF8_LENGTH[*begin], ++numberOfCharacters );
++
++ return numberOfCharacters;
++}
++
++uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint32_t numberOfCharacters )
++{
++ uint32_t numberOfBytes = 0u;
++
++ const uint32_t* begin = utf32;
++ const uint32_t* end = utf32 + numberOfCharacters;
++
++ for( ; begin < end; ++begin )
++ {
++ const uint32_t code = *begin;
++
++ if( code < 0x80u )
++ {
++ ++numberOfBytes;
++ }
++ else if( code < 0x800u )
++ {
++ numberOfBytes += U2;
++ }
++ else if( code < 0x10000u )
++ {
++ numberOfBytes += U3;
++ }
++ else if( code < 0x200000u )
++ {
++ numberOfBytes += U4;
++ }
++ }
++
++ return numberOfBytes;
++}
++
++uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf32 )
++{
++ uint32_t numberOfCharacters = 0u;
++
++ const uint8_t* begin = utf8;
++ const uint8_t* end = utf8 + length;
++
++ for( ; begin < end ; ++numberOfCharacters )
++ {
++ const uint8_t leadByte = *begin;
++
++ switch( UTF8_LENGTH[leadByte] )
++ {
++ case U1:
++ {
++ *utf32++ = leadByte;
++ begin++;
++ break;
++ }
++
++ case U2:
++ {
++ uint32_t& code = *utf32++;
++ code = leadByte & 0x1fu;
++ begin++;
++ code <<= 6u;
++ code |= *begin++ & 0x3fu;
++ break;
++ }
++
++ case U3:
++ {
++ uint32_t& code = *utf32++;
++ code = leadByte & 0x1fu;
++ begin++;
++ code <<= 6u;
++ code |= *begin++ & 0x3fu;
++ code <<= 6u;
++ code |= *begin++ & 0x3fu;
++ break;
++ }
++
++ case U4:
++ {
++ uint32_t& code = *utf32++;
++ code = leadByte & 0x1fu;
++ begin++;
++ code <<= 6u;
++ code |= *begin++ & 0x3fu;
++ code <<= 6u;
++ code |= *begin++ & 0x3fu;
++ code <<= 6u;
++ code |= *begin++ & 0x3fu;
++ break;
++ }
++ }
++ }
++
++ return numberOfCharacters;
++}
++
++void Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8 )
++{
++ const uint32_t* begin = utf32;
++ const uint32_t* end = utf32 + numberOfCharacters;
++
++ for( ; begin < end; ++begin )
++ {
++ const uint32_t code = *begin;
++
++ if( code < 0x80u )
++ {
++ *utf8++ = code;
++ }
++ else if( code < 0x800u )
++ {
++ *utf8++ = static_cast<uint8_t>( code >> 6u ) | 0xc0u; // lead byte for 2 byte sequence
++ *utf8++ = static_cast<uint8_t>( code & 0x3f ) | 0x80u; // continuation byte
++ }
++ else if( code < 0x10000u )
++ {
++ *utf8++ = static_cast<uint8_t>( code >> 12u ) | 0xe0u; // lead byte for 2 byte sequence
++ *utf8++ = static_cast<uint8_t>( ( code >> 6u ) & 0x3f ) | 0x80u; // continuation byte
++ *utf8++ = static_cast<uint8_t>( code & 0x3f ) | 0x80u; // continuation byte
++ }
++ else if( code < 0x200000u )
++ {
++ *utf8++ = static_cast<uint8_t>( code >> 18u ) | 0xf0u; // lead byte for 2 byte sequence
++ *utf8++ = static_cast<uint8_t>( ( code >> 12u ) & 0x3f ) | 0x80u; // continuation byte
++ *utf8++ = static_cast<uint8_t>( ( code >> 6u ) & 0x3f ) | 0x80u; // continuation byte
++ *utf8++ = static_cast<uint8_t>( code & 0x3f ) | 0x80u; // continuation byte
++ }
++ }
++}
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_CHARACTER_SET_CONVERSION_H__
++#define __DALI_TOOLKIT_CHARACTER_SET_CONVERSION_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali/public-api/common/dali-common.h>
++
++// EXTERNAL INCLUDES
++#include <stdint.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++/**
++ * @brief Retrieves the number of characters of the text array encoded in UTF8
++ *
++ * @param[in] utf8 The pointer to the UTF8 array.
++ * @param[in] length The length of the UTF8 array.
++ *
++ * @return The number of characters.
++ */
++DALI_IMPORT_API uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length );
++
++/**
++ * @brief Retrieves the number of bytes needed to encode in UTF8 the given text array encoded in UTF32.
++ *
++ * @param[in] utf32 The pointer to the UTF32 array.
++ * @param[in] numberOfCharacters The number of characters of the UTF32 array.
++ *
++ * @return The number of bytes.
++ */
++DALI_IMPORT_API uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint32_t numberOfCharacters );
++
++/**
++ * @brief Converts a text array encoded in UTF8 into a text array encoded in UTF32.
++ *
++ * The @p utf32 buffer needs to be big enough to store all the characters.
++ *
++ * @param[in] utf8 The pointer to the UTF8 array.
++ * @param[in] length The length of the UTF8 array.
++ * @param[out] utf32 The pointer to the UTF32 array.
++ *
++ * @return The number of characters.
++ */
++DALI_IMPORT_API uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf32 );
++
++/**
++ * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
++ *
++ * The @p utf8 buffer needs to be big enough to store all the characters.
++ *
++ * @param[in] utf32 The pointer to the UTF32 array.
++ * @param[in] numberOfCharacters The number of characters of the UTF32 array.
++ * @param[out] utf8 The pointer to the UTF8 array.
++ */
++DALI_IMPORT_API void Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint32_t* utf8 );
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_CHARACTER_SET_CONVERSION_H__
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_FONT_RUN_H__
++#define __DALI_TOOLKIT_TEXT_FONT_RUN_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/character-run.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief Run of characters with the same font.
++ */
++struct FontRun
++{
++ CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
++ FontId fontId; ///< Font id of the run.
++ bool isDefault; ///< Whether the font is a default font not defined by the user.
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_FONT_RUN_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/layouts/layout-engine.h>
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/math/vector2.h>
++#include <dali/public-api/text-abstraction/font-client.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/logical-model.h>
++#include <dali-toolkit/public-api/text/visual-model.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++struct LayoutEngine::Impl
++{
++ Impl()
++ : mLayout( LayoutEngine::SINGLE_LINE_BOX )
++ {
++ mFontClient = TextAbstraction::FontClient::Get();
++ }
++
++ void UpdateVisualModel( const Vector2& boundingBox, const LogicalModel& logicalModel, VisualModel& visualModel )
++ {
++ // TODO Switch between different layouts
++
++ TextAbstraction::FontId fontId = mFontClient.GetFontId( "/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-R.ttf", 13*64 );
++
++ const Length characterCount = logicalModel.GetNumberOfCharacters();
++
++ Vector<GlyphInfo> glyphs;
++ glyphs.Reserve( characterCount );
++
++ Vector<CharacterIndex> characterIndices;
++ characterIndices.Reserve( characterCount );
++
++ std::vector<Length> charactersPerGlyph;
++ charactersPerGlyph.assign( characterCount, 1 );
++
++ for( unsigned int i=0; i<characterCount; ++i )
++ {
++ Character charcode;
++ logicalModel.GetText( i, &charcode, 1 );
++
++ // TODO - Perform shaping to get correct glyph indices
++ GlyphIndex glyphIndex = mFontClient.GetGlyphIndex( fontId, charcode );
++
++ glyphs.PushBack( GlyphInfo(fontId, glyphIndex) );
++ characterIndices.PushBack( 1 );
++ }
++
++ if( mFontClient.GetGlyphMetrics( &glyphs[0], glyphs.Size() ) )
++ {
++ visualModel.SetGlyphs( &glyphs[0],
++ &characterIndices[0],
++ &charactersPerGlyph[0],
++ characterCount );
++
++ UpdateGlyphPositions( boundingBox, visualModel );
++ }
++ }
++
++ void UpdateGlyphPositions( const Vector2& boundingBox, VisualModel& visualModel )
++ {
++ if( LayoutEngine::SINGLE_LINE_BOX == mLayout )
++ {
++ SingleLineLayout( boundingBox, visualModel );
++ }
++ else
++ {
++ MultiLineLayout( boundingBox, visualModel );
++ }
++ }
++
++ // TODO - Rewrite this to handle bidi
++ void SingleLineLayout( const Vector2& boundingBox, VisualModel& visualModel )
++ {
++ Length glyphCount = visualModel.GetNumberOfGlyphs();
++
++ std::vector<Vector2> glyphPositions;
++ glyphPositions.reserve( glyphCount );
++
++ if( glyphCount > 0 )
++ {
++ // FIXME Single font assumption
++ Text::FontMetrics fontMetrics;
++ GlyphInfo firstGlyph;
++ visualModel.GetGlyphs( 0, &firstGlyph, 1 );
++ mFontClient.GetFontMetrics( firstGlyph.fontId, fontMetrics );
++
++ float penX( 0 );
++ float penY( fontMetrics.ascender ); // Move to baseline
++
++ for( unsigned int i=0; i<glyphCount; ++i )
++ {
++ GlyphInfo glyph;
++ visualModel.GetGlyphs( i, &glyph, 1 );
++
++ glyphPositions.push_back( Vector2( penX + glyph.xBearing,
++ penY - glyph.yBearing ) );
++
++ penX += glyph.advance;
++ }
++
++ visualModel.SetGlyphPositions( &glyphPositions[0], glyphCount );
++ }
++ }
++
++ // TODO - Rewrite this to handle bidi
++ void MultiLineLayout( const Vector2& boundingBox, VisualModel& visualModel )
++ {
++ Length glyphCount = visualModel.GetNumberOfGlyphs();
++
++ std::vector<Vector2> glyphPositions;
++ glyphPositions.reserve( glyphCount );
++
++ if( glyphCount > 0 )
++ {
++ // FIXME Single font assumption
++ Text::FontMetrics fontMetrics;
++ GlyphInfo firstGlyph;
++ visualModel.GetGlyphs( 0, &firstGlyph, 1 );
++ mFontClient.GetFontMetrics( firstGlyph.fontId, fontMetrics );
++
++ float penX( 0 );
++ float penY( fontMetrics.ascender ); // Move to baseline
++
++ unsigned int i=0;
++ while( i < glyphCount )
++ {
++ // Skip initial whitespace
++ for( ; i<glyphCount; ++i )
++ {
++ GlyphInfo glyph;
++ visualModel.GetGlyphs( i, &glyph, 1 );
++
++ if( glyph.width > 0 &&
++ glyph.height > 0 )
++ {
++ break;
++ }
++ else
++ {
++ glyphPositions.push_back( Vector2( penX + glyph.xBearing,
++ penY - glyph.yBearing ) );
++ }
++ }
++
++ // Find last glyph for the next line
++ unsigned int endIndex = i;
++ float endPenX = penX;
++ unsigned int j=i;
++ for( ; j<glyphCount; ++j )
++ {
++ GlyphInfo glyph;
++ visualModel.GetGlyphs( j, &glyph, 1 );
++
++ endPenX += glyph.advance;
++
++ if( glyph.width <= 0 ||
++ glyph.height <= 0 )
++ {
++ // Potential line end found
++ endIndex = j;
++ }
++ else if( endPenX > boundingBox.width )
++ {
++ break;
++ }
++ }
++
++ // If end of text or no whitespace found
++ if( glyphCount == j ||
++ endIndex == i )
++ {
++ endIndex = j;
++ }
++
++ for( ; i<endIndex; ++i )
++ {
++ GlyphInfo glyph;
++ visualModel.GetGlyphs( i, &glyph, 1 );
++
++ glyphPositions.push_back( Vector2( penX + glyph.xBearing,
++ penY - glyph.yBearing ) );
++
++ penX += glyph.advance;
++ }
++
++ // Go to next line
++ penX = 0;
++ penY += fontMetrics.height;
++ }
++
++ visualModel.SetGlyphPositions( &glyphPositions[0], glyphCount );
++ }
++ }
++
++ unsigned int mLayout;
++
++ TextAbstraction::FontClient mFontClient;
++};
++
++LayoutEngine::LayoutEngine()
++: mImpl( NULL )
++{
++ mImpl = new LayoutEngine::Impl();
++}
++
++LayoutEngine::~LayoutEngine()
++{
++ delete mImpl;
++}
++
++void LayoutEngine::SetLayout( Layout layout )
++{
++ mImpl->mLayout = layout;
++}
++
++void LayoutEngine::UpdateVisualModel( const Vector2& boundingBox, const LogicalModel& logicalModel, VisualModel& visualModel )
++{
++ mImpl->UpdateVisualModel( boundingBox, logicalModel, visualModel );
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
++#define __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++namespace Dali
++{
++
++struct Vector2;
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++class LogicalModel;
++class VisualModel;
++
++/**
++ * @brief LayoutEngine is responsible for calculating the visual position of glyphs in layout.
++ */
++class LayoutEngine
++{
++public:
++
++ enum Layout
++ {
++ SINGLE_LINE_BOX,
++ MULTI_LINE_BOX
++ };
++
++ /**
++ * @brief Create a new instance of a LayoutEngine.
++ */
++ LayoutEngine();
++
++ /**
++ * @brief Virtual destructor.
++ */
++ ~LayoutEngine();
++
++ /**
++ * @brief Choose the required layout.
++ *
++ * @param[in] layout The required layout.
++ */
++ void SetLayout( Layout layout );
++
++ /**
++ * @brief Store the visual position of glyphs in the VisualModel.
++ *
++ * @param[in] boundingBox The size of the box containing the text.
++ * @param[in] logicalModel The logical model.
++ * @param[in] visualModel The visual model to update.
++ */
++ void UpdateVisualModel( const Vector2& boundingBox, const LogicalModel& logicalModel, VisualModel& visualModel );
++
++private:
++
++ // Undefined
++ LayoutEngine( const LayoutEngine& handle );
++
++ // Undefined
++ LayoutEngine& operator=( const LayoutEngine& handle );
++
++private:
++
++ struct Impl;
++ Impl* mImpl;
++};
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_LAYOUT_ENGINE_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/logical-model.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/font-run.h>
++#include <dali-toolkit/public-api/text/script-run.h>
++
++// EXTERNAL INCLUDES
++#include <memory.h>
++#include <stdlib.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++struct LogicalModel::Impl
++{
++ Vector<Character> mText;
++ Vector<ScriptRun> mScriptRuns;
++ Vector<FontRun> mFontRuns;
++};
++
++LogicalModelPtr LogicalModel::New()
++{
++ return LogicalModelPtr( new LogicalModel() );
++}
++
++void LogicalModel::SetText( const Character* text, Length length )
++{
++ Vector<Character>& modelText = mImpl->mText;
++ modelText.Resize( length );
++ memcpy( &modelText[0], text, length*sizeof(Character) );
++}
++
++Length LogicalModel::GetNumberOfCharacters() const
++{
++ return mImpl->mText.Count();
++}
++
++void LogicalModel::GetText( CharacterIndex characterIndex, Character* text, Length numberOfCharacters ) const
++{
++ Vector<Character>& modelText = mImpl->mText;
++ memcpy( text, &modelText[characterIndex], numberOfCharacters*sizeof(Character) );
++}
++
++void LogicalModel::SetScripts( const ScriptRun* const scripts,
++ Length numberOfRuns )
++{
++ Vector<ScriptRun>& scriptRuns = mImpl->mScriptRuns;
++ scriptRuns.Resize( numberOfRuns );
++ memcpy( scriptRuns.Begin(), scripts, numberOfRuns * sizeof( ScriptRun ) );
++}
++
++Length LogicalModel::GetNumberOfScriptRuns( CharacterIndex characterIndex,
++ Length numberOfCharacters ) const
++{
++ if( ( 0u == characterIndex ) && ( mImpl->mText.Count() == numberOfCharacters ) )
++ {
++ return mImpl->mScriptRuns.Count();
++ }
++
++ const CharacterIndex charcterEndIndex = characterIndex + numberOfCharacters;
++ Length numberOfScriptRuns = 0u;
++ bool firstIndexFound = false;
++
++ for( Length index = 0u, length = mImpl->mScriptRuns.Count(); index < length; ++index )
++ {
++ const ScriptRun* const scriptRun = mImpl->mScriptRuns.Begin() + index;
++
++ if( !firstIndexFound &&
++ ( characterIndex < scriptRun->characterRun.characterIndex + scriptRun->characterRun.numberOfCharacters ) )
++ {
++ // The character index is within this script run.
++ // Starts the counter of script runs.
++ firstIndexFound = true;
++ }
++
++ if( firstIndexFound )
++ {
++ ++numberOfScriptRuns;
++ if( scriptRun->characterRun.characterIndex + scriptRun->characterRun.numberOfCharacters > charcterEndIndex )
++ {
++ // This script run exceeds the given range. The number of scripts can be returned.
++ return numberOfScriptRuns;
++ }
++ }
++ }
++
++ return numberOfScriptRuns;
++}
++
++void LogicalModel::GetScriptRuns( ScriptRun* scriptRuns,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const
++{
++ // A better implementation can cache the first script run and the number of then when the GetNumberOfScriptRuns() is called.
++
++ Length numberOfScriptRuns = GetNumberOfScriptRuns( characterIndex,
++ numberOfCharacters );
++
++ for( Length index = 0u, length = mImpl->mScriptRuns.Count(); index < length; ++index )
++ {
++ const ScriptRun* const scriptRun = mImpl->mScriptRuns.Begin() + index;
++
++ if( characterIndex < scriptRun->characterRun.characterIndex + scriptRun->characterRun.numberOfCharacters )
++ {
++ memcpy( scriptRuns, scriptRun, sizeof( ScriptRun ) * numberOfScriptRuns );
++ return;
++ }
++ }
++}
++
++Script LogicalModel::GetScript( CharacterIndex characterIndex ) const
++{
++ // If this operation is too slow, consider a binary search.
++
++ for( Length index = 0u, length = mImpl->mScriptRuns.Count(); index < length; ++index )
++ {
++ const ScriptRun* const scriptRun = mImpl->mScriptRuns.Begin() + index;
++
++ if( ( scriptRun->characterRun.characterIndex <= characterIndex ) &&
++ ( characterIndex < scriptRun->characterRun.characterIndex + scriptRun->characterRun.numberOfCharacters ) )
++ {
++ return scriptRun->script;
++ }
++ }
++
++ return TextAbstraction::UNKNOWN;
++}
++
++void LogicalModel::SetFonts( const FontRun* const fonts,
++ Length numberOfRuns )
++{
++ Vector<FontRun>& fontRuns = mImpl->mFontRuns;
++ fontRuns.Resize( numberOfRuns );
++ memcpy( fontRuns.Begin(), fonts, numberOfRuns * sizeof( FontRun ) );
++}
++
++Length LogicalModel::GetNumberOfFontRuns( CharacterIndex characterIndex,
++ Length numberOfCharacters ) const
++{
++ if( ( 0u == characterIndex ) && ( mImpl->mText.Count() == numberOfCharacters ) )
++ {
++ return mImpl->mFontRuns.Count();
++ }
++
++ const CharacterIndex charcterEndIndex = characterIndex + numberOfCharacters;
++ Length numberOfFontRuns = 0u;
++ bool firstIndexFound = false;
++
++ for( Length index = 0u, length = mImpl->mFontRuns.Count(); index < length; ++index )
++ {
++ const FontRun* const fontRun = mImpl->mFontRuns.Begin() + index;
++
++ if( !firstIndexFound &&
++ ( characterIndex < fontRun->characterRun.characterIndex + fontRun->characterRun.numberOfCharacters ) )
++ {
++ // The character index is within this font run.
++ // Starts the counter of font runs.
++ firstIndexFound = true;
++ }
++
++ if( firstIndexFound )
++ {
++ ++numberOfFontRuns;
++ if( fontRun->characterRun.characterIndex + fontRun->characterRun.numberOfCharacters > charcterEndIndex )
++ {
++ // This font run exceeds the given range. The number of fonts can be returned.
++ return numberOfFontRuns;
++ }
++ }
++ }
++
++ return numberOfFontRuns;
++}
++
++void LogicalModel::GetFontRuns( FontRun* fontRuns,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const
++{
++ // A better implementation can cache the first font run and the number of then when the GetNumberOfFontRuns() is called.
++
++ Length numberOfFontRuns = GetNumberOfFontRuns( characterIndex,
++ numberOfCharacters );
++
++ for( Length index = 0u, length = mImpl->mFontRuns.Count(); index < length; ++index )
++ {
++ const FontRun* const fontRun = mImpl->mFontRuns.Begin() + index;
++
++ if( characterIndex < fontRun->characterRun.characterIndex + fontRun->characterRun.numberOfCharacters )
++ {
++ memcpy( fontRuns, fontRun, sizeof( FontRun ) * numberOfFontRuns );
++ return;
++ }
++ }
++}
++
++FontId LogicalModel::GetFont( CharacterIndex characterIndex ) const
++{
++ for( Length index = 0u, length = mImpl->mFontRuns.Count(); index < length; ++index )
++ {
++ const FontRun* const fontRun = mImpl->mFontRuns.Begin() + index;
++
++ if( ( fontRun->characterRun.characterIndex <= characterIndex ) &&
++ ( characterIndex < fontRun->characterRun.characterIndex + fontRun->characterRun.numberOfCharacters ) )
++ {
++ return fontRun->fontId;
++ }
++ }
++
++ return 0u;
++}
++
++void LogicalModel::SetLineBreakInfo( const LineBreakInfo* const lineBreakInfo,
++ Length length )
++{
++}
++
++void LogicalModel::GetLineBreakInfo( LineBreakInfo* lineBreakInfo,
++ CharacterIndex characterIndex,
++ Length numberOfItems ) const
++{
++}
++
++LineBreakInfo LogicalModel::GetLineBreakInfo( CharacterIndex characterIndex ) const
++{
++ return 0;
++}
++
++void LogicalModel::SetWordBreakInfo( const WordBreakInfo* const wordBreakInfo,
++ Length length )
++{
++}
++
++void LogicalModel::GetWordBreakInfo( WordBreakInfo* wordBreakInfo,
++ CharacterIndex characterIndex,
++ Length numberOfItems ) const
++{
++}
++
++WordBreakInfo LogicalModel::GetWordBreakInfo( CharacterIndex characterIndex ) const
++{
++ return 0;
++}
++
++void LogicalModel::SetBidirectionalInfo( const BidirectionalParagraphInfoRun* const bidirectionalInfo,
++ Length numberOfRuns )
++{
++}
++
++Length LogicalModel::GetNumberOfBidirectionalInfoRuns( CharacterIndex characterIndex,
++ Length numberOfCharacters ) const
++{
++ return 0u;
++}
++
++void LogicalModel::GetCharacterDirections( CharacterDirection* directions,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const
++{
++}
++
++CharacterDirection LogicalModel::GetCharacterDirection( CharacterIndex characterIndex ) const
++{
++ return false;
++}
++
++void LogicalModel::SetVisualToLogicalMap( const BidirectionalLineInfoRun* const bidirectionalInfo,
++ Length numberOfRuns )
++{
++}
++
++CharacterIndex LogicalModel::GetVisualCharacterIndex( CharacterIndex logicalCharacterIndex ) const
++{
++ return 0u;
++}
++
++CharacterIndex LogicalModel::GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const
++{
++ return 0u;
++}
++
++void LogicalModel::GetLogicalToVisualMap( CharacterIndex* logicalToVisualMap,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const
++{
++}
++
++void LogicalModel::GetVisualToLogicalMap( CharacterIndex* visualToLogicalMap,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const
++{
++}
++
++LogicalModel::~LogicalModel()
++{
++ delete mImpl;
++}
++
++LogicalModel::LogicalModel()
++: mImpl( NULL )
++{
++ mImpl = new LogicalModel::Impl();
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_H__
++#define __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/common/intrusive-ptr.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++struct BidirectionalLineInfoRun;
++struct BidirectionalParagraphInfoRun;
++struct FontRun;
++class LogicalModel;
++typedef IntrusivePtr<LogicalModel> LogicalModelPtr;
++struct ScriptRun;
++
++/**
++ * @brief A logical text model contains layout independent information.
++ *
++ * This includes:
++ * - A series of UTF-32 characters in logical order
++ */
++class LogicalModel : public RefObject
++{
++public:
++
++ /**
++ * @brief Create a new instance of a LogicalModel.
++ *
++ * @return A pointer to a new LogicalModel.
++ */
++ static LogicalModelPtr New();
++
++ // Text interface.
++
++ /**
++ * @brief Replaces any text previously set.
++ *
++ * @param[in] text An array of UTF-32 characters.
++ * @param[in] length The length of the array.
++ */
++ void SetText( const Character* text,
++ Length length );
++
++ /**
++ * @brief Retrieves the number of characters of the text.
++ *
++ * @return The number of characters.
++ */
++ Length GetNumberOfCharacters() const;
++
++ /**
++ * @brief Retrieves characters from the text in the given buffer.
++ *
++ * @pre The size of the @p text buffer needs to be big enough to copy the @p numberOfCharacters.
++ * @param[in] characterIndex The index to the first character to copy.
++ * @param[out] text Pointer to a buffer where the text is copied.
++ * @param[in] numberOfCharacters The number of characters to be copied.
++ */
++ void GetText( CharacterIndex characterIndex,
++ Character* text,
++ Length numberOfCharacters ) const;
++
++ // Language support interface.
++
++ /**
++ * Sets the script runs.
++ *
++ * Replaces any scripts previously set.
++ *
++ * A run is a group of consecutive characters. A script run contains the script for a run.
++ *
++ * @param[in] scripts Pointer to a buffer with all the script runs.
++ * @param[in] numberOfRuns The number of script runs.
++ */
++ void SetScripts( const ScriptRun* const scripts,
++ Length numberOfRuns );
++
++ /**
++ * Retrieves the number of script runs for the given range of characters.
++ *
++ * A run is a group of consecutive characters. A script run contains the script for a run.
++ *
++ * @param[in] characterIndex Index to the first character.
++ * @param[in] numberOfCharacters The number of characters.
++ *
++ * @return The number of script runs.
++ */
++ Length GetNumberOfScriptRuns( CharacterIndex characterIndex,
++ Length numberOfCharacters ) const;
++
++ /**
++ * Retrieves the script runs for the given range of characters.
++ *
++ * The @p scriptRuns buffer needs to be big enough to copy the number of script runs.
++ * Call GetNumberOfScriptRuns() to retrieve the number of script runs.
++ *
++ * @param[out] scriptRuns Pointer to a buffer where the script runs are copied.
++ * @param[in] characterIndex Index to the first character.
++ * @param[in] numberOfCharacters The number of characters.
++ */
++ void GetScriptRuns( ScriptRun* scriptRuns,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const;
++
++ /**
++ * Retrieves the script for the given character index.
++ *
++ * @param[in] characterIndex Index to the character.
++ *
++ * @return The character's script.
++ */
++ Script GetScript( CharacterIndex characterIndex ) const;
++
++ /**
++ * Sets the font runs.
++ *
++ * Replaces any fonts previously set.
++ *
++ * A run is a group of consecutive characters. A font run contains the font id for a run.
++ *
++ * @param[in] fonts Pointer to a buffer with all the font runs.
++ * @param[in] numberOfRuns The number of font runs.
++ */
++ void SetFonts( const FontRun* const fonts,
++ Length numberOfRuns );
++
++ /**
++ * Retrieves the number of font runs for the given range of characters.
++ *
++ * A run is a group of consecutive characters. A font run contains the font id for a run.
++ *
++ * @param[in] characterIndex Index to the first character.
++ * @param[in] numberOfCharacters The number of characters.
++ *
++ * @return The number of font runs.
++ */
++ Length GetNumberOfFontRuns( CharacterIndex characterIndex,
++ Length numberOfCharacters ) const;
++
++ /**
++ * Retrieves the font runs for the given range of characters.
++ *
++ * The @p fontRuns buffer needs to be big enough to copy the number of font runs.
++ * Call GetNumberOfFontRuns() to retrieve the number of font runs.
++ *
++ * @param[out] fontRuns Pointer to a buffer where the font runs are copied.
++ * @param[in] characterIndex Index to the first character.
++ * @param[in] numberOfCharacters The number of characters.
++ */
++ void GetFontRuns( FontRun* fontRuns,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const;
++
++ /**
++ * Retrieves the font id for the given character index.
++ *
++ * @param[in] characterIndex Index to the first character.
++ *
++ * @return The font id.
++ */
++ FontId GetFont( CharacterIndex characterIndex ) const;
++
++ // Break info interface.
++
++ /**
++ * Sets the line break info.
++ *
++ * See GetLineBreakInfo() to get how the line break info is encoded.
++ *
++ * Replaces any line break info previously set.
++ *
++ * @param[in] lineBreakInfo Pointer to a buffer with the line break info.
++ * @param[in] length The size of the buffer.
++ */
++ void SetLineBreakInfo( const LineBreakInfo* const lineBreakInfo,
++ Length length );
++
++ /**
++ * Retrieves the line break info in the given buffer.
++ *
++ * The size of the @p lineBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
++ *
++ * Possible values for LineBreakInfo are:
++ *
++ * - 0 is a LINE_MUST_BREAK. Text must be broken into a new line.
++ * - 1 is a LINE_ALLOW_BREAK. Is possible to break the text into a new line.
++ * - 2 is a LINE_NO_BREAK. Text can't be broken into a new line.
++ *
++ @verbatim
++ i.e. Hello big\nworld produces:
++ 2222212220 22220
++ @endverbatim
++ *
++ * @param[out] lineBreakInfo Pointer to a buffer where the line break info is copied.
++ * @param[in] characterIndex Index to the first line break info item.
++ * @param[in] numberOfItems The number of items to be copied.
++ */
++ void GetLineBreakInfo( LineBreakInfo* lineBreakInfo,
++ CharacterIndex characterIndex,
++ Length numberOfItems ) const;
++
++ /**
++ * Retrieves the line break info for the given item index.
++ *
++ * @param[in] characterIndex Index to the line break info item.
++ */
++ LineBreakInfo GetLineBreakInfo( CharacterIndex characterIndex ) const;
++
++ /**
++ * Sets the word break info.
++ *
++ * See GetWordBreakInfo() to get how the word break info is encoded.
++ *
++ * Replaces any word break info previously set.
++ *
++ * @param[in] wordBreakInfo Pointer to a buffer with the word break info.
++ * @param[in] length The size of the buffer.
++ */
++ void SetWordBreakInfo( const WordBreakInfo* const wordBreakInfo,
++ Length length );
++
++ /**
++ * Retrieves the word break info in the given buffer.
++ *
++ * The size of the @p wordBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
++ *
++ * The size of the buffer has to be big enough to store the whole word break info per character.
++ * Call GetNumberOfCharacters() to get the number of characters.
++ *
++ * Possible values for WordBreakInfo are:
++ *
++ * - 0 is a WORD_BREAK. Text can be broken into a new word.
++ * - 1 is a WORD_NO_BREAK. Text can't be broken into a new word.
++ *
++ @verbatim
++ i.e. Hello big\nworld produces:
++ 1111001100 11110
++ @endverbatim
++ *
++ * @param[out] wordBreakInfo Pointer to a buffer where the word break info is copied.
++ * @param[in] characterIndex Index to the first word break info item.
++ * @param[in] numberOfItems The number of items to be copied.
++ */
++ void GetWordBreakInfo( WordBreakInfo* wordBreakInfo,
++ CharacterIndex characterIndex,
++ Length numberOfItems ) const;
++
++ /**
++ * Retrieves the word break info for the given item index.
++ *
++ * @param[in] characterIndex Index to the word break info item.
++ */
++ WordBreakInfo GetWordBreakInfo( CharacterIndex characterIndex ) const;
++
++ // Bidirectional support interface.
++
++ /**
++ * Sets the bidirectional info runs.
++ *
++ * Replaces any bidirectional info previously set.
++ *
++ * Each bidirectional info run stores bidirectional info for a whole 'paragraph' of text which contains right to left scripts.
++
++ * In terms of the bidirectional algorithm, a 'paragraph' is understood as a run of characters between Paragraph Separators or appropriate Newline Functions.
++ * A 'paragraph' may also be determined by higher-level protocols like a mark-up tag.
++ *
++ * @param[in] bidirectionalInfo Pointer to a buffer with all the bidirectional info runs.
++ * @param[in] numberOfRuns The number of bidirectional info runs.
++ */
++ void SetBidirectionalInfo( const BidirectionalParagraphInfoRun* const bidirectionalInfo,
++ Length numberOfRuns );
++
++ /**
++ * Retrieves the number of bidirectional info runs for the given range of characters.
++ *
++ * It may be zero if there is no right to left scripts.
++ *
++ * @param[in] characterIndex Index to the first character.
++ * @param[in] numberOfCharacters The number of characters.
++ *
++ * @return The number of bidirectional info runs.
++ */
++ Length GetNumberOfBidirectionalInfoRuns( CharacterIndex characterIndex,
++ Length numberOfCharacters ) const;
++
++ /**
++ * Retrieves the direction of the characters.
++ *
++ * It sets @c true for right to left characters and @c false for left to right.
++ * For neutral characters it check's the next and previous character's directions:
++ * - If they are equals set that direction. If they are not, sets the paragraph's direction.
++ * - If there is no next, sets the paragraph's direction.
++ *
++ * See SetBidirectionalInfo() to get an explanation of the 'paragraph' meaning in the bidirectional algorithm.
++ *
++ * @param[out] directions Whether the characters are right to left or left to right.
++ * @param[in] characterIndex Index to the first character.
++ * @param[in] numberOfCharacters The number of characters.
++ */
++ void GetCharacterDirections( CharacterDirection* directions,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const;
++
++ /**
++ * Retrieves the direction of a characters.
++ *
++ * See GetCharacterDirections().
++ *
++ * @param[in] characterIndex Index to a character.
++ *
++ * @return The character's direction.
++ */
++ CharacterDirection GetCharacterDirection( CharacterIndex characterIndex ) const;
++
++ // Visual <--> Logical conversion tables.
++
++ /**
++ * Sets the visual to logical and the logical to visual map tables.
++ *
++ * Replaces any map tables previously set.
++ *
++ * @param[in] bidirectionalInfo Pointer to a buffer with all the bidirectional info runs.
++ * @param[in] numberOfRuns The number of bidirectional info runs.
++ */
++ void SetVisualToLogicalMap( const BidirectionalLineInfoRun* const bidirectionalInfo,
++ Length numberOfRuns );
++
++ /**
++ * Retrieves the visual character index for the given logical character index.
++ *
++ * @param[in] logicalCharacterIndex The logical character index.
++ *
++ * @return The visual character index.
++ */
++ CharacterIndex GetVisualCharacterIndex( CharacterIndex logicalCharacterIndex ) const;
++
++ /**
++ * Retrieves the logical character index for the given visual character index.
++ *
++ * @param[in] visualCharacterIndex The visual character index.
++ *
++ * @return The logical character index.
++ */
++ CharacterIndex GetLogicalCharacterIndex( CharacterIndex visualCharacterIndex ) const;
++
++ /**
++ * Retrieves the whole or part of the logical to visual conversion map.
++ *
++ * The size of the buffer needs to be big enough to copy the @p numberOfCharacters.
++ *
++ * @param[out] logicalToVisualMap Pointer to a buffer where the conversion map is copied.
++ * @param[in] characterIndex Index to the first character.
++ * @param[in] numberOfCharacters The number of characters.
++ */
++ void GetLogicalToVisualMap( CharacterIndex* logicalToVisualMap,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const;
++
++ /**
++ * Retrieves the whole or part of the visual to logical conversion map.
++ *
++ * The size of the buffer needs to be big enough to copy the @p numberOfCharacters.
++ *
++ * @param[out] visualToLogicalMap Pointer to a buffer where the conversion map is copied.
++ * @param[in] characterIndex Index to the first character.
++ * @param[in] numberOfCharacters The number of characters.
++ */
++ void GetVisualToLogicalMap( CharacterIndex* visualToLogicalMap,
++ CharacterIndex characterIndex,
++ Length numberOfCharacters ) const;
++protected:
++
++ /**
++ * @brief A reference counted object may only be deleted by calling Unreference().
++ */
++ virtual ~LogicalModel();
++
++private:
++
++ /**
++ * @brief Private constructor.
++ */
++ LogicalModel();
++
++ // Undefined
++ LogicalModel( const LogicalModel& handle );
++
++ // Undefined
++ LogicalModel& operator=( const LogicalModel& handle );
++
++private:
++
++ struct Impl;
++ Impl* mImpl;
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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 HEADER
++#include <dali-toolkit/public-api/text/multi-language-support.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/internal/text/multi-language-support-impl.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++MultilanguageSupport::MultilanguageSupport()
++{
++}
++
++MultilanguageSupport::~MultilanguageSupport()
++{
++}
++
++MultilanguageSupport::MultilanguageSupport( Internal::MultilanguageSupport* implementation )
++: BaseHandle( implementation )
++{
++}
++
++MultilanguageSupport MultilanguageSupport::Get()
++{
++ return Internal::MultilanguageSupport::Get();
++}
++
++void MultilanguageSupport::SetScripts( LogicalModel& model )
++{
++ GetImplementation( *this ).SetScripts( model );
++}
++
++void MultilanguageSupport::ValidateFonts( LogicalModel& model )
++{
++ GetImplementation( *this ).ValidateFonts( model );
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H__
++#define __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/object/base-handle.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++namespace Internal DALI_INTERNAL
++{
++
++class MultilanguageSupport;
++
++} // Internal
++
++class LogicalModel;
++
++/**
++ * @brief Sets the character's scripts to the model and validates the fonts set by the user or assigns default ones.
++ */
++class MultilanguageSupport : public BaseHandle
++{
++public:
++
++ /**
++ * @brief Create an uninitialized MultilanguageSupport handle.
++ */
++ MultilanguageSupport();
++
++ /**
++ * @brief Destructor
++ *
++ * This is non-virtual since derived Handle types must not contain data or virtual methods.
++ */
++ ~MultilanguageSupport();
++
++ /**
++ * @brief This constructor is used by MultilanguageSupport::Get().
++ *
++ * @param[in] implementation A pointer to the internal multi-language support object.
++ */
++ explicit DALI_INTERNAL MultilanguageSupport( Internal::MultilanguageSupport* implementation );
++
++ /**
++ * @brief Retrieve a handle to the MultilanguageSupport instance.
++ *
++ * @return A handle to the MultilanguageSupport.
++ */
++ static MultilanguageSupport Get();
++
++ /**
++ * @brief Sets the scripts of the whole text.
++ *
++ * Any script info previously set is removed.
++ *
++ * Scripts are used to validate and set default fonts and to shape the text in further steps.
++ *
++ * @pre The @p model needs to have a text set.
++ *
++ * @param[in,out] model The text's logical model.
++ */
++ void SetScripts( LogicalModel& model );
++
++ /**
++ * @brief Validates the character's font of the whole text.
++ *
++ * It may update fonts set by application developers.
++ *
++ * This method ensures all characters are going to be rendered using an appropriate font. Provided a valid font
++ * exists in the platform.
++ *
++ * For those characters with no font set, it sets a default one.
++ *
++ * If a font has been set by the application developer, this method checks if the font supports the character.
++ * If it doesn't, this method replaces it by a default one.
++ *
++ * @pre The @p model needs to have a text set.
++ * @pre The @p model needs to have the scripts set.
++ *
++ * @param[in,out] model The text's logical model.
++ */
++ void ValidateFonts( LogicalModel& model );
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_MULTI_LANGUAGE_SUPPORT_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.h>
++
++// EXTERNAL INCLUDES
++#include <dali/dali.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/rendering/shaders/text-basic-shader.h>
++
++using namespace Dali;
++using namespace Dali::Toolkit;
++using namespace Dali::Toolkit::Text;
++
++namespace
++{
++
++const std::size_t PADDING = 2; //< To avoid GL filtering artefacts
++
++struct TextureCoordinates
++{
++ TextureCoordinates()
++ : topLeft( 0.0f, 0.0f ),
++ topRight( 1.0f, 0.0f ),
++ bottomLeft( 0.0f, 1.0f ),
++ bottomRight( 1.0f, 1.0f )
++ {
++ }
++
++ Vector2 topLeft;
++ Vector2 topRight;
++ Vector2 bottomLeft;
++ Vector2 bottomRight;
++};
++
++struct AtlasHelperGlyph
++{
++ AtlasHelperGlyph()
++ : fontId( 0 ),
++ index( 0 ),
++ xOffset( 0 ),
++ width( 0 ),
++ height( 0 )
++ {
++ }
++
++ AtlasHelperGlyph( FontId id,
++ GlyphIndex glyphIndex,
++ std::size_t offset,
++ std::size_t widthPixels,
++ std::size_t heightPixels )
++ : fontId( id ),
++ index( glyphIndex ),
++ xOffset( offset ),
++ width( widthPixels ),
++ height( heightPixels )
++ {
++ }
++
++ FontId fontId;
++ GlyphIndex index;
++ std::size_t xOffset;
++ std::size_t width;
++ std::size_t height;
++ TextureCoordinates coords;
++};
++
++struct AtlasHelper
++{
++ AtlasHelper()
++ : mWidth( 0.0f ),
++ mHeight( 0.0f )
++ {
++ mFontClient = TextAbstraction::FontClient::Get();
++ }
++
++ void Reset()
++ {
++ mWidth = 0.0f;
++ mHeight = 0.0f;
++ mGlyphs.clear();
++ }
++
++ void Reserve( std::size_t size )
++ {
++ mGlyphs.reserve( size );
++ }
++
++ bool GlyphFound( FontId fontId, GlyphIndex index ) const
++ {
++ for( unsigned int i=0; i<mGlyphs.size(); ++i )
++ {
++ const AtlasHelperGlyph& glyph = mGlyphs[i];
++
++ if( fontId == glyph.fontId &&
++ index == glyph.index )
++ {
++ return true;
++ }
++ }
++
++ return false;
++ }
++
++ void AddGlyph( const GlyphInfo& glyphInfo )
++ {
++ mGlyphs.push_back( AtlasHelperGlyph( glyphInfo.fontId, glyphInfo.index, mWidth, glyphInfo.width, glyphInfo.height ) );
++
++ mWidth += glyphInfo.width + PADDING;
++ if( mHeight < glyphInfo.height + PADDING )
++ {
++ mHeight = glyphInfo.height + PADDING;
++ }
++ }
++
++ Atlas CreateAtlas()
++ {
++ Atlas atlas = Atlas::New( mWidth, mHeight, Pixel::L8 );
++
++ for( unsigned int i=0; i<mGlyphs.size(); ++i )
++ {
++ AtlasHelperGlyph& glyph = mGlyphs[i];
++ BitmapImage bitmap = mFontClient.CreateBitmap( glyph.fontId, glyph.index );
++ atlas.Upload( bitmap, glyph.xOffset, 0 );
++
++ TextureCoordinates& coords = glyph.coords;
++ coords.topLeft.x = static_cast<float>(glyph.xOffset) / static_cast<float>(mWidth);
++ coords.topLeft.y = 0.0f;
++ coords.topRight.x = static_cast<float>(glyph.xOffset + glyph.width) / static_cast<float>(mWidth);
++ coords.topRight.y = 0.0f;
++ coords.bottomLeft.x = static_cast<float>(glyph.xOffset) / static_cast<float>(mWidth);
++ coords.bottomLeft.y = static_cast<float>(glyph.height) / static_cast<float>(mHeight);
++ coords.bottomRight.x = static_cast<float>(glyph.xOffset + glyph.width) / static_cast<float>(mWidth);
++ coords.bottomRight.y = static_cast<float>(glyph.height) / static_cast<float>(mHeight);
++ }
++
++ return atlas;
++ }
++
++ void GetTextureCoordinates( FontId fontId, GlyphIndex index, TextureCoordinates& coords )
++ {
++ for( unsigned int i=0; i<mGlyphs.size(); ++i )
++ {
++ const AtlasHelperGlyph& glyph = mGlyphs[i];
++
++ if( fontId == glyph.fontId &&
++ index == glyph.index )
++ {
++ coords = glyph.coords;
++ return;
++ }
++ }
++ }
++
++private: // Data
++
++ std::size_t mWidth;
++ std::size_t mHeight;
++
++ std::vector<AtlasHelperGlyph> mGlyphs;
++
++ TextAbstraction::FontClient mFontClient;
++};
++
++} // unnamed namespace
++
++struct BasicRenderer::Impl
++{
++ /**
++ * @brief Ccreate an Atlas, uploading the necessary glyph bitmaps
++ *
++ * @param[in] glyphs The glyphs to upload.
++ */
++ Atlas CreateAtlas( const Vector<GlyphInfo>& glyphs )
++ {
++ AtlasHelper& helper = mAtlasHelper;
++
++ // Clear previous atlas
++ helper.Reset();
++ helper.Reserve( glyphs.Count() );
++
++ for( unsigned int i=0; i<glyphs.Count(); ++i )
++ {
++ float width = glyphs[i].width;
++ float height = glyphs[i].height;
++
++ if( width > 0 &&
++ height > 0 ) // skip whitespace
++ {
++ if( !helper.GlyphFound( glyphs[i].fontId, glyphs[i].index ) )
++ {
++ helper.AddGlyph( glyphs[i] );
++ }
++ }
++ }
++
++ // Uploads the bitmaps to Dali
++ return helper.CreateAtlas();
++ }
++
++ /**
++ * @brief Helper method to create a mesh with one quad per glyph.
++ *
++ * @param[in] glyphs The glyphs to display.
++ * @param[in] positions The 2D positions of the glyphs.
++ * @param[in] image The material uses this as a diffuse texture.
++ */
++ Mesh CreateMesh( const Vector<GlyphInfo>& glyphs, const std::vector<Vector2>& positions, Image image )
++ {
++ MeshData::VertexContainer vertices( 4 * glyphs.Count() ); // 1 quad per glyph
++
++ MeshData::FaceIndices faces;
++ faces.reserve( 6 * glyphs.Count() ); // 2 triangles per quad
++
++ for( unsigned int i=0; i<glyphs.Count(); ++i )
++ {
++ float width = glyphs[i].width;
++ float height = glyphs[i].height;
++
++ if( width > 0 &&
++ height > 0 ) // skip whitespace
++ {
++ const Vector2& position = positions[i];
++
++ TextureCoordinates coords;
++ mAtlasHelper.GetTextureCoordinates( glyphs[i].fontId, glyphs[i].index, coords );
++
++ vertices[ i*4 + 0 ] = MeshData::Vertex( Vector3( position.x + 0.0f*width, position.y + 0.0f*height, 0.0f ), coords.topLeft, Vector3( 1.0f, 0.0f, 0.0f ) );
++ vertices[ i*4 + 1 ] = MeshData::Vertex( Vector3( position.x + 1.0f*width, position.y + 0.0f*height, 0.0f ), coords.topRight, Vector3( 1.0f, 1.0f, 0.0f ) );
++ vertices[ i*4 + 2 ] = MeshData::Vertex( Vector3( position.x + 0.0f*width, position.y + 1.0f*height, 0.0f ), coords.bottomLeft, Vector3( 0.0f, 1.0f, 0.0f ) );
++ vertices[ i*4 + 3 ] = MeshData::Vertex( Vector3( position.x + 1.0f*width, position.y + 1.0f*height, 0.0f ), coords.bottomRight, Vector3( 0.0f, 0.0f, 1.0f ) );
++
++ faces.push_back( i*4 + 0 ); faces.push_back( i*4 + 3 ); faces.push_back( i*4 + 1 );
++ faces.push_back( i*4 + 0 ); faces.push_back( i*4 + 2 ); faces.push_back( i*4 + 3 );
++ }
++ }
++
++ Material material = Material::New( "Material" );
++ material.SetDiffuseTexture( image );
++
++ // Create the mesh data from the vertices and faces
++ MeshData meshData;
++ meshData.SetHasColor( false );
++ meshData.SetMaterial( material );
++ meshData.SetVertices( vertices );
++ meshData.SetFaceIndices( faces );
++
++ // Create a mesh from the data
++ Dali::Mesh mesh = Mesh::New( meshData );
++ return mesh;
++ }
++
++ RenderableActor mActor; ///< The actor which renders the text
++
++ AtlasHelper mAtlasHelper; ///< A helper class for storing atlas positions etc.
++};
++
++Text::RendererPtr BasicRenderer::New()
++{
++ return Text::RendererPtr( new BasicRenderer() );
++}
++
++RenderableActor BasicRenderer::Render( Text::ViewInterface& view )
++{
++ Text::Length numberOfGlyphs = view.GetNumberOfGlyphs();
++
++ if( numberOfGlyphs > 0 )
++ {
++ Vector<GlyphInfo> glyphs;
++ glyphs.Resize( numberOfGlyphs );
++
++ view.GetGlyphs( 0, &glyphs[0], numberOfGlyphs );
++
++ std::vector<Vector2> positions;
++ positions.resize( numberOfGlyphs );
++ view.GetGlyphPositions( 0, &positions[0], numberOfGlyphs );
++
++ Atlas atlas = mImpl->CreateAtlas( glyphs );
++
++ MeshActor actor = MeshActor::New( mImpl->CreateMesh( glyphs, positions, atlas ) );
++ actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
++ actor.SetAffectedByLighting( false );
++
++ ShaderEffect shader = BasicShader::New();
++ actor.SetShaderEffect( shader );
++
++ mImpl->mActor = actor;
++ }
++
++ return mImpl->mActor;
++}
++
++BasicRenderer::BasicRenderer()
++{
++ mImpl = new Impl();
++}
++
++BasicRenderer::~BasicRenderer()
++{
++ delete mImpl;
++}
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_BASIC_RENDERER_H__
++#define __DALI_TOOLKIT_TEXT_BASIC_RENDERER_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/rendering/text-renderer.h>
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief A reference implementation of Text::Renderer.
++ *
++ * This is intended for testing & performance comparisons with more complex solutions.
++ * Each basic renderer creates its own texture atlas, and uses a simple packing algorithm,
++ * in which glyphs are stored in a single row.
++ */
++class BasicRenderer : public Renderer
++{
++public:
++
++ /**
++ * @brief Create the renderer.
++ */
++ static RendererPtr New();
++
++ /**
++ * @brief Render the glyphs from a ViewInterface.
++ *
++ * @param[in] view The interface to a view.
++ * @return The Renderable actor used to position the text.
++ */
++ virtual RenderableActor Render( ViewInterface& view );
++
++protected:
++
++ /**
++ * @brief Constructor.
++ */
++ BasicRenderer();
++
++ /**
++ * @brief A reference counted object may only be deleted by calling Unreference().
++ */
++ virtual ~BasicRenderer();
++
++private:
++
++ // Undefined
++ BasicRenderer( const BasicRenderer& handle );
++
++ // Undefined
++ BasicRenderer& operator=( const BasicRenderer& handle );
++
++private:
++
++ struct Impl;
++ Impl* mImpl;
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_BASIC_RENDERER_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/rendering/text-renderer.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++namespace BasicShader
++{
++
++Dali::ShaderEffect New()
++{
++ std::string vertexShader = DALI_COMPOSE_SHADER(
++ uniform mediump vec4 uTextureRect;\n
++ void main()\n
++ {\n
++ gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n
++ vTexCoord = aTexCoord.xy;\n
++ }\n
++ );
++
++ std::string fragmentShader = DALI_COMPOSE_SHADER(
++ void main()\n
++ {\n
++ mediump vec4 color = texture2D( sTexture, vTexCoord );
++ gl_FragColor = vec4(uColor.rgb, uColor.a*color.r);
++ }\n
++ );
++
++ Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( vertexShader, fragmentShader,
++ Dali::GeometryType( Dali::GEOMETRY_TYPE_TEXTURED_MESH ),
++ Dali::ShaderEffect::GeometryHints( Dali::ShaderEffect::HINT_NONE ) );
++ return shaderEffect;
++}
++
++} // namespace BasicShader
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_BASIC_SHADER_H__
++#define __DALI_TOOLKIT_TEXT_BASIC_SHADER_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/shader-effects/shader-effect.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief A basic shader for rendering glyphs in Pixel::L8 format.
++ */
++namespace BasicShader
++{
++
++/**
++ * Create a basic text shader.
++ * @return A handle to a newly allocated ShaderEffect
++ */
++Dali::ShaderEffect New();
++
++} // namespace BasicShader
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_BASIC_SHADER_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/rendering/text-renderer.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++Renderer::Renderer()
++{
++}
++
++Renderer::~Renderer()
++{
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_RENDERER_H__
++#define __DALI_TOOLKIT_TEXT_RENDERER_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/actors/renderable-actor.h>
++#include <dali/public-api/common/intrusive-ptr.h>
++#include <dali/public-api/object/ref-object.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-view-interface.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++class Renderer;
++typedef IntrusivePtr<Renderer> RendererPtr;
++
++/**
++ * @brief Abstract base class for Text rendering back-ends.
++ *
++ * This is reponsible for rendering the glyphs from a ViewInterface in the specified positions.
++ * It is implemented by returning a RenderableActor intended as the child of a UI control.
++ */
++class Renderer : public RefObject
++{
++public:
++
++ /**
++ * @brief Render the glyphs from a ViewInterface.
++ *
++ * @param[in] view The interface to a view.
++ * @return The Renderable actor used to position the text.
++ */
++ virtual RenderableActor Render( ViewInterface& view ) = 0;
++
++protected:
++
++ /**
++ * @brief Constructor.
++ */
++ Renderer();
++
++ /**
++ * @brief A reference counted object may only be deleted by calling Unreference().
++ */
++ virtual ~Renderer();
++
++private:
++
++ // Undefined
++ Renderer( const Renderer& handle );
++
++ // Undefined
++ Renderer& operator=( const Renderer& handle );
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_RENDERER_H__
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_SCRIPT_RUN_H__
++#define __DALI_TOOLKIT_TEXT_SCRIPT_RUN_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/character-run.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief Run of characters with the same script.
++ */
++struct ScriptRun
++{
++ CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
++ Script script; ///< Script of the run.
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_SCRIPT_RUN_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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 HEADER
++#include <dali-toolkit/public-api/text/script.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++Script GetCharacterScript( Character character )
++{
++ // Latin script:
++ // 0x0000 - 0x007f C0 Controls and Basic Latin
++ // 0x0080 - 0x00ff C1 Controls and Latin-1 Supplement
++ // 0x0100 - 0x017f Latin Extended-A
++ // 0x0180 - 0x024f Latin Extended-B
++ // 0x0250 - 0x02af IPA Extensions
++ // 0x02b0 - 0x02ff Spacing Modifier Letters
++ // 0x1d00 - 0x1d7f Phonetic Extensions
++ // 0x1d80 - 0x1dbf Phonetic Extensions Supplement
++ // 0x1e00 - 0x1eff Latin Extended Additional
++ // 0x2070 - 0x209f Superscripts and Subscripts
++ // 0x2100 - 0x214f Letterlike symbols
++ // 0x2150 - 0x218f Number Forms
++ // 0x2c60 - 0x2c7f Latin Extended-C
++ // 0xa720 - 0xa7ff Latin Extended-D
++ // 0xab30 - 0xab6f Latin Extended-E
++ // 0xfb00 - 0xfb4f Alphabetic Presentation Forms
++ // 0xff00 - 0xffef Halfwidth and Fullwidth Forms
++
++ // Brahmic scripts:
++ // 0x0900 - 0x097f Devanagari
++ // 0x0980 - 0x09ff Bengali
++ // 0x0a00 - 0x0a7f Gurmukhi
++ // 0x0a80 - 0x0aff Gujarati
++ // 0x0b00 - 0x0b7f Oriya
++ // 0x0b80 - 0x0bff Tamil
++ // 0x0c00 - 0x0c7f Telugu
++ // 0x0c80 - 0x0cff Kannada
++ // 0x0d00 - 0x0d7f Malayalam
++
++ // Sinhala script.
++ // 0x0d80 - 0x0dff Sinhala
++
++ // Arabic script.
++ // 0x0600 - 0x06ff Arabic
++ // 0x0750 - 0x077f Arabic Supplement
++ // 0x08A0 - 0x08ff Arabic Extended-A
++ // 0xfb50 - 0xfdff Arabic Presentation Forms-A
++ // 0xfe70 - 0xfeff Arabic Presentation Forms-B
++ // 0x1ee00 - 0x1eeff Arabic Mathematical Alphabetic Symbols
++
++ // CJK and Vietnamese script.
++ // 0x2E80 - 0x2eff CJK Radicals Supplement
++ // 0x3000 - 0x303f CJK Symbols and Punctuation
++ // 0x3200 - 0x32ff Enclosed CJK Letters and Months
++ // 0x3400 - 0x4dbf CJK Unified Ideographs Extension A
++ // 0x4e00 - 0x62ff CJK Unified Ideographs
++ // 0x6300 - 0x77ff CJK Unified Ideographs
++ // 0x7800 - 0x8cff CJK Unified Ideographs
++ // 0x8d00 - 0x9fff CJK Unified Ideographs
++ // 0x20000 - 0x215ff CJK Unified Ideographs Extension B
++ // 0x21600 - 0x230ff CJK Unified Ideographs Extension B
++ // 0x23100 - 0x245ff CJK Unified Ideographs Extension B
++ // 0x24600 - 0x260ff CJK Unified Ideographs Extension B
++ // 0x26100 - 0x275ff CJK Unified Ideographs Extension B
++ // 0x27600 - 0x290ff CJK Unified Ideographs Extension B
++ // 0x29100 - 0x2a6df CJK Unified Ideographs Extension B
++ // 2a700-2b73f. CJK Unified Ideographs Extension C
++ // 2b740-2b81f. CJK Unified Ideographs Extension D
++
++ // Hangul script
++ // 0x1100 - 0x11ff Hangul jamo
++ // 0x3130 - 0x318f Hangul Compatibility Jamo
++ // 0xa960 - 0xa97f Hangul Jamo Extended-A
++ // 0xac00 - 0xd7af Hangul Syllables
++ // 0xd7b0 - 0xd7ff Hangul Jamo Extended-B
++
++ // Khmer script
++ // 0x1780 - 0x17ff Khmer
++ // 0x19e0 - 0x19ff Khmer Symbols
++
++ // Lao script
++ // 0x0e80 - 0x0eff Lao
++
++ // Thai script
++ // 0x0e00 - 0x0e7f Thai
++
++ // Burmese script
++ // 0x1000 - 0x104f Myanmar
++
++
++ if( character <= 0x0cff )
++ {
++ if( character <= 0x09ff )
++ {
++ if( character <= 0x077f )
++ {
++ if( character <= 0x02ff )
++ {
++ return TextAbstraction::LATIN;
++ }
++ if( ( 0x0600 <= character ) && ( character <= 0x06ff ) )
++ {
++ return TextAbstraction::ARABIC;
++ }
++ if( ( 0x0750 <= character ) && ( character <= 0x077f ) )
++ {
++ return TextAbstraction::ARABIC;
++ }
++ }
++ else // > 0x077f
++ {
++ if( ( 0x08A0 <= character ) && ( character <= 0x08ff ) )
++ {
++ return TextAbstraction::ARABIC;
++ }
++ if( ( 0x0900 <= character ) && ( character <= 0x097f ) )
++ {
++ return TextAbstraction::DEVANAGARI;
++ }
++ if( ( 0x0980 <= character ) && ( character <= 0x09ff ) )
++ {
++ return TextAbstraction::BENGALI;
++ }
++ }
++ }
++ else // > 0x09ff
++ {
++ if( character <= 0x0b7f )
++ {
++ if( ( 0x0a00 <= character ) && ( character <= 0x0a7f ) )
++ {
++ return TextAbstraction::GURMUKHI;
++ }
++ if( ( 0x0a80 <= character ) && ( character <= 0x0aff ) )
++ {
++ return TextAbstraction::GUJARATI;
++ }
++ if( ( 0x0b00 <= character ) && ( character <= 0x0b7f ) )
++ {
++ return TextAbstraction::ORIYA;
++ }
++ }
++ else // > 0x0b7f
++ {
++ if( ( 0x0b80 <= character ) && ( character <= 0x0bff ) )
++ {
++ return TextAbstraction::TAMIL;
++ }
++ if( ( 0x0c00 <= character ) && ( character <= 0x0c7f ) )
++ {
++ return TextAbstraction::TELUGU;
++ }
++ if( ( 0x0c80 <= character ) && ( character <= 0x0cff ) )
++ {
++ return TextAbstraction::KANNADA;
++ }
++ }
++ }
++ }
++ else // > 0x0cff
++ {
++ if( character <= 0x2c7f )
++ {
++ if( character <= 0x1eff )
++ {
++ if( ( 0x0d00 <= character ) && ( character <= 0x0d7f ) )
++ {
++ return TextAbstraction::MALAYALAM;
++ }
++ if( ( 0x0d80 <= character ) && ( character <= 0x0dff ) )
++ {
++ return TextAbstraction::SINHALA;
++ }
++ if( ( 0x0e00 <= character ) && ( character <= 0x0e7f ) )
++ {
++ return TextAbstraction::THAI;
++ }
++ if( ( 0x0e80 <= character ) && ( character <= 0x0eff ) )
++ {
++ return TextAbstraction::LAO;
++ }
++ if( ( 0x1000 <= character ) && ( character <= 0x104f ) )
++ {
++ return TextAbstraction::BURMESE;
++ }
++ if( ( 0x1100 <= character ) && ( character <= 0x11ff ) )
++ {
++ return TextAbstraction::HANGUL;
++ }
++ if( ( 0x1780 <= character ) && ( character <= 0x17ff ) )
++ {
++ return TextAbstraction::KHMER;
++ }
++ if( ( 0x19e0 <= character ) && ( character <= 0x19ff ) )
++ {
++ return TextAbstraction::KHMER;
++ }
++ if( ( 0x1d00 <= character ) && ( character <= 0x1eff ) )
++ {
++ return TextAbstraction::LATIN;
++ }
++ }
++ else // > 0x1eff
++ {
++ if( ( 0x2070 <= character ) && ( character <= 0x209f ) )
++ {
++ return TextAbstraction::LATIN;
++ }
++ if( ( 0x2100 <= character ) && ( character <= 0x218f ) )
++ {
++ return TextAbstraction::LATIN;
++ }
++ if( ( 0x2c60 <= character ) && ( character <= 0x2c7f ) )
++ {
++ return TextAbstraction::LATIN;
++ }
++ }
++ }
++ else // > 0x2c7f
++ {
++ if( character <= 0xfdff )
++ {
++ if( ( 0x2e80 <= character ) && ( character <= 0x2eff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x3000 <= character ) && ( character <= 0x303f ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x3130 <= character ) && ( character <= 0x318f ) )
++ {
++ return TextAbstraction::HANGUL;
++ }
++ if( ( 0x3200 <= character ) && ( character <= 0x32ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x3400 <= character ) && ( character <= 0x4dbf ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x4e00 <= character ) && ( character <= 0x62ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x6300 <= character ) && ( character <= 0x77ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x7800 <= character ) && ( character <= 0x8cff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x8d00 <= character ) && ( character <= 0x9fff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0xa720 <= character ) && ( character <= 0xa7ff ) )
++ {
++ return TextAbstraction::LATIN;
++ }
++ if( ( 0xa960 <= character ) && ( character <= 0xa97f ) )
++ {
++ return TextAbstraction::HANGUL;
++ }
++ if( ( 0xab30 <= character ) && ( character <= 0xab6f ) )
++ {
++ return TextAbstraction::LATIN;
++ }
++ if( ( 0xac00 <= character ) && ( character <= 0xd7af ) )
++ {
++ return TextAbstraction::HANGUL;
++ }
++ if( ( 0xd7b0 <= character ) && ( character <= 0xd7ff ) )
++ {
++ return TextAbstraction::HANGUL;
++ }
++ if( ( 0xfb00 <= character ) && ( character <= 0xfb4f ) )
++ {
++ return TextAbstraction::LATIN;
++ }
++ if( ( 0xfb50 <= character ) && ( character <= 0xfdff ) )
++ {
++ return TextAbstraction::ARABIC;
++ }
++ }
++ else // > 0xfdff
++ {
++ if( ( 0xfe70 <= character ) && ( character <= 0xfeff ) )
++ {
++ return TextAbstraction::ARABIC;
++ }
++ if( ( 0xff00 <= character ) && ( character <= 0xffef ) )
++ {
++ return TextAbstraction::LATIN;
++ }
++ if( ( 0x1ee00 <= character ) && ( character <= 0x1eeff ) )
++ {
++ return TextAbstraction::ARABIC;
++ }
++ if( ( 0x20000 <= character ) && ( character <= 0x215ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x21600 <= character ) && ( character <= 0x230ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x23100 <= character ) && ( character <= 0x245ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x24600 <= character ) && ( character <= 0x260ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x26100 <= character ) && ( character <= 0x275ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x27600 <= character ) && ( character <= 0x290ff ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x29100 <= character ) && ( character <= 0x2a6df ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x2a700 <= character ) && ( character <= 0x2b73f ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ if( ( 0x2b740 <= character ) && ( character <= 0x2b81f ) )
++ {
++ return TextAbstraction::CJK;
++ }
++ }
++ }
++ }
++
++ return TextAbstraction::UNKNOWN;
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_SCRIPT_H__
++#define __DALI_TOOLKIT_TEXT_SCRIPT_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief Retrieves a character's script.
++ *
++ * @param[in] character The character.
++ *
++ * @return The chraracter's script.
++ */
++Script GetCharacterScript( Character character );
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_SCRIPT_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/segmentation.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++void SetLineBreakInfo( LogicalModel& model )
++{
++}
++
++void SetWordBreakInfo( LogicalModel& model )
++{
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_SEGMENTATION_H__
++#define __DALI_TOOLKIT_TEXT_SEGMENTATION_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++class LogicalModel;
++
++/**
++ * Sets line break info.
++ *
++ * Any line break info previously set is removed.
++ *
++ * @pre The @p model needs to have a text set.
++ *
++ * @param[in,out] model The text's logical model.
++ */
++void SetLineBreakInfo( LogicalModel& model );
++
++/**
++ * Sets word break info.
++ *
++ * Any word break info previously set is removed.
++ *
++ * @pre The @p model needs to have a text set.
++ *
++ * @param[in,out] model The text's logical model.
++ */
++void SetWordBreakInfo( LogicalModel& model );
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_SEGMENTATION_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/text-controller.h>
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/text-abstraction/font-client.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/character-set-conversion.h>
++#include <dali-toolkit/public-api/text/layouts/layout-engine.h>
++#include <dali-toolkit/public-api/text/logical-model.h>
++#include <dali-toolkit/public-api/text/text-view.h>
++#include <dali-toolkit/public-api/text/visual-model.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++struct Controller::Impl
++{
++ Impl()
++ : mNewTextArrived( false )
++ {
++ mLogicalModel = LogicalModel::New();
++ mVisualModel = VisualModel::New();
++
++ mView.SetVisualModel( mVisualModel );
++
++ mFontClient = TextAbstraction::FontClient::Get();
++ }
++
++ std::string mNewText;
++ bool mNewTextArrived;
++
++ LogicalModelPtr mLogicalModel;
++ VisualModelPtr mVisualModel;
++
++ View mView;
++
++ LayoutEngine mLayoutEngine;
++
++ TextAbstraction::FontClient mFontClient;
++};
++
++ControllerPtr Controller::New()
++{
++ return ControllerPtr( new Controller() );
++}
++
++void Controller::SetText( const std::string& text )
++{
++ // Keep until size negotiation
++ mImpl->mNewText = text;
++ mImpl->mNewTextArrived = true;
++}
++
++bool Controller::Relayout( const Vector2& size )
++{
++ bool viewUpdated( false );
++
++ if( mImpl->mNewTextArrived )
++ {
++ std::string& text = mImpl->mNewText;
++
++ // Convert text into UTF-32
++ Vector<Character> utf32Characters;
++ utf32Characters.Resize( text.size() );
++
++ // This is a bit horrible but std::string returns a (signed) char*
++ const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
++
++ Length characterCount = Utf8ToUtf32( utf8, text.size(), &utf32Characters[0] );
++
++ // Manipulate the logical model
++ mImpl->mLogicalModel->SetText( &utf32Characters[0], characterCount );
++
++ // Update the visual model
++ mImpl->mLayoutEngine.UpdateVisualModel( size, *mImpl->mLogicalModel, *mImpl->mVisualModel );
++
++ // Discard temporary text
++ mImpl->mNewTextArrived = false;
++ text.clear();
++
++ viewUpdated = true;
++ }
++
++ return viewUpdated;
++}
++
++View& Controller::GetView()
++{
++ return mImpl->mView;
++}
++
++LayoutEngine& Controller::GetLayoutEngine()
++{
++ return mImpl->mLayoutEngine;
++}
++
++Controller::~Controller()
++{
++ delete mImpl;
++}
++
++Controller::Controller()
++: mImpl( NULL )
++{
++ mImpl = new Controller::Impl();
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_CONTROLLER_H__
++#define __DALI_TOOLKIT_TEXT_CONTROLLER_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/common/intrusive-ptr.h>
++#include <dali/public-api/object/ref-object.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-view.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++class Controller;
++class LayoutEngine;
++
++typedef IntrusivePtr<Controller> ControllerPtr;
++
++/**
++ * @brief A Text Controller is used by UI Controls which display text.
++ *
++ * It manipulates the Logical & Visual text models on behalf of the UI Controls.
++ * It provides a view of the text that can be used by rendering back-ends.
++ */
++class Controller : public RefObject
++{
++public:
++
++ /**
++ * @brief Create a new instance of a Controller.
++ *
++ * @return A pointer to a new Controller.
++ */
++ static ControllerPtr New();
++
++ /**
++ * @brief Replaces any text previously set.
++ *
++ * @note This will be converted into UTF-32 when stored in the text model.
++ * @param[in] text A string of UTF-8 characters.
++ */
++ void SetText( const std::string& text );
++
++ /**
++ * @brief Triggers a relayout which updates View (if necessary).
++ *
++ * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
++ * @param[in] size A the size of a bounding box to layout text within.
++ * @return True if the View was updated.
++ */
++ bool Relayout( const Vector2& size );
++
++ /**
++ * @brief Return the layout engine.
++ *
++ * @return A reference to the layout engine.
++ */
++ LayoutEngine& GetLayoutEngine();
++
++ /**
++ * @brief Return a view of the text.
++ *
++ * @return A reference to the view.
++ */
++ View& GetView();
++
++protected:
++
++ /**
++ * @brief A reference counted object may only be deleted by calling Unreference().
++ */
++ virtual ~Controller();
++
++private:
++
++ /**
++ * @brief Private constructor.
++ */
++ Controller();
++
++ /**
++ * @brief Populates the visual model.
++ */
++ void UpdateVisualModel();
++
++ // Undefined
++ Controller( const Controller& handle );
++
++ // Undefined
++ Controller& operator=( const Controller& handle );
++
++private:
++
++ struct Impl;
++ Impl* mImpl;
++};
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__
--- /dev/null
--- /dev/null
++#ifndef __DALI_TEXT_ABSTRACTION_TEXT_TYPE_DEFINITIONS_H__
++#define __DALI_TEXT_ABSTRACTION_TEXT_TYPE_DEFINITIONS_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/text-abstraction/text-abstraction.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++typedef TextAbstraction::FontId FontId; ///< The unique identifier for a font face (generated by FontClient)
++typedef TextAbstraction::FontMetrics FontMetrics; ///< The metrics for a Font expressed in 26.6 fractional pixel format
++typedef TextAbstraction::PointSize26Dot6 PointSize26Dot6; ///< The point size in 26.6 fractional points
++typedef TextAbstraction::FaceIndex FaceIndex; ///< Used with fonts which allow several font faces
++typedef TextAbstraction::GlyphIndex GlyphIndex; ///< Uniquely identifies a glyph within a particular font
++typedef TextAbstraction::Character Character; ///< A UTF-32 representation of a character
++typedef TextAbstraction::GlyphInfo GlyphInfo; ///< The information describing a glyph (font ID, index, metrics)
++typedef TextAbstraction::CharacterIndex CharacterIndex; ///< An index into an array of characters
++typedef TextAbstraction::Length Length; ///< The length of an array
++typedef TextAbstraction::BidiInfoIndex BidiInfoIndex; ///< Index to the bidirectional info for a paragraph.
++typedef TextAbstraction::Script Script; ///< The character's script.
++typedef TextAbstraction::LineBreakInfo LineBreakInfo; ///< Line break info (must break, allow break, no break). Possible values are: @e LINE_MUST_BREAK, @e LINE_ALLOW_BREAK and @e LINE_NO_BREAK (in the TextAbstraction namespace).
++typedef TextAbstraction::WordBreakInfo WordBreakInfo; ///< Word break info (break, no break). Possible values are: @e WORD_BREAK and @e WORD_NO_BREAK (in the TextAbstraction namespace).
++
++typedef uint32_t GlyphIndex; ///< An index into an array of glyphs
++typedef bool CharacterDirection; ///< The character's direction: @e false is left to right, @e true is right to left.
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TEXT_ABSTRACTION_TEXT_TYPE_DEFINITIONS_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/text-view-interface.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++ViewInterface::ViewInterface()
++{
++}
++
++ViewInterface::~ViewInterface()
++{
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H__
++#define __DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++namespace Dali
++{
++
++struct Vector2;
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief Abstract interface to provide the information necessary displaying text.
++ *
++ * This includes:
++ * - The font & glyph IDs needed to get bitmaps etc. from TextAbstraction
++ * - The visual position of each glyph within the layout
++ * - A window into the text layout e.g. which page of a document to view
++ */
++class ViewInterface
++{
++public:
++
++ /**
++ * @brief Constructor.
++ */
++ ViewInterface();
++
++ /**
++ * @brief Virtual destructor
++ */
++ virtual ~ViewInterface();
++
++ /**
++ * Retrieves the number of glyphs.
++ *
++ * @return The number of glyphs.
++ */
++ virtual Length GetNumberOfGlyphs() const = 0;
++
++ /**
++ * @brief Retrieves glyphs in the given buffer.
++ *
++ * The size of the @p glyphs buffer needs to be big enough to copy the @p numberOfGlyphs.
++ * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
++ * @param[in] glyphIndex Index to the first glyph.
++ * @param[in] numberOfGlyphs Number of glyphs to be copied.
++ */
++ virtual void GetGlyphs( GlyphIndex glyphIndex,
++ GlyphInfo* glyphs,
++ Length numberOfGlyphs ) const = 0;
++
++ /**
++ * @brief Retrieves the glyph positions.
++ *
++ * @pre The size of the @p positions buffer needs to be big enough to copy the @p numberOfGlyphs positions.
++ * @param[in] glyphIndex Index to the first glyph position.
++ * @param[out] glyphPositions Pointer to a buffer where the glyph positions are copied.
++ * @param[in] numberOfGlyphs The number of positions to be copied.
++ */
++ virtual void GetGlyphPositions( GlyphIndex glyphIndex,
++ Vector2* glyphPositions,
++ Length numberOfGlyphs ) const = 0;
++};
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/text-view.h>
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/math/vector2.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++struct View::Impl
++{
++ VisualModelPtr mVisualModel;
++};
++
++View::View()
++: mImpl( NULL )
++{
++ mImpl = new View::Impl();
++}
++
++View::~View()
++{
++ delete mImpl;
++}
++
++void View::SetVisualModel( VisualModelPtr visualModel )
++{
++ mImpl->mVisualModel = visualModel;
++}
++
++Length View::GetNumberOfGlyphs() const
++{
++ if( mImpl->mVisualModel )
++ {
++ return mImpl->mVisualModel->GetNumberOfGlyphs();
++ }
++
++ return 0;
++}
++
++void View::GetGlyphs( GlyphIndex glyphIndex,
++ GlyphInfo* glyphs,
++ Length numberOfGlyphs ) const
++{
++ if( mImpl->mVisualModel )
++ {
++ mImpl->mVisualModel->GetGlyphs( glyphIndex, glyphs, numberOfGlyphs );
++ }
++}
++
++void View::GetGlyphPositions( GlyphIndex glyphIndex,
++ Vector2* glyphPositions,
++ Length numberOfGlyphs ) const
++{
++ if( mImpl->mVisualModel )
++ {
++ mImpl->mVisualModel->GetGlyphPositions( glyphIndex, glyphPositions, numberOfGlyphs );
++ }
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_VIEW_H__
++#define __DALI_TOOLKIT_TEXT_VIEW_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-view-interface.h>
++#include <dali-toolkit/public-api/text/visual-model.h>
++
++namespace Dali
++{
++
++struct Vector2;
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++/**
++ * @brief View provides an interface between the Text layout engine and rendering back-end.
++ */
++class View : public ViewInterface
++{
++public:
++
++ /**
++ * @brief Create a new instance of a View.
++ */
++ View();
++
++ /**
++ * @brief Virtual destructor.
++ */
++ virtual ~View();
++
++ /**
++ * @brief Set the visual model.
++ *
++ * @param[in] visualModel The visual model used by the View.
++ */
++ void SetVisualModel( VisualModelPtr visualModel );
++
++ /**
++ * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfGlyphs()
++ */
++ virtual Length GetNumberOfGlyphs() const;
++
++ /**
++ * @copydoc Dali::Toolkit::Text::ViewInterface::GetGlyphs()
++ */
++ virtual void GetGlyphs( GlyphIndex glyphIndex,
++ GlyphInfo* glyphs,
++ Length numberOfGlyphs ) const;
++
++ /**
++ * @copydoc Dali::Toolkit::Text::ViewInterface::GetGlyphPositions()
++ */
++ virtual void GetGlyphPositions( GlyphIndex glyphIndex,
++ Vector2* glyphPositions,
++ Length numberOfGlyphs ) const;
++
++private:
++
++ // Undefined
++ View( const View& handle );
++
++ // Undefined
++ View& operator=( const View& handle );
++
++private:
++
++ struct Impl;
++ Impl* mImpl;
++};
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_VIEW_H__
--- /dev/null
--- /dev/null
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// CLASS HEADER
++#include <dali-toolkit/public-api/text/visual-model.h>
++
++// EXTERNAL INCLUDES
++#include <string.h>
++#include <vector>
++#include <dali/public-api/math/vector2.h>
++
++namespace Dali
++{
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++struct VisualModel::Impl
++{
++ Vector<GlyphInfo> mGlyphs;
++ Vector<CharacterIndex> mGlyphsToCharacters;
++ Vector<Length> mCharactersPerGlyph;
++ std::vector<Vector2> mGlyphPositions;
++};
++
++VisualModelPtr VisualModel::New()
++{
++ return VisualModelPtr( new VisualModel() );
++}
++
++void VisualModel::SetGlyphs( const GlyphInfo* glyphs,
++ const CharacterIndex* characterIndices,
++ const Length* charactersPerGlyph,
++ Length numberOfGlyphs )
++{
++ Vector<GlyphInfo>& modelGlyphs = mImpl->mGlyphs;
++ modelGlyphs.Resize( numberOfGlyphs );
++ memcpy( &modelGlyphs[0], glyphs, numberOfGlyphs*sizeof(GlyphInfo) );
++
++ Vector<CharacterIndex>& glyphsToCharacters = mImpl->mGlyphsToCharacters;
++ glyphsToCharacters.Resize( numberOfGlyphs );
++ memcpy( &glyphsToCharacters[0], characterIndices, numberOfGlyphs*sizeof(CharacterIndex) );
++
++ Vector<Length>& modelCharactersPerGlyph = mImpl->mCharactersPerGlyph;
++ modelCharactersPerGlyph.Resize( numberOfGlyphs );
++ memcpy( &modelCharactersPerGlyph[0], charactersPerGlyph, numberOfGlyphs*sizeof(Length) );
++}
++
++Length VisualModel::GetNumberOfGlyphs() const
++{
++ return mImpl->mGlyphs.Count();
++}
++
++void VisualModel::GetGlyphs( GlyphIndex glyphIndex,
++ GlyphInfo* glyphs,
++ Length numberOfGlyphs ) const
++{
++ Vector<GlyphInfo>& modelGlyphs = mImpl->mGlyphs;
++ memcpy( glyphs, &modelGlyphs[glyphIndex], numberOfGlyphs*sizeof(GlyphInfo) );
++}
++
++CharacterIndex VisualModel::GetCharacterIndex( GlyphIndex glyphIndex ) const
++{
++ return mImpl->mGlyphsToCharacters[glyphIndex];
++}
++
++Length VisualModel::GetCharactersPerGlyph( GlyphIndex glyphIndex ) const
++{
++ return mImpl->mCharactersPerGlyph[glyphIndex];
++}
++
++GlyphIndex VisualModel::GetGlyphIndex( CharacterIndex characterIndex ) const
++{
++ GlyphIndex index( 0 );
++
++ for( unsigned int i=0; i<mImpl->mGlyphsToCharacters.Count(); ++i )
++ {
++ if( mImpl->mGlyphsToCharacters[i] == characterIndex )
++ {
++ index = i;
++ break;
++ }
++ }
++
++ return index;
++}
++
++void VisualModel::SetGlyphPositions( const Vector2* glyphPositions,
++ Length numberOfGlyphs )
++{
++ std::vector<Vector2>& modelPositions = mImpl->mGlyphPositions;
++ modelPositions.resize( numberOfGlyphs );
++ memcpy( &modelPositions[0], glyphPositions, numberOfGlyphs*sizeof(Vector2) );
++}
++
++void VisualModel::GetGlyphPositions( GlyphIndex glyphIndex,
++ Vector2* glyphPositions,
++ Length numberOfGlyphs ) const
++{
++ std::vector<Vector2>& modelPositions = mImpl->mGlyphPositions;
++ memcpy( glyphPositions, &modelPositions[0], numberOfGlyphs*sizeof(Vector2) );
++}
++
++VisualModel::~VisualModel()
++{
++ delete mImpl;
++}
++
++VisualModel::VisualModel()
++: mImpl( NULL )
++{
++ mImpl = new VisualModel::Impl();
++}
++
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
--- /dev/null
--- /dev/null
++#ifndef __DALI_TOOLKIT_TEXT_VISUAL_MODEL_H__
++#define __DALI_TOOLKIT_TEXT_VISUAL_MODEL_H__
++
++/*
++ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * 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.
++ *
++ */
++
++// EXTERNAL INCLUDES
++#include <dali/public-api/common/intrusive-ptr.h>
++
++// INTERNAL INCLUDES
++#include <dali-toolkit/public-api/text/text-definitions.h>
++
++namespace Dali
++{
++
++struct Vector2;
++
++namespace Toolkit
++{
++
++namespace Text
++{
++
++class VisualModel;
++typedef IntrusivePtr<VisualModel> VisualModelPtr;
++
++/**
++ * @brief A visual text model contains layout specific information.
++ *
++ * This includes:
++ * - A series of glyphs in visual order i.e. after the bidirectional reordering.
++ * - The position of each glyph within a 2D bounding box.
++ */
++class VisualModel : public RefObject
++{
++public:
++
++ /**
++ * @brief Create a new instance of a VisualModel.
++ *
++ * @return A pointer to a new VisualModel.
++ */
++ static VisualModelPtr New();
++
++ // Glyph interface.
++
++ /**
++ * @brief Replaces any glyphs previously set.
++ *
++ * @param[in] glyphs An array of glyphs in the visual order.
++ * @param[in] characterIndices An array containing the first character in the logical model that each glyph relates to.
++ * @param[in] charactersPerGlyph An array of containing the number of characters per glyph.
++ * @param[in] numberOfGlyphs The number of glyphs.
++ */
++ void SetGlyphs( const GlyphInfo* glyphs,
++ const CharacterIndex* characterIndices,
++ const Length* charactersPerGlyph,
++ Length numberOfGlyphs );
++
++ /**
++ * Retrieves the number of glyphs.
++ *
++ * @return The number of glyphs.
++ */
++ Length GetNumberOfGlyphs() const;
++
++ /**
++ * @brief Retrieves glyphs in the given buffer.
++ *
++ * The size of the @p glyphs buffer needs to be big enough to copy the @p numberOfGlyphs.
++ * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
++ * @param[in] glyphIndex Index to the first glyph.
++ * @param[in] numberOfGlyphs Number of glyphs to be copied.
++ */
++ void GetGlyphs( GlyphIndex glyphIndex,
++ GlyphInfo* glyphs,
++ Length numberOfGlyphs ) const;
++
++ // Character <--> Glyph conversion
++
++ /**
++ * @brief Retrieves the first character in the logical model which a glyph represents.
++ *
++ * @note After shaping several characters may be represented by the same glyph.
++ * Alternatively several glyphs may be required to display a character.
++ * @param[in] glyphIndex The glyph index.
++ * @return The character index.
++ */
++ CharacterIndex GetCharacterIndex( GlyphIndex glyphIndex ) const;
++
++ /**
++ * @brief Query the number of characters the glyph represents.
++ *
++ * @param[in] glyphIndex The glyph index.
++ * @return The number of characters represented by the glyph.
++ */
++ Length GetCharactersPerGlyph( GlyphIndex glyphIndex ) const;
++
++ /**
++ * Retrieves the first glyph in the visual model which represents a given character.
++ *
++ * @note After shaping several characters may be represented by the same glyph.
++ * Alternatively several glyphs may be required to display a character.
++ * @param[in] characterIndex The character index.
++ * @return The glyph index.
++ */
++ GlyphIndex GetGlyphIndex( CharacterIndex characterIndex ) const;
++
++ // Position interface
++
++ /**
++ * @brief Replaces any glyph positions previously set.
++ *
++ * @param[in] glyphPositions An array of visual positions for each glyph.
++ * @param[in] numberOfGlyphs The number of positions.
++ */
++ void SetGlyphPositions( const Vector2* glyphPositions,
++ Length numberOfGlyphs );
++
++ /**
++ * @brief Retrieves the glyph positions.
++ *
++ * @pre The size of the @p positions buffer needs to be big enough to copy the @p numberOfGlyphs positions.
++ * @param[in] glyphIndex Index to the first glyph position.
++ * @param[out] glyphPositions Pointer to a buffer where the glyph positions are copied.
++ * @param[in] numberOfGlyphs The number of positions to be copied.
++ */
++ void GetGlyphPositions( GlyphIndex glyphIndex,
++ Vector2* glyphPositions,
++ Length numberOfGlyphs ) const;
++
++protected:
++
++ /**
++ * @brief A reference counted object may only be deleted by calling Unreference().
++ */
++ virtual ~VisualModel();
++
++private:
++
++ /**
++ * @brief Private constructor.
++ */
++ VisualModel();
++
++ // Undefined
++ VisualModel( const VisualModel& handle );
++
++ // Undefined
++ VisualModel& operator=( const VisualModel& handle );
++
++private:
++
++ struct Impl;
++ Impl* mImpl;
++};
++} // namespace Text
++
++} // namespace Toolkit
++
++} // namespace Dali
++
++#endif // __DALI_TOOLKIT_TEXT_VISUAL_MODEL_H__