Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
2216daa587
13 changed files with 101 additions and 22 deletions
|
|
@ -521,6 +521,14 @@ mediaviewPlaybackInactiveOver: #474747; // video playback progress upcoming (not
|
||||||
mediaviewPlaybackProgressFg: #ffffffc7; // video playback progress text
|
mediaviewPlaybackProgressFg: #ffffffc7; // video playback progress text
|
||||||
mediaviewPlaybackIconFg: mediaviewPlaybackActive; // video playback controls icon
|
mediaviewPlaybackIconFg: mediaviewPlaybackActive; // video playback controls icon
|
||||||
mediaviewPlaybackIconFgOver: mediaviewPlaybackActiveOver; // video playback controls icon with mouse over
|
mediaviewPlaybackIconFgOver: mediaviewPlaybackActiveOver; // video playback controls icon with mouse over
|
||||||
|
mediaviewPlaybackIconRipple: #ffffff14; // video playback controls ripple effect
|
||||||
|
|
||||||
|
mediaviewPipControlsFg: #ffffffd9; // picture-in-picture controls
|
||||||
|
mediaviewPipControlsFgOver: #ffffff; // picture-in-picture controls with mouse over
|
||||||
|
mediaviewPipFade: #00000095; // picture-in-picture gradient fade controls background
|
||||||
|
mediaviewPipPlaybackActive: #ffffffda; // picture-in-picture playback progress already played part
|
||||||
|
mediaviewPipPlaybackInactive: #ffffff26; // picture-in-picture playback progress upcoming (not played yet) part
|
||||||
|
|
||||||
mediaviewTransparentBg: #ffffff; // transparent filling part (when viewing a transparent .png file in Media Viewer)
|
mediaviewTransparentBg: #ffffff; // transparent filling part (when viewing a transparent .png file in Media Viewer)
|
||||||
mediaviewTransparentFg: #cccccc; // another transparent filling part
|
mediaviewTransparentFg: #cccccc; // another transparent filling part
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class QPaintEvent;
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
inline void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {
|
inline void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void InitOnTopPanel(not_null<QWidget*> panel) {
|
inline void InitOnTopPanel(not_null<QWidget*> panel) {
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@ void InitOnTopPanel(not_null<QWidget*> panel) {
|
||||||
auto platformPanel = static_cast<NSPanel*>(platformWindow);
|
auto platformPanel = static_cast<NSPanel*>(platformWindow);
|
||||||
[platformPanel setLevel:NSPopUpMenuWindowLevel];
|
[platformPanel setLevel:NSPopUpMenuWindowLevel];
|
||||||
[platformPanel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorFullScreenAuxiliary|NSWindowCollectionBehaviorIgnoresCycle];
|
[platformPanel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorFullScreenAuxiliary|NSWindowCollectionBehaviorIgnoresCycle];
|
||||||
[platformPanel setFloatingPanel:YES];
|
|
||||||
[platformPanel setHidesOnDeactivate:NO];
|
[platformPanel setHidesOnDeactivate:NO];
|
||||||
|
//[platformPanel setFloatingPanel:YES];
|
||||||
|
|
||||||
Integration::Instance().activationFromTopPanel();
|
Integration::Instance().activationFromTopPanel();
|
||||||
}
|
}
|
||||||
|
|
@ -67,12 +67,12 @@ void ReInitOnTopPanel(not_null<QWidget*> panel) {
|
||||||
[platformPanel setCollectionBehavior:newBehavior];
|
[platformPanel setCollectionBehavior:newBehavior];
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {
|
void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects) {
|
||||||
#ifdef OS_MAC_OLD
|
|
||||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
p.fillRect(e->rect(), Qt::transparent);
|
for (const auto &r : rects) {
|
||||||
|
p.fillRect(r, Qt::transparent);
|
||||||
|
}
|
||||||
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||||
#endif // OS_MAC_OLD
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
|
void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Platform {
|
||||||
[[nodiscard]] bool IsApplicationActive();
|
[[nodiscard]] bool IsApplicationActive();
|
||||||
|
|
||||||
[[nodiscard]] bool TranslucentWindowsSupported(QPoint globalPosition);
|
[[nodiscard]] bool TranslucentWindowsSupported(QPoint globalPosition);
|
||||||
void StartTranslucentPaint(QPainter &p, QPaintEvent *e);
|
void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects);
|
||||||
|
|
||||||
void InitOnTopPanel(not_null<QWidget*> panel);
|
void InitOnTopPanel(not_null<QWidget*> panel);
|
||||||
void DeInitOnTopPanel(not_null<QWidget*> panel);
|
void DeInitOnTopPanel(not_null<QWidget*> panel);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ void UpdateOverlayed(not_null<QWidget*> widget) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IgnoreAllActivation(not_null<QWidget*> widget) {
|
void IgnoreAllActivation(not_null<QWidget*> widget) {
|
||||||
|
widget->createWinId();
|
||||||
|
|
||||||
const auto handle = reinterpret_cast<HWND>(widget->winId());
|
const auto handle = reinterpret_cast<HWND>(widget->winId());
|
||||||
Assert(handle != nullptr);
|
Assert(handle != nullptr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ inline void DeInitOnTopPanel(not_null<QWidget*> panel) {
|
||||||
inline void ReInitOnTopPanel(not_null<QWidget*> panel) {
|
inline void ReInitOnTopPanel(not_null<QWidget*> panel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {
|
inline void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
|
inline void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ void DrawRoundedRect(
|
||||||
const auto y = rect.y();
|
const auto y = rect.y();
|
||||||
const auto w = rect.width();
|
const auto w = rect.width();
|
||||||
const auto h = rect.height();
|
const auto h = rect.height();
|
||||||
auto cornerWidth = corners[0].width() / pixelRatio;
|
const auto cornerWidth = corners[0].width() / pixelRatio;
|
||||||
auto cornerHeight = corners[0].height() / pixelRatio;
|
const auto cornerHeight = corners[0].height() / pixelRatio;
|
||||||
if (w < 2 * cornerWidth || h < 2 * cornerHeight) return;
|
if (w < 2 * cornerWidth || h < 2 * cornerHeight) return;
|
||||||
if (w > 2 * cornerWidth) {
|
if (w > 2 * cornerWidth) {
|
||||||
if (parts & RectPart::Top) {
|
if (parts & RectPart::Top) {
|
||||||
|
|
@ -85,4 +85,47 @@ void RoundRect::paint(
|
||||||
DrawRoundedRect(p, rect, _color, _corners, parts);
|
DrawRoundedRect(p, rect, _color, _corners, parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RoundRect::paintSomeRounded(
|
||||||
|
QPainter &p,
|
||||||
|
const QRect &rect,
|
||||||
|
RectParts corners) const {
|
||||||
|
DrawRoundedRect(
|
||||||
|
p,
|
||||||
|
rect,
|
||||||
|
_color,
|
||||||
|
_corners,
|
||||||
|
corners | RectPart::Top | RectPart::NoTopBottom | RectPart::Bottom);
|
||||||
|
|
||||||
|
const auto pixelRatio = style::DevicePixelRatio();
|
||||||
|
const auto cornerWidth = _corners[0].width() / pixelRatio;
|
||||||
|
const auto cornerHeight = _corners[0].height() / pixelRatio;
|
||||||
|
if (!(corners & RectPart::TopLeft)) {
|
||||||
|
p.fillRect(rect.x(), rect.y(), cornerWidth, cornerHeight, _color);
|
||||||
|
}
|
||||||
|
if (!(corners & RectPart::TopRight)) {
|
||||||
|
p.fillRect(
|
||||||
|
rect.x() + rect.width() - cornerWidth,
|
||||||
|
rect.y(),
|
||||||
|
cornerWidth,
|
||||||
|
cornerHeight,
|
||||||
|
_color);
|
||||||
|
}
|
||||||
|
if (!(corners & RectPart::BottomRight)) {
|
||||||
|
p.fillRect(
|
||||||
|
rect.x() + rect.width() - cornerWidth,
|
||||||
|
rect.y() + rect.height() - cornerHeight,
|
||||||
|
cornerWidth,
|
||||||
|
cornerHeight,
|
||||||
|
_color);
|
||||||
|
}
|
||||||
|
if (!(corners & RectPart::BottomLeft)) {
|
||||||
|
p.fillRect(
|
||||||
|
rect.x(),
|
||||||
|
rect.y() + rect.height() - cornerHeight,
|
||||||
|
cornerWidth,
|
||||||
|
cornerHeight,
|
||||||
|
_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ public:
|
||||||
QPainter &p,
|
QPainter &p,
|
||||||
const QRect &rect,
|
const QRect &rect,
|
||||||
RectParts parts = RectPart::Full) const;
|
RectParts parts = RectPart::Full) const;
|
||||||
|
void paintSomeRounded(
|
||||||
|
QPainter &p,
|
||||||
|
const QRect &rect,
|
||||||
|
RectParts corners) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
style::color _color;
|
style::color _color;
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,7 @@ void StartFonts() {
|
||||||
#endif // !DESKTOP_APP_USE_PACKAGED_FONTS
|
#endif // !DESKTOP_APP_USE_PACKAGED_FONTS
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
auto list = QStringList();
|
auto list = QStringList();
|
||||||
|
list.append("STIXGeneral");
|
||||||
list.append(".SF NS Text");
|
list.append(".SF NS Text");
|
||||||
list.append("Helvetica Neue");
|
list.append("Helvetica Neue");
|
||||||
list.append("Lucida Grande");
|
list.append("Lucida Grande");
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,10 @@ void Menu::init() {
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
|
if (_st.itemBg->c.alpha() == 255) {
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
not_null<QAction*> Menu::addAction(const QString &text, const QObject *receiver, const char* member, const style::icon *icon, const style::icon *iconOver) {
|
not_null<QAction*> Menu::addAction(const QString &text, const QObject *receiver, const char* member, const style::icon *icon, const style::icon *iconOver) {
|
||||||
const auto action = addAction(new QAction(text, this), icon, iconOver);
|
const auto action = addAction(new QAction(text, this), icon, iconOver);
|
||||||
|
|
@ -261,6 +263,9 @@ void Menu::paintEvent(QPaintEvent *e) {
|
||||||
} else {
|
} else {
|
||||||
auto enabled = action->isEnabled();
|
auto enabled = action->isEnabled();
|
||||||
auto selected = ((i == _selected || i == _pressed) && enabled);
|
auto selected = ((i == _selected || i == _pressed) && enabled);
|
||||||
|
if (selected && _st.itemBgOver->c.alpha() < 255) {
|
||||||
|
p.fillRect(0, 0, width(), actionHeight, _st.itemBg);
|
||||||
|
}
|
||||||
p.fillRect(0, 0, width(), actionHeight, selected ? _st.itemBgOver : _st.itemBg);
|
p.fillRect(0, 0, width(), actionHeight, selected ? _st.itemBgOver : _st.itemBg);
|
||||||
if (data.ripple) {
|
if (data.ripple) {
|
||||||
data.ripple->paint(p, 0, 0, width());
|
data.ripple->paint(p, 0, 0, width());
|
||||||
|
|
|
||||||
|
|
@ -121,10 +121,6 @@ const std::vector<not_null<QAction*>> &PopupMenu::actions() const {
|
||||||
void PopupMenu::paintEvent(QPaintEvent *e) {
|
void PopupMenu::paintEvent(QPaintEvent *e) {
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
|
|
||||||
if (_useTransparency) {
|
|
||||||
Platform::StartTranslucentPaint(p, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_a_show.animating()) {
|
if (_a_show.animating()) {
|
||||||
if (auto opacity = _a_opacity.value(_hiding ? 0. : 1.)) {
|
if (auto opacity = _a_opacity.value(_hiding ? 0. : 1.)) {
|
||||||
_showAnimation->paintFrame(p, 0, 0, width(), _a_show.value(1.), opacity);
|
_showAnimation->paintFrame(p, 0, 0, width(), _a_show.value(1.), opacity);
|
||||||
|
|
@ -304,7 +300,11 @@ void PopupMenu::childHiding(PopupMenu *child) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::setOrigin(PanelAnimation::Origin origin) {
|
void PopupMenu::setOrigin(PanelAnimation::Origin origin) {
|
||||||
_origin = origin;
|
_origin = _forcedOrigin.value_or(origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupMenu::setForcedOrigin(PanelAnimation::Origin origin) {
|
||||||
|
_forcedOrigin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenu::showAnimated(PanelAnimation::Origin origin) {
|
void PopupMenu::showAnimated(PanelAnimation::Origin origin) {
|
||||||
|
|
@ -461,14 +461,28 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
||||||
}
|
}
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
|
|
||||||
auto origin = PanelAnimation::Origin::TopLeft;
|
using Origin = PanelAnimation::Origin;
|
||||||
|
auto origin = Origin::TopLeft;
|
||||||
|
const auto forceLeft = _forcedOrigin
|
||||||
|
&& (*_forcedOrigin == Origin::TopLeft
|
||||||
|
|| *_forcedOrigin == Origin::BottomLeft);
|
||||||
|
const auto forceTop = _forcedOrigin
|
||||||
|
&& (*_forcedOrigin == Origin::TopLeft
|
||||||
|
|| *_forcedOrigin == Origin::TopRight);
|
||||||
|
const auto forceRight = _forcedOrigin
|
||||||
|
&& (*_forcedOrigin == Origin::TopRight
|
||||||
|
|| *_forcedOrigin == Origin::BottomRight);
|
||||||
|
const auto forceBottom = _forcedOrigin
|
||||||
|
&& (*_forcedOrigin == Origin::BottomLeft
|
||||||
|
|| *_forcedOrigin == Origin::BottomRight);
|
||||||
auto w = p - QPoint(0, _padding.top());
|
auto w = p - QPoint(0, _padding.top());
|
||||||
auto r = QApplication::desktop()->screenGeometry(p);
|
auto r = QApplication::desktop()->screenGeometry(p);
|
||||||
_useTransparency = Platform::TranslucentWindowsSupported(p);
|
_useTransparency = Platform::TranslucentWindowsSupported(p);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency);
|
setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency);
|
||||||
handleCompositingUpdate();
|
handleCompositingUpdate();
|
||||||
if (style::RightToLeft()) {
|
if (style::RightToLeft()) {
|
||||||
if (w.x() - width() < r.x() - _padding.left()) {
|
const auto badLeft = (w.x() - width() < r.x() - _padding.left());
|
||||||
|
if (forceRight || (badLeft && !forceLeft)) {
|
||||||
if (_parent && w.x() + _parent->width() - _padding.left() - _padding.right() + width() - _padding.right() <= r.x() + r.width()) {
|
if (_parent && w.x() + _parent->width() - _padding.left() - _padding.right() + width() - _padding.right() <= r.x() + r.width()) {
|
||||||
w.setX(w.x() + _parent->width() - _padding.left() - _padding.right());
|
w.setX(w.x() + _parent->width() - _padding.left() - _padding.right());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -478,7 +492,8 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
||||||
w.setX(w.x() - width());
|
w.setX(w.x() - width());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (w.x() + width() - _padding.right() > r.x() + r.width()) {
|
const auto badLeft = (w.x() + width() - _padding.right() > r.x() + r.width());
|
||||||
|
if (forceRight || (badLeft && !forceLeft)) {
|
||||||
if (_parent && w.x() - _parent->width() + _padding.left() + _padding.right() - width() + _padding.right() >= r.x() - _padding.left()) {
|
if (_parent && w.x() - _parent->width() + _padding.left() + _padding.right() - width() + _padding.right() >= r.x() - _padding.left()) {
|
||||||
w.setX(w.x() + _padding.left() + _padding.right() - _parent->width() - width() + _padding.left() + _padding.right());
|
w.setX(w.x() + _padding.left() + _padding.right() - _parent->width() - width() + _padding.left() + _padding.right());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -487,7 +502,8 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
||||||
origin = PanelAnimation::Origin::TopRight;
|
origin = PanelAnimation::Origin::TopRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (w.y() + height() - _padding.bottom() > r.y() + r.height()) {
|
const auto badTop = (w.y() + height() - _padding.bottom() > r.y() + r.height());
|
||||||
|
if (forceBottom || (badTop && !forceTop)) {
|
||||||
if (_parent) {
|
if (_parent) {
|
||||||
w.setY(r.y() + r.height() - height() + _padding.bottom());
|
w.setY(r.y() + r.height() - height() + _padding.bottom());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public:
|
||||||
void deleteOnHide(bool del);
|
void deleteOnHide(bool del);
|
||||||
void popup(const QPoint &p);
|
void popup(const QPoint &p);
|
||||||
void hideMenu(bool fast = false);
|
void hideMenu(bool fast = false);
|
||||||
|
void setForcedOrigin(PanelAnimation::Origin origin);
|
||||||
|
|
||||||
void setDestroyedCallback(Fn<void()> callback) {
|
void setDestroyedCallback(Fn<void()> callback) {
|
||||||
_destroyedCallback = std::move(callback);
|
_destroyedCallback = std::move(callback);
|
||||||
|
|
@ -109,6 +110,7 @@ private:
|
||||||
SubmenuPointer _activeSubmenu;
|
SubmenuPointer _activeSubmenu;
|
||||||
|
|
||||||
PanelAnimation::Origin _origin = PanelAnimation::Origin::TopLeft;
|
PanelAnimation::Origin _origin = PanelAnimation::Origin::TopLeft;
|
||||||
|
std::optional<PanelAnimation::Origin> _forcedOrigin;
|
||||||
std::unique_ptr<PanelAnimation> _showAnimation;
|
std::unique_ptr<PanelAnimation> _showAnimation;
|
||||||
Animations::Simple _a_show;
|
Animations::Simple _a_show;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,6 @@ void Tooltip::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
if (_useTransparency) {
|
if (_useTransparency) {
|
||||||
Platform::StartTranslucentPaint(p, e);
|
|
||||||
|
|
||||||
p.setPen(_st->textBorder);
|
p.setPen(_st->textBorder);
|
||||||
p.setBrush(_st->textBg);
|
p.setBrush(_st->textBg);
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue