mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-07 07:36:44 +02:00
UI improvements
This commit is contained in:
parent
ee15739e7e
commit
60bea894d8
4 changed files with 82 additions and 18 deletions
|
@ -255,6 +255,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
|
||||
initMenu();
|
||||
|
||||
_swatch = new Swatch(_voxelPaintColor);
|
||||
|
||||
QRect available = desktop()->availableGeometry();
|
||||
_window->resize(available.size());
|
||||
_window->setVisible(true);
|
||||
|
@ -1544,8 +1546,6 @@ void Application::init() {
|
|||
|
||||
sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL());
|
||||
|
||||
|
||||
_swatch = new Swatch(_voxelPaintColor);
|
||||
_palette.init();
|
||||
_palette.addAction(_addVoxelMode, 0, 0);
|
||||
_palette.addAction(_deleteVoxelMode, 0, 1);
|
||||
|
@ -2292,7 +2292,7 @@ void Application::displayOverlay() {
|
|||
|
||||
_palette.render(_glWidget->width(), _glWidget->height());
|
||||
|
||||
if (_eyedropperMode->isChecked()) {
|
||||
if (_eyedropperMode->isChecked() && _voxelPaintColor->data().value<QColor>() != _swatch->getColor()) {
|
||||
QColor color(_voxelPaintColor->data().value<QColor>());
|
||||
TextRenderer textRenderer(SANS_FONT_FAMILY, -1, 100);
|
||||
const char* line1("Assign this color to a swatch");
|
||||
|
@ -2329,8 +2329,8 @@ void Application::displayOverlay() {
|
|||
glEnd();
|
||||
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
textRenderer.draw(left + 74, top + 10, line1);
|
||||
textRenderer.draw(left + 74, top + 30, line2);
|
||||
textRenderer.draw(left + 74, top + 12, line1);
|
||||
textRenderer.draw(left + 74, top + 27, line2);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
@ -2863,7 +2863,8 @@ void Application::loadSettings(QSettings* settings) {
|
|||
settings->endGroup();
|
||||
|
||||
scanMenuBar(&Application::loadAction, settings);
|
||||
getAvatar()->loadData(settings);
|
||||
getAvatar()->loadData(settings);
|
||||
_swatch->loadData(settings);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2885,8 +2886,11 @@ void Application::saveSettings(QSettings* settings) {
|
|||
settings->setValue("echoCancellation", _audio.isCancellingEcho());
|
||||
settings->endGroup();
|
||||
|
||||
|
||||
|
||||
scanMenuBar(&Application::saveAction, settings);
|
||||
getAvatar()->saveData(settings);
|
||||
_swatch->saveData(settings);
|
||||
}
|
||||
|
||||
void Application::importSettings() {
|
||||
|
|
|
@ -18,45 +18,102 @@ Swatch::Swatch(QAction* action) : Tool(action, 0, -1, -1),
|
|||
_colors[7].setRgb(0, 0, 0);
|
||||
|
||||
QPixmap map(16, 16);
|
||||
map.fill(_colors[0]);
|
||||
map.fill(_colors[_selected - 1]);
|
||||
_action->setData(_colors[_selected - 1]) ;
|
||||
_action->setIcon(map);
|
||||
}
|
||||
|
||||
QColor Swatch::getColor() {
|
||||
return _colors[_selected - 1];
|
||||
}
|
||||
|
||||
void Swatch::saveData(QSettings* settings) {
|
||||
settings->beginGroup("Swatch");
|
||||
|
||||
for (int i(0); i < SWATCH_SIZE; ++i) {
|
||||
QString name("R0");
|
||||
name[1] = '1' + i;
|
||||
settings->setValue(name, _colors[i].red());
|
||||
name[0] = 'G';
|
||||
settings->setValue(name, _colors[i].green());
|
||||
name[0] = 'B';
|
||||
settings->setValue(name, _colors[i].blue());
|
||||
}
|
||||
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void Swatch::loadData(QSettings* settings) {
|
||||
settings->beginGroup("Swatch");
|
||||
|
||||
_colors[0].setRgb(settings->value("R1", 128).toInt(),
|
||||
settings->value("G1", 128).toInt(),
|
||||
settings->value("B1", 128).toInt());
|
||||
_colors[1].setRgb(settings->value("R2", 128).toInt(),
|
||||
settings->value("G2", 128).toInt(),
|
||||
settings->value("B2", 128).toInt());
|
||||
_colors[2].setRgb(settings->value("R3", 128).toInt(),
|
||||
settings->value("G3", 128).toInt(),
|
||||
settings->value("B3", 128).toInt());
|
||||
_colors[3].setRgb(settings->value("R4", 128).toInt(),
|
||||
settings->value("G4", 128).toInt(),
|
||||
settings->value("B4", 128).toInt());
|
||||
_colors[4].setRgb(settings->value("R5", 128).toInt(),
|
||||
settings->value("G5", 128).toInt(),
|
||||
settings->value("B5", 128).toInt());
|
||||
_colors[5].setRgb(settings->value("R6", 128).toInt(),
|
||||
settings->value("G6", 128).toInt(),
|
||||
settings->value("B6", 128).toInt());
|
||||
_colors[6].setRgb(settings->value("R7", 128).toInt(),
|
||||
settings->value("G7", 128).toInt(),
|
||||
settings->value("B7", 128).toInt());
|
||||
_colors[7].setRgb(settings->value("R8", 128).toInt(),
|
||||
settings->value("G8", 128).toInt(),
|
||||
settings->value("B8", 128).toInt());
|
||||
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void Swatch::handleEvent(int key, bool getColor) {
|
||||
int next(0);
|
||||
|
||||
switch (key) {
|
||||
case Qt::Key_1:
|
||||
_selected = 1;
|
||||
next = 1;
|
||||
break;
|
||||
case Qt::Key_2:
|
||||
_selected = 2;
|
||||
next = 2;
|
||||
break;
|
||||
case Qt::Key_3:
|
||||
_selected = 3;
|
||||
next = 3;
|
||||
break;
|
||||
case Qt::Key_4:
|
||||
_selected = 4;
|
||||
next = 4;
|
||||
break;
|
||||
case Qt::Key_5:
|
||||
_selected = 5;
|
||||
next = 5;
|
||||
break;
|
||||
case Qt::Key_6:
|
||||
_selected = 6;
|
||||
next = 6;
|
||||
break;
|
||||
case Qt::Key_7:
|
||||
_selected = 7;
|
||||
next = 7;
|
||||
break;
|
||||
case Qt::Key_8:
|
||||
_selected = 8;
|
||||
next = 8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (getColor) {
|
||||
_colors[_selected - 1] = _action->data().value<QColor>();
|
||||
if (_action->data().value<QColor>() != _colors[_selected - 1]) {
|
||||
_selected = next;
|
||||
_colors[_selected - 1] = _action->data().value<QColor>();
|
||||
}
|
||||
}
|
||||
else {
|
||||
_selected = next;
|
||||
QPixmap map(16, 16);
|
||||
map.fill(_colors[_selected - 1]);
|
||||
_action->setData(_colors[_selected - 1]) ;
|
||||
|
@ -121,5 +178,4 @@ void Swatch::render(int screenWidth, int screenHeight) {
|
|||
}
|
||||
|
||||
glTranslated(0, 8*(_height - _margin) + _margin + 5, 0);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
class Swatch : public Tool {
|
||||
public:
|
||||
Swatch(QAction* action);
|
||||
QColor getColor();
|
||||
void saveData(QSettings* settings);
|
||||
void loadData(QSettings* settings);
|
||||
|
||||
void render(int screenWidth, int screenHeight);
|
||||
void handleEvent(int key, bool getColor);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
ToolsPalette::ToolsPalette() {
|
||||
// Load SVG
|
||||
QSvgRenderer renderer(QString("./resources/images/hifi-interface-tools.svg"));
|
||||
QSvgRenderer renderer(QString("/Users/graysonstebbins/Documents/hifi/interface/resources/images/hifi-interface-tools.svg"));
|
||||
|
||||
// Prepare a QImage with desired characteritisc
|
||||
QImage image(124, 400, QImage::Format_ARGB32);
|
||||
|
|
Loading…
Reference in a new issue