UI Nits: Tile Mode cleaner

Made the spacing in tile mode smaller and cleaned up
the decorations to make them cleaner and more in line
with modern UIs like Win 8 and OSX.

Also parameterised the spacing / margins in HomeWindow
in case we want to add a slidebar to adjust them or
maybe even a zooming.
This commit is contained in:
Mark Liversedge
2013-01-20 12:58:23 +00:00
parent e140f7f8f1
commit f08e83210b
2 changed files with 45 additions and 26 deletions

View File

@@ -257,19 +257,19 @@ GcWindow::paintEvent(QPaintEvent * /*event*/)
// fill in the title bar
QRect bar(0,0,width(),contentsMargins().top());
if (contentsMargins().top() < 25) {
QColor bg;
if (property("active").toBool() == true) {
bg = GColor(CTILEBARSELECT);
painter.drawPixmap(bar, aluBar);
} else {
bg = GColor(CTILEBAR);
painter.drawPixmap(bar, aluBarDark);
}
} else {
//if (contentsMargins().top() < 25) {
//QColor bg;
//if (property("active").toBool() == true) {
//bg = GColor(CTILEBARSELECT);
//painter.drawPixmap(bar, aluBar);
//} else {
//bg = GColor(CTILEBAR);
//painter.drawPixmap(bar, aluBarDark);
//}
//} else {
painter.setPen(Qt::darkGray);
painter.drawRect(QRect(0,0,width()-1,height()-1));
}
//}
// heading
QFont font;
@@ -281,13 +281,29 @@ GcWindow::paintEvent(QPaintEvent * /*event*/)
QString heading = subtitle != "" ? subtitle : title;
// embossed...
QRect shad = bar;
shad.setY(bar.y()+2);
//QRect shad = bar;
//shad.setY(bar.y()+2);
//shad.setX(bar.x()+2);
painter.setPen(QColor(255,255,255,180));
painter.drawText(shad, heading, Qt::AlignVCenter | Qt::AlignCenter);
//painter.setPen(QColor(255,255,255,180));
//painter.drawText(shad, heading, Qt::AlignVCenter | Qt::AlignCenter);
painter.setPen(QColor(0,0,0,200));
// pen color needs to contrast to background color
QColor bgColor = property("color").value<QColor>();
QColor fgColor;
if (bgColor == Qt::black) fgColor = Qt::white;
else if (bgColor == Qt::white) fgColor = Qt::black;
else {
QColor cRGB = bgColor.convertTo(QColor::Rgb);
// lets work it out..
int r = cRGB.red() < 128 ? 255 : 0;
int g = cRGB.green() < 128 ? 255 : 0;
int b = cRGB.blue() < 128 ? 255 : 0;
fgColor = QColor(r,g,b);
}
painter.setPen(fgColor);
painter.drawText(bar, heading, Qt::AlignVCenter | Qt::AlignCenter);
// border

View File

@@ -24,6 +24,9 @@
#include <QGraphicsDropShadowEffect>
static const int tileMargin = 20;
static const int tileSpacing = 10;
HomeWindow::HomeWindow(MainWindow *mainWindow, QString name, QString /* windowtitle */) :
GcWindow(mainWindow), mainWindow(mainWindow), name(name), active(false),
clicked(NULL), dropPending(false), chartCursor(-2), loaded(false)
@@ -173,8 +176,8 @@ HomeWindow::HomeWindow(MainWindow *mainWindow, QString name, QString /* windowti
winWidget->setContentsMargins(0,0,0,0);
winWidget->setPalette(palette);
winFlow = new GcWindowLayout(winWidget, 0, 20, 20);
winFlow->setContentsMargins(20,20,20,20);
winFlow = new GcWindowLayout(winWidget, 0, tileSpacing, tileSpacing);
winFlow->setContentsMargins(tileMargin,tileMargin,tileMargin,tileMargin);
winArea = new QScrollArea(this);
winArea->setAutoFillBackground(false);
@@ -666,13 +669,13 @@ HomeWindow::addChart(GcWindow* newone)
// divided by the number of items
double newwidth = (winArea->width() - 20 /* scrollbar */
- 40 /* left and right marings */
- ((widthFactor-1) * 20) /* internal spacing */
- (tileMargin*2) /* left and right marings */
- ((widthFactor-1) * tileSpacing) /* internal spacing */
) / widthFactor;
double newheight = (winArea->height()
- 40 /* top and bottom marings */
- ((heightFactor-1) * 20) /* internal spacing */
- (tileMargin*2) /* top and bottom marings */
- ((heightFactor-1) * tileSpacing) /* internal spacing */
) / heightFactor;
int minWidth = 10;
@@ -815,13 +818,13 @@ HomeWindow::resizeEvent(QResizeEvent * /* e */)
double newwidth = (winArea->width() - 20 /* scrollbar */
- 40 /* left and right marings */
- ((widthFactor-1) * 20) /* internal spacing */
- (tileMargin*2) /* left and right marings */
- ((widthFactor-1) * tileSpacing) /* internal spacing */
) / widthFactor;
double newheight = (winArea->height()
- 40 /* top and bottom marings */
- ((heightFactor-1) * 20) /* internal spacing */
- (tileMargin*2) /* top and bottom marings */
- ((heightFactor-1) * tileSpacing) /* internal spacing */
) / heightFactor;
int minWidth = 10;