[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11267: more improvements to TextFie
From: |
Bob Naugle |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11267: more improvements to TextField. Allowances for multiple TextRecords on same line. MemCheck clean (i think). Lines display and scroll correctly. |
Date: |
Wed, 15 Jul 2009 15:42:03 -0600 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11267
committer: Bob Naugle <address@hidden>
branch nick: trunk
timestamp: Wed 2009-07-15 15:42:03 -0600
message:
more improvements to TextField. Allowances for multiple TextRecords on same
line. MemCheck clean (i think). Lines display and scroll correctly.
known issues:
- noticed slight incorrect behavior with PGUP/PGDN
modified:
libcore/TextField.cpp
libcore/TextField.h
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2009-07-15 16:55:54 +0000
+++ b/libcore/TextField.cpp 2009-07-15 21:42:03 +0000
@@ -344,7 +344,7 @@
}
SWF::TextRecord::displayRecords(renderer, m, get_world_cxform(),
- _textRecords, _embedFonts);
+ _displayRecords, _embedFonts);
if (m_has_focus) show_cursor(renderer, wmat);
@@ -998,8 +998,8 @@
TextField::format_text()
{
_textRecords.clear();
+ _displayRecords.clear();
_line_starts.clear();
- TextRecords temporary;
// nothing more to do if text is empty
if ( _text.empty() )
@@ -1340,9 +1340,8 @@
x += last_line.glyphs().back().advance;
previous_x -= last_line.glyphs().back().advance;
last_line.clearGlyphs(1);
-
//record the new line start
- while ( linestartit <
linestartend && *linestartit < (it-_text.begin())-1)
+ while ( linestartit !=
linestartend && *linestartit <= (it-_text.begin())-1)
{
linestartit++;
}
@@ -1397,7 +1396,8 @@
}
// Add the last line to our output.
- if (!rec.glyphs().empty()) _textRecords.push_back(rec);
+ //if (!rec.glyphs().empty()) _textRecords.push_back(rec);
+ _textRecords.push_back(rec);
linestartit = _line_starts.begin();
linestartend = _line_starts.end();
@@ -1406,43 +1406,29 @@
int linestart = 0;
int manylines = _line_starts.size();
int manyrecords = _textRecords.size();
- int yoffset = _top_visible_line*(fontHeight + leading);
-
SWF::TextRecord cursorposition_line;
while(linestartit != linestartend && *linestartit <= m_cursor) {
linestart = *linestartit++;
}
current_line = linestartit - _line_starts.begin();
- ///COMPUTE THE LINES TO DISPLAY
- if (manylines - _top_visible_line <= _linesindisplay) {
- if(manylines - _linesindisplay <= 0)
- _top_visible_line = 0;
- else {
- _top_visible_line = manylines - _linesindisplay;
- }
- //if we are at a higher position, scoot the lines down
- //INVALID READ - Conditional jump or move depends on uninitialised
value(s)
- } else if ( m_cursor < (_line_starts[_top_visible_line]) ) {
- _top_visible_line -= _top_visible_line-current_line;
- //if we are at a lower position, scoot the lines up
- } else if (manylines > _top_visible_line+_linesindisplay) {
- if ( m_cursor >= (_line_starts[last_visible_line])) {
- _top_visible_line += current_line - (last_visible_line);
- }
- }
- ///MOVE THE LINES TO SHOW CORRECT SECTION OF TEXT
+ changeTopVisibleLine(current_line);
+
+ ///ASSIGN THE VISIBLE LINES TO _displayRecord
+ int yoffset = _top_visible_line*(fontHeight + leading) + PADDING_TWIPS;
for(unsigned int i = 0; i < manyrecords; ++i) {
- //if(_textRecords[i].yOffset() - yoffset < defBounds.height()) {
- //} else if (_textRecords
- _textRecords[i].setYOffset(_textRecords[i].yOffset() -
(_top_visible_line*(fontHeight + leading)));
+ //if the record is in the section we want to show
+ if(_textRecords[i].yOffset() - yoffset < defBounds.height() &&
+ _textRecords[i].yOffset() - yoffset > 0) {
+ _displayRecords.push_back(_textRecords[i]);
+
_displayRecords.back().setYOffset(_displayRecords.back().yOffset() - yoffset);
+ }
}
-
///POSITION THE CURSOR IN X-DIRECTION
- if ( current_line <= manyrecords ) {
+ if ( current_line <= manyrecords && current_line >= 1) {
cursorposition_line = _textRecords[current_line-1];
- for ( unsigned int i = linestart; i < m_cursor; ++i ) {
- //INVALID READ
+ //extra checks keep MemCheck happy!
+ for ( unsigned int i = linestart; i < m_cursor && i <
cursorposition_line.glyphs().size(); ++i ) {
m_xcursor +=
cursorposition_line.glyphs()[i-linestart].advance;
}
}
@@ -1460,6 +1446,28 @@
set_invalidated(); //redraw
}
+void
+TextField::changeTopVisibleLine(int current_line)
+{
+ int manylines = _textRecords.size();
+ int lastvisibleline = _top_visible_line + _linesindisplay;
+ if (manylines - _top_visible_line <= _linesindisplay) {
+ if(manylines - _linesindisplay <= 0)
+ _top_visible_line = 0;
+ else {
+ _top_visible_line = manylines - _linesindisplay;
+ }
+ //if we are at a higher position, scoot the lines down
+ } else if ( m_cursor < (_line_starts[_top_visible_line]) ) {
+ _top_visible_line -= _top_visible_line-current_line;
+ //if we are at a lower position, scoot the lines up
+ } else if (manylines > _top_visible_line+_linesindisplay) {
+ if ( m_cursor >= (_line_starts[lastvisibleline])) {
+ _top_visible_line += current_line - (lastvisibleline);
+ }
+ }
+}
+
TextField::VariableRef
TextField::parseTextVariableRef(const std::string& variableName) const
{
=== modified file 'libcore/TextField.h'
--- a/libcore/TextField.h 2009-07-14 15:20:00 +0000
+++ b/libcore/TextField.h 2009-07-15 21:42:03 +0000
@@ -509,6 +509,9 @@
/// text_glyph_records to be rendered.
void format_text();
+ /// Move viewable lines based on m_cursor
+ void changeTopVisibleLine(int current_line);
+
/// Extracts an HTML tag.
///
/// @param tag This string is filled with the extracted HTML tag.
@@ -578,6 +581,7 @@
typedef std::vector<SWF::TextRecord> TextRecords;
TextRecords _textRecords;
+ TextRecords _displayRecords;
bool _underlined;
boost::uint16_t _leading;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11267: more improvements to TextField. Allowances for multiple TextRecords on same line. MemCheck clean (i think). Lines display and scroll correctly.,
Bob Naugle <=