mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Further inset configurability, moving charstyle stuff to collapsable
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19640 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f91f682ef9
commit
3c504502bf
@ -1,6 +1,11 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2007-08-17 Martin Vermeer
|
||||
|
||||
* format incremented to 280: the show_label parameter
|
||||
is depreciated in favour of (Collapsable) status.
|
||||
|
||||
2007-08-17 Martin Vermeer
|
||||
|
||||
* format incremented to 279: CharStyle names are now
|
||||
|
@ -78,7 +78,7 @@ format_relation = [("0_06", [200], generate_minor_versions("0.6" , 4)),
|
||||
("1_3", [221], generate_minor_versions("1.3" , 7)),
|
||||
("1_4", range(222,246), generate_minor_versions("1.4" , 5)),
|
||||
("1_5", range(246,277), generate_minor_versions("1.5" , 1)),
|
||||
("1_6", range(277,280), generate_minor_versions("1.6" , 0))]
|
||||
("1_6", range(277,281), generate_minor_versions("1.6" , 0))]
|
||||
|
||||
|
||||
def formats_list():
|
||||
|
@ -105,6 +105,45 @@ def revert_long_charstyle_names(document):
|
||||
i += 1
|
||||
|
||||
|
||||
def axe_show_label(document):
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset CharStyle", i)
|
||||
if i == -1:
|
||||
return
|
||||
if document.body[i + 1].find("show_label") != -1:
|
||||
if document.body[i + 1].find("true") != -1:
|
||||
document.body[i + 1] = "status open"
|
||||
del document.body[ i + 2]
|
||||
else:
|
||||
if document.body[i + 1].find("false") != -1:
|
||||
document.body[i + 1] = "status collapsed"
|
||||
del document.body[ i + 2]
|
||||
else:
|
||||
document.warning("Malformed LyX document: show_label neither false nor true.")
|
||||
else:
|
||||
document.warning("Malformed LyX document: show_label missing in CharStyle.")
|
||||
|
||||
i += 1
|
||||
|
||||
|
||||
def revert_show_label(document):
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset CharStyle", i)
|
||||
if i == -1:
|
||||
return
|
||||
if document.body[i + 1].find("status open") != -1:
|
||||
document.body.insert(i + 1, "show_label true")
|
||||
else:
|
||||
if document.body[i + 1].find("status collapsed") != -1:
|
||||
document.body.insert(i + 1, "show_label false")
|
||||
else:
|
||||
document.warning("Malformed LyX document: no legal status line in CharStyle.")
|
||||
i += 1
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -113,10 +152,12 @@ supported_versions = ["1.6.0","1.6"]
|
||||
convert = [
|
||||
[277, [fix_wrong_tables]],
|
||||
[278, [close_begin_deeper]],
|
||||
[279, [long_charstyle_names]]
|
||||
[279, [long_charstyle_names]],
|
||||
[280, [axe_show_label]]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[279, [revert_show_label]],
|
||||
[278, [revert_long_charstyle_names]],
|
||||
[277, []],
|
||||
[276, []]
|
||||
|
@ -137,7 +137,7 @@ namespace fs = boost::filesystem;
|
||||
|
||||
namespace {
|
||||
|
||||
int const LYX_FORMAT = 279;
|
||||
int const LYX_FORMAT = 280;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
@ -50,13 +50,11 @@ using std::ostringstream;
|
||||
|
||||
|
||||
void InsetCharStyle::init()
|
||||
{
|
||||
setDrawFrame(false);
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
InsetCharStyle::InsetCharStyle(BufferParams const & bp, string const s)
|
||||
: InsetCollapsable(bp)
|
||||
: InsetCollapsable(bp, Collapsed)
|
||||
{
|
||||
params_.type = s;
|
||||
setUndefined();
|
||||
@ -66,7 +64,7 @@ InsetCharStyle::InsetCharStyle(BufferParams const & bp, string const s)
|
||||
|
||||
InsetCharStyle::InsetCharStyle(BufferParams const & bp,
|
||||
CharStyles::iterator cs)
|
||||
: InsetCollapsable(bp)
|
||||
: InsetCollapsable(bp, Collapsed)
|
||||
{
|
||||
params_.type = cs->name;
|
||||
setDefined(cs);
|
||||
@ -101,7 +99,6 @@ void InsetCharStyle::setUndefined()
|
||||
params_.font = Font(Font::ALL_INHERIT);
|
||||
params_.labelfont = Font(Font::ALL_INHERIT);
|
||||
params_.labelfont.setColor(Color::error);
|
||||
params_.show_label = true;
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +109,6 @@ void InsetCharStyle::setDefined(CharStyles::iterator cs)
|
||||
params_.latexparam = cs->latexparam;
|
||||
params_.font = cs->font;
|
||||
params_.labelfont = cs->labelfont;
|
||||
params_.show_label = true;
|
||||
}
|
||||
|
||||
|
||||
@ -145,7 +141,7 @@ bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
|
||||
InsetText::metrics(mi, dim);
|
||||
mi.base.font = tmpfont;
|
||||
if (params_.show_label) {
|
||||
if (status() == Open) {
|
||||
// consider width of the inset label
|
||||
Font font(params_.labelfont);
|
||||
font.realize(Font(Font::ALL_SANE));
|
||||
@ -168,9 +164,13 @@ bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.des += TEXT_TO_INSET_OFFSET;
|
||||
dim.wid += 2 * TEXT_TO_INSET_OFFSET;
|
||||
mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
|
||||
if (params_.show_label)
|
||||
if (status() == Open)
|
||||
dim.des += ascent();
|
||||
bool const changed = dim_ != dim;
|
||||
else {
|
||||
dim.des -= 3;
|
||||
dim.asc -= 3;
|
||||
}
|
||||
bool const changed = dim_ != dim;
|
||||
dim_ = dim;
|
||||
return changed;
|
||||
}
|
||||
@ -184,12 +184,14 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
|
||||
getDrawFont(pi.base.font);
|
||||
// I don't understand why the above .reduce and .realize aren't
|
||||
//needed, or even wanted, here. It just works. -- MV 10.04.2005
|
||||
InsetText::draw(pi, x + TEXT_TO_INSET_OFFSET, y);
|
||||
InsetCollapsable::draw(pi, x, y);
|
||||
pi.base.font = tmpfont;
|
||||
|
||||
int desc = InsetText::descent();
|
||||
if (params_.show_label)
|
||||
if (status() == Open)
|
||||
desc -= ascent();
|
||||
else
|
||||
desc -= 3;
|
||||
|
||||
pi.pain.line(x, y + desc - 4, x, y + desc, params_.labelfont.color());
|
||||
pi.pain.line(x, y + desc, x + dim_.wid - 3, y + desc,
|
||||
@ -198,7 +200,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
|
||||
params_.labelfont.color());
|
||||
|
||||
// the name of the charstyle. Can be toggled.
|
||||
if (params_.show_label) {
|
||||
if (status() == Open) {
|
||||
Font font(params_.labelfont);
|
||||
font.realize(Font(Font::ALL_SANE));
|
||||
font.decSize();
|
||||
@ -218,10 +220,11 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
|
||||
s, font, Color::none, Color::none);
|
||||
}
|
||||
|
||||
// a visual clue when the cursor is inside the inset
|
||||
// a visual cue when the cursor is inside the inset
|
||||
Cursor & cur = pi.base.bv->cursor();
|
||||
if (cur.isInside(this)) {
|
||||
y -= ascent();
|
||||
y += 3;
|
||||
pi.pain.line(x, y + 4, x, y, params_.labelfont.color());
|
||||
pi.pain.line(x + 4, y, x, y, params_.labelfont.color());
|
||||
pi.pain.line(x + dim_.wid - 3, y + 4, x + dim_.wid - 3, y,
|
||||
@ -244,18 +247,24 @@ void InsetCharStyle::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.button() == mouse_button::button3)
|
||||
params_.show_label = !params_.show_label;
|
||||
if (status() == Open)
|
||||
setStatus(cur, Collapsed);
|
||||
else
|
||||
setStatus(cur, Open);
|
||||
else
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
break;
|
||||
|
||||
case LFUN_INSET_TOGGLE:
|
||||
if (cmd.argument() == "open")
|
||||
params_.show_label = true;
|
||||
setStatus(cur, Open);
|
||||
else if (cmd.argument() == "close")
|
||||
params_.show_label = false;
|
||||
setStatus(cur, Collapsed);
|
||||
else if (cmd.argument() == "toggle" || cmd.argument().empty())
|
||||
params_.show_label = !params_.show_label;
|
||||
if (status() == Open)
|
||||
setStatus(cur, Collapsed);
|
||||
else
|
||||
setStatus(cur, Open);
|
||||
else // if assign or anything else
|
||||
cur.undispatched();
|
||||
cur.dispatched();
|
||||
@ -351,7 +360,6 @@ void InsetCharStyle::validate(LaTeXFeatures & features) const
|
||||
void InsetCharStyleParams::write(ostream & os) const
|
||||
{
|
||||
os << "CharStyle " << type << "\n";
|
||||
os << "show_label " << convert<string>(show_label) << "\n";
|
||||
}
|
||||
|
||||
|
||||
@ -366,11 +374,7 @@ void InsetCharStyleParams::read(Lexer & lex)
|
||||
type = lex.getString();
|
||||
}
|
||||
|
||||
else if (token == "show_label") {
|
||||
lex.next();
|
||||
show_label = lex.getBool();
|
||||
}
|
||||
|
||||
// This is handled in Collapsable
|
||||
else if (token == "status") {
|
||||
lex.pushToken(token);
|
||||
break;
|
||||
|
@ -38,8 +38,6 @@ public:
|
||||
Font font;
|
||||
///
|
||||
Font labelfont;
|
||||
///
|
||||
bool show_label;
|
||||
};
|
||||
|
||||
|
||||
|
@ -228,43 +228,47 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
const int xx = x + TEXT_TO_INSET_OFFSET;
|
||||
|
||||
if (decoration() == Minimalistic) {
|
||||
InsetText::draw(pi, xx, y);
|
||||
} else {
|
||||
Dimension dimc = dimensionCollapsed();
|
||||
int const top = y - ascent() + TEXT_TO_INSET_OFFSET;
|
||||
// Draw button first -- top, left or only
|
||||
Dimension dimc = dimensionCollapsed();
|
||||
int const top = y - ascent() + TEXT_TO_INSET_OFFSET;
|
||||
if (decoration() == Classic) {
|
||||
button_dim.x1 = xx + 0;
|
||||
button_dim.x2 = xx + dimc.width();
|
||||
button_dim.y1 = top;
|
||||
button_dim.y2 = top + dimc.height();
|
||||
|
||||
pi.pain.buttonText(xx, top + dimc.asc, label, layout_.labelfont, mouse_hover_);
|
||||
}
|
||||
|
||||
int textx, texty;
|
||||
switch (geometry()) {
|
||||
case LeftButton:
|
||||
textx = xx + dimc.width();
|
||||
texty = top + textdim_.asc;
|
||||
InsetText::draw(pi, textx, texty);
|
||||
break;
|
||||
case TopButton:
|
||||
textx = xx;
|
||||
texty = top + dimc.height() + textdim_.asc;
|
||||
InsetText::draw(pi, textx, texty);
|
||||
break;
|
||||
case ButtonOnly:
|
||||
break;
|
||||
case NoButton:
|
||||
textx = xx;
|
||||
texty = top + textdim_.asc;
|
||||
InsetText::draw(pi, textx, texty);
|
||||
break;
|
||||
case SubLabel:
|
||||
case Corners:
|
||||
// FIXME add handling of SubLabel, Corners
|
||||
// still in CharStyle
|
||||
break;
|
||||
}
|
||||
int textx, texty;
|
||||
switch (geometry()) {
|
||||
case LeftButton:
|
||||
textx = xx + dimc.width();
|
||||
texty = top + textdim_.asc;
|
||||
InsetText::draw(pi, textx, texty);
|
||||
break;
|
||||
case TopButton:
|
||||
textx = xx;
|
||||
texty = top + dimc.height() + textdim_.asc;
|
||||
InsetText::draw(pi, textx, texty);
|
||||
break;
|
||||
case ButtonOnly:
|
||||
break;
|
||||
case NoButton:
|
||||
textx = xx;
|
||||
texty = y + textdim_.asc;
|
||||
InsetText::draw(pi, textx, texty);
|
||||
break;
|
||||
case SubLabel:
|
||||
case Corners:
|
||||
// FIXME add handling of SubLabel, Corners
|
||||
// still in CharStyle
|
||||
textx = xx;
|
||||
texty = y + textdim_.asc;
|
||||
const_cast<InsetCollapsable *>(this)->setDrawFrame(false);
|
||||
InsetText::draw(pi, textx, texty);
|
||||
const_cast<InsetCollapsable *>(this)->setDrawFrame(true);
|
||||
break;
|
||||
}
|
||||
setPosCache(pi, x, y);
|
||||
}
|
||||
|
@ -184,6 +184,7 @@ void InsetNote::setButtonLabel()
|
||||
{
|
||||
docstring const label = notetranslator_loc().find(params_.type);
|
||||
setLabel(label);
|
||||
// isn't this an identity? - MV
|
||||
setLabelFont(layout_.labelfont);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user