There are several large issues with this dialog collected in bug 3893. It really doesn't work very well. Here is a radical suggestion: Get rid of it in favor of character styles. So we'd have character styles like Italic, SmallCaps, and the like, accessed via the Edit>Text Styles menu, rather than through a dialog. These could all be defined in a StdCharStyles.inc file to be included in other layouts.

There are some issues with this. At present, nesting character styles can lead to some ugly display, because the lines under the text nest and create quite a mess. I'd suggest making these optional, via a Layout setting. The attached patch gives some idea how this might work. It can be tried with these character styles:
CharStyle Italic
 LatexType               Command
 LatexName               textit
 ShowBox false
Font Shape Italic
 EndFont
End

CharStyle SmallCaps
 LatexType Command
 LatexName textsc
 ShowBox false
 Font
   Shape SmallCaps
 EndFont
End
But there are still some issues here with the behavior of the cursor, as it seems to expect a border between the inset and the surrounding text, which has been removed.

Another issue is that the Edit>Text Style menu could become very crowded. It'd be nice to be able to define character styles and put them into submenus, perhaps via a setting that was something like:
   Submenu Shape
Which would create and populate submenus.

Richard

--
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

Index: src/insets/InsetCharStyle.cpp
===================================================================
--- src/insets/InsetCharStyle.cpp	(revision 19107)
+++ src/insets/InsetCharStyle.cpp	(working copy)
@@ -102,6 +102,7 @@
 	params_.font = Font(Font::ALL_INHERIT);
 	params_.labelfont = Font(Font::ALL_INHERIT);
 	params_.labelfont.setColor(Color::error);
+	params_.showbox = true;
 	params_.show_label = true;
 }
 
@@ -113,7 +114,8 @@
 	params_.latexparam = cs->latexparam;
 	params_.font = cs->font;
 	params_.labelfont = cs->labelfont;
-	params_.show_label = true;
+	params_.showbox = cs->showbox;
+	params_.show_label = cs->showbox; //can't show label if no box
 }
 
 
@@ -144,31 +146,34 @@
 	getDrawFont(mi.base.font);
 	mi.base.font.reduce(Font(Font::ALL_SANE));
 	mi.base.font.realize(tmpfont);
-	mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
+	if (params_.showbox)
+		mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
 	InsetText::metrics(mi, dim);
 	mi.base.font = tmpfont;
