From 5bf5ffb1fb3e65adb40e23388c51bf9663287d19 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 6 Mar 2006 23:26:07 +0000 Subject: [PATCH] text_wrap_mode --- panda/src/gobj/texture.cxx | 38 ++++++++++++++++++++++++++++++ panda/src/gobj/texture.h | 3 +++ panda/src/text/config_text.cxx | 3 +++ panda/src/text/config_text.h | 1 + panda/src/text/dynamicTextPage.cxx | 4 ++-- 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 58acc6fa11..339e41c4d6 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -2008,3 +2008,41 @@ operator >> (istream &in, Texture::FilterType &ft) { ft = Texture::string_filter_type(word); return in; } + +//////////////////////////////////////////////////////////////////// +// Function: Texture::WrapMode output operator +// Description: +//////////////////////////////////////////////////////////////////// +ostream & +operator << (ostream &out, Texture::WrapMode wm) { + switch (wm) { + case Texture::WM_clamp: + return out << "clamp"; + case Texture::WM_repeat: + return out << "repeat"; + case Texture::WM_mirror: + return out << "mirror"; + case Texture::WM_mirror_once: + return out << "mirror_once"; + case Texture::WM_border_color: + return out << "border_color"; + + case Texture::WM_invalid: + return out << "invalid"; + } + + return out << "(**invalid Texture::WrapMode(" << (int)wm << ")**)"; +} + +//////////////////////////////////////////////////////////////////// +// Function: Texture::WrapMode input operator +// Description: +//////////////////////////////////////////////////////////////////// +istream & +operator >> (istream &in, Texture::WrapMode &wm) { + string word; + in >> word; + + wm = Texture::string_wrap_mode(word); + return in; +} diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 88d130af15..c6f58da40b 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -414,6 +414,9 @@ private: EXPCL_PANDA ostream &operator << (ostream &out, Texture::FilterType ft); EXPCL_PANDA istream &operator >> (istream &in, Texture::FilterType &ft); +EXPCL_PANDA ostream &operator << (ostream &out, Texture::WrapMode wm); +EXPCL_PANDA istream &operator >> (istream &in, Texture::WrapMode &wm); + #include "texture.I" #endif diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index b96f88232e..521abc708e 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -171,6 +171,9 @@ ConfigVariableEnum text_minfilter ConfigVariableEnum text_magfilter ("text-magfilter", Texture::FT_linear, PRC_DESC("The default texture magfilter type for dynamic text fonts")); +ConfigVariableEnum text_wrap_mode +("text-wrap-mode", Texture::WM_border_color, + PRC_DESC("The default wrap mode for dynamic text fonts")); diff --git a/panda/src/text/config_text.h b/panda/src/text/config_text.h index ab6abd0f0b..6f2de921ca 100644 --- a/panda/src/text/config_text.h +++ b/panda/src/text/config_text.h @@ -52,6 +52,7 @@ extern ConfigVariableInt text_max_never_break; extern ConfigVariableEnum text_minfilter; extern ConfigVariableEnum text_magfilter; +extern ConfigVariableEnum text_wrap_mode; extern EXPCL_PANDA void init_libtext(); diff --git a/panda/src/text/dynamicTextPage.cxx b/panda/src/text/dynamicTextPage.cxx index a6c3460fb6..093a3e0cb0 100644 --- a/panda/src/text/dynamicTextPage.cxx +++ b/panda/src/text/dynamicTextPage.cxx @@ -53,8 +53,8 @@ DynamicTextPage(DynamicTextFont *font, int page_number) : // Clamp to an explicit invisible border, so we don't get bleeding // at the edges at all. - set_wrap_u(WM_border_color); - set_wrap_v(WM_border_color); + set_wrap_u(text_wrap_mode); + set_wrap_v(text_wrap_mode); set_border_color(Colorf(0.0f, 0.0f, 0.0f, 0.0f)); }