On 9/17/07, Uwe Stöhr <[EMAIL PROTECTED]> wrote: > >> I would suggest (think I did) to completely leave Idx: off, and make the > >> appearance of the button distinctive. People are curious and will click > >> if they wonder what it is, and will quickly learn. > > > > This would be an option. > > This would indeed be a solution, together with a limit for the label length > of 20 chars.
I quickly hacked something like the attached (screenshot and patch). If people like it, I can implement it seriously later on (I will be quite busy in the next two weeks, and this will have low priority). I am be happy if someone (Uwe?) can take it over. The obvious things to add may be a separate index background color, or something to the left of the box to make it look like a P shape with | meaning Index. I suspect that it would be difficult to satisfy everyone with the new look of this index inset. Cheers, Bo
<<attachment: index.png>>
Index: src/insets/RenderButton.cpp =================================================================== --- src/insets/RenderButton.cpp (revision 20333) +++ src/insets/RenderButton.cpp (working copy) @@ -23,7 +23,7 @@ RenderButton::RenderButton() - : editable_(false) + : editable_(false), type_(Regular) {} @@ -43,20 +43,37 @@ bool RenderButton::metrics(MetricsInfo &, Dimension & dim) const { Font font(Font::ALL_SANE); - font.decSize(); - frontend::FontMetrics const & fm = - theFontMetrics(font); + if (type_ == Regular) { + font.decSize(); + frontend::FontMetrics const & fm = + theFontMetrics(font); - if (editable_) - fm.buttonText(text_, dim.wid, dim.asc, dim.des); - else - fm.rectText(text_, dim.wid, dim.asc, dim.des); + if (editable_) + fm.buttonText(text_, dim.wid, dim.asc, dim.des); + else + fm.rectText(text_, dim.wid, dim.asc, dim.des); - dim.wid += 4; - if (dim_ == dim) - return false; - dim_ = dim; - return true; + dim.wid += 4; + if (dim_ == dim) + return false; + dim_ = dim; + return true; + } else if (type_ == UpperCorner) { + font.setSize(Font::SIZE_TINY); + frontend::FontMetrics const & fm = + theFontMetrics(font); + + if (editable_) + fm.buttonText(text_, dim.wid, dim.asc, dim.des); + else + fm.rectText(text_, dim.wid, dim.asc, dim.des); + + dim.wid += 2; + if (dim_ == dim) + return false; + dim_ = dim; + return true; + } } @@ -65,13 +82,22 @@ // Draw it as a box with the LaTeX text Font font(Font::ALL_SANE); font.setColor(Color::command); - font.decSize(); - - if (editable_) { - pi.pain.buttonText(x + 2, y, text_, font, renderState()); - } else { - pi.pain.rectText(x + 2, y, text_, font, - Color::commandbg, Color::commandframe); + if (type_ == Regular) { + font.decSize(); + if (editable_) { + pi.pain.buttonText(x + 2, y, text_, font, renderState()); + } else { + pi.pain.rectText(x + 2, y, text_, font, + Color::commandbg, Color::commandframe); + } + } else if (type_ == UpperCorner) { + font.setSize(Font::SIZE_TINY); + if (editable_) { + pi.pain.buttonText(x + 2, y - 8, text_, font, renderState()); + } else { + pi.pain.rectText(x + 2, y - 8, text_, font, + Color::commandbg, Color::commandframe); + } } } Index: src/insets/InsetIndex.cpp =================================================================== --- src/insets/InsetIndex.cpp (revision 20333) +++ src/insets/InsetIndex.cpp (working copy) @@ -29,14 +29,16 @@ InsetIndex::InsetIndex(InsetCommandParams const & p) : InsetCommand(p, "index") -{} +{ + setButtonType(RenderButton::UpperCorner); +} docstring const InsetIndex::getScreenLabel(Buffer const &) const { size_t const maxLabelChars = 25; - docstring label = _("Idx: ") + getParam("name"); + docstring label = getParam("name"); if (label.size() > maxLabelChars) { label.erase(maxLabelChars - 3); label += "..."; Index: src/insets/InsetCommand.h =================================================================== --- src/insets/InsetCommand.h (revision 20333) +++ src/insets/InsetCommand.h (working copy) @@ -109,7 +109,8 @@ void setParams(InsetCommandParams const &); /// This should provide the text for the button virtual docstring const getScreenLabel(Buffer const &) const = 0; - + /// + void setButtonType(RenderButton::ButtonType type) { button_.setType(type); } private: /// InsetCommandParams p_; Index: src/insets/RenderButton.h =================================================================== --- src/insets/RenderButton.h (revision 20333) +++ src/insets/RenderButton.h (working copy) @@ -23,6 +23,12 @@ class RenderButton : public RenderBase { public: + + enum ButtonType { + Regular, + UpperCorner, + }; + RenderButton(); RenderBase * clone(Inset const *) const; @@ -43,11 +49,13 @@ /// equivalent to dynamic_cast virtual RenderButton * asButton() { return this; } + void setType(ButtonType type) { type_ = type; } private: /// The stored data. docstring text_; bool editable_; Box button_box_; + ButtonType type_; };