Alfredo Braunstein wrote:

>> I don't have time to act on this until saturday so feel free to change
>> that if you want.
> 
> I don't have time either unfortunately. I'll be a rather busy (read
> traveling) in the next 30 days or so... IMHO, (if you agree) we should
> just revert the full patch series if possible.

That is btw:

20068
20070
20071
20079
20080
20083
20100
20101
20103

Patch attached. I don't know if I'm missing anything. There are maybe
related changes (like the removal of textmetrics in InsetText) that should
be redone.

A/

Index: insets/InsetCaption.cpp
===================================================================
--- insets/InsetCaption.cpp	(revision 20113)
+++ insets/InsetCaption.cpp	(working copy)
@@ -163,8 +163,7 @@
 	labelwidth_ = pi.pain.text(x, y, full_label_, pi.base.font);
 	// add some space to separate the label from the inset text
 	labelwidth_ += 2 * TEXT_TO_INSET_OFFSET;
-	int const ty  = y - ascent() + TEXT_TO_INSET_OFFSET;
-	InsetText::draw(pi, x + labelwidth_, ty);
+	InsetText::draw(pi, x + labelwidth_, y);
 	setPosCache(pi, x, y);
 }
 
Index: insets/InsetTabular.cpp
===================================================================
--- insets/InsetTabular.cpp	(revision 20113)
+++ insets/InsetTabular.cpp	(working copy)
@@ -3015,7 +3015,6 @@
 		int const a = tabular.rowAscent(i);
 		int const d = tabular.rowDescent(i);
 		idx = tabular.cellIndex(i, 0);
-		int const cy = y - a;
 		for (col_type j = 0; j < tabular.columnCount(); ++j) {
 			if (tabular.isPartOfMultiColumn(i, j))
 				continue;
@@ -3028,11 +3027,11 @@
 			    || y + d < 0
 			    || y - a > bv->workHeight()) {
 				pi.pain.setDrawingEnabled(false);
-				cell(idx)->draw(pi, cx, cy);
+				cell(idx)->draw(pi, cx, y);
 				drawCellLines(pi.pain, nx, y, i, idx, pi.erased_);
 				pi.pain.setDrawingEnabled(true);
 			} else {
-				cell(idx)->draw(pi, cx, cy);
+				cell(idx)->draw(pi, cx, y);
 				drawCellLines(pi.pain, nx, y, i, idx, pi.erased_);
 			}
 			nx += tabular.columnWidth(idx);
Index: insets/InsetCollapsable.cpp
===================================================================
--- insets/InsetCollapsable.cpp	(revision 20113)
+++ insets/InsetCollapsable.cpp	(working copy)
@@ -94,6 +94,7 @@
 		status_(rhs.status_),
 		openinlined_(rhs.openinlined_),
 		autoOpen_(rhs.autoOpen_),
