From a3390cb9c1cd0aeddbcd4aa89d6045592a123dd3 Mon Sep 17 00:00:00 2001
From: Paul Wisbey
Date: Sun, 15 Mar 2015 13:02:20 +0000
Subject: [PATCH] Framework for Font styles
Change-Id: Ia99b027f43ab0b2787d15c07dfb7cfd3c4a24473
---
.../controls/text-controls/text-field-impl.cpp | 10 +++++++--
.../controls/text-controls/text-field-impl.h | 5 +++++
.../controls/text-controls/text-label-impl.cpp | 10 +++++++--
.../controls/text-controls/text-label-impl.h | 7 +++++-
dali-toolkit/public-api/controls/control-impl.cpp | 26 ++++++----------------
dali-toolkit/public-api/controls/control-impl.h | 25 +++------------------
dali-toolkit/styles/tizen-dark-theme.json | 26 +++++++++-------------
7 files changed, 47 insertions(+), 62 deletions(-)
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
index 5c5591a..5f8d498 100644
--- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
@@ -28,9 +28,10 @@
#include
// INTERNAL INCLUDES
+#include
#include
#include
-#include
+#include
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 )
{
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
index b94c318..5d103c9 100644
--- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
@@ -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();
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
index fdce0ed..00ae80d 100644
--- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
@@ -24,9 +24,10 @@
#include
// INTERNAL INCLUDES
+#include
#include
#include
-#include
+#include
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 )
{
}
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
index c72c9c5..6356651 100644
--- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
@@ -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 );
diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp
index b79badd..21b2a4d 100644
--- a/dali-toolkit/public-api/controls/control-impl.cpp
+++ b/dali-toolkit/public-api/controls/control-impl.cpp
@@ -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
diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h
index a441b07..09c035c 100644
--- a/dali-toolkit/public-api/controls/control-impl.h
+++ b/dali-toolkit/public-api/controls/control-impl.h
@@ -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
diff --git a/dali-toolkit/styles/tizen-dark-theme.json b/dali-toolkit/styles/tizen-dark-theme.json
index a771860..a9e30d7 100644
--- a/dali-toolkit/styles/tizen-dark-theme.json
+++ b/dali-toolkit/styles/tizen-dark-theme.json
@@ -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":
{
--
2.7.4