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
|
||||
mediaviewPlaybackIconFg: mediaviewPlaybackActive; // video playback controls icon
|
||||
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)
|
||||
mediaviewTransparentFg: #cccccc; // another transparent filling part
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class QPaintEvent;
|
|||
namespace Ui {
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ void InitOnTopPanel(not_null<QWidget*> panel) {
|
|||
auto platformPanel = static_cast<NSPanel*>(platformWindow);
|
||||
[platformPanel setLevel:NSPopUpMenuWindowLevel];
|
||||
[platformPanel setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorFullScreenAuxiliary|NSWindowCollectionBehaviorIgnoresCycle];
|
||||
[platformPanel setFloatingPanel:YES];
|
||||
[platformPanel setHidesOnDeactivate:NO];
|
||||
//[platformPanel setFloatingPanel:YES];
|
||||
|
||||
Integration::Instance().activationFromTopPanel();
|
||||
}
|
||||
|
|
@ -67,12 +67,12 @@ void ReInitOnTopPanel(not_null<QWidget*> panel) {
|
|||
[platformPanel setCollectionBehavior:newBehavior];
|
||||
}
|
||||
|
||||
void StartTranslucentPaint(QPainter &p, QPaintEvent *e) {
|
||||
#ifdef OS_MAC_OLD
|
||||
void StartTranslucentPaint(QPainter &p, gsl::span<const QRect> rects) {
|
||||
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);
|
||||
#endif // OS_MAC_OLD
|
||||
}
|
||||
|
||||
void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Platform {
|
|||
[[nodiscard]] bool IsApplicationActive();
|
||||
|
||||
[[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 DeInitOnTopPanel(not_null<QWidget*> panel);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ void UpdateOverlayed(not_null<QWidget*> widget) {
|
|||
}
|
||||
|
||||
void IgnoreAllActivation(not_null<QWidget*> widget) {
|
||||
widget->createWinId();
|
||||
|
||||
const auto handle = reinterpret_cast<HWND>(widget->winId());
|
||||
Assert(handle != nullptr);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ inline void DeInitOnTopPanel(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) {
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ void DrawRoundedRect(
|
|||
const auto y = rect.y();
|
||||
const auto w = rect.width();
|
||||
const auto h = rect.height();
|
||||
auto cornerWidth = corners[0].width() / pixelRatio;
|
||||
auto cornerHeight = corners[0].height() / pixelRatio;
|
||||
const auto cornerWidth = corners[0].width() / pixelRatio;
|
||||
const auto cornerHeight = corners[0].height() / pixelRatio;
|
||||
if (w < 2 * cornerWidth || h < 2 * cornerHeight) return;
|
||||
if (w > 2 * cornerWidth) {
|
||||
if (parts & RectPart::Top) {
|
||||
|
|
@ -85,4 +85,47 @@ void RoundRect::paint(
|
|||
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
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ public:
|
|||
QPainter &p,
|
||||
const QRect &rect,
|
||||
RectParts parts = RectPart::Full) const;
|
||||
void paintSomeRounded(
|
||||
QPainter &p,
|
||||
const QRect &rect,
|
||||
RectParts corners) const;
|
||||
|
||||
private:
|
||||
style::color _color;
|
||||
|
|
|
|||
|
|
@ -236,6 +236,7 @@ void StartFonts() {
|
|||
#endif // !DESKTOP_APP_USE_PACKAGED_FONTS
|
||||
#ifdef Q_OS_MAC
|
||||
auto list = QStringList();
|
||||
list.append("STIXGeneral");
|
||||
list.append(".SF NS Text");
|
||||
list.append("Helvetica Neue");
|
||||
list.append("Lucida Grande");
|
||||
|
|
|
|||
|
|
@ -90,8 +90,10 @@ void Menu::init() {
|
|||
|
||||
setMouseTracking(true);
|
||||
|
||||
if (_st.itemBg->c.alpha() == 255) {
|
||||
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) {
|
||||
const auto action = addAction(new QAction(text, this), icon, iconOver);
|
||||
|
|
@ -261,6 +263,9 @@ void Menu::paintEvent(QPaintEvent *e) {
|
|||
} else {
|
||||
auto enabled = action->isEnabled();
|
||||
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);
|
||||
if (data.ripple) {
|
||||
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) {
|
||||
QPainter p(this);
|
||||
|
||||
if (_useTransparency) {
|
||||
Platform::StartTranslucentPaint(p, e);
|
||||
}
|
||||
|
||||
if (_a_show.animating()) {
|
||||
if (auto opacity = _a_opacity.value(_hiding ? 0. : 1.)) {
|
||||
_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) {
|
||||
_origin = origin;
|
||||
_origin = _forcedOrigin.value_or(origin);
|
||||
}
|
||||
|
||||
void PopupMenu::setForcedOrigin(PanelAnimation::Origin origin) {
|
||||
_forcedOrigin = origin;
|
||||
}
|
||||
|
||||
void PopupMenu::showAnimated(PanelAnimation::Origin origin) {
|
||||
|
|
@ -461,14 +461,28 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
|||
}
|
||||
_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 r = QApplication::desktop()->screenGeometry(p);
|
||||
_useTransparency = Platform::TranslucentWindowsSupported(p);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency);
|
||||
handleCompositingUpdate();
|
||||
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()) {
|
||||
w.setX(w.x() + _parent->width() - _padding.left() - _padding.right());
|
||||
} else {
|
||||
|
|
@ -478,7 +492,8 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
|||
w.setX(w.x() - width());
|
||||
}
|
||||
} 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()) {
|
||||
w.setX(w.x() + _padding.left() + _padding.right() - _parent->width() - width() + _padding.left() + _padding.right());
|
||||
} else {
|
||||
|
|
@ -487,7 +502,8 @@ void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource sou
|
|||
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) {
|
||||
w.setY(r.y() + r.height() - height() + _padding.bottom());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public:
|
|||
void deleteOnHide(bool del);
|
||||
void popup(const QPoint &p);
|
||||
void hideMenu(bool fast = false);
|
||||
void setForcedOrigin(PanelAnimation::Origin origin);
|
||||
|
||||
void setDestroyedCallback(Fn<void()> callback) {
|
||||
_destroyedCallback = std::move(callback);
|
||||
|
|
@ -109,6 +110,7 @@ private:
|
|||
SubmenuPointer _activeSubmenu;
|
||||
|
||||
PanelAnimation::Origin _origin = PanelAnimation::Origin::TopLeft;
|
||||
std::optional<PanelAnimation::Origin> _forcedOrigin;
|
||||
std::unique_ptr<PanelAnimation> _showAnimation;
|
||||
Animations::Simple _a_show;
|
||||
|
||||
|
|
|
|||
|
|
@ -132,8 +132,6 @@ void Tooltip::paintEvent(QPaintEvent *e) {
|
|||
Painter p(this);
|
||||
|
||||
if (_useTransparency) {
|
||||
Platform::StartTranslucentPaint(p, e);
|
||||
|
||||
p.setPen(_st->textBorder);
|
||||
p.setBrush(_st->textBg);
|
||||
PainterHighQualityEnabler hq(p);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue