Jean-Marc Lasgouttes wrote:
>> I'm fine with anything which allows me to create branches like "green-text
>> emphasized" or "blue-footnotes" without need to embed such constructs into
>> each of branch insets and both of the proposals seems to provide this. I'm
>> not expert in the layout machinery to see what is more elegant, though 1)
>> looks less work. If you are concerned about UI level only, we wouldn't
>> define Branch Allow 1 for our generic insets...
>
> I think that 2/ would already work, except that our code probably takes too
> many shortcuts. In principle, our InsetLayout mechanism allows for that. It
> would be interesting to try it out.
I'm surprised that only slight touch was enough to get margin-like branch. Even
latex export works correctly. Richard does this change involve layout format
increment?
Pavel
diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc
index faa6d1c..9999628 100644
--- a/lib/layouts/stdinsets.inc
+++ b/lib/layouts/stdinsets.inc
@@ -465,3 +465,11 @@ InsetLayout Preview
Decoration minimalistic
MultiPar true
End
+
+InsetLayout Branch:test
+ LabelString Brancc
+ Decoration minimalistic
+ MultiPar true
+ LatexType command
+ LatexName marginpar
+End
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 82740cb..416a97b 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -667,6 +667,7 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc,
ReadType rt)
break;
}
docstring const name = subst(lexrc.getDocString(), '_',
' ');
+ lyxerr<<"name: "<<name<<"\n";
if (name.empty()) {
string s = "Could not read name for
InsetLayout: `$$Token' "
+ lexrc.getString() + " is probably not
valid UTF-8!";
diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp
index 6ab2fb7..07d3985 100644
--- a/src/insets/InsetBranch.cpp
+++ b/src/insets/InsetBranch.cpp
@@ -318,6 +318,25 @@ void InsetBranch::addToToc(DocIterator const & cpit) const
}
+bool InsetBranch::hasSpecificLayout() const
+{
+ return buffer_ &&
buffer().params().documentClass().hasInsetLayout(branch());
+}
+
+
+InsetLayout const & InsetBranch::getLayout() const
+{
+ if (!buffer_)
+ return DocumentClass::plainInsetLayout();
+
+ DocumentClass const & dc = buffer().params().documentClass();
+ docstring const dname = branch();
+ if (dc.hasInsetLayout(dname))
+ return dc.insetLayout(dname);
+ return dc.insetLayout(from_utf8("Branch:") + branch());
+}
+
+
void InsetBranchParams::write(ostream & os) const
{
os << to_utf8(branch);
@@ -330,4 +349,5 @@ void InsetBranchParams::read(Lexer & lex)
branch = lex.getDocString();
}
+
} // namespace lyx
diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h
index 64029c0..ef17e82 100644
--- a/src/insets/InsetBranch.h
+++ b/src/insets/InsetBranch.h
@@ -109,9 +109,13 @@ private:
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///
- docstring layoutName() const { return from_ascii("Branch"); }
+ docstring layoutName() const { return from_ascii("Branch:") + branch();
}
///
Inset * clone() const { return new InsetBranch(*this); }
+ ///
+ InsetLayout const & getLayout() const;
+ /// User defined layout for specific branch
+ bool hasSpecificLayout() const;
///
friend class InsetBranchParams;