|
@@ -13,29 +13,32 @@ TypeHandle GuiLabel::_type_handle;
|
|
|
|
|
|
|
|
void GuiLabel::recompute_transform(void) {
|
|
void GuiLabel::recompute_transform(void) {
|
|
|
this->freeze();
|
|
this->freeze();
|
|
|
-
|
|
|
|
|
/*
|
|
/*
|
|
|
- LMatrix4f mat = LMatrix4f::scale_mat(LVector3f::rfu(_scale_x, _scale_y,
|
|
|
|
|
- _scale_z)) *
|
|
|
|
|
- LMatrix4f::scale_mat(_scale) *
|
|
|
|
|
- LMatrix4f::scale_mat(LVector3f::rfu((_mirror_x?-1.0f:1.0f), 1.0f,
|
|
|
|
|
- (_mirror_y?-1.0f:1.0f))) *
|
|
|
|
|
- LMatrix4f::translate_mat(_pos);
|
|
|
|
|
-*/
|
|
|
|
|
|
|
+ LMatrix4f mat = LMatrix4f::scale_mat(LVector3f::rfu(_scale_x, _scale_y,
|
|
|
|
|
+ _scale_z)) *
|
|
|
|
|
+ LMatrix4f::scale_mat(_scale) *
|
|
|
|
|
+ LMatrix4f::scale_mat(LVector3f::rfu((_mirror_x?-1.0f:1.0f), 1.0f,
|
|
|
|
|
+ (_mirror_y?-1.0f:1.0f))) *
|
|
|
|
|
+ LMatrix4f::translate_mat(_pos);
|
|
|
|
|
+*/
|
|
|
// optimize the above calculation
|
|
// optimize the above calculation
|
|
|
- LVector3f scalevec1 = LVector3f::rfu(_scale_x*_scale, _scale_y*_scale, _scale_z*_scale);
|
|
|
|
|
- LVector3f scalevec2 = LVector3f::rfu((_mirror_x?-1.0f:1.0f),
|
|
|
|
|
- 1.0f,
|
|
|
|
|
- (_mirror_y?-1.0f:1.0f));
|
|
|
|
|
-
|
|
|
|
|
- scalevec1._v.v._0 *= scalevec2._v.v._0;
|
|
|
|
|
- scalevec1._v.v._1 *= scalevec2._v.v._1;
|
|
|
|
|
- scalevec1._v.v._2 *= scalevec2._v.v._2;
|
|
|
|
|
|
|
|
|
|
- LMatrix4f mat(scalevec1._v.v._0, 0.0f, 0.0f, 0.0f,
|
|
|
|
|
- 0.0f, scalevec1._v.v._1, 0.0f, 0.0f,
|
|
|
|
|
- 0.0f, 0.0f, scalevec1._v.v._2, 0.0f,
|
|
|
|
|
- _pos._v.v._0, _pos._v.v._1, _pos._v.v._2, 1.0f);
|
|
|
|
|
|
|
+ float sx,sy,sz;
|
|
|
|
|
+
|
|
|
|
|
+ sx = _scale_x*_scale;
|
|
|
|
|
+ if(_mirror_x)
|
|
|
|
|
+ sx = -sx;
|
|
|
|
|
+ sy = _scale_y*_scale;
|
|
|
|
|
+ sz = _scale_z*_scale;
|
|
|
|
|
+ if(_mirror_y)
|
|
|
|
|
+ sz = -sz;
|
|
|
|
|
+
|
|
|
|
|
+ LVector3f scalevec1 = LVector3f::rfu(sx,sy,sz);
|
|
|
|
|
+
|
|
|
|
|
+ LMatrix4f mat(scalevec1[0], 0.0f, 0.0f, 0.0f,
|
|
|
|
|
+ 0.0f, scalevec1[1], 0.0f, 0.0f,
|
|
|
|
|
+ 0.0f, 0.0f, scalevec1[2], 0.0f,
|
|
|
|
|
+ _pos[0], _pos[1], _pos[2], 1.0f);
|
|
|
|
|
|
|
|
switch (_type) {
|
|
switch (_type) {
|
|
|
case SIMPLE_TEXT:
|
|
case SIMPLE_TEXT:
|
|
@@ -53,34 +56,40 @@ void GuiLabel::recompute_transform(void) {
|
|
|
break;
|
|
break;
|
|
|
case MODEL:
|
|
case MODEL:
|
|
|
{
|
|
{
|
|
|
|
|
+/*
|
|
|
float w=_have_width?_scale*_width:_scale;
|
|
float w=_have_width?_scale*_width:_scale;
|
|
|
float h=_have_height?_scale*_height:_scale;
|
|
float h=_have_height?_scale*_height:_scale;
|
|
|
|
|
|
|
|
-/*
|
|
|
|
|
LMatrix4f mat = LMatrix4f::scale_mat(LVector3f::rfu(_scale_x, _scale_y,
|
|
LMatrix4f mat = LMatrix4f::scale_mat(LVector3f::rfu(_scale_x, _scale_y,
|
|
|
- _scale_z)) *
|
|
|
|
|
- LMatrix4f::scale_mat(LVector3f::rfu(w, 1.0f, h)) *
|
|
|
|
|
- LMatrix4f::scale_mat(LVector3f::rfu((_mirror_x?-1.0f:1.0f), 1.0f,
|
|
|
|
|
- (_mirror_y?-1.0f:1.0f))) *
|
|
|
|
|
- LMatrix4f::translate_mat(_pos + _model_pos);
|
|
|
|
|
-*/
|
|
|
|
|
- // optimize above calculation
|
|
|
|
|
- LVector3f scalevec3 = LVector3f::rfu(w, 1.0f, h);
|
|
|
|
|
-
|
|
|
|
|
- mat._m.m._00 *= scalevec3._v.v._0;
|
|
|
|
|
- mat._m.m._11 *= scalevec3._v.v._1;
|
|
|
|
|
- mat._m.m._22 *= scalevec3._v.v._2;
|
|
|
|
|
-
|
|
|
|
|
- mat._m.m._30 += _model_pos._v.v._0;
|
|
|
|
|
- mat._m.m._31 += _model_pos._v.v._1;
|
|
|
|
|
- mat._m.m._32 += _model_pos._v.v._2;
|
|
|
|
|
|
|
+ _scale_z)) *
|
|
|
|
|
+ LMatrix4f::scale_mat(LVector3f::rfu(w, 1.0f, h)) *
|
|
|
|
|
+ LMatrix4f::scale_mat(LVector3f::rfu((_mirror_x?-1.0f:1.0f), 1.0f,
|
|
|
|
|
+ (_mirror_y?-1.0f:1.0f))) *
|
|
|
|
|
+ LMatrix4f::translate_mat(_pos + _model_pos);
|
|
|
|
|
+*/
|
|
|
|
|
+ // optimize above calculation, which was already partially done at start
|
|
|
|
|
+
|
|
|
|
|
+ if(_have_width || _have_height) {
|
|
|
|
|
+ float w=_have_width?_width:1.0f;
|
|
|
|
|
+ float h=_have_height?_height:1.0f;
|
|
|
|
|
+
|
|
|
|
|
+ LVector3f scalevec3 = LVector3f::rfu(w, 1.0f, h);
|
|
|
|
|
+
|
|
|
|
|
+ mat(0,0) *= scalevec3[0];
|
|
|
|
|
+ mat(1,1) *= scalevec3[1];
|
|
|
|
|
+ mat(2,2) *= scalevec3[2];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mat(3,0) += _model_pos[0];
|
|
|
|
|
+ mat(3,1) += _model_pos[1];
|
|
|
|
|
+ mat(3,2) += _model_pos[2];
|
|
|
|
|
|
|
|
_internal->set_transition(new TransformTransition(mat));
|
|
_internal->set_transition(new TransformTransition(mat));
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
gui_cat->warning() << "recompute_transform on invalid label type ("
|
|
gui_cat->warning() << "recompute_transform on invalid label type ("
|
|
|
- << (int)_type << ")" << endl;
|
|
|
|
|
|
|
+ << (int)_type << ")" << endl;
|
|
|
}
|
|
}
|
|
|
set_properties();
|
|
set_properties();
|
|
|
this->thaw();
|
|
this->thaw();
|
|
@@ -92,45 +101,45 @@ void GuiLabel::set_properties(void) {
|
|
|
{
|
|
{
|
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
|
if (_have_foreground)
|
|
if (_have_foreground)
|
|
|
- n->set_text_color(_foreground);
|
|
|
|
|
|
|
+ n->set_text_color(_foreground);
|
|
|
n->clear_card();
|
|
n->clear_card();
|
|
|
if ((_have_background) || (_tex == (Texture*)0L)) {
|
|
if ((_have_background) || (_tex == (Texture*)0L)) {
|
|
|
- if (_have_background)
|
|
|
|
|
- n->set_card_color(_background);
|
|
|
|
|
- if (_tex != (Texture*)0L)
|
|
|
|
|
- n->set_card_texture(_tex);
|
|
|
|
|
- if (_have_width || _have_height) {
|
|
|
|
|
- n->set_card_as_margin(simple_text_margin_left,
|
|
|
|
|
- simple_text_margin_right,
|
|
|
|
|
- simple_text_margin_bottom,
|
|
|
|
|
- simple_text_margin_top);
|
|
|
|
|
- LVecBase4f v = n->get_card_actual();
|
|
|
|
|
- float w = v[1] - v[0];
|
|
|
|
|
- float h = v[3] - v[2];
|
|
|
|
|
- if (_have_width) {
|
|
|
|
|
- w = _width - w;
|
|
|
|
|
- w *= 0.5f;
|
|
|
|
|
- v[1] += w;
|
|
|
|
|
- v[0] -= w;
|
|
|
|
|
- } else {
|
|
|
|
|
- v[0] -= simple_text_margin_left;
|
|
|
|
|
- v[1] += simple_text_margin_right;
|
|
|
|
|
- }
|
|
|
|
|
- if (_have_height) {
|
|
|
|
|
- h = _height - h;
|
|
|
|
|
- h *= 0.5f;
|
|
|
|
|
- v[3] += h;
|
|
|
|
|
- v[2] -= h;
|
|
|
|
|
- } else {
|
|
|
|
|
- v[2] -= simple_text_margin_bottom;
|
|
|
|
|
- v[3] += simple_text_margin_top;
|
|
|
|
|
- }
|
|
|
|
|
- n->set_card_actual(v[0], v[1], v[2], v[3]);
|
|
|
|
|
- } else
|
|
|
|
|
- n->set_card_as_margin(simple_text_margin_left,
|
|
|
|
|
- simple_text_margin_right,
|
|
|
|
|
- simple_text_margin_bottom,
|
|
|
|
|
- simple_text_margin_top);
|
|
|
|
|
|
|
+ if (_have_background)
|
|
|
|
|
+ n->set_card_color(_background);
|
|
|
|
|
+ if (_tex != (Texture*)0L)
|
|
|
|
|
+ n->set_card_texture(_tex);
|
|
|
|
|
+ if (_have_width || _have_height) {
|
|
|
|
|
+ n->set_card_as_margin(simple_text_margin_left,
|
|
|
|
|
+ simple_text_margin_right,
|
|
|
|
|
+ simple_text_margin_bottom,
|
|
|
|
|
+ simple_text_margin_top);
|
|
|
|
|
+ LVecBase4f v = n->get_card_actual();
|
|
|
|
|
+ float w = v[1] - v[0];
|
|
|
|
|
+ float h = v[3] - v[2];
|
|
|
|
|
+ if (_have_width) {
|
|
|
|
|
+ w = _width - w;
|
|
|
|
|
+ w *= 0.5f;
|
|
|
|
|
+ v[1] += w;
|
|
|
|
|
+ v[0] -= w;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ v[0] -= simple_text_margin_left;
|
|
|
|
|
+ v[1] += simple_text_margin_right;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (_have_height) {
|
|
|
|
|
+ h = _height - h;
|
|
|
|
|
+ h *= 0.5f;
|
|
|
|
|
+ v[3] += h;
|
|
|
|
|
+ v[2] -= h;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ v[2] -= simple_text_margin_bottom;
|
|
|
|
|
+ v[3] += simple_text_margin_top;
|
|
|
|
|
+ }
|
|
|
|
|
+ n->set_card_actual(v[0], v[1], v[2], v[3]);
|
|
|
|
|
+ } else
|
|
|
|
|
+ n->set_card_as_margin(simple_text_margin_left,
|
|
|
|
|
+ simple_text_margin_right,
|
|
|
|
|
+ simple_text_margin_bottom,
|
|
|
|
|
+ simple_text_margin_top);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
@@ -145,9 +154,9 @@ void GuiLabel::set_properties(void) {
|
|
|
_internal->set_transition(new ColorTransition(_foreground));
|
|
_internal->set_transition(new ColorTransition(_foreground));
|
|
|
TransparencyProperty::Mode mode;
|
|
TransparencyProperty::Mode mode;
|
|
|
if (_foreground[3] != 1.0f)
|
|
if (_foreground[3] != 1.0f)
|
|
|
- mode = TransparencyProperty::M_alpha;
|
|
|
|
|
|
|
+ mode = TransparencyProperty::M_alpha;
|
|
|
else
|
|
else
|
|
|
- mode = TransparencyProperty::M_none;
|
|
|
|
|
|
|
+ mode = TransparencyProperty::M_none;
|
|
|
_internal->set_transition(new TransparencyTransition(mode));
|
|
_internal->set_transition(new TransparencyTransition(mode));
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
@@ -164,13 +173,13 @@ void GuiLabel::set_properties(void) {
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
gui_cat->warning() << "set_properties on invalid label type ("
|
|
gui_cat->warning() << "set_properties on invalid label type ("
|
|
|
- << (int)_type << ")" << endl;
|
|
|
|
|
|
|
+ << (int)_type << ")" << endl;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
GuiLabel::~GuiLabel(void) {
|
|
GuiLabel::~GuiLabel(void) {
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
- if (gui_cat->is_debug())
|
|
|
|
|
|
|
+ if (gui_cat.is_debug())
|
|
|
gui_cat->debug() << "deleting label (0x" << (void*)this << ")" << endl;
|
|
gui_cat->debug() << "deleting label (0x" << (void*)this << ")" << endl;
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
@@ -234,7 +243,7 @@ GuiLabel* GuiLabel::make_simple_texture_label(Texture* texture) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
GuiLabel* GuiLabel::make_simple_text_label(const string& text, TextFont* font,
|
|
GuiLabel* GuiLabel::make_simple_text_label(const string& text, TextFont* font,
|
|
|
- Texture* tex) {
|
|
|
|
|
|
|
+ Texture* tex) {
|
|
|
GuiLabel* ret = new GuiLabel();
|
|
GuiLabel* ret = new GuiLabel();
|
|
|
ret->_type = SIMPLE_TEXT;
|
|
ret->_type = SIMPLE_TEXT;
|
|
|
TextNode* n = new TextNode("GUI label");
|
|
TextNode* n = new TextNode("GUI label");
|
|
@@ -263,7 +272,7 @@ GuiLabel* GuiLabel::make_simple_card_label(void) {
|
|
|
GeomNode* n2 = new GeomNode();
|
|
GeomNode* n2 = new GeomNode();
|
|
|
ret->_internal = new RenderRelation(ret->_geom, n2);
|
|
ret->_internal = new RenderRelation(ret->_geom, n2);
|
|
|
ret->_internal->set_transition(
|
|
ret->_internal->set_transition(
|
|
|
- new ColorTransition(Colorf(ret->_foreground)));
|
|
|
|
|
|
|
+ new ColorTransition(Colorf(ret->_foreground)));
|
|
|
GeomTristrip *geoset = new GeomTristrip;
|
|
GeomTristrip *geoset = new GeomTristrip;
|
|
|
PTA_int lengths(0);
|
|
PTA_int lengths(0);
|
|
|
lengths.push_back(4);
|
|
lengths.push_back(4);
|
|
@@ -287,7 +296,7 @@ GuiLabel* GuiLabel::make_null_label(void) {
|
|
|
NamedNode* n2 = new NamedNode("dummy");
|
|
NamedNode* n2 = new NamedNode("dummy");
|
|
|
ret->_internal = new RenderRelation(ret->_geom, n2);
|
|
ret->_internal = new RenderRelation(ret->_geom, n2);
|
|
|
ret->_internal->set_transition(
|
|
ret->_internal->set_transition(
|
|
|
- new ColorTransition(Colorf(ret->_foreground)));
|
|
|
|
|
|
|
+ new ColorTransition(Colorf(ret->_foreground)));
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -300,28 +309,28 @@ GuiLabel* GuiLabel::make_model_label(Node* geom, float w, float h) {
|
|
|
ret->_internal = new RenderRelation(ret->_geom, geom);
|
|
ret->_internal = new RenderRelation(ret->_geom, geom);
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
gui_cat->debug() << "created model label 0x" << (void*)ret
|
|
gui_cat->debug() << "created model label 0x" << (void*)ret
|
|
|
- << " from node 0x" << (void*)geom
|
|
|
|
|
- << ", set _type(" << (int)(ret->_type) << ") to MODEL("
|
|
|
|
|
- << (int)MODEL << ")" << endl;
|
|
|
|
|
|
|
+ << " from node 0x" << (void*)geom
|
|
|
|
|
+ << ", set _type(" << (int)(ret->_type) << ") to MODEL("
|
|
|
|
|
+ << (int)MODEL << ")" << endl;
|
|
|
#endif
|
|
#endif
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
GuiLabel* GuiLabel::make_model_label(Node* geom, float left, float right,
|
|
GuiLabel* GuiLabel::make_model_label(Node* geom, float left, float right,
|
|
|
- float bottom, float top) {
|
|
|
|
|
|
|
+ float bottom, float top) {
|
|
|
GuiLabel* ret = new GuiLabel();
|
|
GuiLabel* ret = new GuiLabel();
|
|
|
ret->_type = MODEL;
|
|
ret->_type = MODEL;
|
|
|
ret->_geom = new NamedNode("GUI label");
|
|
ret->_geom = new NamedNode("GUI label");
|
|
|
ret->_model_pos = LVector3f::rfu(-(left + right) * 0.5f, 0.0f,
|
|
ret->_model_pos = LVector3f::rfu(-(left + right) * 0.5f, 0.0f,
|
|
|
- -(bottom + top) * 0.5f);
|
|
|
|
|
|
|
+ -(bottom + top) * 0.5f);
|
|
|
ret->_model_width = right - left;
|
|
ret->_model_width = right - left;
|
|
|
ret->_model_height = top - bottom;
|
|
ret->_model_height = top - bottom;
|
|
|
ret->_internal = new RenderRelation(ret->_geom, geom);
|
|
ret->_internal = new RenderRelation(ret->_geom, geom);
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
gui_cat->debug() << "created model label 0x" << (void*)ret
|
|
gui_cat->debug() << "created model label 0x" << (void*)ret
|
|
|
- << " from node 0x" << (void*)geom
|
|
|
|
|
- << ", set _type(" << (int)(ret->_type) << ") to MODEL("
|
|
|
|
|
- << (int)MODEL << ")" << endl;
|
|
|
|
|
|
|
+ << " from node 0x" << (void*)geom
|
|
|
|
|
+ << ", set _type(" << (int)(ret->_type) << ") to MODEL("
|
|
|
|
|
+ << (int)MODEL << ")" << endl;
|
|
|
#endif
|
|
#endif
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
@@ -332,7 +341,7 @@ int GuiLabel::freeze() {
|
|
|
{
|
|
{
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
gui_cat->spam() << "GuiLabel:: freezing text node (0x" << (void*)this
|
|
gui_cat->spam() << "GuiLabel:: freezing text node (0x" << (void*)this
|
|
|
- << ")" << endl;
|
|
|
|
|
|
|
+ << ")" << endl;
|
|
|
#endif
|
|
#endif
|
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
|
return n->freeze();
|
|
return n->freeze();
|
|
@@ -349,7 +358,7 @@ int GuiLabel::thaw() {
|
|
|
{
|
|
{
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
gui_cat->spam() << "GuiLabel:: thawing text node (0x" << (void*)this
|
|
gui_cat->spam() << "GuiLabel:: thawing text node (0x" << (void*)this
|
|
|
- << ")" << endl;
|
|
|
|
|
|
|
+ << ")" << endl;
|
|
|
#endif
|
|
#endif
|
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
|
return n->thaw();
|
|
return n->thaw();
|
|
@@ -366,20 +375,20 @@ void GuiLabel::get_extents(float& l, float& r, float& b, float& t) {
|
|
|
{
|
|
{
|
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
|
if (n->has_card()) {
|
|
if (n->has_card()) {
|
|
|
- LVecBase4f v = n->get_card_transformed();
|
|
|
|
|
- l = v[0];
|
|
|
|
|
- r = v[1];
|
|
|
|
|
- b = v[2];
|
|
|
|
|
- t = v[3];
|
|
|
|
|
|
|
+ LVecBase4f v = n->get_card_transformed();
|
|
|
|
|
+ l = v[0];
|
|
|
|
|
+ r = v[1];
|
|
|
|
|
+ b = v[2];
|
|
|
|
|
+ t = v[3];
|
|
|
} else {
|
|
} else {
|
|
|
- LVector3f ul = n->get_upper_left_3d() - LPoint3f::origin();
|
|
|
|
|
- LVector3f lr = n->get_lower_right_3d() - LPoint3f::origin();
|
|
|
|
|
- LVector3f up = LVector3f::up();
|
|
|
|
|
- LVector3f right = LVector3f::right();
|
|
|
|
|
- l = ul.dot(right);
|
|
|
|
|
- r = lr.dot(right);
|
|
|
|
|
- b = lr.dot(up);
|
|
|
|
|
- t = ul.dot(up);
|
|
|
|
|
|
|
+ LVector3f ul = n->get_upper_left_3d() - LPoint3f::origin();
|
|
|
|
|
+ LVector3f lr = n->get_lower_right_3d() - LPoint3f::origin();
|
|
|
|
|
+ LVector3f up = LVector3f::up();
|
|
|
|
|
+ LVector3f right = LVector3f::right();
|
|
|
|
|
+ l = ul.dot(right);
|
|
|
|
|
+ r = lr.dot(right);
|
|
|
|
|
+ b = lr.dot(up);
|
|
|
|
|
+ t = ul.dot(up);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
@@ -391,46 +400,46 @@ void GuiLabel::get_extents(float& l, float& r, float& b, float& t) {
|
|
|
LVector3f ul, lr;
|
|
LVector3f ul, lr;
|
|
|
|
|
|
|
|
if (xs > ys) {
|
|
if (xs > ys) {
|
|
|
- // horizontally dominant
|
|
|
|
|
- ratio = ((float)ys) / ((float)xs);
|
|
|
|
|
- ratio *= 0.5f;
|
|
|
|
|
- ul = LVector3f::rfu(-0.5f, 0.0f, ratio);
|
|
|
|
|
- lr = LVector3f::rfu(0.5f, 0.0f, -ratio);
|
|
|
|
|
|
|
+ // horizontally dominant
|
|
|
|
|
+ ratio = ((float)ys) / ((float)xs);
|
|
|
|
|
+ ratio *= 0.5f;
|
|
|
|
|
+ ul = LVector3f::rfu(-0.5f, 0.0f, ratio);
|
|
|
|
|
+ lr = LVector3f::rfu(0.5f, 0.0f, -ratio);
|
|
|
} else {
|
|
} else {
|
|
|
- // vertically dominant
|
|
|
|
|
- ratio = ((float)xs) / ((float)ys);
|
|
|
|
|
- ratio *= 0.5f;
|
|
|
|
|
- ul = LVector3f::rfu(-ratio, 0.0f, 0.5f);
|
|
|
|
|
- lr = LVector3f::rfu(ratio, 0.0f, -0.5f);
|
|
|
|
|
|
|
+ // vertically dominant
|
|
|
|
|
+ ratio = ((float)xs) / ((float)ys);
|
|
|
|
|
+ ratio *= 0.5f;
|
|
|
|
|
+ ul = LVector3f::rfu(-ratio, 0.0f, 0.5f);
|
|
|
|
|
+ lr = LVector3f::rfu(ratio, 0.0f, -0.5f);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
LMatrix4f mat = LMatrix4f::scale_mat(LVector3f::rfu(_scale_x, _scale_y,
|
|
LMatrix4f mat = LMatrix4f::scale_mat(LVector3f::rfu(_scale_x, _scale_y,
|
|
|
- _scale_z)) *
|
|
|
|
|
- LMatrix4f::scale_mat(_scale) *
|
|
|
|
|
- LMatrix4f::translate_mat(_pos);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ _scale_z)) *
|
|
|
|
|
+ LMatrix4f::scale_mat(_scale) *
|
|
|
|
|
+ LMatrix4f::translate_mat(_pos);
|
|
|
|
|
+
|
|
|
ul = ul * mat;
|
|
ul = ul * mat;
|
|
|
- lr = lr * mat;
|
|
|
|
|
-*/
|
|
|
|
|
- // optimize above
|
|
|
|
|
|
|
+ lr = lr * mat;
|
|
|
|
|
+*/
|
|
|
|
|
+ // optimize above
|
|
|
|
|
|
|
|
LVector3f scalevec1 = LVector3f::rfu(_scale_x*_scale, _scale_y*_scale, _scale_z*_scale);
|
|
LVector3f scalevec1 = LVector3f::rfu(_scale_x*_scale, _scale_y*_scale, _scale_z*_scale);
|
|
|
- LVector3f scalevec2 = LVector3f::rfu((_mirror_x?-1.0f:1.0f),
|
|
|
|
|
- 1.0f,
|
|
|
|
|
- (_mirror_y?-1.0f:1.0f));
|
|
|
|
|
|
|
+ LVector3f scalevec2 = LVector3f::rfu((_mirror_x?-1.0f:1.0f),
|
|
|
|
|
+ 1.0f,
|
|
|
|
|
+ (_mirror_y?-1.0f:1.0f));
|
|
|
|
|
|
|
|
- scalevec1._v.v._0 *= scalevec2._v.v._0;
|
|
|
|
|
- scalevec1._v.v._1 *= scalevec2._v.v._1;
|
|
|
|
|
- scalevec1._v.v._2 *= scalevec2._v.v._2;
|
|
|
|
|
|
|
+ scalevec1._v.v._0 *= scalevec2._v.v._0;
|
|
|
|
|
+ scalevec1._v.v._1 *= scalevec2._v.v._1;
|
|
|
|
|
+ scalevec1._v.v._2 *= scalevec2._v.v._2;
|
|
|
|
|
|
|
|
- ul._v.v._0 = scalevec1._v.v._0 * ul._v.v._0 + _pos._v.v._0;
|
|
|
|
|
- ul._v.v._1 = scalevec1._v.v._1 * ul._v.v._1 + _pos._v.v._1;
|
|
|
|
|
- ul._v.v._2 = scalevec1._v.v._2 * ul._v.v._2 + _pos._v.v._2;
|
|
|
|
|
|
|
+ ul._v.v._0 = scalevec1._v.v._0 * ul._v.v._0 + _pos._v.v._0;
|
|
|
|
|
+ ul._v.v._1 = scalevec1._v.v._1 * ul._v.v._1 + _pos._v.v._1;
|
|
|
|
|
+ ul._v.v._2 = scalevec1._v.v._2 * ul._v.v._2 + _pos._v.v._2;
|
|
|
|
|
|
|
|
- lr._v.v._0 = scalevec1._v.v._0 * lr._v.v._0 + _pos._v.v._0;
|
|
|
|
|
- lr._v.v._1 = scalevec1._v.v._1 * lr._v.v._1 + _pos._v.v._1;
|
|
|
|
|
- lr._v.v._2 = scalevec1._v.v._2 * lr._v.v._2 + _pos._v.v._2;
|
|
|
|
|
|
|
+ lr._v.v._0 = scalevec1._v.v._0 * lr._v.v._0 + _pos._v.v._0;
|
|
|
|
|
+ lr._v.v._1 = scalevec1._v.v._1 * lr._v.v._1 + _pos._v.v._1;
|
|
|
|
|
+ lr._v.v._2 = scalevec1._v.v._2 * lr._v.v._2 + _pos._v.v._2;
|
|
|
|
|
|
|
|
l = ul.dot(ul.right());
|
|
l = ul.dot(ul.right());
|
|
|
r = lr.dot(lr.right());
|
|
r = lr.dot(lr.right());
|
|
@@ -495,10 +504,10 @@ float GuiLabel::get_width(void) {
|
|
|
{
|
|
{
|
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
|
if (n->has_card()) {
|
|
if (n->has_card()) {
|
|
|
- LVecBase4f v = n->get_card_actual();
|
|
|
|
|
- w = v[1] - v[0];
|
|
|
|
|
|
|
+ LVecBase4f v = n->get_card_actual();
|
|
|
|
|
+ w = v[1] - v[0];
|
|
|
} else
|
|
} else
|
|
|
- w = n->get_width();
|
|
|
|
|
|
|
+ w = n->get_width();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case SIMPLE_TEXTURE:
|
|
case SIMPLE_TEXTURE:
|
|
@@ -529,10 +538,10 @@ float GuiLabel::get_height(void) {
|
|
|
{
|
|
{
|
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
TextNode* n = DCAST(TextNode, _geom);
|
|
|
if (n->has_card()) {
|
|
if (n->has_card()) {
|
|
|
- LVecBase4f v = n->get_card_actual();
|
|
|
|
|
- h = v[3] - v[2];
|
|
|
|
|
|
|
+ LVecBase4f v = n->get_card_actual();
|
|
|
|
|
+ h = v[3] - v[2];
|
|
|
} else
|
|
} else
|
|
|
- h = n->get_width();
|
|
|
|
|
|
|
+ h = n->get_width();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case SIMPLE_TEXTURE:
|
|
case SIMPLE_TEXTURE:
|
|
@@ -591,7 +600,7 @@ void GuiLabel::set_text(const string& val) {
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
gui_cat->warning() << "trying to set text on an unknown label type ("
|
|
gui_cat->warning() << "trying to set text on an unknown label type ("
|
|
|
- << (int)_type << ")" << endl;
|
|
|
|
|
|
|
+ << (int)_type << ")" << endl;
|
|
|
}
|
|
}
|
|
|
recompute();
|
|
recompute();
|
|
|
}
|
|
}
|
|
@@ -606,7 +615,7 @@ void GuiLabel::set_shadow_color(const Colorf& c) {
|
|
|
break;
|
|
break;
|
|
|
case SIMPLE_TEXTURE:
|
|
case SIMPLE_TEXTURE:
|
|
|
gui_cat->warning() << "tried to set shadow color on a texture label"
|
|
gui_cat->warning() << "tried to set shadow color on a texture label"
|
|
|
- << endl;
|
|
|
|
|
|
|
+ << endl;
|
|
|
break;
|
|
break;
|
|
|
case SIMPLE_CARD:
|
|
case SIMPLE_CARD:
|
|
|
gui_cat->warning() << "tried to set shadow color on a card label" << endl;
|
|
gui_cat->warning() << "tried to set shadow color on a card label" << endl;
|
|
@@ -647,7 +656,7 @@ void GuiLabel::set_shadow(float x, float y) {
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
gui_cat->warning() << "trying to set shadow on an unknown label type ("
|
|
gui_cat->warning() << "trying to set shadow on an unknown label type ("
|
|
|
- << (int)_type << ")" << endl;
|
|
|
|
|
|
|
+ << (int)_type << ")" << endl;
|
|
|
}
|
|
}
|
|
|
recompute();
|
|
recompute();
|
|
|
}
|
|
}
|
|
@@ -674,7 +683,7 @@ void GuiLabel::set_align(int a) {
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
gui_cat->warning() << "trying to set align on an unknown label type ("
|
|
gui_cat->warning() << "trying to set align on an unknown label type ("
|
|
|
- << (int)_type << ")" << endl;
|
|
|
|
|
|
|
+ << (int)_type << ")" << endl;
|
|
|
}
|
|
}
|
|
|
recompute();
|
|
recompute();
|
|
|
}
|
|
}
|
|
@@ -730,7 +739,7 @@ int GuiLabel::set_draw_order(int order) {
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
gui_cat->warning() << "trying to set draw order on an unknown label type ("
|
|
gui_cat->warning() << "trying to set draw order on an unknown label type ("
|
|
|
- << (int)_type << ")" << endl;
|
|
|
|
|
|
|
+ << (int)_type << ")" << endl;
|
|
|
}
|
|
}
|
|
|
this->thaw();
|
|
this->thaw();
|
|
|
return ret;
|
|
return ret;
|
|
@@ -758,7 +767,7 @@ int GuiLabel::soft_set_draw_order(int order) {
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
gui_cat->warning() << "trying to set draw order on an unknown label type ("
|
|
gui_cat->warning() << "trying to set draw order on an unknown label type ("
|
|
|
- << (int)_type << ")" << endl;
|
|
|
|
|
|
|
+ << (int)_type << ")" << endl;
|
|
|
}
|
|
}
|
|
|
this->thaw();
|
|
this->thaw();
|
|
|
return ret;
|
|
return ret;
|