From 156e592636d520f04eb6dae8000ab8352c92657d Mon Sep 17 00:00:00 2001 From: twanvl Date: Thu, 11 Dec 2008 17:40:17 +0000 Subject: [PATCH] made padding and line height scriptable git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1249 0fc631ac-6414-0410-93d0-97cfa31319b6 --- doc/type/style.txt | 12 ++++++------ src/data/field/text.cpp | 17 +++++++++++++++- src/data/field/text.hpp | 43 +++++++++++++++++++++-------------------- src/gui/value/text.cpp | 2 +- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/doc/type/style.txt b/doc/type/style.txt index a9975c90..36b610b1 100644 --- a/doc/type/style.txt +++ b/doc/type/style.txt @@ -87,19 +87,19 @@ The rest of the properties depend on the type of [[type:field]] this style is fo | ^^^ @allow formating@ [[type:boolean]] @true@ Is custom formating (bold, italic) allowed? | ^^^ @alignment@ [[type:scriptable]] [[type:alignment]] @top left@ Alignment of the text. | ^^^ @direction@ [[type:direction]] @"left to right"@ Direction in which the text flows. If set to @"vertical"@ it is as if a line break is inserted after each character. -| ^^^ @padding left@ [[type:double]] @0@ Padding between the text and the border of the box, in pixels. +| ^^^ @padding left@ [[type:scriptable]] [[type:double]] @0@ Padding between the text and the border of the box, in pixels. | ^^^ @padding right@ ^^^ ^^^ ^^^ | ^^^ @padding top@ ^^^ ^^^ ^^^ | ^^^ @padding bottom@ ^^^ ^^^ ^^^ -| ^^^ @padding left min@ [[type:double]] ∞ Minimal padding around the field.
When the text is scalled down the padding is scalled as well, but it becomes no smaller than this. +| ^^^ @padding left min@ [[type:scriptable]] [[type:double]] ∞ Minimal padding around the field.
When the text is scalled down the padding is scalled as well, but it becomes no smaller than this. | ^^^ @padding right min@ ^^^ ^^^ ^^^ | ^^^ @padding top min@ ^^^ ^^^ ^^^ | ^^^ @padding bottom min@ ^^^ ^^^ ^^^ -| ^^^ @line height soft@ [[type:double]] @1@ Multiplier for the line height of 'soft' line breaks. These are breaks caused by wrapping around lines that are too long.
+| ^^^ @line height soft@ [[type:scriptable]] [[type:double]] @1@ Multiplier for the line height of 'soft' line breaks. These are breaks caused by wrapping around lines that are too long.
A line height of @0@ means all lines are in the same position, @1@ is normal behaviour, @2@ skips a line, etc. -| ^^^ @line height hard@ [[type:double]] @1@ Multiplier for the line height of 'hard' line breaks. These are breaks caused by the enter key. -| ^^^ @line height line@ [[type:double]] @1@ Multiplier for the line height of 'soft' line breaks. These are breaks caused by @"\n"@ tags. -| ^^^ @line height soft max@ [[type:double]] ''disabled'' When there is still vertical room in the text box, increase the line heights to at most these values to spread the text more evenly. +| ^^^ @line height hard@ [[type:scriptable]] [[type:double]] @1@ Multiplier for the line height of 'hard' line breaks. These are breaks caused by the enter key. +| ^^^ @line height line@ [[type:scriptable]] [[type:double]] @1@ Multiplier for the line height of 'soft' line breaks. These are breaks caused by @"\n"@ tags. +| ^^^ @line height soft max@ [[type:scriptable]] [[type:double]] ''disabled'' When there is still vertical room in the text box, increase the line heights to at most these values to spread the text more evenly. | ^^^ @line height hard max@ ^^^ ^^^ ^^^ | ^^^ @line height line max@ ^^^ ^^^ ^^^ | ^^^ @paragraph height@ [[type:double]] ''flexible'' The height of paragraphs. If specified, each paragraph is given this much space, and aligned inside that space as specified by @alignment@.
diff --git a/src/data/field/text.cpp b/src/data/field/text.cpp index 6984bbaa..2ba0adaa 100644 --- a/src/data/field/text.cpp +++ b/src/data/field/text.cpp @@ -70,7 +70,22 @@ int TextStyle::update(Context& ctx) { return Style ::update(ctx) | font .update(ctx) * CHANGE_OTHER | symbol_font.update(ctx) * CHANGE_OTHER - | alignment .update(ctx) * CHANGE_OTHER; + | alignment .update(ctx) * CHANGE_OTHER + | ( padding_left .update(ctx) + | padding_left_min .update(ctx) + | padding_right .update(ctx) + | padding_right_min .update(ctx) + | padding_top .update(ctx) + | padding_top_min .update(ctx) + | padding_bottom .update(ctx) + | padding_bottom_min .update(ctx) + | line_height_soft .update(ctx) + | line_height_hard .update(ctx) + | line_height_line .update(ctx) + | line_height_soft_max.update(ctx) + | line_height_hard_max.update(ctx) + | line_height_line_max.update(ctx) + ) * CHANGE_OTHER; } void TextStyle::initDependencies(Context& ctx, const Dependency& dep) const { Style ::initDependencies(ctx, dep); diff --git a/src/data/field/text.hpp b/src/data/field/text.hpp index 82382d4f..0e3b0ba0 100644 --- a/src/data/field/text.hpp +++ b/src/data/field/text.hpp @@ -51,26 +51,27 @@ class TextStyle : public Style { TextStyle(const TextFieldP&); DECLARE_STYLE_TYPE(Text); - Font font; ///< Font to use for the text - SymbolFontRef symbol_font; ///< Symbol font for symbols in the text - bool always_symbol; ///< Should everything be drawn as symbols? - bool allow_formating; ///< Is formating (bold/italic/..) allowed? - Scriptable alignment; ///< Alignment inside the box - double padding_left, padding_left_min; ///< Padding - double padding_right, padding_right_min; ///< Padding - double padding_top, padding_top_min; ///< Padding - double padding_bottom, padding_bottom_min; ///< Padding - double line_height_soft; ///< Line height for soft linebreaks - double line_height_hard; ///< Line height for hard linebreaks - double line_height_line; ///< Line height for tags - double line_height_soft_max; ///< Maximum line height - double line_height_hard_max; ///< Maximum line height - double line_height_line_max; ///< Maximum line height - double paragraph_height; ///< Fixed height of paragraphs - Direction direction; ///< In what direction is text layed out? + Font font; ///< Font to use for the text + SymbolFontRef symbol_font; ///< Symbol font for symbols in the text + bool always_symbol; ///< Should everything be drawn as symbols? + bool allow_formating; ///< Is formating (bold/italic/..) allowed? + Scriptable alignment; ///< Alignment inside the box + Scriptable + padding_left, padding_left_min, ///< Padding + padding_right, padding_right_min, ///< Padding + padding_top, padding_top_min, ///< Padding + padding_bottom, padding_bottom_min, ///< Padding + line_height_soft, ///< Line height for soft linebreaks + line_height_hard, ///< Line height for hard linebreaks + line_height_line, ///< Line height for tags + line_height_soft_max, ///< Maximum line height + line_height_hard_max, ///< Maximum line height + line_height_line_max, ///< Maximum line height + paragraph_height; ///< Fixed height of paragraphs + Direction direction; ///< In what direction is text layed out? // information from text rendering - double content_width, content_height; ///< Size of the rendered text - int content_lines; ///< Number of rendered lines + double content_width, content_height; ///< Size of the rendered text + int content_lines; ///< Number of rendered lines virtual int update(Context&); virtual void initDependencies(Context&, const Dependency&) const; @@ -88,8 +89,8 @@ class TextValue : public Value { inline TextValue(const TextFieldP& field) : Value(field), last_update(1) {} DECLARE_VALUE_TYPE(Text, Defaultable); - ValueType value; ///< The text of this value - Age last_update; ///< When was the text last changed? + ValueType value; ///< The text of this value + Age last_update; ///< When was the text last changed? virtual bool update(Context&); }; diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index 91ce0ec9..9f320a72 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -322,7 +322,7 @@ IMPLEMENT_VALUE_EDITOR(Text) { if (viewer.nativeLook() && field().multi_line) { scrollbar = new TextValueEditorScrollBar(*this); - style->padding_right = max(style->padding_right, (double)scrollbar->GetSize().x); + style->padding_right = max(style->padding_right(), (double)scrollbar->GetSize().x); } }