[Scummvm-git-logs] scummvm master -> fa3883c86e4b370c1920aff480dc168fad64baa3
sev-
noreply at scummvm.org
Mon Oct 9 23:46:30 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fa3883c86e GRAPHICS: MACGUI: Initial attempt to render tables in MacText
Commit: fa3883c86e4b370c1920aff480dc168fad64baa3
https://github.com/scummvm/scummvm/commit/fa3883c86e4b370c1920aff480dc168fad64baa3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-10-10T01:45:36+02:00
Commit Message:
GRAPHICS: MACGUI: Initial attempt to render tables in MacText
Changed paths:
graphics/macgui/mactext.cpp
graphics/macgui/mactext.h
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index f24cb551ac6..44c91288a8b 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -1134,6 +1134,12 @@ void MacTextCanvas::render(int from, int to, int shadow) {
continue;
}
+ if (_text[i].tableSurface) {
+ surface->blitFrom(*_text[i].tableSurface, Common::Point(0, _text[i].y));
+
+ continue;
+ }
+
int xOffset = getAlignOffset(i) + _text[i].indent + _text[i].firstLineIndent;
xOffset++;
@@ -2898,7 +2904,8 @@ const Surface *MacText::getImageSurface(Common::String &fname) {
void MacText::processTable(int line) {
Common::Array<MacTextTableRow> *table = _canvas._text[line].table;
uint numCols = table->front().cells.size();
- Common::Array<int> maxW(numCols), maxL(numCols), colW(numCols);
+ uint numRows = table->size();
+ Common::Array<int> maxW(numCols), maxL(numCols), colW(numCols), rowH(numRows);
Common::Array<bool> flex(numCols), wrap(numCols);
int width = _canvas._maxWidth * 0.9;
@@ -2983,19 +2990,69 @@ void MacText::processTable(int line) {
warning("%d: %d", i, colW[i]);
}
+ int r = 0;
for (auto &row : *table) {
- int i = 0;
+ int c = 0;
+ rowH[r] = 0;
for (auto &cell : row.cells) {
- cell._maxWidth = colW[i];
+ cell._maxWidth = colW[c];
cell.recalcDims();
cell.reallocSurface();
cell._surface->clear(_bgcolor);
cell.render(0, cell._text.size());
- i++;
+ rowH[r] = MAX(rowH[r], cell._textMaxHeight);
+
+ c++;
+ }
+
+ r++;
+ }
+
+ int tW = 1, tH = 1;
+ for (uint i = 0; i < table->size(); i++)
+ tH += rowH[i] + gutter * 2 + 1;
+
+ for (uint i = 0; i < table->front().cells.size(); i++)
+ tW += colW[i] + gutter * 2 + 1;
+
+ ManagedSurface *surf = new ManagedSurface(tW, tH, _wm->_pixelformat);
+ _canvas._text[line].tableSurface = surf;
+ _canvas._text[line].height = tH;
+ surf->clear(_bgcolor);
+
+ surf->hLine(0, 0, tW, _fgcolor);
+ surf->vLine(0, 0, tH, _fgcolor);
+
+ int y = 1;
+ for (uint i = 0; i < table->size(); i++) {
+ y += gutter * 2 + rowH[i];
+ surf->hLine(0, y, tW, _fgcolor);
+ y++;
+ }
+
+ int x = 1;
+ for (uint i = 0; i < table->front().cells.size(); i++) {
+ x += gutter * 2 + rowH[i];
+ surf->vLine(x, 0, tH, _fgcolor);
+ x++;
+ }
+
+ r = 0;
+ x = 1 + gutter;
+ y = 1 + gutter;
+ for (auto &row : *table) {
+ int c = 0;
+ for (auto &cell : row.cells) {
+ surf->blitFrom(*cell._surface, Common::Point(x, y));
+ x += gutter * 2 + 1 + colW[c];
+ c++;
}
+ y += gutter * 2 + 1 + rowH[r];
+ r++;
}
+
}
} // End of namespace Graphics
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 1f797ab4441..f95f7714345 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -179,6 +179,7 @@ struct MacTextLine {
Common::U32String picalt, pictitle;
uint16 picpercent = 50;
Common::Array<MacTextTableRow> *table = nullptr;
+ ManagedSurface *tableSurface = nullptr;
Common::Array<MacFontRun> chunks;
More information about the Scummvm-git-logs
mailing list