Re: [patch] LyX logo logoification

2015-03-15 Thread Abdelrazak Younes

On 13/03/2015 15:21, Jean-Marc Lasgouttes wrote:

Le 13/03/2015 12:10, Jean-Marc Lasgouttes a écrit :

In this patch, I change our new LyX logo inset to look like the real
thing. Georg, is there a reason why your chose not to follow this route
(or only lack of time/motivation).

Also, I am not sure that the Color_special color is the best choice (try
to load the Intro manual, for example). Would it be a problem to use
normal color once it is clear that the logo is something special, not
plain text?


With this new patch all logos are logoified and the color is the 
normal plain one.


Comments?


You use lots of hardcoded constants nobody except you will understand 1 
month from now, and not even you 1 year from now :-P


At least those are used 4 times and should use meaningfully named 
constants: 0.16667 and 0.125.


Nitpick: 0.16667 ~= 1/6 so if you want to be more accurate you'd better 
use division per 6.
Nitpick 2: You are using floating point calculation while you could 
fixed point calculation easily. Not a problem on PC but on some ARM 
systems (eg older Raspberry Pi).


My 2 cts of the year :-)

Abdel.



Re: [patch] LyX logo logoification

2015-03-15 Thread Abdelrazak Younes

On 15/03/2015 18:29, Jean-Marc Lasgouttes wrote:

Le 15/03/15 08:44, Abdelrazak Younes a écrit :

Comments?


You use lots of hardcoded constants nobody except you will understand 1
month from now, and not even you 1 year from now :-P


What is the LaTeX source code good for?


I didn't know that... I am not literate in Latex as you may know :-)



I added some documentation, although I am not sure that it will help 
you more.


It helped me understand the roots of the code, indeed. And I think this 
reference is valuable in the code, thanks!




It helped me to notice a couple oversights. Thanks.


Thanks.




At least those are used 4 times and should use meaningfully named
constants: 0.16667 and 0.125.


These are just numbers: 1/6em and 1/8em. Ask Knuth for their proper 
names.


Didn't know that. Still ugly though :-)





Nitpick: 0.16667 ~= 1/6 so if you want to be more accurate you'd better
use division per 6.


Being accurate in this case is doing what TeX does.


I see.



Nitpick 2: You are using floating point calculation while you could
fixed point calculation easily. Not a problem on PC but on some ARM
systems (eg older Raspberry Pi).


As Knuth wrote, premature optimization is the root of all evil.


Which is maybe the reason why LateX code is so ugly. I guess LaTeX has 
some special way to do fixed point calculation based on floating point 
representation, hasn't it?


Thanks,
Abdel.



Re: [patch] LyX logo logoification

2015-03-15 Thread Jean-Marc Lasgouttes

Le 15/03/15 08:44, Abdelrazak Younes a écrit :

Comments?


You use lots of hardcoded constants nobody except you will understand 1
month from now, and not even you 1 year from now :-P


What is the LaTeX source code good for?

I added some documentation, although I am not sure that it will help you 
more.


It helped me to notice a couple oversights. Thanks.


At least those are used 4 times and should use meaningfully named
constants: 0.16667 and 0.125.


These are just numbers: 1/6em and 1/8em. Ask Knuth for their proper names.



Nitpick: 0.16667 ~= 1/6 so if you want to be more accurate you'd better
use division per 6.


Being accurate in this case is doing what TeX does.


Nitpick 2: You are using floating point calculation while you could
fixed point calculation easily. Not a problem on PC but on some ARM
systems (eg older Raspberry Pi).


As Knuth wrote, premature optimization is the root of all evil.


My 2 cts of the year :-)


You're welcome.

JMarc

PS: I do find this code ugly too, but I still think that this form is 
the easiest to understand :)




Re: [patch] LyX logo logoification

2015-03-15 Thread Abdelrazak Younes

On 13/03/2015 15:21, Jean-Marc Lasgouttes wrote:

Le 13/03/2015 12:10, Jean-Marc Lasgouttes a écrit :

In this patch, I change our new LyX logo inset to look like the real
thing. Georg, is there a reason why your chose not to follow this route
(or only lack of time/motivation).

Also, I am not sure that the Color_special color is the best choice (try
to load the Intro manual, for example). Would it be a problem to use
normal color once it is clear that the logo is something special, not
plain text?


With this new patch all logos are logoified and the color is the 
normal plain one.


Comments?


You use lots of hardcoded constants nobody except you will understand 1 
month from now, and not even you 1 year from now :-P


At least those are used 4 times and should use meaningfully named 
constants: 0.16667 and 0.125.


Nitpick: 0.16667 ~= 1/6 so if you want to be more accurate you'd better 
use division per 6.
Nitpick 2: You are using floating point calculation while you could 
fixed point calculation easily. Not a problem on PC but on some ARM 
systems (eg older Raspberry Pi).


My 2 cts of the year :-)

Abdel.



Re: [patch] LyX logo logoification

2015-03-15 Thread Jean-Marc Lasgouttes

Le 15/03/15 08:44, Abdelrazak Younes a écrit :

Comments?


You use lots of hardcoded constants nobody except you will understand 1
month from now, and not even you 1 year from now :-P


What is the LaTeX source code good for?

I added some documentation, although I am not sure that it will help you 
more.


It helped me to notice a couple oversights. Thanks.


At least those are used 4 times and should use meaningfully named
constants: 0.16667 and 0.125.


These are just numbers: 1/6em and 1/8em. Ask Knuth for their proper names.



Nitpick: 0.16667 ~= 1/6 so if you want to be more accurate you'd better
use division per 6.


Being accurate in this case is doing what TeX does.


Nitpick 2: You are using floating point calculation while you could
fixed point calculation easily. Not a problem on PC but on some ARM
systems (eg older Raspberry Pi).


As Knuth wrote, "premature optimization is the root of all evil".


My 2 cts of the year :-)


You're welcome.

JMarc

PS: I do find this code ugly too, but I still think that this form is 
the easiest to understand :)




Re: [patch] LyX logo logoification

2015-03-15 Thread Abdelrazak Younes

On 15/03/2015 18:29, Jean-Marc Lasgouttes wrote:

Le 15/03/15 08:44, Abdelrazak Younes a écrit :

Comments?


You use lots of hardcoded constants nobody except you will understand 1
month from now, and not even you 1 year from now :-P


What is the LaTeX source code good for?


I didn't know that... I am not literate in Latex as you may know :-)



I added some documentation, although I am not sure that it will help 
you more.


It helped me understand the roots of the code, indeed. And I think this 
reference is valuable in the code, thanks!




It helped me to notice a couple oversights. Thanks.


Thanks.




At least those are used 4 times and should use meaningfully named
constants: 0.16667 and 0.125.


These are just numbers: 1/6em and 1/8em. Ask Knuth for their proper 
names.


Didn't know that. Still ugly though :-)





Nitpick: 0.16667 ~= 1/6 so if you want to be more accurate you'd better
use division per 6.


Being accurate in this case is doing what TeX does.


I see.



Nitpick 2: You are using floating point calculation while you could
fixed point calculation easily. Not a problem on PC but on some ARM
systems (eg older Raspberry Pi).


As Knuth wrote, "premature optimization is the root of all evil".


Which is maybe the reason why LateX code is so ugly. I guess LaTeX has 
some special way to do fixed point calculation based on floating point 
representation, hasn't it?


Thanks,
Abdel.



Re: [patch] LyX logo logoification

2015-03-13 Thread Jean-Marc Lasgouttes

Le 13/03/2015 18:07, Georg Baum a écrit :

With this new patch all logos are logoified and the color is the normal
plain one.


I like this. I only used the special color because otherwise it would be
impossible to distinguish the special inset from standard text.


The only ugly thing is when trying to click on thiese large insets, the 
cursor always ends up on the left on the inset. I tried to debug it, but 
it is in the ugly parts of BufferView::mouseSetCursor.


JMarc



[patch] LyX logo logoification

2015-03-13 Thread Jean-Marc Lasgouttes
In this patch, I change our new LyX logo inset to look like the real 
thing. Georg, is there a reason why your chose not to follow this route 
(or only lack of time/motivation).