-	if (params_.show_label) {
-		// consider width of the inset label
-		Font font(params_.labelfont);
-		font.realize(Font(Font::ALL_SANE));
-		font.decSize();
-		font.decSize();
-		int w = 0;
-		int a = 0;
-		int d = 0;
-		// FIXME UNICODE
-		docstring s(from_utf8(params_.type));
-		if (undefined())
-			s = _("Undef: ") + s;
-		theFontMetrics(font).rectText(s, w, a, d);
-		dim.wid = max(dim.wid, w);
+	if (params_.showbox) {
+		if (params_.show_label) {
+			// consider width of the inset label
+			Font font(params_.labelfont);
+			font.realize(Font(Font::ALL_SANE));
+			font.decSize();
+			font.decSize();
+			int w = 0;
+			int a = 0;
+			int d = 0;
+			// FIXME UNICODE
+			docstring s(from_utf8(params_.type));
+			if (undefined())
+				s = _("Undef: ") + s;
+			theFontMetrics(font).rectText(s, 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;
+		mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
+		if (params_.show_label)
+			dim.des += ascent();
 	}
-	dim.asc += TEXT_TO_INSET_OFFSET;
-	dim.des += TEXT_TO_INSET_OFFSET;
-	dim.wid += 2 * TEXT_TO_INSET_OFFSET;
-	mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
-	if (params_.show_label)
-		dim.des += ascent();
 	bool const changed = dim_ != dim;
 	dim_ = dim;
 	return changed;
@@ -183,40 +188,42 @@
 	getDrawFont(pi.base.font);
 	// I don't understand why the above .reduce and .realize aren't
 	//needed, or even wanted, here. It just works. -- MV 10.04.2005
-	InsetText::draw(pi, x + TEXT_TO_INSET_OFFSET, y);
+	InsetText::draw(pi, x + (params_.showbox ? TEXT_TO_INSET_OFFSET : 0), y);
 	pi.base.font = tmpfont;
 
 	int desc = InsetText::descent();
-	if (params_.show_label)
-		desc -= ascent();
 
-	pi.pain.line(x, y + desc - 4, x, y + desc, params_.labelfont.color());
-	pi.pain.line(x, y + desc, x + dim_.wid - 3, y + desc,
-		params_.labelfont.color());
-	pi.pain.line(x + dim_.wid - 3, y + desc, x + dim_.wid - 3, y + desc - 4,
-		params_.labelfont.color());
+	if (params_.showbox) {
+		if (params_.show_label)
+			desc -= ascent();
+		pi.pain.line(x, y + desc - 4, x, y + desc, params_.labelfont.color());
+		pi.pain.line(x, y + desc, x + dim_.wid - 3, y + desc,
+			params_.labelfont.color());
+		pi.pain.line(x + dim_.wid - 3, y + desc, x + dim_.wid - 3, y + desc - 4,
+			params_.labelfont.color());
 
-	// the name of the charstyle. Can be toggled.
-	if (params_.show_label) {
-		Font font(params_.labelfont);
-		font.realize(Font(Font::ALL_SANE));
-		font.decSize();
-		font.decSize();
-		int w = 0;
-		int a = 0;
-		int d = 0;
-		// FIXME UNICODE
-		docstring s(from_utf8(params_.type));
-		if (undefined())
-			s = _("Undef: ") + s;
-		theFontMetrics(font).rectText(s, w, a, d);
-		pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a,
-			s, font, Color::none, Color::none);
+		// the name of the charstyle. Can be toggled.
+		if (params_.show_label) {
+			Font font(params_.labelfont);
+			font.realize(Font(Font::ALL_SANE));
+			font.decSize();
+			font.decSize();
+			int w = 0;
+			int a = 0;
+			int d = 0;
+			// FIXME UNICODE
+			docstring s(from_utf8(params_.type));
+			if (undefined())
+				s = _("Undef: ") + s;
+			theFontMetrics(font).rectText(s, w, a, d);
+			pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a,
+				s, font, Color::none, Color::none);
+		}
 	}
-
+	
 	// a visual clue when the cursor is inside the inset
 	Cursor & cur = pi.base.bv->cursor();
-	if (cur.isInside(this)) {
+	if (cur.isInside(this) || mouse_hover_) {
 		y -= ascent();
 		pi.pain.line(x, y + 4, x, y, params_.labelfont.color());
 		pi.pain.line(x + 4, y, x, y, params_.labelfont.color());
@@ -240,7 +247,7 @@
 	switch (cmd.action) {
 
 	case LFUN_MOUSE_RELEASE:
-			if (cmd.button() == mouse_button::button3)
+			if (params_.showbox && cmd.button() == mouse_button::button3)
 				params_.show_label = !params_.show_label;
 			else
 				InsetCollapsable::doDispatch(cur, cmd);
Index: src/insets/InsetCharStyle.h
===================================================================
--- src/insets/InsetCharStyle.h	(revision 19107)
+++ src/insets/InsetCharStyle.h	(working copy)
@@ -35,6 +35,8 @@
 	///
 	std::string latexparam;
 	///
+	bool showbox;
+	///
 	Font font;
 	///
 	Font labelfont;
Index: src/insets/InsetCollapsable.h
===================================================================
--- src/insets/InsetCollapsable.h	(revision 19107)
+++ src/insets/InsetCollapsable.h	(working copy)
@@ -114,6 +114,8 @@
 	mutable int topbaseline;
 	///
 	mutable docstring label;
+	/// changes color when mouse enters/leaves this inset
+	bool mouse_hover_;
 private:
 	///
 	mutable CollapseStatus status_;
@@ -123,8 +125,6 @@
 	mutable bool autoOpen_;
 	///
 	mutable Dimension textdim_;
-	/// changes color when mouse enters/leaves this inset
-	bool mouse_hover_;
 };
 
 // A helper function that pushes the cursor out of the inset.
Index: src/TextClass.cpp
===================================================================
--- src/TextClass.cpp	(revision 19107)
+++ src/TextClass.cpp	(working copy)
@@ -601,6 +601,7 @@
 	CS_LATEXTYPE,
 	CS_LATEXNAME,
 	CS_LATEXPARAM,
+	CS_SHOWBOX,
 	CS_PREAMBLE,
 	CS_END
 };
@@ -615,7 +616,8 @@
 		{ "latexname", CS_LATEXNAME },
 		{ "latexparam", CS_LATEXPARAM },
 		{ "latextype", CS_LATEXTYPE },
-		{ "preamble", CS_PREAMBLE}
+ 		{ "preamble", CS_PREAMBLE},
+		{ "showbox", CS_SHOWBOX }
 	};
 
 	lexrc.pushTable(elementTags, CS_END);
@@ -623,6 +625,7 @@
 	string latextype;
 	string latexname;
 	string latexparam;
+	bool showbox = true;
 	Font font(Font::ALL_INHERIT);
 	Font labelfont(Font::ALL_INHERIT);
 	string preamble;
@@ -649,6 +652,10 @@
 			lexrc.next();
 			latexparam = subst(lexrc.getString(), """, "\"");
 			break;
+		case CS_SHOWBOX:
+			lexrc.next();
+			showbox = lexrc.getBool();
+			break;
 		case CS_LABELFONT:
 			labelfont.lyxRead(lexrc);
 			break;
@@ -670,6 +677,7 @@
 	if (getout) {
 		CharStyle cs;
 		cs.name = name;
+		cs.showbox = showbox;
 		cs.latextype = latextype;
 		cs.latexname = latexname;
 		cs.latexparam = latexparam;
Index: src/TextClass.h
===================================================================
--- src/TextClass.h	(revision 19107)
+++ src/TextClass.h	(working copy)
@@ -34,6 +34,7 @@
 	std::string latextype;
 	std::string latexname;
 	std::string latexparam;
+	bool showbox;
 	Font font;
 	Font labelfont;
 	docstring preamble;

Reply via email to