Display dark background for PiP controls.

This commit is contained in:
John Preston 2020-02-03 15:38:42 +04:00
parent e095c325b3
commit 2cfb3c6755
4 changed files with 62 additions and 9 deletions

View File

@ -289,7 +289,6 @@ pipResizeArea: 10px;
pipControlSkip: 6px;
pipPlaybackWidth: 2px;
pipPlaybackSkip: 4px;
pipPlayBottom: 16px;
pipPlayIcon: icon {{ "player_pip_play", mediaviewPipControlsFg }};
pipPlayIconOver: icon {{ "player_pip_play", mediaviewPipControlsFgOver }};
pipPauseIcon: icon {{ "player_pip_pause", mediaviewPipControlsFg }};

View File

@ -300,6 +300,10 @@ QRect PipPanel::inner() const {
return rect().marginsRemoved(_padding);
}
RectParts PipPanel::attached() const {
return _attached;
}
bool PipPanel::dragging() const {
return _dragState.has_value();
}
@ -703,6 +707,7 @@ Pip::Pip(
, _panel(
_delegate->pipParentWidget(),
[=](QPainter &p, const FrameRequest &request) { paint(p, request); })
, _roundRect(ImageRoundRadius::Large, st::radialBg)
, _closeAndContinue(std::move(closeAndContinue))
, _destroy(std::move(destroy)) {
setupPanel();
@ -862,10 +867,7 @@ void Pip::setupButtons() {
{ skip, skip, skip, skip });
_play.icon = QRect(
rect.x() + (rect.width() - st::pipPlayIcon.width()) / 2,
(rect.y()
+ rect.height()
- st::pipPlayBottom
- st::pipPlayIcon.height()),
rect.y() + (rect.height() - st::pipPlayIcon.height()) / 2,
st::pipPlayIcon.width(),
st::pipPlayIcon.height());
const auto playbackHeight = 2 * st::pipPlaybackSkip
@ -904,14 +906,14 @@ void Pip::setupStreaming() {
void Pip::paint(QPainter &p, FrameRequest request) {
const auto image = videoFrameForDirectPaint(request);
const auto inner = _panel.inner();
p.drawImage(
QRect{
_panel.inner().topLeft(),
request.outer / style::DevicePixelRatio() },
QRect{ inner.topLeft(), request.outer / style::DevicePixelRatio() },
image);
if (_instance.player().ready()) {
_instance.markFrameShown();
}
paintRadialLoadingContent(p, inner);
paintControls(p);
}
@ -923,6 +925,22 @@ void Pip::paintControls(QPainter &p) {
}
p.setOpacity(shown);
using Part = RectPart;
const auto sides = _panel.attached();
const auto rounded = RectPart(0)
| ((sides & (Part::Top | Part::Left)) ? Part(0) : Part::TopLeft)
| ((sides & (Part::Top | Part::Right)) ? Part(0) : Part::TopRight)
| ((sides & (Part::Bottom | Part::Right))
? Part(0)
: Part::BottomRight)
| ((sides & (Part::Bottom | Part::Left))
? Part(0)
: Part::BottomLeft);
_roundRect.paintSomeRounded(
p,
_panel.inner(),
rounded | Part::NoTopBottom | Part::Top | Part::Bottom);
const auto outer = _panel.width();
const auto drawOne = [&](
const Button &button,
@ -1059,6 +1077,38 @@ QImage Pip::videoFrameForDirectPaint(const FrameRequest &request) const {
return result;
}
void Pip::paintRadialLoadingContent(QPainter &p, QRect outer) const {
if (!_instance.waitingShown()) {
return;
}
const auto inner = QRect(
outer.x() + (outer.width() - st::radialSize.width()) / 2,
outer.y() + (outer.height() - st::radialSize.height()) / 2,
st::radialSize.width(),
st::radialSize.height());
const auto arc = inner.marginsRemoved(QMargins(
st::radialLine,
st::radialLine,
st::radialLine,
st::radialLine));
p.setOpacity(_instance.waitingOpacity());
p.setPen(Qt::NoPen);
p.setBrush(st::radialBg);
{
PainterHighQualityEnabler hq(p);
p.drawEllipse(inner);
}
p.setOpacity(1.);
Ui::InfiniteRadialAnimation::Draw(
p,
_instance.waitingState(),
arc.topLeft(),
arc.size(),
_panel.width(),
st::radialFg,
st::radialLine);
}
Pip::OverState Pip::computeState(QPoint position) const {
if (!_panel.inner().contains(position)) {
return OverState::None;

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/streaming/media_streaming_instance.h"
#include "ui/effects/animations.h"
#include "ui/round_rect.h"
#include "ui/rp_widget.h"
#include <QtCore/QPointer>
@ -54,6 +55,7 @@ public:
[[nodiscard]] Position countPosition() const;
void setPosition(Position position);
[[nodiscard]] QRect inner() const;
[[nodiscard]] RectParts attached() const;
[[nodiscard]] bool dragging() const;
[[nodiscard]] rpl::producer<> saveGeometryRequests() const;
@ -158,6 +160,7 @@ private:
void handleClose();
void paintControls(QPainter &p);
void paintRadialLoadingContent(QPainter &p, QRect inner) const;
const not_null<Delegate*> _delegate;
Streaming::Instance _instance;
@ -173,6 +176,7 @@ private:
Button _playback;
Button _play;
Ui::Animations::Simple _controlsShown;
Ui::RoundRect _roundRect;
FnMut<void()> _closeAndContinue;
FnMut<void()> _destroy;

@ -1 +1 @@
Subproject commit 18ba60ec86f1494d994ce507bb3e43ebe1766c20
Subproject commit 1888853b52291c32ce5bbca7212e67c262c76cee