Also, I am not sure that the Color_special color is the best choice (try 
to load the Intro manual, for example). Would it be a problem to use 
normal color once it is clear that the logo is something special, not 
plain text?


JMarc

From a2c198a561b7ee28a14bbefe0164350110f4f020 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes lasgout...@lyx.org
Date: Fri, 13 Mar 2015 12:05:15 +0100
Subject: [PATCH] Improve display of LyX logo.

---
 src/insets/InsetSpecialChar.cpp |   32 +++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp
index 77792b9..bc46465 100644
--- a/src/insets/InsetSpecialChar.cpp
+++ b/src/insets/InsetSpecialChar.cpp
@@ -49,6 +49,7 @@ void InsetSpecialChar::metrics(MetricsInfo  mi, Dimension  dim) const
 		theFontMetrics(mi.base.font);
 	dim.asc = fm.maxAscent();
 	dim.des = fm.maxDescent();
+	dim.wid = 0;
 
 	docstring s;
 	switch (kind_) {
@@ -65,7 +66,9 @@ void InsetSpecialChar::metrics(MetricsInfo  mi, Dimension  dim) const
 			s = from_ascii( x );
 			break;
 		case HYPHENATION:
-			s = from_ascii(-);
+			dim.wid = fm.width(from_ascii(-));
+			if (dim.wid  5)
+dim.wid -= 2; // to make it look shorter
 			break;
 		case SLASH:
 			s = from_ascii(/);
@@ -73,9 +76,13 @@ void InsetSpecialChar::metrics(MetricsInfo  mi, Dimension  dim) const
 		case NOBREAKDASH:
 			s = from_ascii(-);
 			break;
-		case PHRASE_LYX:
-			s = from_ascii(LyX);
+		case PHRASE_LYX: {
+			double const em = fm.width('M');
+			dim.wid = fm.width(from_ascii(L)) - 0.16667 * em
++ fm.width(from_ascii(Y)) - 0.125 * em
++ fm.width(from_ascii(X));
 			break;
+		}
 		case PHRASE_TEX:
 			s = from_ascii(TeX);
 			break;
@@ -86,10 +93,9 @@ void InsetSpecialChar::metrics(MetricsInfo  mi, Dimension  dim) const
 			s = from_ascii(LaTeX);
 			break;
 	}
-	dim.wid = fm.width(s);
-	if (kind_ == HYPHENATION  dim.wid  5)
-		dim.wid -= 2; // to make it look shorter
-	
+	if (dim.wid == 0)
+		dim.wid = fm.width(s);
+
 	setDimCache(mi, dim);
 }
 
@@ -156,10 +162,18 @@ void InsetSpecialChar::draw(PainterInfo  pi, int x, int y) const
 		pi.pain.text(x, y, char_type('-'), font);
 		break;
 	}
-	case PHRASE_LYX:
+	case PHRASE_LYX: {
 		font.setColor(Color_special);
-		pi.pain.text(x, y, from_ascii(LyX), font);
+		// FIXME: this definition of em is bogus, but there is a need
+		// for a big refactoring of the code around this issue anyway.
+		double const em = theFontMetrics(font).width('M');
+		x += pi.pain.text(x, y, from_ascii(L), font);
+		x -= 0.16667 * em;
+		x += pi.pain.text(x, y + 0.25 * em, from_ascii(Y), font);
+		x -= 0.125 * em;
+		pi.pain.text(x, y, from_ascii(X), font);
 		break;
+	}
 	case PHRASE_TEX:
 		font.setColor(Color_special);
 		pi.pain.text(x, y, from_ascii(TeX), font);
-- 
1.7.9.5



Re: [patch] LyX logo logoification

2015-03-13 Thread Jürgen Spitzmüller
2015-03-13 15:21 GMT+01:00 Jean-Marc Lasgouttes:

 With this new patch all logos are logoified and the color is the normal
 plain one.

 Comments?


Good. I also think the logos could go into an own sub(sub)menu, since they
are probably not widely used.

Jürgen



 JMarc






Re: [patch] LyX logo logoification

2015-03-13 Thread Jean-Marc Lasgouttes

