Hello,
in a desparate attempt to find a simple bug to fix - so that Lars no
longer has a reason to reject my key bindings patch - I came across char
styles:
If there are consecutive char styles with little content, there is a
good chance that the inset labels are printed on top of each other
(which looks ugly). I have fixed the metrics method in a way that it
considers the inset label for the computation of the inset width.
Guys, I am not sure whether this is the best way to fix the problem. Any
comments (including "commit it" :-)) are welcome.
Michael
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1179
diff -u -r1.1179 ChangeLog
--- src/insets/ChangeLog 7 Aug 2005 18:36:20 -0000 1.1179
+++ src/insets/ChangeLog 5 Sep 2005 20:15:06 -0000
@@ -1,3 +1,8 @@
+2005-09-05 Michael Gerz <[EMAIL PROTECTED]>
+
+ * insetcharstyle.C (metrics): consider inset label for
+ width computation
+
2005-08-07 Martin Vermeer <[EMAIL PROTECTED]>
* insettabular.C (getStatus): fix Helge's bug that a number of insets
Index: src/insets/insetcharstyle.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcharstyle.C,v
retrieving revision 1.36
diff -u -r1.36 insetcharstyle.C
--- src/insets/insetcharstyle.C 9 Jun 2005 09:58:07 -0000 1.36
+++ src/insets/insetcharstyle.C 5 Sep 2005 20:15:06 -0000
@@ -38,6 +38,7 @@
using std::string;
using std::auto_ptr;
using std::istringstream;
+using std::max;
using std::ostream;
using std::ostringstream;
@@ -139,6 +140,21 @@
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
InsetText::metrics(mi, dim);
mi.base.font = tmpfont;
+ if (has_label_) {
+ // consider width of the inset label
+ LyXFont font(params_.labelfont);
+ font.realize(LyXFont(LyXFont::ALL_SANE));
+ font.decSize();
+ font.decSize();
+ int w = 0;
+ int a = 0;
+ int d = 0;
+ string s(params_.type);
+ if (undefined())
+ s = _("Undef: ") + s;
+ font_metrics::rectText(params_.type, font, w, a, d);
+ dim.wid = max(dim.wid, w);
+ }
dim.asc += TEXT_TO_INSET_OFFSET;
dim.des += TEXT_TO_INSET_OFFSET;
dim.wid += 2 * TEXT_TO_INSET_OFFSET;