mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:09:52 +02:00
commit
4f756c31f2
5 changed files with 32 additions and 17 deletions
|
@ -57,7 +57,7 @@ var LocationMenu = function(opts) {
|
||||||
y: 0,
|
y: 0,
|
||||||
width: menuWidth + 10,
|
width: menuWidth + 10,
|
||||||
height: (menuHeight * (pageSize + 1)) + 10,
|
height: (menuHeight * (pageSize + 1)) + 10,
|
||||||
color: { red: 0, green: 0, blue: 0},
|
backgroundColor: { red: 0, green: 0, blue: 0},
|
||||||
topMargin: 4,
|
topMargin: 4,
|
||||||
leftMargin: 4,
|
leftMargin: 4,
|
||||||
text: "",
|
text: "",
|
||||||
|
@ -71,7 +71,7 @@ var LocationMenu = function(opts) {
|
||||||
y: 0,
|
y: 0,
|
||||||
width: menuWidth,
|
width: menuWidth,
|
||||||
height: menuHeight,
|
height: menuHeight,
|
||||||
color: inactiveColor,
|
backgroundColor: inactiveColor,
|
||||||
topMargin: margin,
|
topMargin: margin,
|
||||||
leftMargin: margin,
|
leftMargin: margin,
|
||||||
text: (i == 0) ? "Loading..." : "",
|
text: (i == 0) ? "Loading..." : "",
|
||||||
|
@ -85,7 +85,7 @@ var LocationMenu = function(opts) {
|
||||||
y: 0,
|
y: 0,
|
||||||
width: menuWidth / 2,
|
width: menuWidth / 2,
|
||||||
height: menuHeight,
|
height: menuHeight,
|
||||||
color: disabledColor,
|
backgroundColor: disabledColor,
|
||||||
topMargin: margin,
|
topMargin: margin,
|
||||||
leftMargin: margin,
|
leftMargin: margin,
|
||||||
text: "Previous",
|
text: "Previous",
|
||||||
|
@ -97,7 +97,7 @@ var LocationMenu = function(opts) {
|
||||||
y: 0,
|
y: 0,
|
||||||
width: menuWidth / 2,
|
width: menuWidth / 2,
|
||||||
height: menuHeight,
|
height: menuHeight,
|
||||||
color: disabledColor,
|
backgroundColor: disabledColor,
|
||||||
topMargin: margin,
|
topMargin: margin,
|
||||||
leftMargin: margin,
|
leftMargin: margin,
|
||||||
text: "Next",
|
text: "Next",
|
||||||
|
@ -175,10 +175,10 @@ var LocationMenu = function(opts) {
|
||||||
if (start + i < this.locations.length) {
|
if (start + i < this.locations.length) {
|
||||||
location = this.locations[start + i];
|
location = this.locations[start + i];
|
||||||
update.text = (start + i + 1) + ". " + location.username;
|
update.text = (start + i + 1) + ". " + location.username;
|
||||||
update.color = inactiveColor;
|
update.backgroundColor = inactiveColor;
|
||||||
} else {
|
} else {
|
||||||
update.text = "";
|
update.text = "";
|
||||||
update.color = disabledColor;
|
update.backgroundColor = disabledColor;
|
||||||
}
|
}
|
||||||
Overlays.editOverlay(this.menuItems[i].overlay, update);
|
Overlays.editOverlay(this.menuItems[i].overlay, update);
|
||||||
this.menuItems[i].location = location;
|
this.menuItems[i].location = location;
|
||||||
|
@ -187,8 +187,8 @@ var LocationMenu = function(opts) {
|
||||||
this.previousEnabled = pageNumber > 0;
|
this.previousEnabled = pageNumber > 0;
|
||||||
this.nextEnabled = pageNumber < (this.numPages - 1);
|
this.nextEnabled = pageNumber < (this.numPages - 1);
|
||||||
|
|
||||||
Overlays.editOverlay(this.previousButton, { color: this.previousEnabled ? prevNextColor : disabledColor});
|
Overlays.editOverlay(this.previousButton, { backgroundColor: this.previousEnabled ? prevNextColor : disabledColor});
|
||||||
Overlays.editOverlay(this.nextButton, { color: this.nextEnabled ? prevNextColor : disabledColor });
|
Overlays.editOverlay(this.nextButton, { backgroundColor: this.nextEnabled ? prevNextColor : disabledColor });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mousePressEvent = function(event) {
|
this.mousePressEvent = function(event) {
|
||||||
|
@ -198,17 +198,17 @@ var LocationMenu = function(opts) {
|
||||||
self.toggleMenu();
|
self.toggleMenu();
|
||||||
} else if (clickedOverlay == self.previousButton) {
|
} else if (clickedOverlay == self.previousButton) {
|
||||||
if (self.previousEnabled) {
|
if (self.previousEnabled) {
|
||||||
Overlays.editOverlay(clickedOverlay, { color: activeColor });
|
Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor });
|
||||||
}
|
}
|
||||||
} else if (clickedOverlay == self.nextButton) {
|
} else if (clickedOverlay == self.nextButton) {
|
||||||
if (self.nextEnabled) {
|
if (self.nextEnabled) {
|
||||||
Overlays.editOverlay(clickedOverlay, { color: activeColor });
|
Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < self.menuItems.length; i++) {
|
for (var i = 0; i < self.menuItems.length; i++) {
|
||||||
if (clickedOverlay == self.menuItems[i].overlay) {
|
if (clickedOverlay == self.menuItems[i].overlay) {
|
||||||
if (self.menuItems[i].location != null) {
|
if (self.menuItems[i].location != null) {
|
||||||
Overlays.editOverlay(clickedOverlay, { color: activeColor });
|
Overlays.editOverlay(clickedOverlay, { backgroundColor: activeColor });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -221,19 +221,19 @@ var LocationMenu = function(opts) {
|
||||||
|
|
||||||
if (clickedOverlay == self.previousButton) {
|
if (clickedOverlay == self.previousButton) {
|
||||||
if (self.previousEnabled) {
|
if (self.previousEnabled) {
|
||||||
Overlays.editOverlay(clickedOverlay, { color: inactiveColor });
|
Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor });
|
||||||
self.goToPage(self.page - 1);
|
self.goToPage(self.page - 1);
|
||||||
}
|
}
|
||||||
} else if (clickedOverlay == self.nextButton) {
|
} else if (clickedOverlay == self.nextButton) {
|
||||||
if (self.nextEnabled) {
|
if (self.nextEnabled) {
|
||||||
Overlays.editOverlay(clickedOverlay, { color: inactiveColor });
|
Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor });
|
||||||
self.goToPage(self.page + 1);
|
self.goToPage(self.page + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < self.menuItems.length; i++) {
|
for (var i = 0; i < self.menuItems.length; i++) {
|
||||||
if (clickedOverlay == self.menuItems[i].overlay) {
|
if (clickedOverlay == self.menuItems[i].overlay) {
|
||||||
if (self.menuItems[i].location != null) {
|
if (self.menuItems[i].location != null) {
|
||||||
Overlays.editOverlay(clickedOverlay, { color: inactiveColor });
|
Overlays.editOverlay(clickedOverlay, { backgroundColor: inactiveColor });
|
||||||
var location = self.menuItems[i].location;
|
var location = self.menuItems[i].location;
|
||||||
Window.location = "hifi://" + location.domain + "/"
|
Window.location = "hifi://" + location.domain + "/"
|
||||||
+ location.x + "," + location.y + "," + location.z;
|
+ location.x + "," + location.y + "," + location.z;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
Overlay::Overlay() :
|
Overlay::Overlay() :
|
||||||
_parent(NULL),
|
_parent(NULL),
|
||||||
_alpha(DEFAULT_ALPHA),
|
_alpha(DEFAULT_ALPHA),
|
||||||
_color(DEFAULT_BACKGROUND_COLOR),
|
_color(DEFAULT_OVERLAY_COLOR),
|
||||||
_visible(true),
|
_visible(true),
|
||||||
_anchor(NO_ANCHOR)
|
_anchor(NO_ANCHOR)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <SharedUtil.h> // for xColor
|
#include <SharedUtil.h> // for xColor
|
||||||
|
|
||||||
const xColor DEFAULT_BACKGROUND_COLOR = { 255, 255, 255 };
|
const xColor DEFAULT_OVERLAY_COLOR = { 255, 255, 255 };
|
||||||
const float DEFAULT_ALPHA = 0.7f;
|
const float DEFAULT_ALPHA = 0.7f;
|
||||||
|
|
||||||
class Overlay : public QObject {
|
class Overlay : public QObject {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "ui/TextRenderer.h"
|
#include "ui/TextRenderer.h"
|
||||||
|
|
||||||
TextOverlay::TextOverlay() :
|
TextOverlay::TextOverlay() :
|
||||||
|
_backgroundColor(DEFAULT_BACKGROUND_COLOR),
|
||||||
_leftMargin(DEFAULT_MARGIN),
|
_leftMargin(DEFAULT_MARGIN),
|
||||||
_topMargin(DEFAULT_MARGIN),
|
_topMargin(DEFAULT_MARGIN),
|
||||||
_fontSize(DEFAULT_FONTSIZE)
|
_fontSize(DEFAULT_FONTSIZE)
|
||||||
|
@ -33,7 +34,7 @@ void TextOverlay::render() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const float MAX_COLOR = 255;
|
const float MAX_COLOR = 255;
|
||||||
glColor4f(0 / MAX_COLOR, 0 / MAX_COLOR, 0 / MAX_COLOR, _alpha);
|
glColor4f(_backgroundColor.red / MAX_COLOR, _backgroundColor.green / MAX_COLOR, _backgroundColor.blue / MAX_COLOR, _alpha);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex2f(_bounds.left(), _bounds.top());
|
glVertex2f(_bounds.left(), _bounds.top());
|
||||||
|
@ -82,6 +83,18 @@ void TextOverlay::setProperties(const QScriptValue& properties) {
|
||||||
setText(text.toVariant().toString());
|
setText(text.toVariant().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScriptValue backgroundColor = properties.property("backgroundColor");
|
||||||
|
if (backgroundColor.isValid()) {
|
||||||
|
QScriptValue red = backgroundColor.property("red");
|
||||||
|
QScriptValue green = backgroundColor.property("green");
|
||||||
|
QScriptValue blue = backgroundColor.property("blue");
|
||||||
|
if (red.isValid() && green.isValid() && blue.isValid()) {
|
||||||
|
_backgroundColor.red = red.toVariant().toInt();
|
||||||
|
_backgroundColor.green = green.toVariant().toInt();
|
||||||
|
_backgroundColor.blue = blue.toVariant().toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (properties.property("leftMargin").isValid()) {
|
if (properties.property("leftMargin").isValid()) {
|
||||||
setLeftMargin(properties.property("leftMargin").toVariant().toInt());
|
setLeftMargin(properties.property("leftMargin").toVariant().toInt());
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "Overlay.h"
|
#include "Overlay.h"
|
||||||
#include "Overlay2D.h"
|
#include "Overlay2D.h"
|
||||||
|
|
||||||
|
const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 };
|
||||||
const int DEFAULT_MARGIN = 10;
|
const int DEFAULT_MARGIN = 10;
|
||||||
const int DEFAULT_FONTSIZE = 11;
|
const int DEFAULT_FONTSIZE = 11;
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString _text;
|
QString _text;
|
||||||
|
xColor _backgroundColor;
|
||||||
int _leftMargin;
|
int _leftMargin;
|
||||||
int _topMargin;
|
int _topMargin;
|
||||||
int _fontSize;
|
int _fontSize;
|
||||||
|
|
Loading…
Reference in a new issue