Re: [patch] Space displayed after macro, #3705
On Fri, Jun 15, 2007 at 08:39:14AM +0200, Stefan Schimanski wrote: Here is a patch for http://bugzilla.lyx.org/show_bug.cgi?id=3705. It adds the kerning method to a macro to inherit the kerning from the expanded form. Moreover the marker metrics calls are remove as they are not drawn anyway. Stefan Index: src/mathed/MathMacro.h === --- src/mathed/MathMacro.h (Revision 18774) +++ src/mathed/MathMacro.h (Arbeitskopie) @@ -54,6 +54,8 @@ /// docstring name() const; /// + int kerning() const { return kerning_; } Could that be int kerning() const { return expanded_.kerning(); } or is expanded_ smashed before we access its kerning? The expanded_ only makes sense if not edited. Even if the value of it might sense in edit mode as well I wouldn't depend on it. Those implicit assumptions pay back if you change the code months later and you don't remember about it. Here a few pixels have no consequences of course... But also inlining has no effect here with a virtual method. Stefan PGP.sig Description: Signierter Teil der Nachricht
Re: [patch] Space displayed after macro, #3705
On Sun, Jun 17, 2007 at 06:02:19PM +0200, Stefan Schimanski wrote: On Fri, Jun 15, 2007 at 08:39:14AM +0200, Stefan Schimanski wrote: Here is a patch for http://bugzilla.lyx.org/show_bug.cgi?id=3705. It adds the kerning method to a macro to inherit the kerning from the expanded form. Moreover the marker metrics calls are remove as they are not drawn anyway. Stefan Index: src/mathed/MathMacro.h === --- src/mathed/MathMacro.h (Revision 18774) +++ src/mathed/MathMacro.h (Arbeitskopie) @@ -54,6 +54,8 @@ /// docstring name() const; /// + int kerning() const { return kerning_; } Could that be int kerning() const { return expanded_.kerning(); } or is expanded_ smashed before we access its kerning? The expanded_ only makes sense if not edited. Even if the value of it might sense in edit mode as well I wouldn't depend on it. Those implicit assumptions pay back if you change the code months later and you don't remember about it. Here a few pixels have no consequences of course... But also inlining has no effect here with a virtual method. It's not about inlining, it's about that extra kerning_ member that needs to be kept in sync with expanded_.kerning() Andre'
Re: [patch] Space displayed after macro, #3705
On Fri, Jun 15, 2007 at 08:39:14AM +0200, Stefan Schimanski wrote: Here is a patch for http://bugzilla.lyx.org/show_bug.cgi?id=3705. It adds the kerning method to a macro to inherit the kerning from the expanded form. Moreover the marker metrics calls are remove as they are not drawn anyway. Stefan Index: src/mathed/MathMacro.h === --- src/mathed/MathMacro.h (Revision 18774) +++ src/mathed/MathMacro.h (Arbeitskopie) @@ -54,6 +54,8 @@ /// docstring name() const; /// + int kerning() const { return kerning_; } Could that be int kerning() const { return expanded_.kerning(); } or is expanded_ smashed before we access its kerning? The expanded_ only makes sense if not edited. Even if the value of it might sense in edit mode as well I wouldn't depend on it. Those implicit assumptions pay back if you change the code months later and you don't remember about it. Here a few pixels have no consequences of course... But also inlining has no effect here with a virtual method. Stefan PGP.sig Description: Signierter Teil der Nachricht
Re: [patch] Space displayed after macro, #3705
On Sun, Jun 17, 2007 at 06:02:19PM +0200, Stefan Schimanski wrote: > >On Fri, Jun 15, 2007 at 08:39:14AM +0200, Stefan Schimanski wrote: > >>Here is a patch for http://bugzilla.lyx.org/show_bug.cgi?id=3705. It > >>adds the kerning method to a macro to inherit the kerning from the > >>expanded form. Moreover the marker metrics calls are remove as they > >>are not drawn anyway. > >> > >>Stefan > >> > >>Index: src/mathed/MathMacro.h > >>=== > >>--- src/mathed/MathMacro.h (Revision 18774) > >>+++ src/mathed/MathMacro.h (Arbeitskopie) > >>@@ -54,6 +54,8 @@ > >>/// > >>docstring name() const; > >>/// > >>+ int kerning() const { return kerning_; } > > > >Could that be > > > > int kerning() const { return expanded_.kerning(); } > > > >or is expanded_ smashed before we access its kerning? > > The expanded_ only makes sense if not edited. Even if the value of it > might sense in edit mode as well I wouldn't depend on it. Those > implicit assumptions pay back if you change the code months later and > you don't remember about it. Here a few pixels have no consequences > of course... But also inlining has no effect here with a virtual method. It's not about inlining, it's about that extra kerning_ member that needs to be kept in sync with expanded_.kerning() Andre'
Re: [patch] Space displayed after macro, #3705
On Fri, Jun 15, 2007 at 08:39:14AM +0200, Stefan Schimanski wrote: Here is a patch for http://bugzilla.lyx.org/show_bug.cgi?id=3705. It adds the kerning method to a macro to inherit the kerning from the expanded form. Moreover the marker metrics calls are remove as they are not drawn anyway. Stefan Index: src/mathed/MathMacro.h === --- src/mathed/MathMacro.h(Revision 18774) +++ src/mathed/MathMacro.h(Arbeitskopie) @@ -54,6 +54,8 @@ /// docstring name() const; /// + int kerning() const { return kerning_; } Could that be int kerning() const { return expanded_.kerning(); } or is expanded_ smashed before we access its kerning? Andre'
Re: [patch] Space displayed after macro, #3705
On Fri, Jun 15, 2007 at 08:39:14AM +0200, Stefan Schimanski wrote: > Here is a patch for http://bugzilla.lyx.org/show_bug.cgi?id=3705. It > adds the kerning method to a macro to inherit the kerning from the > expanded form. Moreover the marker metrics calls are remove as they > are not drawn anyway. > > Stefan > > Index: src/mathed/MathMacro.h > === > --- src/mathed/MathMacro.h(Revision 18774) > +++ src/mathed/MathMacro.h(Arbeitskopie) > @@ -54,6 +54,8 @@ > /// > docstring name() const; > /// > + int kerning() const { return kerning_; } Could that be int kerning() const { return expanded_.kerning(); } or is expanded_ smashed before we access its kerning? Andre'
Re: [patch] Space displayed after macro, #3705
On Friday 15 June 2007 19:01:23 Stefan Schimanski wrote: Is it ok, José? It's only about cosmetics... Stefan OK. -- José Abílio
Re: [patch] Space displayed after macro, #3705
Is it ok, José? It's only about cosmetics... Stefan Am 15.06.2007 um 08:39 schrieb Stefan Schimanski: Here is a patch for http://bugzilla.lyx.org/show_bug.cgi?id=3705. It adds the kerning method to a macro to inherit the kerning from the expanded form. Moreover the marker metrics calls are remove as they are not drawn anyway. Stefan Index: src/mathed/MathMacro.h === --- src/mathed/MathMacro.h (Revision 18774) +++ src/mathed/MathMacro.h (Arbeitskopie) @@ -54,6 +54,8 @@ /// docstring name() const; /// + int kerning() const { return kerning_; } + /// void setExpansion(MathData const exp, MathData const args) const; /// @@ -85,6 +87,8 @@ mutable MacroData macroBackup_; /// mutable bool editing_; + /// + mutable int kerning_; }; Index: src/mathed/MathMacro.cpp === --- src/mathed/MathMacro.cpp(Revision 18774) +++ src/mathed/MathMacro.cpp(Arbeitskopie) @@ -44,6 +44,8 @@ bool metrics(MetricsInfo mi, Dimension dim) const; /// void draw(PainterInfo , int x, int y) const; + /// + int kerning() const { return mathMacro_.cell(idx_).kerning(); } private: std::auto_ptrInset doClone() const; @@ -65,7 +67,6 @@ macro.unlock(); mathMacro_.cell(idx_).metrics(mi, dim); macro.lock(); - metricsMarkers2(dim); if (dim_ == dim) return false; dim_ = dim; @@ -114,6 +115,7 @@ bool MathMacro::metrics(MetricsInfo mi, Dimension dim) const { + kerning_ = 0; if (!MacroTable::globalMacros().has(name())) { mathed_string_dim(mi.base.font, Unknown: + name(), dim); } else { @@ -143,10 +145,10 @@ macro.lock(); expanded_.metrics(mi, dim); macro.unlock(); + kerning_ = expanded_.kerning(); editing_ = false; } } - metricsMarkers2(dim); if (dim_ == dim) return false; dim_ = dim; @@ -199,7 +201,6 @@ if (editing_ != editing(pi.base.bv) || macroBackup_ != macro) pi.base.bv-cursor().updateFlags(Update::Force); } - drawMarkers2(pi, x, y); } macrospacearound.patch PGP.sig Description: Signierter Teil der Nachricht
Re: [patch] Space displayed after macro, #3705
On Friday 15 June 2007 19:01:23 Stefan Schimanski wrote: > Is it ok, José? It's only about cosmetics... > > Stefan OK. -- José Abílio
Re: [patch] Space displayed after macro, #3705
Is it ok, José? It's only about cosmetics... Stefan Am 15.06.2007 um 08:39 schrieb Stefan Schimanski: Here is a patch for http://bugzilla.lyx.org/show_bug.cgi?id=3705. It adds the kerning method to a macro to inherit the kerning from the expanded form. Moreover the marker metrics calls are remove as they are not drawn anyway. Stefan Index: src/mathed/MathMacro.h === --- src/mathed/MathMacro.h (Revision 18774) +++ src/mathed/MathMacro.h (Arbeitskopie) @@ -54,6 +54,8 @@ /// docstring name() const; /// + int kerning() const { return kerning_; } + /// void setExpansion(MathData const & exp, MathData const & args) const; /// @@ -85,6 +87,8 @@ mutable MacroData macroBackup_; /// mutable bool editing_; + /// + mutable int kerning_; }; Index: src/mathed/MathMacro.cpp === --- src/mathed/MathMacro.cpp(Revision 18774) +++ src/mathed/MathMacro.cpp(Arbeitskopie) @@ -44,6 +44,8 @@ bool metrics(MetricsInfo & mi, Dimension & dim) const; /// void draw(PainterInfo &, int x, int y) const; + /// + int kerning() const { return mathMacro_.cell(idx_).kerning(); } private: std::auto_ptr doClone() const; @@ -65,7 +67,6 @@ macro.unlock(); mathMacro_.cell(idx_).metrics(mi, dim); macro.lock(); - metricsMarkers2(dim); if (dim_ == dim) return false; dim_ = dim; @@ -114,6 +115,7 @@ bool MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const { + kerning_ = 0; if (!MacroTable::globalMacros().has(name())) { mathed_string_dim(mi.base.font, "Unknown: " + name(), dim); } else { @@ -143,10 +145,10 @@ macro.lock(); expanded_.metrics(mi, dim); macro.unlock(); + kerning_ = expanded_.kerning(); editing_ = false; } } - metricsMarkers2(dim); if (dim_ == dim) return false; dim_ = dim; @@ -199,7 +201,6 @@ if (editing_ != editing(pi.base.bv) || macroBackup_ != macro) pi.base.bv->cursor().updateFlags(Update::Force); } - drawMarkers2(pi, x, y); } PGP.sig Description: Signierter Teil der Nachricht