Le 13/03/2015 12:10, Jean-Marc Lasgouttes a écrit :

In this patch, I change our new LyX logo inset to look like the real
thing. Georg, is there a reason why your chose not to follow this route
(or only lack of time/motivation).

Also, I am not sure that the Color_special color is the best choice (try
to load the Intro manual, for example). Would it be a problem to use
normal color once it is clear that the logo is something special, not
plain text?


With this new patch all logos are logoified and the color is the normal 
plain one.


Comments?

JMarc



From c0ff3f2d9f310b3a4dfe1b3544ed741ecd0b20bb Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes lasgout...@lyx.org
Date: Fri, 13 Mar 2015 12:05:15 +0100
Subject: [PATCH] Improve display of the logos.

This look now more like the real logos. Moreover, we use not the normal font color because Color_special is a bit too flashy.
---
 src/insets/InsetSpecialChar.cpp |  120 +++
 1 file changed, 97 insertions(+), 23 deletions(-)

diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp
index 77792b9..e4fd180 100644
--- a/src/insets/InsetSpecialChar.cpp
+++ b/src/insets/InsetSpecialChar.cpp
@@ -43,12 +43,54 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const
 }
 
 
+namespace {
+
+int logoWidth(FontInfo const  font, InsetSpecialChar::Kind kind) {
+	frontend::FontMetrics const  fm = theFontMetrics(font);
+	double const em = fm.width('M');
+	int width = 0;
+	switch (kind) {
+	case InsetSpecialChar::PHRASE_LYX:
+		width = fm.width(from_ascii(L)) - 0.16667 * em
+			+ fm.width(from_ascii(Y)) - 0.125 * em
+			+ fm.width(from_ascii(X));
+		break;
+
+	case InsetSpecialChar::PHRASE_TEX:
+		width = fm.width(from_ascii(T)) - 0.16667 * em
+			+ fm.width(from_ascii(E)) - 0.125 * em
+			+ fm.width(from_ascii(X));
+		break;
+
+	case InsetSpecialChar::PHRASE_LATEX2E:
+		width = logoWidth(font, InsetSpecialChar::PHRASE_LATEX)
+			+ fm.width(from_ascii(2) + char_type(0x03b5));
+		break;
+	case InsetSpecialChar::PHRASE_LATEX: {
+		FontInfo smaller = font;
+		smaller.decSize().decSize();
+		width = fm.width(from_ascii(L)) - 0.36 * em
+			+ theFontMetrics(smaller).width(from_ascii(A)) - 0.15 * em
+			+ logoWidth(font, InsetSpecialChar::PHRASE_TEX);
+		break;
+	}
+	default:
+		LYXERR0(No information for computing width of logo   kind);
+	}
+
+	return width;
+}
+
+}
+
+
 void InsetSpecialChar::metrics(MetricsInfo  mi, Dimension  dim) const
 {
 	frontend::FontMetrics const  fm =
 		theFontMetrics(mi.base.font);
 	dim.asc = fm.maxAscent();
 	dim.des = fm.maxDescent();
+	dim.wid = 0;
 
 	docstring s;
 	switch (kind_) {
@@ -65,7 +107,9 @@ void InsetSpecialChar::metrics(MetricsInfo  mi, Dimension  dim) const
 			s = from_ascii( x );
 			break;
 		case HYPHENATION:
-			s = from_ascii(-);
+			dim.wid = fm.width(from_ascii(-));
+			if (dim.wid  5)
+dim.wid -= 2; // to make it look shorter
 			break;
 		case SLASH:
 			s = from_ascii(/);
@@ -74,26 +118,66 @@ void InsetSpecialChar::metrics(MetricsInfo  mi, Dimension  dim) const
 			s = from_ascii(-);
 			break;
 		case PHRASE_LYX:
-			s = from_ascii(LyX);
-			break;
 		case PHRASE_TEX:
-			s = from_ascii(TeX);
-			break;
 		case PHRASE_LATEX2E:
-			s = from_ascii(LaTeX2) + char_type(0x03b5);
-			break;
 		case PHRASE_LATEX:
-			s = from_ascii(LaTeX);
+			dim.wid = logoWidth(mi.base.font, kind_);
 			break;
 	}
-	dim.wid = fm.width(s);
-	if (kind_ == HYPHENATION  dim.wid  5)
-		dim.wid -= 2; // to make it look shorter
-	
+	if (dim.wid == 0)
+		dim.wid = fm.width(s);
+
 	setDimCache(mi, dim);
 }
 
 
