[Libreoffice-commits] core.git: vcl/workben

Chris Sherlock chris.sherlock at collabora.com
Tue Jan 27 03:15:59 PST 2015


 vcl/workben/vcldemo.cxx |   39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

New commits:
commit 786d5bce816fd0a44a5f525ce59b81412e4c1bc7
Author: Chris Sherlock <chris.sherlock at collabora.com>
Date:   Tue Jan 27 01:23:35 2015 +1100

    vcl: clipping text demo now included
    
    vcldemo now sports a new demo that shows that text is clippable. Also, I've
    clipped all the thumbnails to their boundary boxes, just to make it a bit
    neater.
    
    Change-Id: I5163ad0d5e249ce53a390773399fc64d9fbd8cf0
    Reviewed-on: https://gerrit.libreoffice.org/14185
    Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
    Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index a932c06..4ddeb5c 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -299,6 +299,15 @@ public:
     struct DrawText : public RegionRenderer
     {
         RENDER_DETAILS(text,KEY_T,1)
+
+        bool mbClip;
+
+        DrawText() :
+            mbClip (false) {}
+
+        DrawText( bool bClip )
+            : mbClip (bClip) {}
+
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &) SAL_OVERRIDE
         {
@@ -315,6 +324,10 @@ public:
               };
             for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++)
                 maFontNames.push_back(OUString::createFromAscii(pNames[i]));
+
+            if (mbClip)
+                rDev.SetClipRegion( vcl::Region(r - Point(200, 200) ) );
+
 #define PRINT_N_TEXT 20
             for (int i = 0; i < PRINT_N_TEXT; i++) {
                 rDev.SetTextColor(Color(nCols[i % SAL_N_ELEMENTS(nCols)]));
@@ -323,9 +336,20 @@ public:
                 rDev.SetFont(aFont);
                 rDev.DrawText(r, aText.copy(0, 4 + (aText.getLength() - 4) * (PRINT_N_TEXT - i)/PRINT_N_TEXT));
             }
+
+            if (mbClip)
+                rDev.SetClipRegion();
         }
     };
 
+    struct DrawClipText : public DrawText
+    {
+        RENDER_DETAILS(cliptext,KEY_T,1)
+
+        DrawClipText()
+            : DrawText( true ) {}
+    };
+
     struct DrawCheckered : public RegionRenderer
     {
         RENDER_DETAILS(checks,KEY_C,20)
@@ -969,6 +993,9 @@ public:
             for (size_t i = 0; i < maRenderers.size(); i++)
             {
                 RegionRenderer * r = maRenderers[i];
+
+                rDev.SetClipRegion( vcl::Region( aRegions[i] ) );
+
                 // profiling?
                 if (getIterCount() > 0)
                 {
@@ -981,8 +1008,13 @@ public:
                     } else
                         for (int j = 0; j < r->getTestRepeatCount(); j++)
                             r->RenderRegion(rDev, aRegions[i], aCtx);
-                } else
+                }
+                else
+                {
                     r->RenderRegion(rDev, aRegions[i], aCtx);
+                }
+
+                rDev.SetClipRegion();
             }
         }
     }
@@ -1112,6 +1144,7 @@ void DemoRenderer::InitRenderers()
 {
     maRenderers.push_back(new DrawLines());
     maRenderers.push_back(new DrawText());
+    maRenderers.push_back(new DrawClipText());
     maRenderers.push_back(new DrawPoly());
     maRenderers.push_back(new DrawEllipse());
     maRenderers.push_back(new DrawCheckered());
@@ -1172,7 +1205,7 @@ void DemoRenderer::addTime(int i, double t)
     maRenderers[i]->countTime++;
 }
 
-void DemoRenderer::selectRenderer(const OUString &rName)
+void DemoRenderer::selectRenderer(const OUString &rName )
 {
     for (size_t i = 0; i < maRenderers.size(); i++)
     {
@@ -1384,7 +1417,7 @@ public:
                     if (bLast)
                         return showHelp(aRenderer);
                     else
-                        aRenderer.selectRenderer(GetCommandLineParam(++i));
+                        aRenderer.selectRenderer(GetCommandLineParam(i));
                 }
                 else if (aArg == "--test")
                 {


More information about the Libreoffice-commits mailing list