gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11534: align_line(): shift the long


From: Udo Giacomozzi
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11534: align_line(): shift the long-term _textRecords, not _displayRecords which is valid only during display() ; align the last line (applies to single-line text fields too). This commit should fix the alignment problems (all text fields were left-aligned regardless of their definition
Date: Thu, 01 Oct 2009 19:32:24 +0200
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11534
committer: Udo Giacomozzi <address@hidden>
branch nick: trunk
timestamp: Thu 2009-10-01 19:32:24 +0200
message:
  align_line(): shift the long-term _textRecords, not _displayRecords which is 
valid only during display() ; align the last line (applies to single-line text 
fields too). This commit should fix the alignment problems (all text fields 
were left-aligned regardless of their definition
modified:
  libcore/TextField.cpp
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp     2009-10-01 08:50:53 +0000
+++ b/libcore/TextField.cpp     2009-10-01 17:32:24 +0000
@@ -176,7 +176,6 @@
     _bounds(def.bounds()),
     _selection(0, 0)
 {
-
     // WARNING! remember to set the font *before* setting text value!
     boost::intrusive_ptr<const Font> f = def.getFont();
     if (!f) f = fontlib::get_default_font(); 
@@ -358,7 +357,6 @@
 void
 TextField::display(Renderer& renderer)
 {
-
     registerTextVariable();
 
     const bool drawBorder = getDrawBorder();
@@ -414,6 +412,7 @@
     _displayRecords.clear();
     float scale = getFontHeight() / (float)_font->unitsPerEM(_embedFonts);
     float fontLeading = _font->leading() * scale;
+
     //offset the lines
     int yoffset = (getFontHeight() + fontLeading) + PADDING_TWIPS;
     size_t recordline;
@@ -1024,7 +1023,6 @@
     float right_margin = getRightMargin();
 
     float extra_space = (width - right_margin) - x - PADDING_TWIPS;
-
     //assert(extra_space >= 0.0f);
     if (extra_space <= 0.0f)
     {
@@ -1053,11 +1051,10 @@
         // Shift all the way to the right.
         shift_right = extra_space;
     }
-
     // Shift the beginnings of the records on this line.
-    for (unsigned int i = last_line_start_record; i < _displayRecords.size(); 
++i)
+    for (unsigned int i = last_line_start_record; i < _textRecords.size(); ++i)
     {
-        SWF::TextRecord& rec = _displayRecords[i];
+        SWF::TextRecord& rec = _textRecords[i];
 
         //if ( rec.hasXOffset() ) // why?
             rec.setXOffset(rec.xOffset() + shift_right); 
@@ -1266,10 +1263,10 @@
     std::wstring::const_iterator it = _text.begin();
     const std::wstring::const_iterator e = _text.end();
 
-    ///handleChar takes care of placing the glyphs
+    ///handleChar takes care of placing the glyphs    
     handleChar(it, e, x, y, rec, last_code, last_space_glyph,
             last_line_start_record);
-    
+                
     // Expand bounding box to include the whole text (if autoSize)
     if (_autoSize != autoSizeNone)
     {
@@ -1277,11 +1274,16 @@
     }
 
     // Add the last line to our output.
-       _textRecords.push_back(rec);
+    _textRecords.push_back(rec);
+       
+    // align the last (or single) line
+    align_line(getTextAlignment(), last_line_start_record, x);
+       
 
     scrollLines();
        
     set_invalidated(); //redraw
+    
 }
 
 void
@@ -2690,6 +2692,7 @@
     if ( _autoSize == autoSizeCenter ) textAlignment = ALIGN_CENTER;
     else if ( _autoSize == autoSizeLeft ) textAlignment = ALIGN_LEFT;
     else if ( _autoSize == autoSizeRight ) textAlignment = ALIGN_RIGHT;
+
     return textAlignment;
 }
     


reply via email to

[Prev in Thread] Current Thread [Next in Thread]