mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +08:00
Tested various pin buttons
This commit is contained in:
parent
381acb2449
commit
f71c8ffe5d
@ -35,6 +35,7 @@
|
||||
#include <QDebug>
|
||||
#include <QMap>
|
||||
#include <QWindow>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
#include "DockAreaWidget.h"
|
||||
#include "DockAreaTitleBar.h"
|
||||
@ -204,6 +205,11 @@ struct DockOverlayCrossPrivate
|
||||
{
|
||||
QColor borderColor = iconColor(CDockOverlayCross::FrameColor);
|
||||
QColor backgroundColor = iconColor(CDockOverlayCross::WindowBackgroundColor);
|
||||
QColor overlayColor = iconColor(CDockOverlayCross::OverlayColor);
|
||||
if (overlayColor.alpha() == 255)
|
||||
{
|
||||
overlayColor.setAlpha(64);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x050600
|
||||
double DevicePixelRatio = _this->window()->devicePixelRatioF();
|
||||
@ -261,22 +267,25 @@ struct DockOverlayCrossPrivate
|
||||
}
|
||||
|
||||
QSizeF baseSize = baseRect.size();
|
||||
if (CDockOverlay::ModeContainerOverlay == Mode && DockWidgetArea != CenterDockWidgetArea)
|
||||
bool IsOuterContainerArea = (CDockOverlay::ModeContainerOverlay == Mode)
|
||||
&& (DockWidgetArea != CenterDockWidgetArea)
|
||||
&& !internal::isSideBarArea(DockWidgetArea);
|
||||
|
||||
if (IsOuterContainerArea)
|
||||
{
|
||||
baseRect = areaRect;
|
||||
}
|
||||
|
||||
p.fillRect(baseRect, backgroundColor);
|
||||
//if (!internal::isSideBarArea(DockWidgetArea))
|
||||
//{
|
||||
p.fillRect(baseRect, backgroundColor);
|
||||
//}
|
||||
|
||||
if (areaRect.isValid())
|
||||
{
|
||||
pen = p.pen();
|
||||
pen.setColor(borderColor);
|
||||
QColor Color = iconColor(CDockOverlayCross::OverlayColor);
|
||||
if (Color.alpha() == 255)
|
||||
{
|
||||
Color.setAlpha(64);
|
||||
}
|
||||
p.setBrush(Color);
|
||||
p.setBrush(overlayColor);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRect(areaRect);
|
||||
|
||||
@ -289,23 +298,26 @@ struct DockOverlayCrossPrivate
|
||||
}
|
||||
p.restore();
|
||||
|
||||
p.save();
|
||||
// Draw outer border
|
||||
pen = p.pen();
|
||||
pen.setColor(borderColor);
|
||||
pen.setWidth(1);
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.setPen(pen);
|
||||
p.drawRect(baseRect);
|
||||
//if (!internal::isSideBarArea(DockWidgetArea))
|
||||
//{
|
||||
p.save();
|
||||
// Draw outer border
|
||||
pen = p.pen();
|
||||
pen.setColor(borderColor);
|
||||
pen.setWidth(1);
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.setPen(pen);
|
||||
p.drawRect(baseRect);
|
||||
|
||||
// draw window title bar
|
||||
p.setBrush(borderColor);
|
||||
QRectF FrameRect(baseRect.topLeft(), QSizeF(baseRect.width(), baseSize.height() / 10));
|
||||
p.drawRect(FrameRect);
|
||||
p.restore();
|
||||
// draw window title bar
|
||||
p.setBrush(borderColor);
|
||||
QRectF FrameRect(baseRect.topLeft(), QSizeF(baseRect.width(), baseSize.height() / 10));
|
||||
p.drawRect(FrameRect);
|
||||
p.restore();
|
||||
//}
|
||||
|
||||
// Draw arrow for outer container drop indicators
|
||||
/*if (CDockOverlay::ModeContainerOverlay == Mode && DockWidgetArea != CenterDockWidgetArea)
|
||||
if (IsOuterContainerArea)
|
||||
{
|
||||
QRectF ArrowRect;
|
||||
ArrowRect.setSize(baseSize);
|
||||
@ -339,7 +351,37 @@ struct DockOverlayCrossPrivate
|
||||
}
|
||||
|
||||
p.drawPolygon(Arrow);
|
||||
}*/
|
||||
}
|
||||
|
||||
// Draw the pin icons
|
||||
if (internal::isSideBarArea(DockWidgetArea))
|
||||
{
|
||||
static QIcon PinIcon;
|
||||
if (PinIcon.isNull())
|
||||
{
|
||||
std::cout << "Initializing pin icon" << std::endl;
|
||||
QFile file(":/ads/images/vs-pin-button.svg");
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray baData = file.readAll();
|
||||
baData.replace("#000000", borderColor.name(QColor::HexRgb).toLatin1());
|
||||
//baData.replace("#ffffff", overlayColor.name(QColor::HexArgb).toLatin1());
|
||||
//std::cout << borderColor.name(QColor::HexRgb) << std::endl;
|
||||
QSvgRenderer svgRenderer(baData);
|
||||
QPixmap pix(svgRenderer.defaultSize());
|
||||
pix.fill(Qt::transparent);
|
||||
// create painter to act over pixmap
|
||||
QPainter pixPainter(&pix);
|
||||
svgRenderer.render(&pixPainter);
|
||||
PinIcon = QIcon(pix);
|
||||
}
|
||||
//p.drawPixmap(0, PinIcon.paint(painter, rect, alignment, mode, state));
|
||||
auto Rect = QRect(0, 0, 16, 16);
|
||||
//Rect.setSize(baseRect.size() * 0.8);
|
||||
Rect.moveCenter(baseRect.center().toPoint());
|
||||
PinIcon.paint(&p, Rect, Qt::AlignCenter);
|
||||
//auto Pixmap = PinIcon.pixmap(_this->windowHandle(), QSize(16, 16));
|
||||
//p.drawPixmap(QPoint(0, 0), Pixmap);
|
||||
}
|
||||
|
||||
pm.setDevicePixelRatio(DevicePixelRatio);
|
||||
return pm;
|
||||
|
@ -18,5 +18,7 @@
|
||||
<file>images/vs-pin-button.svg</file>
|
||||
<file>images/vs-pin-button-pinned.svg</file>
|
||||
<file>images/vs-pin-button-pinned-focused.svg</file>
|
||||
<file>images/vs-pin-button_45.svg</file>
|
||||
<file>images/pin-button-big.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
2
src/images/pin-button-big.svg
Normal file
2
src/images/pin-button-big.svg
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="16" height="16" enable-background="new 0 0 122.879 122.867" version="1.1" viewBox="0 0 16 16" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><g transform="matrix(.12293 0 0 .12294 .39712 .49812)" fill="#ffffff" stroke="#000000" stroke-width="8.1347"><path d="m83.88 0.451 38.547 38.549c0.603 0.601 0.603 1.585 0 2.188l-13.128 13.125c-0.602 0.604-1.586 0.604-2.187 0l-3.732-3.73-17.303 17.3c3.882 14.621 0.095 30.857-11.37 42.32-0.266 0.268-0.535 0.529-0.808 0.787-1.004 0.955-0.843 0.949-1.813-0.021l-24.489-24.489-47.597 36.387 36.399-47.584-24.525-24.523c-0.978-0.98-0.896-0.826 0.066-1.837 0.24-0.251 0.485-0.503 0.734-0.753 11.463-11.463 27.702-15.253 42.322-11.37l17.301-17.3-3.733-3.732c-0.601-0.601-0.601-1.585 0-2.188l13.127-13.129c0.604-0.601 1.588-0.601 2.189 0z" clip-rule="evenodd" fill="#ffffff" fill-rule="evenodd" stroke="#000000" stroke-width="8.1347"/></g></svg>
|
After Width: | Height: | Size: 940 B |
2
src/images/vs-pin-button_45.svg
Normal file
2
src/images/vs-pin-button_45.svg
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="16" height="16" enable-background="new 0 0 122.879 122.867" version="1.1" viewBox="0 0 16 16" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m10.286-1.055e-6 -6.8571 6.8571-1.1429-1.1429-1.1429 1.1429 3.4286 3.4286-4.5714 4.5714 1.1429 1.1429 4.5714-4.5714 3.4286 3.4286 1.1429-1.1429-1.1429-1.1429 6.8571-6.8571-4.5714-4.5714zm0 2.2857 2.2857 2.2857-5.7143 5.7143-2.2857-2.2857z" fill="#000000"/></svg>
|
After Width: | Height: | Size: 473 B |
@ -5,7 +5,7 @@ TARGET = $$qtLibraryTarget(qtadvanceddocking)
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
TEMPLATE = lib
|
||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||
QT += core gui widgets
|
||||
QT += core gui widgets svg
|
||||
|
||||
!adsBuildStatic {
|
||||
CONFIG += shared
|
||||
|
Loading…
Reference in New Issue
Block a user