extras/html: Fixed shaky text selection with new TextExtent2()
[sdk] / extras / html / lines.ec
index 6aa9be3..7381e26 100644 (file)
@@ -316,9 +316,9 @@ void RenderLine(HTMLView browser, Surface surface, int x, int y, int w, int h, B
 {
    int textPos = startTextPos;
    Block block = startBlock;
-   bool lineComplete = false;
    int startSel, endSel;
    Block startSelBlock = null, endSelBlock = null;
+   int prevGlyph = 0;
    if(browser.textBlock != browser.selBlock || browser.curPosition != browser.selPosition)
       browser.NormalizeSelection(&startSelBlock, &startSel, &endSelBlock, &endSel);
 
@@ -403,7 +403,7 @@ void RenderLine(HTMLView browser, Surface surface, int x, int y, int w, int h, B
                int l = startSel - textPos;
                if(block.text)
                {
-                  surface.TextExtent(block.text + textPos, l, &tw, &th);
+                  surface.TextExtent2(block.text + textPos, l, &tw, &th, prevGlyph, &prevGlyph, null);
                   surface.WriteText(x, y + h - th, block.text + textPos, l);
                   x += tw;
                }
@@ -423,7 +423,7 @@ void RenderLine(HTMLView browser, Surface surface, int x, int y, int w, int h, B
                   surface.foreground = white;
                   surface.textOpacity = true;
                }
-               surface.TextExtent(block.text + textPos, len, &tw, &th);
+               surface.TextExtent2(block.text + textPos, len, &tw, &th, prevGlyph, &prevGlyph, null);
                surface.WriteText(x, y + h - th, block.text + textPos, len);
                x += tw;
                if(browser.isSelected)
@@ -442,7 +442,7 @@ void RenderLine(HTMLView browser, Surface surface, int x, int y, int w, int h, B
                int l = endPos - textPos;
                if(block.text)
                {
-                  surface.TextExtent(block.text + textPos, l, &tw, &th);
+                  surface.TextExtent2(block.text + textPos, l, &tw, &th, prevGlyph, &prevGlyph, null);
                   surface.WriteText(x, y + h - th, block.text + textPos, l);
                   x += tw;
                }
@@ -457,7 +457,6 @@ void RenderLine(HTMLView browser, Surface surface, int x, int y, int w, int h, B
             break;
         case TABLE:
             RenderTable(browser, surface, x, y, w, h, left, right, block);
-            lineComplete = true;
             block = NextBlockUp(surface, block, null, RenderFlags { render = true });
             textPos = 0;
             break;
@@ -480,7 +479,6 @@ bool PickLine(HTMLView browser, Surface surface, int x, int y, int w, int h, Blo
    bool result = false;
    int textPos = startTextPos;
    Block block = startBlock;
-   bool lineComplete = false;
 
    for(;!result;)
    {
@@ -565,7 +563,6 @@ bool PickLine(HTMLView browser, Surface surface, int x, int y, int w, int h, Blo
             break;
         case TABLE:
             result = PickTable(browser, surface, x, y, w, h, left, right, block, pickX, pickY, pickBlock, pickTextPos);
-            lineComplete = true;
             block = NextBlockUp(surface, block, null, RenderFlags { render = true });
             textPos = 0;
             break;
@@ -589,7 +586,6 @@ void PositionLine(HTMLView browser, Surface surface, int x, int y, int w, int h,
 {
    int textPos = startTextPos;
    Block block = startBlock;
-   bool lineComplete = false;
 
    for(;;)
    {
@@ -608,18 +604,14 @@ void PositionLine(HTMLView browser, Surface surface, int x, int y, int w, int h,
                   block.window.size.w, block.window.size.h);
                //block.window.visible = false;
                x += block.window.size.w;
-               if(block.inputType == text)
-               {
-                  printf("");
-               }
             }
             break;
          }
          case IMAGE:
          {
             int bw = block.pWidth ? (w * block.pWidth / 100) : block.w;
-            int bh = block.pHeight ? (h * block.pHeight / 100) : block.h;
-            int dx, dy;
+            //int bh = block.pHeight ? (h * block.pHeight / 100) : block.h;
+            int dx;//, dy;
 
             switch(block.halign)
             {
@@ -637,12 +629,14 @@ void PositionLine(HTMLView browser, Surface surface, int x, int y, int w, int h,
                   break;
             }
 
+            /*
             switch(block.valign)
             {
                case bottom: dy = y + h - bh; break;
                case top: dy = y; break;
                case middle: dy = y + (h - bh) / 2; break;
             }
+            */
 
             x += bw;
             break;
@@ -667,7 +661,6 @@ void PositionLine(HTMLView browser, Surface surface, int x, int y, int w, int h,
             break;
         case TABLE:
             PositionTable(browser, surface, x, y, w, h, left, right, block);
-            lineComplete = true;
             block = NextBlockUp(surface, block, null, RenderFlags { render = true });
             textPos = 0;
             break;