draw instrument
This commit is contained in:
@@ -12,7 +12,9 @@ QNavigationWidget::QNavigationWidget(QWidget *parent) : QWidget(parent)
|
||||
MouseIndex = -1;
|
||||
|
||||
|
||||
controlBarColor = "#87CEFF";
|
||||
controlBarColor = "#CAE1FF";
|
||||
controlSlideColor = "#1E90FF";
|
||||
|
||||
|
||||
controlBarWidth = 10;
|
||||
|
||||
@@ -86,21 +88,51 @@ void QNavigationWidget::paintEvent(QPaintEvent *)
|
||||
painter.drawRect(rect());
|
||||
|
||||
|
||||
painter.setBrush(QColor(backgroundColor));
|
||||
painter.drawRect(width() - controlBarWidth, 0, controlBarWidth,height());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//QPainterPath MenuPath;
|
||||
//MenuPath.addRect(QRect(width() - controlBarWidth,0,controlBarWidth, height()));
|
||||
//painter.setPen("#202020");
|
||||
//painter.fillPath(MenuPath, QColor("#202020"));
|
||||
|
||||
if(!isHidden)
|
||||
{
|
||||
|
||||
QPainterPath MenuPath;
|
||||
MenuPath.addRect(QRect(width() - controlBarWidth,0,controlBarWidth, height()));
|
||||
painter.setPen("#202020");
|
||||
painter.fillPath(MenuPath, QColor(controlBarColor));
|
||||
|
||||
|
||||
int h = height()/2;
|
||||
|
||||
QPolygon polygon1,polygon2,polygon3,polygon4;
|
||||
|
||||
polygon1.setPoints(4,
|
||||
width() - controlBarWidth,h ,
|
||||
width(), h - controlBarWidth,
|
||||
width(), h - 3 * controlBarWidth / 2,
|
||||
width() - controlBarWidth,h - controlBarWidth / 2);
|
||||
|
||||
polygon2.setPoints(4,
|
||||
width() - controlBarWidth,h ,
|
||||
width(), h + controlBarWidth,
|
||||
width(), h + 3 * controlBarWidth / 2,
|
||||
width() - controlBarWidth,h + controlBarWidth / 2);
|
||||
|
||||
polygon3.setPoints(4,
|
||||
width() - controlBarWidth,h - controlBarWidth ,
|
||||
width(), h - 2 * controlBarWidth,
|
||||
width(), h - 5 * controlBarWidth /2,
|
||||
width() - controlBarWidth,h - 3 * controlBarWidth /2);
|
||||
|
||||
polygon4.setPoints(4,
|
||||
width() - controlBarWidth,h + controlBarWidth ,
|
||||
width(), h + 2 * controlBarWidth,
|
||||
width(), h + 5 * controlBarWidth /2,
|
||||
width() - controlBarWidth,h + 3 * controlBarWidth /2);
|
||||
|
||||
QPainterPath SlidePath;
|
||||
|
||||
SlidePath.addRegion(polygon1);
|
||||
SlidePath.addRegion(polygon2);
|
||||
SlidePath.addRegion(polygon3);
|
||||
SlidePath.addRegion(polygon4);
|
||||
|
||||
painter.fillPath(SlidePath, QColor(controlSlideColor));
|
||||
|
||||
|
||||
// Draw Items
|
||||
@@ -141,7 +173,47 @@ void QNavigationWidget::paintEvent(QPaintEvent *)
|
||||
QPainterPath MenuPath;
|
||||
MenuPath.addRect(QRect(0,0,controlBarWidth, height()));
|
||||
painter.setPen("#202020");
|
||||
painter.fillPath(MenuPath, QColor(backgroundColor));
|
||||
painter.fillPath(MenuPath, QColor(controlBarColor));
|
||||
|
||||
|
||||
int h = height()/2;
|
||||
|
||||
QPolygon polygon1,polygon2,polygon3,polygon4;
|
||||
|
||||
polygon1.setPoints(4,
|
||||
controlBarWidth,h ,
|
||||
0, h - controlBarWidth,
|
||||
0, h - 3 * controlBarWidth / 2,
|
||||
controlBarWidth,h - controlBarWidth / 2);
|
||||
|
||||
polygon2.setPoints(4,
|
||||
controlBarWidth,h ,
|
||||
0, h + controlBarWidth,
|
||||
0, h + 3 * controlBarWidth / 2,
|
||||
controlBarWidth,h + controlBarWidth / 2);
|
||||
|
||||
polygon3.setPoints(4,
|
||||
controlBarWidth,h - controlBarWidth ,
|
||||
0, h - 2 * controlBarWidth,
|
||||
0, h - 5 * controlBarWidth /2,
|
||||
controlBarWidth,h - 3 * controlBarWidth /2);
|
||||
|
||||
polygon4.setPoints(4,
|
||||
controlBarWidth,h + controlBarWidth ,
|
||||
0, h + 2 * controlBarWidth,
|
||||
0, h + 5 * controlBarWidth /2,
|
||||
controlBarWidth,h + 3 * controlBarWidth /2);
|
||||
|
||||
QPainterPath SlidePath;
|
||||
|
||||
SlidePath.addRegion(polygon1);
|
||||
SlidePath.addRegion(polygon2);
|
||||
SlidePath.addRegion(polygon3);
|
||||
SlidePath.addRegion(polygon4);
|
||||
|
||||
painter.fillPath(SlidePath, QColor(controlSlideColor));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +270,7 @@ void QNavigationWidget::mousePressEvent(QMouseEvent *e)
|
||||
if(isHidden){
|
||||
|
||||
setWidth(controlBarWidth);
|
||||
|
||||
}
|
||||
else {
|
||||
setWidth(150);
|
||||
|
||||
Reference in New Issue
Block a user