Richard Heck wrote:
>> 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?
>>
> Wow, that is kind of surprising, but a testament to the power of
> InsetLayout.
>
> I guess I'd like to hear other opinions about whether it's a format change.
> I'm inclined to think it is, on the ground that these sorts of layout files
> would not be readable by <=2.0.3.
I didn't mean we should backport this to 2.0.x, I was not sure whether layout
change should be involved, but looking in more detail its clear that it should.
Attaching patch which seems to do all necessary things. Please check, I'm not
way too familiar with layout machinery.
Pavel
diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index f97cd15..d39433e 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -132,6 +132,7 @@ End
\html_css_as_file 0
\html_be_strict true
\author -195340706 "Georg Baum"
+\author 5863208 "ab"
\end_header
\begin_body
@@ -13961,7 +13962,12 @@ status collapsed
\end_inset
- indicates the inset whose layout is being defined, and here there are two
+ indicates the inset whose layout is being defined, and here there are
+\change_inserted 5863208 1334489266
+three
+\change_deleted 5863208 1334489267
+two
+\change_unchanged
cases.
\end_layout
@@ -14238,6 +14244,65 @@ LyXType
\end_inset
entry, declaring which type of inset it defines.
+\change_inserted 5863208 1334489312
+
+\end_layout
+
+\begin_layout Enumerate
+
+\change_inserted 5863208 1334492248
+The layout for user specific branch is being defined.
+ In this case,
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 5863208 1334489384
+<Type>
+\end_layout
+
+\end_inset
+
+ must be of the form
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 5863208 1334489392
+Branch:<name>
+\end_layout
+
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+, where
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 5863208 1334489384
+name
+\end_layout
+
+\end_inset
+
+ may be be any valid identifier of branch defined in user's document.
+ The identifier may include spaces, but in that case the whole thing must
+ be wrapped in quotes.
+ The main purpose of this feature is to allow LaTeX wrapping around specific
+ branches as user needs.
+\change_unchanged
+
\end_layout
\begin_layout Standard
@@ -14255,6 +14320,7 @@ InsetLayout
\end_layout
\begin_layout Description
+
\change_inserted -195340706 1333913893
\begin_inset Flex Code
status collapsed
@@ -14265,7 +14331,8 @@ BabelPreamble
\end_inset
- Preamble for changing languages. See section
+ Preamble for changing languages.
+ See section
\begin_inset space ~
\end_inset
@@ -14929,22 +14996,22 @@ Branch
\end_inset
) modify this label on the fly.
-
\end_layout
\begin_layout Description
+
\change_inserted -195340706 1333913893
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
-
LangPreamble
\end_layout
\end_inset
- Language dependent preamble. See section
+ Language dependent preamble.
+ See section
\begin_inset space ~
\end_inset
@@ -14956,7 +15023,6 @@ reference "sub:I18n"
\end_inset
.
-
\end_layout
\begin_layout Description
diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx
index b349715..8f8982f 100644
--- a/lib/doc/UserGuide.lyx
+++ b/lib/doc/UserGuide.lyx
@@ -134,7 +134,7 @@ enumitem
\html_math_output 0
\html_css_as_file 0
\html_be_strict true
-\author 424524441 "rgheck"
+\author 5863208 "ab"
\author 2090807402 "usti"
\end_header
@@ -29285,6 +29285,28 @@ Inside math, the same effect can be achieved using
math macros, see the
Math
\emph default
manual.
+\change_inserted 5863208 1334492666
+
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted 5863208 1334493356
+Each type of branch is allowed to have its specific style defined in layout
+ files (e.g.
+ any branch inset can be automatically wrapped by your own LaTeX commands.).
+ For this advanced usage, please study Customization manual (in particular
+ section
+\begin_inset Quotes eld
+\end_inset
+
+Flex insets and InsetLayout
+\begin_inset Quotes erd
+\end_inset
+
+).
+\change_unchanged
+
\end_layout
\begin_layout Section
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 6eebac5..522a12f 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -132,6 +132,9 @@ import os, re, string, sys
# Incremented to format 38, 08 April 2012 by gb
# Introduce LangPreamble and BabelPreamble for InsetLayout.
+# Incremented to format 39, 15 April 2012 by sanda
+# Introduce styling of branches via "InsetLayout Branch:".
+
# Do not forget to document format change in Customization
# Manual (section "Declaring a new text class").
@@ -139,7 +142,7 @@ import os, re, string, sys
# development/tools/updatelayouts.sh script to update all
# layout files to the new format.
-currentFormat = 38
+currentFormat = 39
def usage(prog_name):
@@ -325,6 +328,10 @@ def convert(lines):
i += 1
continue
+ if format == 38:
+ i += 1
+ continue
+
if format == 37:
i += 1
continue
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 82740cb..7f793bb 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -60,7 +60,7 @@ namespace lyx {
// development/tools/updatelayouts.sh script, to update the format of
// all of our layout files.
//
-int const LAYOUT_FORMAT = 38; //gb : LangPreamble and BabelPreamble for
InsetLayout
+int const LAYOUT_FORMAT = 39; //sanda branch styling
namespace {
diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp
index 6ab2fb7..d5a2b97 100644
--- a/src/insets/InsetBranch.cpp
+++ b/src/insets/InsetBranch.cpp
@@ -318,6 +318,32 @@ 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());
+}
+
+docstring InsetBranch::layoutName() const
+{
+ if (hasSpecificLayout())
+ return from_ascii("Branch:") + branch();
+ return from_ascii("Branch");
+}
+
+
void InsetBranchParams::write(ostream & os) const
{
os << to_utf8(branch);
diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h
index 64029c0..77691b5 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;
///
Inset * clone() const { return new InsetBranch(*this); }
+ ///
+ InsetLayout const & getLayout() const;
+ /// User defined layout for specific branch
+ bool hasSpecificLayout() const;
///
friend class InsetBranchParams;