mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 10:13:15 +02:00
Add backgroundAlpha property to 2D and 3D text overlays
This commit is contained in:
parent
dbf64b2de7
commit
f5a1c26492
5 changed files with 27 additions and 1 deletions
|
@ -69,7 +69,8 @@ var text = Overlays.addOverlay("text", {
|
||||||
topMargin: 4,
|
topMargin: 4,
|
||||||
leftMargin: 4,
|
leftMargin: 4,
|
||||||
text: "Here is some text.\nAnd a second line.",
|
text: "Here is some text.\nAnd a second line.",
|
||||||
alpha: 0.7
|
alpha: 0.7,
|
||||||
|
backgroundAlpha: 0.5
|
||||||
});
|
});
|
||||||
|
|
||||||
// This will create an image overlay, which starts out as invisible
|
// This will create an image overlay, which starts out as invisible
|
||||||
|
@ -170,6 +171,7 @@ var clipboardPreview = Overlays.addOverlay("clipboard", {
|
||||||
// Demonstrate retrieving overlay properties
|
// Demonstrate retrieving overlay properties
|
||||||
print("Text overlay text property value =\n" + Overlays.getProperty(text, "text"));
|
print("Text overlay text property value =\n" + Overlays.getProperty(text, "text"));
|
||||||
print("Text overlay alpha =\n" + Overlays.getProperty(text, "alpha"));
|
print("Text overlay alpha =\n" + Overlays.getProperty(text, "alpha"));
|
||||||
|
print("Text overlay background alpha =\n" + Overlays.getProperty(text, "backgroundAlpha"));
|
||||||
print("Text overlay visible =\n" + Overlays.getProperty(text, "visible"));
|
print("Text overlay visible =\n" + Overlays.getProperty(text, "visible"));
|
||||||
print("Text overlay font size =\n" + Overlays.getProperty(text, "font").size);
|
print("Text overlay font size =\n" + Overlays.getProperty(text, "font").size);
|
||||||
print("Text overlay anchor =\n" + Overlays.getProperty(text, "anchor"));
|
print("Text overlay anchor =\n" + Overlays.getProperty(text, "anchor"));
|
||||||
|
|
|
@ -16,12 +16,14 @@
|
||||||
#include "ui/TextRenderer.h"
|
#include "ui/TextRenderer.h"
|
||||||
|
|
||||||
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
|
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
|
||||||
|
const float DEFAULT_BACKGROUND_ALPHA = 0.7f;
|
||||||
const float DEFAULT_MARGIN = 0.1f;
|
const float DEFAULT_MARGIN = 0.1f;
|
||||||
const int FIXED_FONT_POINT_SIZE = 40;
|
const int FIXED_FONT_POINT_SIZE = 40;
|
||||||
const float LINE_SCALE_RATIO = 1.2f;
|
const float LINE_SCALE_RATIO = 1.2f;
|
||||||
|
|
||||||
Text3DOverlay::Text3DOverlay() :
|
Text3DOverlay::Text3DOverlay() :
|
||||||
_backgroundColor(DEFAULT_BACKGROUND_COLOR),
|
_backgroundColor(DEFAULT_BACKGROUND_COLOR),
|
||||||
|
_backgroundAlpha(DEFAULT_BACKGROUND_ALPHA),
|
||||||
_lineHeight(0.1f),
|
_lineHeight(0.1f),
|
||||||
_leftMargin(DEFAULT_MARGIN),
|
_leftMargin(DEFAULT_MARGIN),
|
||||||
_topMargin(DEFAULT_MARGIN),
|
_topMargin(DEFAULT_MARGIN),
|
||||||
|
@ -35,6 +37,7 @@ Text3DOverlay::Text3DOverlay(const Text3DOverlay* text3DOverlay) :
|
||||||
Planar3DOverlay(text3DOverlay),
|
Planar3DOverlay(text3DOverlay),
|
||||||
_text(text3DOverlay->_text),
|
_text(text3DOverlay->_text),
|
||||||
_backgroundColor(text3DOverlay->_backgroundColor),
|
_backgroundColor(text3DOverlay->_backgroundColor),
|
||||||
|
_backgroundAlpha(text3DOverlay->_backgroundAlpha),
|
||||||
_lineHeight(text3DOverlay->_lineHeight),
|
_lineHeight(text3DOverlay->_lineHeight),
|
||||||
_leftMargin(text3DOverlay->_leftMargin),
|
_leftMargin(text3DOverlay->_leftMargin),
|
||||||
_topMargin(text3DOverlay->_topMargin),
|
_topMargin(text3DOverlay->_topMargin),
|
||||||
|
@ -166,6 +169,10 @@ void Text3DOverlay::setProperties(const QScriptValue& properties) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (properties.property("backgroundAlpha").isValid()) {
|
||||||
|
_backgroundAlpha = properties.property("backgroundAlpha").toVariant().toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
if (properties.property("lineHeight").isValid()) {
|
if (properties.property("lineHeight").isValid()) {
|
||||||
setLineHeight(properties.property("lineHeight").toVariant().toFloat());
|
setLineHeight(properties.property("lineHeight").toVariant().toFloat());
|
||||||
}
|
}
|
||||||
|
@ -200,6 +207,9 @@ QScriptValue Text3DOverlay::getProperty(const QString& property) {
|
||||||
if (property == "backgroundColor") {
|
if (property == "backgroundColor") {
|
||||||
return xColorToScriptValue(_scriptEngine, _backgroundColor);
|
return xColorToScriptValue(_scriptEngine, _backgroundColor);
|
||||||
}
|
}
|
||||||
|
if (property == "backgroundAlpha") {
|
||||||
|
return _backgroundAlpha;
|
||||||
|
}
|
||||||
if (property == "lineHeight") {
|
if (property == "lineHeight") {
|
||||||
return _lineHeight;
|
return _lineHeight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
float getBottomMargin() const { return _bottomMargin; }
|
float getBottomMargin() const { return _bottomMargin; }
|
||||||
bool getIsFacingAvatar() const { return _isFacingAvatar; }
|
bool getIsFacingAvatar() const { return _isFacingAvatar; }
|
||||||
xColor getBackgroundColor();
|
xColor getBackgroundColor();
|
||||||
|
float getBackgroundAlpha() const { return _backgroundAlpha; }
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
void setText(const QString& text) { _text = text; }
|
void setText(const QString& text) { _text = text; }
|
||||||
|
@ -59,6 +60,7 @@ private:
|
||||||
|
|
||||||
QString _text;
|
QString _text;
|
||||||
xColor _backgroundColor;
|
xColor _backgroundColor;
|
||||||
|
float _backgroundAlpha;
|
||||||
float _lineHeight;
|
float _lineHeight;
|
||||||
float _leftMargin;
|
float _leftMargin;
|
||||||
float _topMargin;
|
float _topMargin;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
TextOverlay::TextOverlay() :
|
TextOverlay::TextOverlay() :
|
||||||
_backgroundColor(DEFAULT_BACKGROUND_COLOR),
|
_backgroundColor(DEFAULT_BACKGROUND_COLOR),
|
||||||
|
_backgroundAlpha(DEFAULT_BACKGROUND_ALPHA),
|
||||||
_leftMargin(DEFAULT_MARGIN),
|
_leftMargin(DEFAULT_MARGIN),
|
||||||
_topMargin(DEFAULT_MARGIN),
|
_topMargin(DEFAULT_MARGIN),
|
||||||
_fontSize(DEFAULT_FONTSIZE)
|
_fontSize(DEFAULT_FONTSIZE)
|
||||||
|
@ -29,6 +30,7 @@ TextOverlay::TextOverlay(const TextOverlay* textOverlay) :
|
||||||
Overlay2D(textOverlay),
|
Overlay2D(textOverlay),
|
||||||
_text(textOverlay->_text),
|
_text(textOverlay->_text),
|
||||||
_backgroundColor(textOverlay->_backgroundColor),
|
_backgroundColor(textOverlay->_backgroundColor),
|
||||||
|
_backgroundAlpha(textOverlay->_backgroundAlpha),
|
||||||
_leftMargin(textOverlay->_leftMargin),
|
_leftMargin(textOverlay->_leftMargin),
|
||||||
_topMargin(textOverlay->_topMargin),
|
_topMargin(textOverlay->_topMargin),
|
||||||
_fontSize(textOverlay->_fontSize)
|
_fontSize(textOverlay->_fontSize)
|
||||||
|
@ -125,6 +127,10 @@ void TextOverlay::setProperties(const QScriptValue& properties) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (properties.property("backgroundAlpha").isValid()) {
|
||||||
|
_backgroundAlpha = properties.property("backgroundAlpha").toVariant().toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
if (properties.property("leftMargin").isValid()) {
|
if (properties.property("leftMargin").isValid()) {
|
||||||
setLeftMargin(properties.property("leftMargin").toVariant().toInt());
|
setLeftMargin(properties.property("leftMargin").toVariant().toInt());
|
||||||
}
|
}
|
||||||
|
@ -150,6 +156,9 @@ QScriptValue TextOverlay::getProperty(const QString& property) {
|
||||||
if (property == "backgroundColor") {
|
if (property == "backgroundColor") {
|
||||||
return xColorToScriptValue(_scriptEngine, _backgroundColor);
|
return xColorToScriptValue(_scriptEngine, _backgroundColor);
|
||||||
}
|
}
|
||||||
|
if (property == "backgroundAlpha") {
|
||||||
|
return _backgroundAlpha;
|
||||||
|
}
|
||||||
if (property == "leftMargin") {
|
if (property == "leftMargin") {
|
||||||
return _leftMargin;
|
return _leftMargin;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "Overlay2D.h"
|
#include "Overlay2D.h"
|
||||||
|
|
||||||
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
|
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
|
||||||
|
const float DEFAULT_BACKGROUND_ALPHA = 0.7f;
|
||||||
const int DEFAULT_MARGIN = 10;
|
const int DEFAULT_MARGIN = 10;
|
||||||
const int DEFAULT_FONTSIZE = 11;
|
const int DEFAULT_FONTSIZE = 11;
|
||||||
const int DEFAULT_FONT_WEIGHT = 50;
|
const int DEFAULT_FONT_WEIGHT = 50;
|
||||||
|
@ -46,6 +47,7 @@ public:
|
||||||
int getLeftMargin() const { return _leftMargin; }
|
int getLeftMargin() const { return _leftMargin; }
|
||||||
int getTopMargin() const { return _topMargin; }
|
int getTopMargin() const { return _topMargin; }
|
||||||
xColor getBackgroundColor();
|
xColor getBackgroundColor();
|
||||||
|
float getBackgroundAlpha() const { return _backgroundAlpha; }
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
void setText(const QString& text) { _text = text; }
|
void setText(const QString& text) { _text = text; }
|
||||||
|
@ -62,6 +64,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QString _text;
|
QString _text;
|
||||||
xColor _backgroundColor;
|
xColor _backgroundColor;
|
||||||
|
float _backgroundAlpha;
|
||||||
int _leftMargin;
|
int _leftMargin;
|
||||||
int _topMargin;
|
int _topMargin;
|
||||||
int _fontSize;
|
int _fontSize;
|
||||||
|
|
Loading…
Reference in a new issue