mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 16:52:02 +00:00
Make graĥics and external insets tighter
Now RenderGraphics adds offsets that depends on its parent inset. These offsets are set to 0 for InsetGraphics and InsetExternal. A nice consequence is that icons shown by Info inset stick out less on screen. As an unrelated change, the "private:" specifier of these two insets is moved to a more reasonable place.
This commit is contained in:
parent
7d3d07ff40
commit
ba79a4b89e
@ -120,13 +120,20 @@ public:
|
|||||||
///
|
///
|
||||||
void addToToc(DocIterator const & di, bool output_active,
|
void addToToc(DocIterator const & di, bool output_active,
|
||||||
UpdateType utype, TocBackend & backend) const;
|
UpdateType utype, TocBackend & backend) const;
|
||||||
private:
|
|
||||||
///
|
|
||||||
InsetExternal(InsetExternal const &);
|
|
||||||
///
|
///
|
||||||
InsetCode lyxCode() const { return EXTERNAL_CODE; }
|
InsetCode lyxCode() const { return EXTERNAL_CODE; }
|
||||||
///
|
///
|
||||||
bool hasSettings() const { return true; }
|
bool hasSettings() const { return true; }
|
||||||
|
|
||||||
|
///
|
||||||
|
int topOffset(BufferView const *) const { return 0; }
|
||||||
|
///
|
||||||
|
int bottomOffset(BufferView const *) const { return 0; }
|
||||||
|
///
|
||||||
|
int leftOffset(BufferView const *) const { return 0; }
|
||||||
|
///
|
||||||
|
int rightOffset(BufferView const *) const { return 0; }
|
||||||
|
|
||||||
///
|
///
|
||||||
void metrics(MetricsInfo &, Dimension &) const;
|
void metrics(MetricsInfo &, Dimension &) const;
|
||||||
///
|
///
|
||||||
@ -159,6 +166,11 @@ private:
|
|||||||
* and the preview should be regenerated.
|
* and the preview should be regenerated.
|
||||||
*/
|
*/
|
||||||
void fileChanged() const;
|
void fileChanged() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
InsetExternal(InsetExternal const &);
|
||||||
|
|
||||||
/// Is this inset using (instant or graphics) preview?
|
/// Is this inset using (instant or graphics) preview?
|
||||||
bool isPreviewed() const;
|
bool isPreviewed() const;
|
||||||
/// Do we have the right renderer (button, graphic or monitored preview)?
|
/// Do we have the right renderer (button, graphic or monitored preview)?
|
||||||
|
@ -61,13 +61,8 @@ public:
|
|||||||
///
|
///
|
||||||
InsetGraphics const * asInsetGraphics() const { return this; }
|
InsetGraphics const * asInsetGraphics() const { return this; }
|
||||||
|
|
||||||
private:
|
|
||||||
///
|
|
||||||
InsetGraphics(InsetGraphics const &);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
bool isLabeled() const { return true; }
|
bool isLabeled() const { return true; }
|
||||||
void metrics(MetricsInfo &, Dimension &) const;
|
|
||||||
///
|
///
|
||||||
bool hasSettings() const { return true; }
|
bool hasSettings() const { return true; }
|
||||||
///
|
///
|
||||||
@ -96,6 +91,18 @@ private:
|
|||||||
docstring layoutName() const { return from_ascii("Graphics"); }
|
docstring layoutName() const { return from_ascii("Graphics"); }
|
||||||
/// Get the inset parameters, used by the GUIndependent dialog.
|
/// Get the inset parameters, used by the GUIndependent dialog.
|
||||||
InsetGraphicsParams const & params() const;
|
InsetGraphicsParams const & params() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
int topOffset(BufferView const *) const { return 0; }
|
||||||
|
///
|
||||||
|
int bottomOffset(BufferView const *) const { return 0; }
|
||||||
|
///
|
||||||
|
int leftOffset(BufferView const *) const { return 0; }
|
||||||
|
///
|
||||||
|
int rightOffset(BufferView const *) const { return 0; }
|
||||||
|
|
||||||
|
///
|
||||||
|
void metrics(MetricsInfo &, Dimension &) const;
|
||||||
///
|
///
|
||||||
void draw(PainterInfo & pi, int x, int y) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
///
|
///
|
||||||
@ -136,6 +143,10 @@ private:
|
|||||||
///
|
///
|
||||||
OutputParams::CtObject CtObject(OutputParams const &) const { return OutputParams::CT_OBJECT; }
|
OutputParams::CtObject CtObject(OutputParams const &) const { return OutputParams::CT_OBJECT; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
InsetGraphics(InsetGraphics const &);
|
||||||
|
|
||||||
///
|
///
|
||||||
InsetGraphicsParams params_;
|
InsetGraphicsParams params_;
|
||||||
/// holds the entity name that defines the graphics location (SGML).
|
/// holds the entity name that defines the graphics location (SGML).
|
||||||
|
@ -36,14 +36,14 @@ namespace lyx {
|
|||||||
|
|
||||||
|
|
||||||
RenderGraphic::RenderGraphic(Inset const * inset)
|
RenderGraphic::RenderGraphic(Inset const * inset)
|
||||||
: loader_(inset->buffer().fileName())
|
: inset_(inset), loader_(inset->buffer().fileName())
|
||||||
{
|
{
|
||||||
loader_.connect(bind(&Inset::updateFrontend, inset));
|
loader_.connect(bind(&Inset::updateFrontend, inset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RenderGraphic::RenderGraphic(RenderGraphic const & other, Inset const * inset)
|
RenderGraphic::RenderGraphic(RenderGraphic const & other, Inset const * inset)
|
||||||
: RenderBase(other), loader_(other.loader_), params_(other.params_)
|
: RenderBase(other), inset_(inset), loader_(other.loader_), params_(other.params_)
|
||||||
{
|
{
|
||||||
loader_.connect(bind(&Inset::updateFrontend, inset));
|
loader_.connect(bind(&Inset::updateFrontend, inset));
|
||||||
}
|
}
|
||||||
@ -147,7 +147,8 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
|
|
||||||
bool const image_ready = displayGraphic(params_) && readyToDisplay(loader_);
|
bool const image_ready = displayGraphic(params_) && readyToDisplay(loader_);
|
||||||
if (image_ready) {
|
if (image_ready) {
|
||||||
dim.wid = loader_.image()->width() + 2 * Inset::textOffset(mi.base.bv);
|
dim.wid = loader_.image()->width() + inset_->leftOffset(mi.base.bv)
|
||||||
|
+ inset_->rightOffset(mi.base.bv);
|
||||||
dim.asc = loader_.image()->height();
|
dim.asc = loader_.image()->height();
|
||||||
dim_ = dim;
|
dim_ = dim;
|
||||||
return;
|
return;
|
||||||
@ -190,9 +191,9 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
|
|||||||
{
|
{
|
||||||
// This will draw the graphics. If the graphics has not been
|
// This will draw the graphics. If the graphics has not been
|
||||||
// loaded yet, we draw just a rectangle.
|
// loaded yet, we draw just a rectangle.
|
||||||
int const x1 = x + Inset::textOffset(pi.base.bv);
|
int const x1 = x + inset_->leftOffset(pi.base.bv);
|
||||||
int const y1 = y - dim_.asc;
|
int const y1 = y - dim_.asc;
|
||||||
int const w = dim_.wid - 2 * Inset::textOffset(pi.base.bv);
|
int const w = dim_.wid - inset_->leftOffset(pi.base.bv) - inset_->rightOffset(pi.base.bv);
|
||||||
int const h = dim_.height();
|
int const h = dim_.height();
|
||||||
|
|
||||||
if (displayGraphic(params_) && readyToDisplay(loader_))
|
if (displayGraphic(params_) && readyToDisplay(loader_))
|
||||||
|
@ -45,6 +45,9 @@ private:
|
|||||||
/// Not implemented.
|
/// Not implemented.
|
||||||
RenderGraphic & operator=(RenderGraphic const &);
|
RenderGraphic & operator=(RenderGraphic const &);
|
||||||
|
|
||||||
|
/// Reference to owner
|
||||||
|
Inset const * inset_;
|
||||||
|
|
||||||
/// The stored data.
|
/// The stored data.
|
||||||
graphics::Loader loader_;
|
graphics::Loader loader_;
|
||||||
graphics::Params params_;
|
graphics::Params params_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user