+namespace {
+
+void drawLogo(PainterInfo  pi, InsetSpecialChar::Kind kind, int  x, int  y) {
+	FontInfo const  font = pi.base.font;
+	// FIXME: this definition of em is bogus, but there is a need
+	// for a big refactoring of the code around this issue anyway.
+	double const em = theFontMetrics(font).width('M');
+	switch (kind) {
+	case InsetSpecialChar::PHRASE_LYX:
+		x += pi.pain.text(x, y, from_ascii(L), font);
+		x -= 0.16667 * em;
+		x += pi.pain.text(x, y + 0.25 * em, from_ascii(Y), font);
+		x -= 0.125 * em;
+		x += pi.pain.text(x, y, from_ascii(X), font);
+		break;
+
+	case InsetSpecialChar::PHRASE_TEX:
+		x += pi.pain.text(x, y, from_ascii(T), font);
+		x -= 0.16667 * em;
+		x += pi.pain.text(x, y + 0.25 * em, from_ascii(E), font);
+		x -= 0.125 * em;
+		x += pi.pain.text(x, y, from_ascii(X), font);
+		break;
+
+	case InsetSpecialChar::PHRASE_LATEX2E:
+		drawLogo(pi, InsetSpecialChar::PHRASE_LATEX, x, y);
+		x += pi.pain.text(x, y, from_ascii(2), font);
+		x += pi.pain.text(x, y + 0.25 * em, char_type(0x03b5), font);
+		break;
+
+	case InsetSpecialChar::PHRASE_LATEX: {
+		x += pi.pain.text(x, y, from_ascii(L), font);
+		x -= 0.36 * em;
+		FontInfo smaller = font;
+		smaller.decSize().decSize();
+		x += pi.pain.text(x, y - 0.2 * em, from_ascii(A), smaller);
+		x -= 0.15 * em;
+		drawLogo(pi, InsetSpecialChar::PHRASE_TEX, x, y);
+		break;
+	}
+	default:
+		LYXERR0(No 

Re: [patch] LyX logo logoification

2015-03-13 Thread Jean-Marc Lasgouttes

Le 13/03/2015 16:31, Jürgen Spitzmüller a écrit :

2015-03-13 15:21 GMT+01:00 Jean-Marc Lasgouttes:

With this new patch all logos are logoified and the color is the
normal plain one.

Good. I also think the logos could go into an own sub(sub)menu, since
they are probably not widely used.


OTOH, people seeing these insets will probably not understand what they 
are and how to produce them. If we hide them further the situation will 
become a bit difficult.


JMarc



Re: [patch] LyX logo logoification

2015-03-13 Thread Jürgen Spitzmüller
2015-03-13 17:02 GMT+01:00 Jean-Marc Lasgouttes:

 OTOH, people seeing these insets will probably not understand what they
 are and how to produce them. If we hide them further the situation will
 become a bit difficult.


They will not search them under Special Symbols anyway.

Jürgen



 JMarc




Re: [patch] LyX logo logoification

2015-03-13 Thread Georg Baum
Jean-Marc Lasgouttes wrote:

 Le 13/03/2015 12:10, Jean-Marc Lasgouttes a écrit :
 In this patch, I change our new LyX logo inset to look like the real
 thing. Georg, is there a reason why your chose not to follow this route
 (or only lack of time/motivation).

Simply lack of time. My most important goal was to make the file format and 
underlying infrastructure clean.

 Also, I am not sure that the Color_special color is the best choice (try
 to load the Intro manual, for example). Would it be a problem to use
 normal color once it is clear that the logo is something special, not
 plain text?
 
 With this new patch all logos are logoified and the color is the normal
 plain one.

I like this. I only used the special color because otherwise it would be 
impossible to distinguish the special inset from standard text.


Georg



[patch] LyX logo logoification

2015-03-13 Thread Jean-Marc Lasgouttes
In this patch, I change our new LyX logo inset to look like the real 
thing. Georg, is there a reason why your chose not to follow this route 
(or only lack of time/motivation).


Also, I am not sure that the Color_special color is the best choice (try 
to load the Intro manual, for example). Would it be a problem to use 
normal color once it is clear that the logo is something special, not 
plain text?


JMarc

>From a2c198a561b7ee28a14bbefe0164350110f4f020 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes 
Date: Fri, 13 Mar 2015 12:05:15 +0100
Subject: [PATCH] Improve display of LyX logo.

---
 src/insets/InsetSpecialChar.cpp |   32 +++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp
index 77792b9..bc46465 100644
--- a/src/insets/InsetSpecialChar.cpp
+++ b/src/insets/InsetSpecialChar.cpp
@@ -49,6 +49,7 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 		theFontMetrics(mi.base.font);
 	dim.asc = fm.maxAscent();
 	dim.des = fm.maxDescent();
+	dim.wid = 0;
 
 	docstring s;
 	switch (kind_) {
@@ -65,7 +66,9 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 			s = from_ascii(" x ");
 			break;
 		case HYPHENATION:
-			s = from_ascii("-");
+			dim.wid = fm.width(from_ascii("-"));
+			if (dim.wid > 5)
+dim.wid -= 2; // to make it look shorter
 			break;
 		case SLASH:
 			s = from_ascii("/");
@@ -73,9 +76,13 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 		case NOBREAKDASH:
 			s = from_ascii("-");
 			break;
-		case PHRASE_LYX:
-			s = from_ascii("LyX");
+		case PHRASE_LYX: {
+			double const em = fm.width('M');
+			dim.wid = fm.width(from_ascii("L")) - 0.16667 * em
++ fm.width(from_ascii("Y")) - 0.125 * em
++ fm.width(from_ascii("X"));
 			break;
+		}
 		case PHRASE_TEX:
 			s = from_ascii("TeX");
 			break;
@@ -86,10 +93,9 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 			s = from_ascii("LaTeX");
 			break;
 	}
-	dim.wid = fm.width(s);
-	if (kind_ == HYPHENATION && dim.wid > 5)
-		dim.wid -= 2; // to make it look shorter
-	
+	if (dim.wid == 0)
+		dim.wid = fm.width(s);
+
 	setDimCache(mi, dim);
 }
 
@@ -156,10 +162,18 @@ void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
 		pi.pain.text(x, y, char_type('-'), font);
 		break;
 	}
-	case PHRASE_LYX:
+	case PHRASE_LYX: {
 		font.setColor(Color_special);
-		pi.pain.text(x, y, from_ascii("LyX"), font);
+		// FIXME: this definition of em is bogus, but there is a need
+		// for a big refactoring of the code around this issue anyway.
+		double const em = theFontMetrics(font).width('M');
+		x += pi.pain.text(x, y, from_ascii("L"), font);
+		x -= 0.16667 * em;
+		x += pi.pain.text(x, y + 0.25 * em, from_ascii("Y"), font);
+		x -= 0.125 * em;
+		pi.pain.text(x, y, from_ascii("X"), font);
 		break;
+	}
 	case PHRASE_TEX:
 		font.setColor(Color_special);
 		pi.pain.text(x, y, from_ascii("TeX"), font);
-- 
1.7.9.5



Re: [patch] LyX logo logoification

2015-03-13 Thread Jean-Marc Lasgouttes

Le 13/03/2015 12:10, Jean-Marc Lasgouttes a écrit :

In this patch, I change our new LyX logo inset to look like the real
thing. Georg, is there a reason why your chose not to follow this route
(or only lack of time/motivation).

Also, I am not sure that the Color_special color is the best choice (try
to load the Intro manual, for example). Would it be a problem to use
normal color once it is clear that the logo is something special, not
plain text?


With this new patch all logos are logoified and the color is the normal 
plain one.


Comments?

JMarc



>From c0ff3f2d9f310b3a4dfe1b3544ed741ecd0b20bb Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes 
Date: Fri, 13 Mar 2015 12:05:15 +0100
Subject: [PATCH] Improve display of the logos.

This look now more like the real logos. Moreover, we use not the normal font color because Color_special is a bit too flashy.
---
 src/insets/InsetSpecialChar.cpp |  120 +++
 1 file changed, 97 insertions(+), 23 deletions(-)

diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp
index 77792b9..e4fd180 100644
--- a/src/insets/InsetSpecialChar.cpp
+++ b/src/insets/InsetSpecialChar.cpp
@@ -43,12 +43,54 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const
 }
 
 
+namespace {
+
+int logoWidth(FontInfo const & font, InsetSpecialChar::Kind kind) {
+	frontend::FontMetrics const & fm = theFontMetrics(font);
+	double const em = fm.width('M');
+	int width = 0;
+	switch (kind) {
+	case InsetSpecialChar::PHRASE_LYX:
+		width = fm.width(from_ascii("L")) - 0.16667 * em
+			+ fm.width(from_ascii("Y")) - 0.125 * em
+			+ fm.width(from_ascii("X"));
+		break;
+
+	case InsetSpecialChar::PHRASE_TEX:
+		width = fm.width(from_ascii("T")) - 0.16667 * em
+			+ fm.width(from_ascii("E")) - 0.125 * em
+			+ fm.width(from_ascii("X"));
+		break;
+
+	case InsetSpecialChar::PHRASE_LATEX2E:
+		width = logoWidth(font, InsetSpecialChar::PHRASE_LATEX)
+			+ fm.width(from_ascii("2") + char_type(0x03b5));
+		break;
+	case InsetSpecialChar::PHRASE_LATEX: {
+		FontInfo smaller = font;
+		smaller.decSize().decSize();
+		width = fm.width(from_ascii("L")) - 0.36 * em
+			+ theFontMetrics(smaller).width(from_ascii("A")) - 0.15 * em
+			+ logoWidth(font, InsetSpecialChar::PHRASE_TEX);
+		break;
+	}
+	default:
+		LYXERR0("No information for computing width of logo " << kind);
+	}
+
+	return width;
+}
+
+}
+
+
 void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 {
 	frontend::FontMetrics const & fm =
 		theFontMetrics(mi.base.font);
 	dim.asc = fm.maxAscent();
 	dim.des = fm.maxDescent();
+	dim.wid = 0;
 
 	docstring s;
 	switch (kind_) {
@@ -65,7 +107,9 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 			s = from_ascii(" x ");
 			break;
 		case HYPHENATION:
-			s = from_ascii("-");
+			dim.wid = fm.width(from_ascii("-"));
+			if (dim.wid > 5)
+dim.wid -= 2; // to make it look shorter
 			break;
 		case SLASH:
 			s = from_ascii("/");
@@ -74,26 +118,66 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 			s = from_ascii("-");
 			break;
 		case PHRASE_LYX:
-			s = from_ascii("LyX");
-			break;
 		case PHRASE_TEX:
-			s = from_ascii("TeX");
-			break;
 		case PHRASE_LATEX2E:
-			s = from_ascii("LaTeX2") + char_type(0x03b5);
-			break;
 		case PHRASE_LATEX:
-			s = from_ascii("LaTeX");
+			dim.wid = logoWidth(mi.base.font, kind_);
 			break;
 	}
-	dim.wid = fm.width(s);
-	if (kind_ == HYPHENATION && dim.wid > 5)
-		dim.wid -= 2; // to make it look shorter
-	
+	if (dim.wid == 0)
+		dim.wid = fm.width(s);
+
 	setDimCache(mi, dim);
 }
 
 
+namespace {
+
+void drawLogo(PainterInfo & pi, InsetSpecialChar::Kind kind, int & x, int & y) {
+	FontInfo const & font = pi.base.font;
+	// FIXME: this definition of em is bogus, but there is a need
+	// for a big refactoring of the code around this issue anyway.
+	double const em = theFontMetrics(font).width('M');
+	switch (kind) {
+	case InsetSpecialChar::PHRASE_LYX:
+		x += pi.pain.text(x, y, from_ascii("L"), font);
+		x -= 0.16667 * em;
+		x += pi.pain.text(x, y + 0.25 * em, from_ascii("Y"), font);
+		x -= 0.125 * em;
+		x += pi.pain.text(x, y, from_ascii("X"), font);
+		break;
+
+	case InsetSpecialChar::PHRASE_TEX:
+		x += pi.pain.text(x, y, from_ascii("T"), font);
+		x -= 0.16667 * em;
+		x += pi.pain.text(x, y + 0.25 * em, from_ascii("E"), font);
+		x -= 0.125 * em;
+		x += pi.pain.text(x, y, from_ascii("X"), font);
+		break;
+
+	case InsetSpecialChar::PHRASE_LATEX2E:
+		drawLogo(pi, InsetSpecialChar::PHRASE_LATEX, x, y);
+		x += pi.pain.text(x, y, from_ascii("2"), font);
+		x += pi.pain.text(x, y + 0.25 * em, char_type(0x03b5), font);
+		break;
+
+	case InsetSpecialChar::PHRASE_LATEX: {
+		x += pi.pain.text(x, y, from_ascii("L"), font);
+		x -= 0.36 * em;
+		FontInfo smaller = font;
+		smaller.decSize().decSize();
+		x += pi.pain.text(x, y - 0.2 * em, from_ascii("A"), smaller);
+		x -= 0.15 * em;
+		drawLogo(pi, 

Re: [patch] LyX logo logoification

2015-03-13 Thread Jürgen Spitzmüller
2015-03-13 15:21 GMT+01:00 Jean-Marc Lasgouttes:

> With this new patch all logos are logoified and the color is the normal
> plain one.
>
> Comments?
>

Good. I also think the logos could go into an own sub(sub)menu, since they
are probably not widely used.

Jürgen


>
> JMarc
>
>
>
>


Re: [patch] LyX logo logoification

2015-03-13 Thread Jean-Marc Lasgouttes

Le 13/03/2015 16:31, Jürgen Spitzmüller a écrit :

2015-03-13 15:21 GMT+01:00 Jean-Marc Lasgouttes:

With this new patch all logos are logoified and the color is the
normal plain one.

Good. I also think the logos could go into an own sub(sub)menu, since
they are probably not widely used.


OTOH, people seeing these insets will probably not understand what they 
are and how to produce them. If we hide them further the situation will 
become a bit difficult.


JMarc



Re: [patch] LyX logo logoification

2015-03-13 Thread Jürgen Spitzmüller
2015-03-13 17:02 GMT+01:00 Jean-Marc Lasgouttes:

> OTOH, people seeing these insets will probably not understand what they
> are and how to produce them. If we hide them further the situation will
> become a bit difficult.
>

They will not search them under "Special Symbols" anyway.

Jürgen


>
> JMarc
>
>


Re: [patch] LyX logo logoification

2015-03-13 Thread Georg Baum
Jean-Marc Lasgouttes wrote:

> Le 13/03/2015 12:10, Jean-Marc Lasgouttes a écrit :
>> In this patch, I change our new LyX logo inset to look like the real
>> thing. Georg, is there a reason why your chose not to follow this route
>> (or only lack of time/motivation).

Simply lack of time. My most important goal was to make the file format and 
underlying infrastructure clean.

>> Also, I am not sure that the Color_special color is the best choice (try
>> to load the Intro manual, for example). Would it be a problem to use
>> normal color once it is clear that the logo is something special, not
>> plain text?
> 
> With this new patch all logos are logoified and the color is the normal
> plain one.

I like this. I only used the special color because otherwise it would be 
impossible to distinguish the special inset from standard text.


Georg



Re: [patch] LyX logo logoification

2015-03-13 Thread Jean-Marc Lasgouttes

Le 13/03/2015 18:07, Georg Baum a écrit :

With this new patch all logos are logoified and the color is the normal
plain one.


I like this. I only used the special color because otherwise it would be
impossible to distinguish the special inset from standard text.


The only ugly thing is when trying to click on thiese large insets, the 
cursor always ends up on the left on the inset. I tried to debug it, but 
it is in the ugly parts of BufferView::mouseSetCursor.


JMarc