mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
add tab
This commit is contained in:
parent
3112850acc
commit
b202de7983
@ -45,6 +45,8 @@ const int text_page_y_size = config_text.GetInt("text-page-y-size", 256);
|
|||||||
const bool text_small_caps = config_text.GetBool("text-small-caps", false);
|
const bool text_small_caps = config_text.GetBool("text-small-caps", false);
|
||||||
const float text_small_caps_scale = config_text.GetFloat("text-small-caps-scale", 0.8f);
|
const float text_small_caps_scale = config_text.GetFloat("text-small-caps-scale", 0.8f);
|
||||||
const string text_default_font = config_text.GetString("text-default-font", "");
|
const string text_default_font = config_text.GetString("text-default-font", "");
|
||||||
|
const float text_tab_width = config_text.GetFloat("text-tab-width", 5.0f);
|
||||||
|
|
||||||
|
|
||||||
// This is the decimal character number that, embedded in a string, is
|
// This is the decimal character number that, embedded in a string, is
|
||||||
// identified as the soft-hyphen character.
|
// identified as the soft-hyphen character.
|
||||||
|
@ -37,6 +37,7 @@ extern const int text_page_y_size;
|
|||||||
extern const bool text_small_caps;
|
extern const bool text_small_caps;
|
||||||
extern const float text_small_caps_scale;
|
extern const float text_small_caps_scale;
|
||||||
extern const string text_default_font;
|
extern const string text_default_font;
|
||||||
|
extern const float text_tab_width;
|
||||||
extern const int text_soft_hyphen_key;
|
extern const int text_soft_hyphen_key;
|
||||||
extern wstring *text_soft_hyphen_output;
|
extern wstring *text_soft_hyphen_output;
|
||||||
extern const float text_hyphen_ratio;
|
extern const float text_hyphen_ratio;
|
||||||
|
@ -643,11 +643,18 @@ get_frame_as_set() const {
|
|||||||
// size of the current text; if the frame was set via
|
// size of the current text; if the frame was set via
|
||||||
// set_frame_actual(), this returns the values
|
// set_frame_actual(), this returns the values
|
||||||
// actually set.
|
// actually set.
|
||||||
|
//
|
||||||
|
// If the text has no frame at all, this returns the
|
||||||
|
// dimensions of the text itself, as if the frame were
|
||||||
|
// set with a margin of 0, 0, 0, 0.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE LVecBase4f TextNode::
|
INLINE LVecBase4f TextNode::
|
||||||
get_frame_actual() const {
|
get_frame_actual() const {
|
||||||
nassertr(has_frame(), LVecBase4f(0.0, 0.0, 0.0, 0.0));
|
if (!has_frame()) {
|
||||||
if (is_frame_as_margin()) {
|
check_measure();
|
||||||
|
return LVecBase4f(_ul2d[0], _lr2d[0], _lr2d[1], _ul2d[1]);
|
||||||
|
|
||||||
|
} else if (is_frame_as_margin()) {
|
||||||
check_measure();
|
check_measure();
|
||||||
return LVecBase4f(_ul2d[0] - _frame_ul[0],
|
return LVecBase4f(_ul2d[0] - _frame_ul[0],
|
||||||
_lr2d[0] + _frame_lr[0],
|
_lr2d[0] + _frame_lr[0],
|
||||||
@ -982,6 +989,29 @@ get_draw_order() const {
|
|||||||
return _draw_order;
|
return _draw_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TextNode::set_tab_width
|
||||||
|
// Access: Published
|
||||||
|
// Description: Sets the width of each tab stop, in screen units. A
|
||||||
|
// tab character embedded in the text will advance the
|
||||||
|
// horizontal position to the next tab stop.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void TextNode::
|
||||||
|
set_tab_width(float tab_width) {
|
||||||
|
_tab_width = tab_width;
|
||||||
|
invalidate_with_measure();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TextNode::get_tab_width
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the width set via set_tab_width().
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE float TextNode::
|
||||||
|
get_tab_width() const {
|
||||||
|
return _tab_width;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextNode::set_transform
|
// Function: TextNode::set_transform
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -109,6 +109,7 @@ TextNode(const string &name) : PandaNode(name) {
|
|||||||
_shadow_offset.set(0.0f, 0.0f);
|
_shadow_offset.set(0.0f, 0.0f);
|
||||||
|
|
||||||
_draw_order = 1;
|
_draw_order = 1;
|
||||||
|
_tab_width = text_tab_width;
|
||||||
|
|
||||||
_transform = LMatrix4f::ident_mat();
|
_transform = LMatrix4f::ident_mat();
|
||||||
_coordinate_system = CS_default;
|
_coordinate_system = CS_default;
|
||||||
@ -717,8 +718,12 @@ assemble_row(wstring::iterator &si, const wstring::iterator &send,
|
|||||||
// A space is a special case.
|
// A space is a special case.
|
||||||
xpos += font->get_space_advance();
|
xpos += font->get_space_advance();
|
||||||
|
|
||||||
|
} else if (character == '\t') {
|
||||||
|
// So is a tab character.
|
||||||
|
xpos = (floor(xpos / _tab_width) + 1.0f) * _tab_width;
|
||||||
|
|
||||||
} else if (character == text_soft_hyphen_key) {
|
} else if (character == text_soft_hyphen_key) {
|
||||||
// So is the 'soft-hyphen' key character.
|
// And so is the 'soft-hyphen' key character.
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// A printable character.
|
// A printable character.
|
||||||
@ -920,8 +925,12 @@ measure_row(wstring::iterator &si, const wstring::iterator &send,
|
|||||||
// A space is a special case.
|
// A space is a special case.
|
||||||
xpos += font->get_space_advance();
|
xpos += font->get_space_advance();
|
||||||
|
|
||||||
|
} else if (character == '\t') {
|
||||||
|
// So is a tab character.
|
||||||
|
xpos = (floor(xpos / _tab_width) + 1.0f) * _tab_width;
|
||||||
|
|
||||||
} else if (character == text_soft_hyphen_key) {
|
} else if (character == text_soft_hyphen_key) {
|
||||||
// So is the 'soft-hyphen' key character.
|
// And so is the 'soft-hyphen' key character.
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// A printable character.
|
// A printable character.
|
||||||
|
@ -159,6 +159,9 @@ PUBLISHED:
|
|||||||
INLINE int set_draw_order(int draw_order);
|
INLINE int set_draw_order(int draw_order);
|
||||||
INLINE int get_draw_order() const;
|
INLINE int get_draw_order() const;
|
||||||
|
|
||||||
|
INLINE void set_tab_width(float tab_width);
|
||||||
|
INLINE float get_tab_width() const;
|
||||||
|
|
||||||
INLINE void set_transform(const LMatrix4f &transform);
|
INLINE void set_transform(const LMatrix4f &transform);
|
||||||
INLINE LMatrix4f get_transform() const;
|
INLINE LMatrix4f get_transform() const;
|
||||||
|
|
||||||
@ -338,6 +341,7 @@ private:
|
|||||||
|
|
||||||
string _bin;
|
string _bin;
|
||||||
int _draw_order;
|
int _draw_order;
|
||||||
|
float _tab_width;
|
||||||
|
|
||||||
LMatrix4f _transform;
|
LMatrix4f _transform;
|
||||||
CoordinateSystem _coordinate_system;
|
CoordinateSystem _coordinate_system;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user