commit 7efdbeaddf22602334f7d109b3c88a9274a44988
Author: Juergen Spitzmueller <[email protected]>
Date: Mon Jun 13 13:22:58 2022 +0200
Better UI for captions outside floats (#12554)
---
src/insets/InsetCaption.cpp | 25 ++++++++++++++++++++-----
src/insets/InsetCaption.h | 4 ++++
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp
index 5373210..8e415bb 100644
--- a/src/insets/InsetCaption.cpp
+++ b/src/insets/InsetCaption.cpp
@@ -149,7 +149,10 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y)
const
rtl_ = !pi.ltr_pos;
FontInfo tmpfont = pi.base.font;
- pi.base.font.setColor(pi.textColor(pi.base.font.color()).baseColor);
+ if (non_float_)
+ pi.base.font.setColor(Color_error);
+ else
+
pi.base.font.setColor(pi.textColor(pi.base.font.color()).baseColor);
if (is_deleted_)
pi.base.font.setStrikeout(FONT_ON);
else if (isChanged() && lyxrc.ct_additions_underlined)
@@ -324,6 +327,16 @@ docstring InsetCaption::xhtml(XMLStream & xs, OutputParams
const & rp) const
}
+docstring InsetCaption::toolTip(BufferView const & bv, int x, int y) const
+{
+ if (non_float_)
+ return _("Standard captions are not allowed outside floats. You
will get a LaTeX error.\n"
+ "For captions outside floats, please use the module
'Non-Floating Figures and Tables' "
+ "from Document > Settings > Modules.");
+ return InsetText::toolTip(bv, x, y);
+}
+
+
void InsetCaption::getArgument(otexstream & os,
OutputParams const & runparams) const
{
@@ -365,7 +378,7 @@ int InsetCaption::getCaptionAsPlaintext(odocstream & os,
void InsetCaption::getCaptionAsDocBook(XMLStream & xs,
-
OutputParams const & runparams) const
+ OutputParams const & runparams) const
{
if (runparams.docbook_in_float)
return;
@@ -400,9 +413,10 @@ void InsetCaption::updateBuffer(ParIterator const & it,
UpdateType utype, bool c
is_deleted_ = deleted;
// Memorize type for addToToc().
floattype_ = type;
- if (type.empty() || type == "senseless")
- full_label_ = master.B_("Senseless!!! ");
- else {
+ if (type.empty() || type == "senseless") {
+ full_label_ = master.B_("Orphaned caption:");
+ non_float_ = true;
+ } else {
// FIXME: life would be _much_ simpler if listings was
// listed in Floating.
docstring name;
@@ -441,6 +455,7 @@ void InsetCaption::updateBuffer(ParIterator const & it,
UpdateType utype, bool c
if (sec.empty())
sec = from_ascii("#");
full_label_ = bformat(master.B_("%1$s %2$s: [[Caption label
(ex. Figure 1: )]]"), name, sec);
+ non_float_ = false;
}
// Do the real work now.
diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h
index c1bcd17..8d62470 100644
--- a/src/insets/InsetCaption.h
+++ b/src/insets/InsetCaption.h
@@ -85,6 +85,8 @@ private:
void addToToc(DocIterator const & di, bool output_active, UpdateType
utype,
TocBackend & backend) const override;
///
+ docstring toolTip(BufferView const & bv, int x, int y) const override;
+ ///
bool forcePlainLayout(idx_type = 0) const override { return true; }
/// Captions don't accept alignment, spacing, etc.
bool allowParagraphCustomization(idx_type = 0) const override { return
false; }
@@ -104,6 +106,8 @@ private:
///
bool is_deleted_ = false;
///
+ bool non_float_ = false;
+ ///
std::string type_;
};
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs