mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Now Inset::dimension is only an access to cache
Up to now Inset::dimension was either a helper function to access CoordCache, or... something else. This created problems to properly use it. In particular, the definition of InsetText::dimension created problems for child classes. Removing this definition (actually renaming it to dimensionHelper) allows to streamline the code.
This commit is contained in:
parent
fd50fb720f
commit
8aaec85c8c
@ -2804,19 +2804,7 @@ Point BufferView::coordOffset(DocIterator const & dit) const
|
||||
}
|
||||
|
||||
// remember width for the case that sl.inset() is positioned in an RTL inset
|
||||
if (i && dit[i - 1].text()) {
|
||||
// If this Inset is inside a Text Inset, retrieve the Dimension
|
||||
// from the containing text instead of using Inset::dimension() which
|
||||
// might not be implemented.
|
||||
// FIXME (Abdel 23/09/2007): this is a bit messy because of the
|
||||
// elimination of Inset::dim_ cache. This coordOffset() method needs
|
||||
// to be rewritten in light of the new design.
|
||||
Dimension const & dim = coordCache().getInsets().dim(&sl.inset());
|
||||
lastw = dim.wid;
|
||||
} else {
|
||||
Dimension const dim = sl.inset().dimension(*this);
|
||||
lastw = dim.wid;
|
||||
}
|
||||
lastw = sl.inset().dimension(*this).wid;
|
||||
|
||||
//lyxerr << "Cursor::getPos, i: "
|
||||
// << i << " x: " << xx << " y: " << y << endl;
|
||||
|
@ -209,6 +209,9 @@ public:
|
||||
void metricsMarkers(Dimension & dim, int framesize = 1) const;
|
||||
/// add space for markers
|
||||
void metricsMarkers2(Dimension & dim, int framesize = 1) const;
|
||||
|
||||
/// last metrics computed for the inset
|
||||
Dimension const dimension(BufferView const &) const;
|
||||
/// last drawn position for 'important' insets
|
||||
int xo(BufferView const & bv) const;
|
||||
/// last drawn position for 'important' insets
|
||||
@ -218,7 +221,7 @@ public:
|
||||
///
|
||||
void setDimCache(MetricsInfo const &, Dimension const &) const;
|
||||
/// do we cover screen position x/y?
|
||||
virtual bool covers(BufferView const & bv, int x, int y) const;
|
||||
bool covers(BufferView const & bv, int x, int y) const;
|
||||
/// get the screen positions of the cursor (see note in Cursor.cpp)
|
||||
virtual void cursorPos(BufferView const & bv,
|
||||
CursorSlice const & sl, bool boundary, int & x, int & y) const;
|
||||
@ -569,8 +572,6 @@ public:
|
||||
/// reject the changes within the inset
|
||||
virtual void rejectChanges() {}
|
||||
|
||||
///
|
||||
virtual Dimension const dimension(BufferView const &) const;
|
||||
///
|
||||
virtual ColorCode backgroundColor(PainterInfo const &) const;
|
||||
///
|
||||
|
@ -258,7 +258,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
||||
view_[&bv].button_dim_.y2 = 0;
|
||||
}
|
||||
|
||||
Dimension const textdim = InsetText::dimension(bv);
|
||||
Dimension const textdim = dimensionHelper(bv);
|
||||
int const baseline = y;
|
||||
int textx, texty;
|
||||
Geometry g = geometry(bv);
|
||||
@ -366,7 +366,7 @@ void InsetCollapsable::cursorPos(BufferView const & bv,
|
||||
status_ = Open;
|
||||
|
||||
InsetText::cursorPos(bv, sl, boundary, x, y);
|
||||
Dimension const textdim = InsetText::dimension(bv);
|
||||
Dimension const textdim = dimensionHelper(bv);
|
||||
|
||||
switch (geometry(bv)) {
|
||||
case LeftButton:
|
||||
|
@ -99,9 +99,6 @@ protected:
|
||||
std::string contextMenuName() const;
|
||||
///
|
||||
bool showInsetDialog(BufferView * bv) const;
|
||||
///
|
||||
Dimension const dimension(BufferView const &) const
|
||||
{ return button_.dimension(); }
|
||||
//@}
|
||||
|
||||
protected:
|
||||
|
@ -187,7 +187,7 @@ void InsetIPADeco::draw(PainterInfo & pi, int x, int y) const
|
||||
// draw the inset marker
|
||||
drawMarkers(pi, x, y);
|
||||
|
||||
Dimension const dim = Inset::dimension(*pi.base.bv);
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
|
||||
if (params_.type == InsetIPADecoParams::Toptiebar) {
|
||||
FontInfo font(getLayout().labelfont());
|
||||
|
@ -138,14 +138,6 @@ void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
}
|
||||
|
||||
|
||||
Dimension const InsetLine::dimension(BufferView const & bv) const
|
||||
{
|
||||
// We cannot use InsetCommand::dimension() as this returns the dimension
|
||||
// of the button, which is not used here.
|
||||
return Inset::dimension(bv);
|
||||
}
|
||||
|
||||
|
||||
void InsetLine::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
|
@ -41,7 +41,6 @@ private:
|
||||
/// Inset inherited methods.
|
||||
//@{
|
||||
InsetCode lyxCode() const { return LINE_CODE; }
|
||||
Dimension const dimension(BufferView const &) const;
|
||||
int docbook(odocstream &, OutputParams const &) const;
|
||||
/// Does nothing at the moment.
|
||||
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
||||
|
@ -157,7 +157,7 @@ void InsetPhantom::draw(PainterInfo & pi, int x, int y) const
|
||||
ColorCode const origcol = pi.base.font.color();
|
||||
pi.base.font.setColor(Color_special);
|
||||
pi.base.font.setColor(origcol);
|
||||
Dimension const dim = Inset::dimension(*pi.base.bv);
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
|
||||
if (params_.type == InsetPhantomParams::Phantom ||
|
||||
params_.type == InsetPhantomParams::VPhantom) {
|
||||
|
@ -137,7 +137,7 @@ void InsetText::clear()
|
||||
}
|
||||
|
||||
|
||||
Dimension const InsetText::dimension(BufferView const & bv) const
|
||||
Dimension const InsetText::dimensionHelper(BufferView const & bv) const
|
||||
{
|
||||
TextMetrics const & tm = bv.textMetrics(&text_);
|
||||
Dimension dim = tm.dimension();
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
void setBuffer(Buffer &);
|
||||
|
||||
///
|
||||
Dimension const dimension(BufferView const &) const;
|
||||
Dimension const dimensionHelper(BufferView const &) const;
|
||||
|
||||
/// empty inset to empty par
|
||||
void clear();
|
||||
|
Loading…
Reference in New Issue
Block a user