Convert more shaders in dali-toolkit and dali-scene-loader to use shader compilation...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / decorator / text-decorator.cpp
index 2a57d4d..648c17a 100644 (file)
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 
 #ifdef DEBUG_ENABLED
 #define DECORATOR_DEBUG
 
 #endif
 
-#define MAKE_SHADER(A)#A
-
-namespace
-{
-const char* VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec2    aPosition;
-uniform   highp mat4      uMvpMatrix;
-
-void main()
-{
-  mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
-  gl_Position = uMvpMatrix * position;
-}
-);
-
-const char* FRAGMENT_SHADER = MAKE_SHADER(
-uniform      lowp vec4 uColor;
-
-void main()
-{
-  gl_FragColor = uColor;
-}
-);
-}
-
 namespace Dali
 {
 namespace Internal
@@ -266,10 +242,11 @@ struct Decorator::Impl : public ConnectionTracker
     mHorizontalScrollingEnabled( false ),
     mVerticalScrollingEnabled( false ),
     mSmoothHandlePanEnabled( false ),
-    mIsHighlightBoxActive( false )
+    mIsHighlightBoxActive( false ),
+    mHidePrimaryCursorAndGrabHandle( false )
   {
     mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
-    mHighlightShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+    mHighlightShader = Shader::New( SHADER_TEXT_DECORATOR_SHADER_VERT, SHADER_TEXT_DECORATOR_SHADER_FRAG );
     SetupGestures();
   }
 
@@ -290,7 +267,7 @@ struct Decorator::Impl : public ConnectionTracker
     if( mPrimaryCursor )
     {
       const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
-      mPrimaryCursorVisible = ( ( mControlSize.width - ( cursor.position.x + mCursorWidth ) > -Math::MACHINE_EPSILON_1000 ) &&
+      mPrimaryCursorVisible = (!mHidePrimaryCursorAndGrabHandle) && ( ( mControlSize.width - ( cursor.position.x + mCursorWidth ) > -Math::MACHINE_EPSILON_1000 ) &&
                                 ( cursor.position.x > -Math::MACHINE_EPSILON_1000 ) &&
                                 ( mControlSize.height - ( cursor.position.y + cursor.cursorHeight ) > -Math::MACHINE_EPSILON_1000 ) &&
                                 ( cursor.position.y > -Math::MACHINE_EPSILON_1000 ) );
@@ -330,7 +307,7 @@ struct Decorator::Impl : public ConnectionTracker
       grabHandle.verticallyVisible = ( ( ( mControlSize.height - grabHandle.lineHeight ) - grabHandle.position.y > -Math::MACHINE_EPSILON_1000 ) &&
                                        ( grabHandle.position.y > -Math::MACHINE_EPSILON_1000 ) );
 
-      const bool isVisible = grabHandle.horizontallyVisible && grabHandle.verticallyVisible;
+      const bool isVisible = grabHandle.horizontallyVisible && grabHandle.verticallyVisible && (!mHidePrimaryCursorAndGrabHandle);
       if( isVisible )
       {
         CreateGrabHandle();
@@ -1945,6 +1922,7 @@ struct Decorator::Impl : public ConnectionTracker
   bool                mVerticalScrollingEnabled          : 1; ///< Whether the vertical scrolling is enabled.
   bool                mSmoothHandlePanEnabled            : 1; ///< Whether to pan smoothly the handles.
   bool                mIsHighlightBoxActive              : 1; ///< Whether the highlight box is active.
+  bool                mHidePrimaryCursorAndGrabHandle    : 1; ///< Whether the primary cursor and grab are hidden always.
 };
 
 DecoratorPtr Decorator::New( ControllerInterface& controller,
@@ -2093,6 +2071,11 @@ int Decorator::GetCursorWidth() const
   return static_cast<int>( mImpl->mCursorWidth );
 }
 
+void Decorator::SetEditable( bool editable )
+{
+  mImpl->mHidePrimaryCursorAndGrabHandle = !editable;
+  mImpl->Relayout( mImpl->mControlSize );
+}
 /** Handles **/
 
 void Decorator::SetHandleActive( HandleType handleType, bool active )