+		textdim_(rhs.textdim_),
 		// the sole purpose of this copy constructor
 		mouse_hover_(false)
 {
@@ -207,17 +208,16 @@
 		dim = dimensionCollapsed();
 		if (geometry() == TopButton
 		 || geometry() == LeftButton) {
-			Dimension textdim;
-			InsetText::metrics(mi, textdim);
-			openinlined_ = (textdim.wid + dim.wid) < mi.base.textwidth;
+			InsetText::metrics(mi, textdim_);
+			openinlined_ = (textdim_.wid + dim.wid) < mi.base.textwidth;
 			if (openinlined_) {
 				// Correct for button width.
-				dim.wid += textdim.wid;
-				dim.des = max(dim.des - textdim.asc + dim.asc, textdim.des);
-				dim.asc = textdim.asc;
+				dim.wid += textdim_.wid;
+				dim.des = max(dim.des - textdim_.asc + dim.asc, textdim_.des);
+				dim.asc = textdim_.asc;
 			} else {
-				dim.des += textdim.height() + TEXT_TO_BOTTOM_OFFSET;
-				dim.wid = max(dim.wid, textdim.wid);
+				dim.des += textdim_.height() + TEXT_TO_BOTTOM_OFFSET;
+				dim.wid = max(dim.wid, textdim_.wid);
 				if (hasFixedWidth())
 					dim.wid = max(dim.wid, mi.base.textwidth);
 			}
@@ -250,16 +250,16 @@
 
 	// Draw button first -- top, left or only
 	Dimension dimc = dimensionCollapsed();
-
+	int const top  = y - ascent() + TEXT_TO_INSET_OFFSET;
 	if (geometry() == TopButton ||
 	    geometry() == LeftButton ||
 	    geometry() == ButtonOnly) {
 		button_dim.x1 = xx + 0;
 		button_dim.x2 = xx + dimc.width();
-		button_dim.y1 = y - dimc.asc;
-		button_dim.y2 = y + dimc.des;
+		button_dim.y1 = top;
+		button_dim.y2 = top + dimc.height();
 
-		pi.pain.buttonText(xx, y, layout_.labelstring, layout_.labelfont, mouse_hover_);
+		pi.pain.buttonText(xx, top + dimc.asc, layout_.labelstring, layout_.labelfont, mouse_hover_);
 	} else {
 		button_dim.x1 = 0;
 		button_dim.y1 = 0;
@@ -267,31 +267,29 @@
 		button_dim.y2 = 0;
 	}
 
-	TextMetrics const & tm = pi.base.bv->textMetrics(&text_);
-	int const baseline = y - tm.ascent();
 	int textx, texty;
 	switch (geometry()) {
 	case LeftButton:
 		textx = xx + dimc.width();
-		texty = baseline;
+		texty = top + textdim_.asc;
 		InsetText::draw(pi, textx, texty);
 		break;
 	case TopButton:
 		textx = xx;
-		texty = baseline + dimc.height();
+		texty = top + dimc.height() + textdim_.asc;
 		InsetText::draw(pi, textx, texty);
 		break;
 	case ButtonOnly:
 		break;
 	case NoButton:
 		textx = xx;
-		texty = baseline;
+		texty = y + textdim_.asc;
 		InsetText::draw(pi, textx, texty);
 		break;
 	case SubLabel:
 	case Corners:
 		textx = xx;
-		texty = baseline;
+		texty = y + textdim_.asc;
 		const_cast<InsetCollapsable *>(this)->setDrawFrame(false);
 		InsetText::draw(pi, textx, texty);
 		const_cast<InsetCollapsable *>(this)->setDrawFrame(true);
@@ -368,7 +366,7 @@
 		InsetText::drawSelection(pi, x, y);
 		break;
 	case TopButton:
-		y += dimensionCollapsed().des;
+		y += dimensionCollapsed().des + textdim_.asc;
 		InsetText::drawSelection(pi, x, y);
 		break;
 	case ButtonOnly:
@@ -393,12 +391,10 @@
 	case LeftButton:
 		x += dimensionCollapsed().wid;
 		break;
-	case TopButton: {
-		TextMetrics const & tm = bv.textMetrics(&text_);
+	case TopButton:
 		y += dimensionCollapsed().height() - ascent()
-			+ TEXT_TO_INSET_OFFSET + tm.ascent();
+			+ TEXT_TO_INSET_OFFSET + textdim_.asc;
 		break;
-	}
 	case NoButton:
 	case SubLabel:
 	case Corners:
Index: insets/InsetText.cpp
===================================================================
--- insets/InsetText.cpp	(revision 20113)
+++ insets/InsetText.cpp	(working copy)
@@ -188,8 +188,8 @@
 	if (drawFrame_ || pi.full_repaint) {
 		int const w = hasFixedWidth() ? 
 			tm.maxWidth() : tm.width() + 2 * border_;
-		int const a = border_;
-		int const h = a + tm.height() + border_;
+		int const a = tm.ascent() + border_;
+		int const h = a + tm.descent() + border_;
 		if (pi.full_repaint)
 			pi.pain.fillRectangle(x, y - a, w, h, backgroundColor());
 		if (drawFrame_)
Index: insets/InsetCollapsable.h
===================================================================
--- insets/InsetCollapsable.h	(revision 20113)
+++ insets/InsetCollapsable.h	(working copy)
@@ -168,6 +168,8 @@
 	mutable bool openinlined_;
 	/// the inset will automatically open when the cursor is inside
 	mutable bool autoOpen_;
+	///
+	mutable Dimension textdim_;
 	/// changes color when mouse enters/leaves this inset
 	bool mouse_hover_;
 };
Index: BufferView.cpp
===================================================================
--- BufferView.cpp	(revision 20113)
+++ BufferView.cpp	(working copy)
@@ -1551,7 +1551,7 @@
 		tm.drawParagraph(pi, metrics_info_.p1, 0,
 		metrics_info_.y1 + tm.parMetrics(metrics_info_.p1).ascent());
 	else
-		tm.draw(pi, 0, metrics_info_.y1);
+		tm.draw(pi, 0, metrics_info_.y1 + tm.parMetrics(metrics_info_.p1).ascent());
 	LYXERR(Debug::PAINTING) << "\n\t\t*** END DRAWING  ***" << endl;
 
 	// and grey out above (should not happen later)
Index: TextMetrics.cpp
===================================================================
--- TextMetrics.cpp	(revision 20113)
+++ TextMetrics.cpp	(working copy)
@@ -1806,6 +1806,7 @@
 
 	ParMetricsCache::const_iterator it = par_metrics_.begin();
 	ParMetricsCache::const_iterator const pm_end = par_metrics_.end();
+	y -= it->second.ascent();
 	for (; it != pm_end; ++it) {
 		ParagraphMetrics const & pmi = it->second;
 		y += pmi.ascent();

Reply via email to