mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 18:24:48 +00:00
89662a6852
The goal of this patch is to be able to properly remove the space
needed for markers in the case of insets that are inside macros and do
not need these markers. This was attempted at 9a9a6a8
, but did not
work reliably.
To this end, the following simplifications are made:
* instead of drawing its own markers, each inset has a virtual method
marker() which prescribes either NO_MARKER, MARKER (normal bottom
marker) or MARKER2 (top and bottom marker). All explicit calls to
(draw|metrics)Markers(|2) are removed.
* the space necessary for the markers is now counted in the
before/above margins in the row structure. Therefore painting will
not happen at (x + 1, y), but just (x,y).
* the methods drawDecoration are removed.
* the helper methods InsetMath::(draw|metrics)Markers(|2) are removed
and replaced by a new function drawMarkers in MathRow.cpp.
Now the marker type is kept in the MathRow::Element object (and set to
NO_MARKER in not editable context) and the marker is accounted for in
MathRow::(metrics|draw).
Moreover, the extra pixel for the marker is taken on the before/After
space if possible. The marker will only require extra space when
before/after is 0.
See comment 168 of #8883 to understand what issues are fixed.
75 lines
1.3 KiB
C++
75 lines
1.3 KiB
C++
/**
|
|
* \file InsetMathEnv.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author André Pönitz
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "InsetMathEnv.h"
|
|
|
|
#include "MathData.h"
|
|
#include "MathStream.h"
|
|
#include "MathStream.h"
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
#include "support/gettext.h"
|
|
#include "support/lstrings.h"
|
|
|
|
#include <ostream>
|
|
|
|
using namespace lyx::support;
|
|
|
|
namespace lyx {
|
|
|
|
InsetMathEnv::InsetMathEnv(Buffer * buf, docstring const & name)
|
|
: InsetMathNest(buf, 1), name_(name)
|
|
{}
|
|
|
|
|
|
Inset * InsetMathEnv::clone() const
|
|
{
|
|
return new InsetMathEnv(*this);
|
|
}
|
|
|
|
|
|
void InsetMathEnv::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
{
|
|
Changer dummy = mi.base.changeEnsureMath();
|
|
cell(0).metrics(mi, dim);
|
|
}
|
|
|
|
|
|
void InsetMathEnv::draw(PainterInfo & pi, int x, int y) const
|
|
{
|
|
Changer dummy = pi.base.changeEnsureMath();
|
|
cell(0).draw(pi, x, y);
|
|
}
|
|
|
|
|
|
void InsetMathEnv::write(WriteStream & os) const
|
|
{
|
|
MathEnsurer ensurer(os);
|
|
os << "\\begin{" << name_ << '}' << cell(0) << "\\end{" << name_ << '}';
|
|
}
|
|
|
|
|
|
void InsetMathEnv::normalize(NormalStream & os) const
|
|
{
|
|
os << "[env " << name_ << ' ' << cell(0) << ']';
|
|
}
|
|
|
|
|
|
void InsetMathEnv::infoize(odocstream & os) const
|
|
{
|
|
os << bformat(_("Environment: %1$s"), name_);
|
|
}
|
|
|
|
|
|
} // namespace lyx
|