mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
changed scrollbar highlight color
This commit is contained in:
parent
6b24f249f7
commit
a48a233785
|
@ -115,6 +115,9 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
|||
{QColor("#00aeef"), QColor("#00aeef"), QColor("#00aeef")}};
|
||||
}
|
||||
|
||||
// scrollbar
|
||||
this->scrollbars.highlights.highlight = QColor("#ee6166");
|
||||
|
||||
// this->tabs.newMessage = {
|
||||
// fg,
|
||||
// {QBrush(blendColors(themeColor, "#ccc", 0.9), Qt::FDiagPattern),
|
||||
|
|
|
@ -109,8 +109,9 @@ public:
|
|||
QColor background;
|
||||
QColor thumb;
|
||||
QColor thumbSelected;
|
||||
// const int highlightsCount = 3;
|
||||
// QColor highlights[3];
|
||||
struct {
|
||||
QColor highlight;
|
||||
} highlights;
|
||||
} scrollbars;
|
||||
|
||||
/// TOOLTIP
|
||||
|
|
|
@ -54,8 +54,6 @@ BaseWindow::Flags BaseWindow::getFlags()
|
|||
|
||||
void BaseWindow::init()
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
this->setWindowIcon(QIcon(":/images/icon.png"));
|
||||
|
||||
#ifdef USEWINSDK
|
||||
|
@ -132,14 +130,14 @@ void BaseWindow::init()
|
|||
|
||||
#ifdef USEWINSDK
|
||||
// fourtf: don't ask me why we need to delay this
|
||||
QTimer::singleShot(1, this, [this] {
|
||||
if (!(this->flags & Flags::TopMost)) {
|
||||
if (!(this->flags & Flags::TopMost)) {
|
||||
QTimer::singleShot(1, this, [this] {
|
||||
getApp()->settings->windowTopMost.connect([this](bool topMost, auto) {
|
||||
::SetWindowPos((HWND)this->winId(), topMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0,
|
||||
0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
::SetWindowPos(HWND(this->winId()), topMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0,
|
||||
0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
#else
|
||||
// if (getApp()->settings->windowTopMost.getValue()) {
|
||||
// this->setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||
|
@ -251,10 +249,12 @@ void BaseWindow::leaveEvent(QEvent *)
|
|||
TooltipWidget::getInstance()->hide();
|
||||
}
|
||||
|
||||
void BaseWindow::moveTo(QWidget *parent, QPoint point)
|
||||
void BaseWindow::moveTo(QWidget *parent, QPoint point, bool offset)
|
||||
{
|
||||
// point.rx() += 16;
|
||||
// point.ry() += 16;
|
||||
if (offset) {
|
||||
point.rx() += 16;
|
||||
point.ry() += 16;
|
||||
}
|
||||
|
||||
this->move(point);
|
||||
this->moveIntoDesktopRect(parent);
|
||||
|
@ -343,14 +343,13 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
|
|||
} else {
|
||||
return QWidget::nativeEvent(eventType, message, result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
case WM_NCHITTEST: {
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
*result = 0;
|
||||
const LONG border_width = 8; // in pixels
|
||||
RECT winrect;
|
||||
GetWindowRect((HWND)winId(), &winrect);
|
||||
GetWindowRect(HWND(winId()), &winrect);
|
||||
|
||||
long x = GET_X_LPARAM(msg->lParam);
|
||||
long y = GET_Y_LPARAM(msg->lParam);
|
||||
|
@ -442,13 +441,13 @@ void BaseWindow::showEvent(QShowEvent *event)
|
|||
// WS_MINIMIZEBOX);
|
||||
|
||||
const MARGINS shadow = {8, 8, 8, 8};
|
||||
DwmExtendFrameIntoClientArea((HWND)this->winId(), &shadow);
|
||||
DwmExtendFrameIntoClientArea(HWND(this->winId()), &shadow);
|
||||
}
|
||||
|
||||
BaseWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void BaseWindow::paintEvent(QPaintEvent *event)
|
||||
void BaseWindow::paintEvent(QPaintEvent *)
|
||||
{
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
QPainter painter(this);
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
void setStayInScreenRect(bool value);
|
||||
bool getStayInScreenRect() const;
|
||||
|
||||
void moveTo(QWidget *widget, QPoint point);
|
||||
void moveTo(QWidget *widget, QPoint point, bool offset = true);
|
||||
|
||||
Flags getFlags();
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ void SplitHeader::enterEvent(QEvent *event)
|
|||
{
|
||||
if (!this->tooltip.isEmpty()) {
|
||||
auto tooltipWidget = TooltipWidget::getInstance();
|
||||
tooltipWidget->moveTo(this, this->mapToGlobal(this->rect().bottomLeft()));
|
||||
tooltipWidget->moveTo(this, this->mapToGlobal(this->rect().bottomLeft()), false);
|
||||
tooltipWidget->setText(this->tooltip);
|
||||
tooltipWidget->show();
|
||||
tooltipWidget->raise();
|
||||
|
|
|
@ -20,7 +20,7 @@ Scrollbar::Scrollbar(ChannelView *parent)
|
|||
: BaseWidget(parent)
|
||||
, currentValueAnimation(this, "currentValue")
|
||||
{
|
||||
resize((int)(16 * this->getScale()), 100);
|
||||
resize(int(16 * this->getScale()), 100);
|
||||
this->currentValueAnimation.setDuration(150);
|
||||
this->currentValueAnimation.setEasingCurve(QEasingCurve(QEasingCurve::OutCubic));
|
||||
|
||||
|
@ -31,7 +31,7 @@ Scrollbar::Scrollbar(ChannelView *parent)
|
|||
timer->setSingleShot(true);
|
||||
|
||||
connect(timer, &QTimer::timeout, [=]() {
|
||||
resize((int)(16 * this->getScale()), 100);
|
||||
resize(int(16 * this->getScale()), 100);
|
||||
timer->deleteLater();
|
||||
});
|
||||
|
||||
|
@ -98,7 +98,7 @@ void Scrollbar::setDesiredValue(qreal value, bool animated)
|
|||
animated &= app->settings->enableSmoothScrolling.getValue();
|
||||
value = std::max(this->minimum, std::min(this->maximum - this->largeChange, value));
|
||||
|
||||
if (this->desiredValue + this->smoothScrollingOffset != value) {
|
||||
if (std::abs(this->desiredValue + this->smoothScrollingOffset - value) > 0.0001) {
|
||||
if (animated) {
|
||||
this->currentValueAnimation.stop();
|
||||
this->currentValueAnimation.setStartValue(this->currentValue +
|
||||
|
@ -196,8 +196,10 @@ void Scrollbar::printCurrentState(const QString &prefix) const
|
|||
|
||||
void Scrollbar::paintEvent(QPaintEvent *)
|
||||
{
|
||||
auto *app = getApp();
|
||||
|
||||
bool mouseOver = this->mouseOverIndex != -1;
|
||||
int xOffset = mouseOver ? 0 : width() - (int)(4 * this->getScale());
|
||||
int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale());
|
||||
|
||||
QPainter painter(this);
|
||||
// painter.fillRect(rect(), this->themeManager->ScrollbarBG);
|
||||
|
@ -221,7 +223,7 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
|||
|
||||
// draw highlights
|
||||
auto snapshot = this->highlights.getSnapshot();
|
||||
int snapshotLength = (int)snapshot.getLength();
|
||||
size_t snapshotLength = snapshot.getLength();
|
||||
|
||||
if (snapshotLength == 0) {
|
||||
return;
|
||||
|
@ -229,19 +231,31 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
|||
|
||||
int w = this->width();
|
||||
float y = 0;
|
||||
float dY = (float)(this->height()) / (float)snapshotLength;
|
||||
int highlightHeight = std::ceil(dY);
|
||||
float dY = float(this->height()) / float(snapshotLength);
|
||||
int highlightHeight = int(std::ceil(dY));
|
||||
|
||||
for (int i = 0; i < snapshotLength; i++) {
|
||||
for (size_t i = 0; i < snapshotLength; i++) {
|
||||
ScrollbarHighlight const &highlight = snapshot[i];
|
||||
|
||||
if (!highlight.isNull()) {
|
||||
if (highlight.getStyle() == ScrollbarHighlight::Default) {
|
||||
painter.fillRect(w / 8 * 3, (int)y, w / 4, highlightHeight,
|
||||
this->themeManager->tabs.selected.backgrounds.regular.color());
|
||||
} else {
|
||||
painter.fillRect(0, (int)y, w, 1,
|
||||
this->themeManager->tabs.selected.backgrounds.regular.color());
|
||||
QColor color = [&] {
|
||||
switch (highlight.getColor()) {
|
||||
case ScrollbarHighlight::Highlight:
|
||||
return app->themes->scrollbars.highlights.highlight;
|
||||
}
|
||||
return QColor();
|
||||
}();
|
||||
|
||||
switch (highlight.getStyle()) {
|
||||
case ScrollbarHighlight::Default: {
|
||||
painter.fillRect(w / 8 * 3, int(y), w / 4, highlightHeight, color);
|
||||
} break;
|
||||
|
||||
case ScrollbarHighlight::Line: {
|
||||
painter.fillRect(0, int(y), w, 1, color);
|
||||
} break;
|
||||
|
||||
case ScrollbarHighlight::None:;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,7 +265,7 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
|||
|
||||
void Scrollbar::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
this->resize((int)(16 * this->getScale()), this->height());
|
||||
this->resize(int(16 * this->getScale()), this->height());
|
||||
}
|
||||
|
||||
void Scrollbar::mouseMoveEvent(QMouseEvent *event)
|
||||
|
@ -279,7 +293,7 @@ void Scrollbar::mouseMoveEvent(QMouseEvent *event)
|
|||
} else if (this->mouseDownIndex == 2) {
|
||||
int delta = event->pos().y() - this->lastMousePosition.y();
|
||||
|
||||
setDesiredValue(this->desiredValue + (qreal)delta / this->trackHeight * this->maximum);
|
||||
setDesiredValue(this->desiredValue + qreal(delta) / this->trackHeight * this->maximum);
|
||||
}
|
||||
|
||||
this->lastMousePosition = event->pos();
|
||||
|
@ -342,8 +356,8 @@ void Scrollbar::updateScroll()
|
|||
this->trackHeight = height() - this->buttonHeight - this->buttonHeight - MIN_THUMB_HEIGHT - 1;
|
||||
|
||||
this->thumbRect = QRect(
|
||||
0, (int)(this->currentValue / this->maximum * this->trackHeight) + 1 + this->buttonHeight,
|
||||
width(), (int)(this->largeChange / this->maximum * this->trackHeight) + MIN_THUMB_HEIGHT);
|
||||
0, int(this->currentValue / this->maximum * this->trackHeight) + 1 + this->buttonHeight,
|
||||
width(), int(this->largeChange / this->maximum * this->trackHeight) + MIN_THUMB_HEIGHT);
|
||||
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class Scrollbar : public BaseWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Scrollbar(ChannelView *parent = 0);
|
||||
Scrollbar(ChannelView *parent = nullptr);
|
||||
|
||||
void addHighlight(ScrollbarHighlight highlight);
|
||||
void addHighlightsAtStart(const std::vector<ScrollbarHighlight> &highlights);
|
||||
|
|
|
@ -16,6 +16,15 @@
|
|||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
TooltipWidget *TooltipWidget::getInstance()
|
||||
{
|
||||
static TooltipWidget *tooltipWidget = nullptr;
|
||||
if (tooltipWidget == nullptr) {
|
||||
tooltipWidget = new TooltipWidget();
|
||||
}
|
||||
return tooltipWidget;
|
||||
}
|
||||
|
||||
TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
: BaseWindow(parent, BaseWindow::TopMost)
|
||||
, displayText(new QLabel())
|
||||
|
@ -49,7 +58,7 @@ TooltipWidget::~TooltipWidget()
|
|||
#ifdef USEWINSDK
|
||||
void TooltipWidget::raise()
|
||||
{
|
||||
::SetWindowPos((HWND)this->winId(), HWND_TOPMOST, 0, 0, 0, 0,
|
||||
::SetWindowPos(HWND(this->winId()), HWND_TOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -14,20 +14,13 @@ class TooltipWidget : public BaseWindow
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static TooltipWidget *getInstance();
|
||||
|
||||
TooltipWidget(BaseWidget *parent = nullptr);
|
||||
~TooltipWidget();
|
||||
virtual ~TooltipWidget() override;
|
||||
|
||||
void setText(QString text);
|
||||
|
||||
static TooltipWidget *getInstance()
|
||||
{
|
||||
static TooltipWidget *tooltipWidget = nullptr;
|
||||
if (tooltipWidget == nullptr) {
|
||||
tooltipWidget = new TooltipWidget();
|
||||
}
|
||||
return tooltipWidget;
|
||||
}
|
||||
|
||||
#ifdef USEWINSDK
|
||||
void raise();
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue