Framework for Font styles 10/36810/7
authorPaul Wisbey <p.wisbey@samsung.com>
Sun, 15 Mar 2015 13:02:20 +0000 (13:02 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Sun, 15 Mar 2015 13:37:23 +0000 (13:37 +0000)
Change-Id: Ia99b027f43ab0b2787d15c07dfb7cfd3c4a24473

dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.h
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control-impl.h
dali-toolkit/styles/tizen-dark-theme.json

index 5c5591a..5f8d498 100644 (file)
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/public-api/text/rendering-backend.h>
 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
-#include <dali-toolkit/public-api/text/rendering-backend.h>
+#include <dali-toolkit/internal/styling/style-manager-impl.h>
 
 using namespace Dali::Toolkit::Text;
 
@@ -390,6 +391,11 @@ void TextField::OnInitialize()
   }
 }
 
+void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
+{
+  GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+}
+
 Vector3 TextField::GetNaturalSize()
 {
   return mController->GetNaturalSize();
@@ -495,7 +501,7 @@ void TextField::EnableClipping( bool clipping, const Vector2& size )
 }
 
 TextField::TextField()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mRenderingBackend( DEFAULT_RENDERING_BACKEND ),
   mExceedPolicy( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP )
 {
index b94c318..5d103c9 100644 (file)
@@ -76,6 +76,11 @@ private: // From Control
   virtual void OnInitialize();
 
   /**
+   * @copydoc Control::OnStyleChange()
+   */
+  virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
+
+  /**
    * @copydoc Control::GetNaturalSize()
    */
   virtual Vector3 GetNaturalSize();
index fdce0ed..00ae80d 100644 (file)
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/public-api/text/rendering-backend.h>
 #include <dali-toolkit/internal/text/layouts/layout-engine.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
-#include <dali-toolkit/public-api/text/rendering-backend.h>
+#include <dali-toolkit/internal/styling/style-manager-impl.h>
 
 using Dali::Toolkit::Text::LayoutEngine;
 using Dali::Toolkit::Text::Backend;
@@ -219,6 +220,11 @@ void TextLabel::OnInitialize()
   mController = Text::Controller::New( *this );
 }
 
+void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
+{
+  GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+}
+
 Vector3 TextLabel::GetNaturalSize()
 {
   return mController->GetNaturalSize();
@@ -265,7 +271,7 @@ void TextLabel::RequestTextRelayout()
 }
 
 TextLabel::TextLabel()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_NONE ) ),
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mRenderingBackend( DEFAULT_RENDERING_BACKEND )
 {
 }
index c72c9c5..6356651 100644 (file)
@@ -73,7 +73,12 @@ private: // From Control
   virtual void OnInitialize();
 
   /**
-   * @copydoc Control::OnInitialize()
+   * @copydoc Control::OnStyleChange()
+   */
+  virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
+
+  /**
+   * @copydoc Control::OnRelayout()
    */
   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
 
index b79badd..21b2a4d 100644 (file)
@@ -1102,7 +1102,7 @@ void Control::Initialize()
     Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
 
     // Register for style changes
-    styleManager.StyleChangeSignal().Connect( this, &Control::DoStyleChange );
+    styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
 
     // SetTheme
     GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
@@ -1206,13 +1206,13 @@ void Control::OnActivated()
 {
 }
 
-void Control::OnThemeChange( Toolkit::StyleManager styleManager )
-{
-  GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
-}
-
-void Control::OnFontChange( bool defaultFontChange, bool defaultFontSizeChange )
+void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
 {
+  // By default the control is only interested in theme (not font) changes
+  if( change.themeChange )
+  {
+    GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+  }
 }
 
 void Control::OnPinch(const PinchGesture& pinch)
@@ -1380,18 +1380,6 @@ void Control::SignalDisconnected( SlotObserver* slotObserver, CallbackBase* call
   mImpl->SignalDisconnected( slotObserver, callback );
 }
 
-void Control::DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
-{
-  if( change.themeChange )
-  {
-    OnThemeChange( styleManager );
-  }
-  else if( change.defaultFontChange || change.defaultFontSizeChange )
-  {
-    OnFontChange( change.defaultFontChange, change.defaultFontSizeChange );
-  }
-}
-
 } // namespace Internal
 
 } // namespace Toolkit
index a441b07..09c035c 100644 (file)
@@ -477,21 +477,12 @@ private:
   virtual void OnActivated();
 
   /**
-   * @brief This method should be overridden by deriving classes when
-   * they wish to be notified when the style manager changes the theme.
+   * @brief This method should be overridden by deriving classes requiring notifications when the style changes.
    *
    * @param[in] styleManager  The StyleManager object.
+   * @param[in] change  Information denoting what has changed.
    */
-  virtual void OnThemeChange( Toolkit::StyleManager styleManager );
-
-  /**
-   * @brief This method should be overridden by deriving classes when
-   * they wish to be notified when the style changes the default font.
-   *
-   * @param[in] defaultFontChange  Information denoting whether the default font has changed.
-   * @param[in] defaultFontSizeChange Information denoting whether the default font size has changed.
-   */
-  virtual void OnFontChange( bool defaultFontChange, bool defaultFontSizeChange );
+  virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
 
   /**
    * @brief Called whenever a pinch gesture is detected on this control.
@@ -721,16 +712,6 @@ private:
    */
   virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback );
 
-  // Style
-
-  /**
-   * @brief This method is the callback for the StyleChangeSignal from StyleManager
-   *
-   * @param[in] styleManager The StyleManager Object
-   * @param[in] change  Information denoting what has changed.
-   */
-  DALI_INTERNAL void DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change );
-
 private:
 
   // Undefined
index a771860..a9e30d7 100644 (file)
@@ -31,23 +31,17 @@ distributing this software or its derivatives.
 {
   "styles":
   {
-    "textinput":
+    "textlabel":
     {
-      "highlight-color":"F060",
-      "cut-and-paste-bg-color":"B061L41",
-      "cut-and-paste-pressed-color":"B061L41P",
-      "cut-and-paste-border-color":"B061L42",
-      "cut-and-paste-icon-color":"T126",
-      "cut-and-paste-icon-pressed-color":"T126P",
-      "cut-and-paste-text-color":"T1221",
-      "cut-and-paste-text-pressed-color":"T1221P",
-      "cut-button-position-priority":4,
-      "copy-button-position-priority":3,
-      "paste-button-position-priority":5,
-      "select-button-position-priority":1,
-      "select-all-button-position-priority":2,
-      "clipboard-button-position-priority":6,
-      "cursor-color":"F052"
+      "font-family":"TizenSansFallback",
+      "font-style":"Regular",
+      "point-size":10
+    },
+    "textfield":
+    {
+      "font-family":"TizenSansFallback",
+      "font-style":"Regular",
+      "point-size":10
     },
     "scrollview":
     {