Updated lib_ui sources to TDesktop version 2.8.8
This commit is contained in:
commit
075d2ff49a
34 changed files with 460 additions and 144 deletions
|
|
@ -51,6 +51,8 @@ PRIVATE
|
||||||
ui/effects/numbers_animation.h
|
ui/effects/numbers_animation.h
|
||||||
ui/effects/panel_animation.cpp
|
ui/effects/panel_animation.cpp
|
||||||
ui/effects/panel_animation.h
|
ui/effects/panel_animation.h
|
||||||
|
ui/effects/path_shift_gradient.cpp
|
||||||
|
ui/effects/path_shift_gradient.h
|
||||||
ui/effects/radial_animation.cpp
|
ui/effects/radial_animation.cpp
|
||||||
ui/effects/radial_animation.h
|
ui/effects/radial_animation.h
|
||||||
ui/effects/ripple_animation.cpp
|
ui/effects/ripple_animation.cpp
|
||||||
|
|
|
||||||
|
|
@ -641,6 +641,9 @@ sideBarBadgeFg: #ffffff; // filters side bar badge text
|
||||||
|
|
||||||
songCoverOverlayFg: #00000066; // song cover overlay
|
songCoverOverlayFg: #00000066; // song cover overlay
|
||||||
|
|
||||||
|
photoEditorBg: boxTitleAdditionalFg; // photo editor background
|
||||||
|
photoEditorItemBaseHandleFg: #3ccaef; // photo editor handle circle
|
||||||
|
|
||||||
// kotatogram
|
// kotatogram
|
||||||
ktgTopBarBg: topBarBg; // Kotatogram: top bar background
|
ktgTopBarBg: topBarBg; // Kotatogram: top bar background
|
||||||
ktgTopBarNameFg: dialogsNameFg; // Kotatogram: top bar name text
|
ktgTopBarNameFg: dialogsNameFg; // Kotatogram: top bar name text
|
||||||
|
|
|
||||||
|
|
@ -416,7 +416,6 @@ void PanelAnimation::paintFrame(QPainter &p, int x, int y, int outerWidth, float
|
||||||
if (fadeTop != fadeBottom) {
|
if (fadeTop != fadeBottom) {
|
||||||
auto painterFadeTop = fadeTop / pixelRatio;
|
auto painterFadeTop = fadeTop / pixelRatio;
|
||||||
auto painterFrameWidth = frameWidth / pixelRatio;
|
auto painterFrameWidth = frameWidth / pixelRatio;
|
||||||
auto painterFrameHeight = frameHeight / pixelRatio;
|
|
||||||
p.drawPixmap(painterFrameLeft, painterFadeTop, painterFrameWidth, painterFadeBottom - painterFadeTop, _fadeMask, 0, fadeSkipLines, pixelRatio, fadeBottom - fadeTop);
|
p.drawPixmap(painterFrameLeft, painterFadeTop, painterFrameWidth, painterFadeBottom - painterFadeTop, _fadeMask, 0, fadeSkipLines, pixelRatio, fadeBottom - fadeTop);
|
||||||
}
|
}
|
||||||
if (fadeBottom != frameBottom) {
|
if (fadeBottom != frameBottom) {
|
||||||
|
|
@ -424,8 +423,6 @@ void PanelAnimation::paintFrame(QPainter &p, int x, int y, int outerWidth, float
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto frameInts = _frameInts + frameLeft + frameTop * _frameIntsPerLine;
|
|
||||||
auto frameIntsPerLineAdd = (_finalWidth - frameWidth) + _frameIntsPerLineAdded;
|
|
||||||
|
|
||||||
// Draw corners
|
// Draw corners
|
||||||
paintCorner(_topLeft, frameLeft, frameTop);
|
paintCorner(_topLeft, frameLeft, frameTop);
|
||||||
|
|
|
||||||
175
ui/effects/path_shift_gradient.cpp
Normal file
175
ui/effects/path_shift_gradient.cpp
Normal file
|
|
@ -0,0 +1,175 @@
|
||||||
|
// This file is part of Desktop App Toolkit,
|
||||||
|
// a set of libraries for developing nice desktop applications.
|
||||||
|
//
|
||||||
|
// For license and copyright information please follow this link:
|
||||||
|
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||||
|
//
|
||||||
|
#include "ui/effects/path_shift_gradient.h"
|
||||||
|
|
||||||
|
#include "base/call_delayed.h"
|
||||||
|
#include "ui/effects/animations.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kSlideDuration = crl::time(1000);
|
||||||
|
constexpr auto kWaitDuration = crl::time(1000);
|
||||||
|
constexpr auto kFullDuration = kSlideDuration + kWaitDuration;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
struct PathShiftGradient::AnimationData {
|
||||||
|
Ui::Animations::Simple animation;
|
||||||
|
base::flat_set<not_null<PathShiftGradient*>> active;
|
||||||
|
bool scheduled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::weak_ptr<PathShiftGradient::AnimationData> PathShiftGradient::Animation;
|
||||||
|
|
||||||
|
PathShiftGradient::PathShiftGradient(
|
||||||
|
const style::color &bg,
|
||||||
|
const style::color &fg,
|
||||||
|
Fn<void()> animationCallback)
|
||||||
|
: _bg(bg)
|
||||||
|
, _fg(fg)
|
||||||
|
, _animationCallback(std::move(animationCallback)) {
|
||||||
|
refreshColors();
|
||||||
|
style::PaletteChanged(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
refreshColors();
|
||||||
|
}, _lifetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
PathShiftGradient::~PathShiftGradient() {
|
||||||
|
if (const auto strong = _animation.get()) {
|
||||||
|
strong->active.erase(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathShiftGradient::overrideColors(
|
||||||
|
const style::color &bg,
|
||||||
|
const style::color &fg) {
|
||||||
|
_colorsOverriden = true;
|
||||||
|
refreshColors(bg, fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathShiftGradient::clearOverridenColors() {
|
||||||
|
if (!_colorsOverriden) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_colorsOverriden = false;
|
||||||
|
refreshColors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathShiftGradient::startFrame(
|
||||||
|
int viewportLeft,
|
||||||
|
int viewportWidth,
|
||||||
|
int gradientWidth) {
|
||||||
|
_viewportLeft = viewportLeft;
|
||||||
|
_viewportWidth = viewportWidth;
|
||||||
|
_gradientWidth = gradientWidth;
|
||||||
|
_geometryUpdated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathShiftGradient::updateGeometry() {
|
||||||
|
if (_geometryUpdated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_geometryUpdated = true;
|
||||||
|
const auto now = crl::now();
|
||||||
|
const auto period = now % kFullDuration;
|
||||||
|
if (period >= kSlideDuration) {
|
||||||
|
_gradientEnabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto progress = period / float64(kSlideDuration);
|
||||||
|
_gradientStart = anim::interpolate(
|
||||||
|
_viewportLeft - _gradientWidth,
|
||||||
|
_viewportLeft + _viewportWidth,
|
||||||
|
progress);
|
||||||
|
_gradientFinalStop = _gradientStart + _gradientWidth;
|
||||||
|
_gradientEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PathShiftGradient::paint(Fn<bool(const Background&)> painter) {
|
||||||
|
updateGeometry();
|
||||||
|
if (_gradientEnabled) {
|
||||||
|
_gradient.setStart(_gradientStart, 0);
|
||||||
|
_gradient.setFinalStop(_gradientFinalStop, 0);
|
||||||
|
}
|
||||||
|
const auto background = _gradientEnabled
|
||||||
|
? Background(&_gradient)
|
||||||
|
: _bgOverride
|
||||||
|
? *_bgOverride
|
||||||
|
: _bg;
|
||||||
|
if (!painter(background)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
activateAnimation();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathShiftGradient::activateAnimation() {
|
||||||
|
if (_animationActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_animationActive = true;
|
||||||
|
if (!_animation) {
|
||||||
|
_animation = Animation.lock();
|
||||||
|
if (!_animation) {
|
||||||
|
_animation = std::make_shared<AnimationData>();
|
||||||
|
Animation = _animation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const auto raw = _animation.get();
|
||||||
|
if (_animationCallback) {
|
||||||
|
raw->active.emplace(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto globalCallback = [] {
|
||||||
|
const auto strong = Animation.lock();
|
||||||
|
if (!strong) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
strong->scheduled = false;
|
||||||
|
while (!strong->active.empty()) {
|
||||||
|
const auto entry = strong->active.back();
|
||||||
|
strong->active.erase(strong->active.end() - 1);
|
||||||
|
entry->_animationActive = false;
|
||||||
|
entry->_animationCallback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto now = crl::now();
|
||||||
|
const auto period = now % kFullDuration;
|
||||||
|
if (period >= kSlideDuration) {
|
||||||
|
const auto tillWaitFinish = kFullDuration - period;
|
||||||
|
if (!raw->scheduled) {
|
||||||
|
raw->scheduled = true;
|
||||||
|
raw->animation.stop();
|
||||||
|
base::call_delayed(tillWaitFinish, globalCallback);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const auto tillSlideFinish = kSlideDuration - period;
|
||||||
|
if (!raw->animation.animating()) {
|
||||||
|
raw->animation.start(globalCallback, 0., 1., tillSlideFinish);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathShiftGradient::refreshColors() {
|
||||||
|
refreshColors(_bg, _fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathShiftGradient::refreshColors(
|
||||||
|
const style::color &bg,
|
||||||
|
const style::color &fg) {
|
||||||
|
_gradient.setStops({
|
||||||
|
{ 0., bg->c },
|
||||||
|
{ 0.5, fg->c },
|
||||||
|
{ 1., bg->c },
|
||||||
|
});
|
||||||
|
_bgOverride = _colorsOverriden ? &bg : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Ui
|
||||||
64
ui/effects/path_shift_gradient.h
Normal file
64
ui/effects/path_shift_gradient.h
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
// This file is part of Desktop App Toolkit,
|
||||||
|
// a set of libraries for developing nice desktop applications.
|
||||||
|
//
|
||||||
|
// For license and copyright information please follow this link:
|
||||||
|
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ui/style/style_core_types.h"
|
||||||
|
|
||||||
|
#include <QtGui/QLinearGradient>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
|
||||||
|
class PathShiftGradient final {
|
||||||
|
public:
|
||||||
|
PathShiftGradient(
|
||||||
|
const style::color &bg,
|
||||||
|
const style::color &fg,
|
||||||
|
Fn<void()> animationCallback);
|
||||||
|
~PathShiftGradient();
|
||||||
|
|
||||||
|
void startFrame(
|
||||||
|
int viewportLeft,
|
||||||
|
int viewportWidth,
|
||||||
|
int gradientWidth);
|
||||||
|
|
||||||
|
void overrideColors(const style::color &bg, const style::color &fg);
|
||||||
|
void clearOverridenColors();
|
||||||
|
|
||||||
|
using Background = std::variant<QLinearGradient*, style::color>;
|
||||||
|
bool paint(Fn<bool(const Background&)> painter);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct AnimationData;
|
||||||
|
|
||||||
|
void refreshColors();
|
||||||
|
void refreshColors(const style::color &bg, const style::color &fg);
|
||||||
|
void updateGeometry();
|
||||||
|
void activateAnimation();
|
||||||
|
|
||||||
|
static std::weak_ptr<AnimationData> Animation;
|
||||||
|
|
||||||
|
const style::color &_bg;
|
||||||
|
const style::color &_fg;
|
||||||
|
const style::color *_bgOverride = nullptr;
|
||||||
|
QLinearGradient _gradient;
|
||||||
|
std::shared_ptr<AnimationData> _animation;
|
||||||
|
const Fn<void()> _animationCallback;
|
||||||
|
int _viewportLeft = 0;
|
||||||
|
int _viewportWidth = 0;
|
||||||
|
int _gradientWidth = 0;
|
||||||
|
int _gradientStart = 0;
|
||||||
|
int _gradientFinalStop = 0;
|
||||||
|
bool _gradientEnabled = false;
|
||||||
|
bool _geometryUpdated = false;
|
||||||
|
bool _animationActive = false;
|
||||||
|
bool _colorsOverriden = false;
|
||||||
|
|
||||||
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Ui
|
||||||
|
|
@ -222,7 +222,6 @@ RadialState InfiniteRadialAnimation::computeState() {
|
||||||
kFullArcLength };
|
kFullArcLength };
|
||||||
}
|
}
|
||||||
if (anim::Disabled()) {
|
if (anim::Disabled()) {
|
||||||
const auto shown = 1.;
|
|
||||||
return { 1., 0, kFullArcLength };
|
return { 1., 0, kFullArcLength };
|
||||||
}
|
}
|
||||||
const auto min = int(std::round(kFullArcLength * _st.arcMin));
|
const auto min = int(std::round(kFullArcLength * _st.arcMin));
|
||||||
|
|
@ -245,9 +244,6 @@ RadialState InfiniteRadialAnimation::computeState() {
|
||||||
const auto cycles = (now - _workStarted) / _st.sinePeriod;
|
const auto cycles = (now - _workStarted) / _st.sinePeriod;
|
||||||
const auto relative = (now - _workStarted) % _st.sinePeriod;
|
const auto relative = (now - _workStarted) % _st.sinePeriod;
|
||||||
const auto smallDuration = _st.sineShift - _st.sineDuration;
|
const auto smallDuration = _st.sineShift - _st.sineDuration;
|
||||||
const auto largeDuration = _st.sinePeriod
|
|
||||||
- _st.sineShift
|
|
||||||
- _st.sineDuration;
|
|
||||||
const auto basic = int((linear
|
const auto basic = int((linear
|
||||||
+ min
|
+ min
|
||||||
+ (cycles * (kFullArcLength + min - max))) % kFullArcLength);
|
+ (cycles * (kFullArcLength + min - max))) % kFullArcLength);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@ constexpr auto kSetVersion = uint32(2);
|
||||||
constexpr auto kCacheVersion = uint32(6);
|
constexpr auto kCacheVersion = uint32(6);
|
||||||
constexpr auto kMaxId = uint32(1 << 8);
|
constexpr auto kMaxId = uint32(1 << 8);
|
||||||
|
|
||||||
|
#if defined Q_OS_MAC && !defined OS_MAC_OLD
|
||||||
constexpr auto kScaleForTouchBar = 150;
|
constexpr auto kScaleForTouchBar = 150;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum class ConfigResult {
|
enum class ConfigResult {
|
||||||
Invalid,
|
Invalid,
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,31 @@
|
||||||
#include "base/debug_log.h"
|
#include "base/debug_log.h"
|
||||||
|
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
|
#include <QtCore/QFile>
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
#include <QtGui/QOpenGLContext>
|
#include <QtGui/QOpenGLContext>
|
||||||
#include <QtGui/QOpenGLFunctions>
|
#include <QtGui/QOpenGLFunctions>
|
||||||
#include <QtWidgets/QOpenGLWidget>
|
#include <QtWidgets/QOpenGLWidget>
|
||||||
|
|
||||||
#define LOG_ONCE(x) static auto logged = [&] { LOG(x); return true; }();
|
#define LOG_ONCE(x) [[maybe_unused]] static auto logged = [&] { LOG(x); return true; }();
|
||||||
|
|
||||||
namespace Ui::GL {
|
namespace Ui::GL {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool ForceDisabled/* = false*/;
|
bool ForceDisabled/* = false*/;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
ANGLE ResolvedANGLE = ANGLE::Auto;
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
|
void CrashCheckStart() {
|
||||||
|
auto f = QFile(Integration::Instance().openglCheckFilePath());
|
||||||
|
if (f.open(QIODevice::WriteOnly)) {
|
||||||
|
f.write("1", 1);
|
||||||
|
f.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Capabilities CheckCapabilities(QWidget *widget) {
|
Capabilities CheckCapabilities(QWidget *widget) {
|
||||||
|
|
@ -47,9 +60,9 @@ Capabilities CheckCapabilities(QWidget *widget) {
|
||||||
auto tester = QOpenGLWidget(widget);
|
auto tester = QOpenGLWidget(widget);
|
||||||
tester.setFormat(format);
|
tester.setFormat(format);
|
||||||
|
|
||||||
Ui::Integration::Instance().openglCheckStart();
|
CrashCheckStart();
|
||||||
tester.grabFramebuffer(); // Force initialize().
|
tester.grabFramebuffer(); // Force initialize().
|
||||||
Ui::Integration::Instance().openglCheckFinish();
|
CrashCheckFinish();
|
||||||
|
|
||||||
if (!tester.window()->windowHandle()) {
|
if (!tester.window()->windowHandle()) {
|
||||||
tester.window()->createWinId();
|
tester.window()->createWinId();
|
||||||
|
|
@ -91,7 +104,7 @@ Capabilities CheckCapabilities(QWidget *widget) {
|
||||||
LOG_ONCE(("OpenGL Profile: Compatibility."));
|
LOG_ONCE(("OpenGL Profile: Compatibility."));
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
static const auto extensionsLogged = [&] {
|
[[maybe_unused]] static const auto extensionsLogged = [&] {
|
||||||
const auto renderer = reinterpret_cast<const char*>(
|
const auto renderer = reinterpret_cast<const char*>(
|
||||||
functions->glGetString(GL_RENDERER));
|
functions->glGetString(GL_RENDERER));
|
||||||
LOG(("OpenGL Renderer: %1").arg(renderer ? renderer : "[nullptr]"));
|
LOG(("OpenGL Renderer: %1").arg(renderer ? renderer : "[nullptr]"));
|
||||||
|
|
@ -102,7 +115,7 @@ Capabilities CheckCapabilities(QWidget *widget) {
|
||||||
functions->glGetString(GL_VERSION));
|
functions->glGetString(GL_VERSION));
|
||||||
LOG(("OpenGL Version: %1").arg(version ? version : "[nullptr]"));
|
LOG(("OpenGL Version: %1").arg(version ? version : "[nullptr]"));
|
||||||
auto list = QStringList();
|
auto list = QStringList();
|
||||||
for (const auto extension : context->extensions()) {
|
for (const auto &extension : context->extensions()) {
|
||||||
list.append(QString::fromLatin1(extension));
|
list.append(QString::fromLatin1(extension));
|
||||||
}
|
}
|
||||||
LOG(("OpenGL Extensions: %1").arg(list.join(", ")));
|
LOG(("OpenGL Extensions: %1").arg(list.join(", ")));
|
||||||
|
|
@ -123,8 +136,71 @@ Capabilities CheckCapabilities(QWidget *widget) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LastCrashCheckFailed() {
|
||||||
|
return QFile::exists(Integration::Instance().openglCheckFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CrashCheckFinish() {
|
||||||
|
QFile::remove(Integration::Instance().openglCheckFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
void ForceDisable(bool disable) {
|
void ForceDisable(bool disable) {
|
||||||
ForceDisabled = disable;
|
ForceDisabled = disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
|
void ConfigureANGLE() {
|
||||||
|
qunsetenv("DESKTOP_APP_QT_ANGLE_PLATFORM");
|
||||||
|
const auto path = Ui::Integration::Instance().angleBackendFilePath();
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto f = QFile(path);
|
||||||
|
if (!f.open(QIODevice::ReadOnly)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto bytes = f.read(32);
|
||||||
|
const auto check = [&](const char *backend, ANGLE angle) {
|
||||||
|
if (bytes.startsWith(backend)) {
|
||||||
|
ResolvedANGLE = angle;
|
||||||
|
qputenv("DESKTOP_APP_QT_ANGLE_PLATFORM", backend);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
check("gl", ANGLE::OpenGL);
|
||||||
|
check("d3d9", ANGLE::D3D9);
|
||||||
|
check("d3d11", ANGLE::D3D11);
|
||||||
|
check("d3d11on12", ANGLE::D3D11on12);
|
||||||
|
if (ResolvedANGLE == ANGLE::Auto) {
|
||||||
|
LOG(("ANGLE Warning: Unknown backend: %1"
|
||||||
|
).arg(QString::fromUtf8(bytes)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChangeANGLE(ANGLE backend) {
|
||||||
|
const auto path = Ui::Integration::Instance().angleBackendFilePath();
|
||||||
|
const auto write = [&](QByteArray backend) {
|
||||||
|
auto f = QFile(path);
|
||||||
|
if (!f.open(QIODevice::WriteOnly)) {
|
||||||
|
LOG(("ANGLE Warning: Could not write to %1.").arg(path));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
f.write(backend);
|
||||||
|
};
|
||||||
|
switch (backend) {
|
||||||
|
case ANGLE::Auto: QFile(path).remove(); break;
|
||||||
|
case ANGLE::D3D9: write("d3d9"); break;
|
||||||
|
case ANGLE::D3D11: write("d3d11"); break;
|
||||||
|
case ANGLE::D3D11on12: write("d3d11on12"); break;
|
||||||
|
case ANGLE::OpenGL: write("gl"); break;
|
||||||
|
default: Unexpected("ANGLE backend value.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ANGLE CurrentANGLE() {
|
||||||
|
return ResolvedANGLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
} // namespace Ui::GL
|
} // namespace Ui::GL
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,20 @@ struct Capabilities {
|
||||||
|
|
||||||
void ForceDisable(bool disable);
|
void ForceDisable(bool disable);
|
||||||
|
|
||||||
|
[[nodiscard]] bool LastCrashCheckFailed();
|
||||||
|
void CrashCheckFinish();
|
||||||
|
|
||||||
|
// Windows only.
|
||||||
|
enum class ANGLE {
|
||||||
|
Auto,
|
||||||
|
D3D9,
|
||||||
|
D3D11,
|
||||||
|
D3D11on12,
|
||||||
|
OpenGL,
|
||||||
|
};
|
||||||
|
|
||||||
|
void ConfigureANGLE(); // Requires Ui::Integration being set.
|
||||||
|
void ChangeANGLE(ANGLE backend);
|
||||||
|
[[nodiscard]] ANGLE CurrentANGLE();
|
||||||
|
|
||||||
} // namespace Ui::GL
|
} // namespace Ui::GL
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,11 @@ void Image::bind(QOpenGLFunctions &f) {
|
||||||
f.glTexImage2D(
|
f.glTexImage2D(
|
||||||
GL_TEXTURE_2D,
|
GL_TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
GL_RGBA,
|
kFormatRGBA,
|
||||||
_subimage.width(),
|
_subimage.width(),
|
||||||
_subimage.height(),
|
_subimage.height(),
|
||||||
0,
|
0,
|
||||||
GL_RGBA,
|
kFormatRGBA,
|
||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
_image.constBits());
|
_image.constBits());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -106,7 +106,7 @@ void Image::bind(QOpenGLFunctions &f) {
|
||||||
0,
|
0,
|
||||||
_subimage.width(),
|
_subimage.width(),
|
||||||
_subimage.height(),
|
_subimage.height(),
|
||||||
GL_RGBA,
|
kFormatRGBA,
|
||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
_image.constBits());
|
_image.constBits());
|
||||||
}
|
}
|
||||||
|
|
@ -155,4 +155,14 @@ TexturedRect Image::texturedRect(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLint CurrentSingleComponentFormat() {
|
||||||
|
const auto context = QOpenGLContext::currentContext();
|
||||||
|
Assert(context != nullptr);
|
||||||
|
|
||||||
|
const auto format = context->format();
|
||||||
|
return (format.renderableType() == QSurfaceFormat::OpenGLES)
|
||||||
|
? GL_LUMINANCE
|
||||||
|
: GL_RED;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Ui::GL
|
} // namespace Ui::GL
|
||||||
|
|
|
||||||
|
|
@ -134,4 +134,14 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] GLint CurrentSingleComponentFormat();
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
inline constexpr auto kFormatRGBA = GL_BGRA_EXT;
|
||||||
|
inline constexpr auto kSwizzleRedBlue = false;
|
||||||
|
#else // Q_OS_WIN
|
||||||
|
inline constexpr auto kFormatRGBA = GL_RGBA;
|
||||||
|
inline constexpr auto kSwizzleRedBlue = true;
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
} // namespace Ui::GL
|
} // namespace Ui::GL
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ void FillTriangles(
|
||||||
const QColor &color,
|
const QColor &color,
|
||||||
Fn<void()> additional = nullptr);
|
Fn<void()> additional = nullptr);
|
||||||
|
|
||||||
|
|
||||||
void FillRectangle(
|
void FillRectangle(
|
||||||
QOpenGLFunctions &f,
|
QOpenGLFunctions &f,
|
||||||
not_null<QOpenGLShaderProgram*> program,
|
not_null<QOpenGLShaderProgram*> program,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
//
|
//
|
||||||
#include "ui/gl/gl_shader.h"
|
#include "ui/gl/gl_shader.h"
|
||||||
|
|
||||||
|
#include "ui/gl/gl_image.h"
|
||||||
#include "base/debug_log.h"
|
#include "base/debug_log.h"
|
||||||
|
|
||||||
#include <QtGui/QOpenGLContext>
|
#include <QtGui/QOpenGLContext>
|
||||||
|
|
@ -72,8 +73,10 @@ uniform sampler2D s_texture;
|
||||||
)",
|
)",
|
||||||
.body = R"(
|
.body = R"(
|
||||||
result = texture2D(s_texture, v_texcoord);
|
result = texture2D(s_texture, v_texcoord);
|
||||||
|
)" + (kSwizzleRedBlue
|
||||||
|
? R"(
|
||||||
result = vec4(result.b, result.g, result.r, result.a);
|
result = vec4(result.b, result.g, result.r, result.a);
|
||||||
)",
|
)" : QString()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
namespace Ui::GL {
|
namespace Ui::GL {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kUseNativeChild = ::Platform::IsWindows();
|
constexpr auto kUseNativeChild = false;// ::Platform::IsWindows();
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ QImage prepareBlur(QImage img) {
|
||||||
|
|
||||||
uchar *pix = img.bits();
|
uchar *pix = img.bits();
|
||||||
if (pix) {
|
if (pix) {
|
||||||
int w = img.width(), h = img.height(), wold = w, hold = h;
|
int w = img.width(), h = img.height();
|
||||||
const int radius = 3;
|
const int radius = 3;
|
||||||
const int r1 = radius + 1;
|
const int r1 = radius + 1;
|
||||||
const int div = radius * 2 + 1;
|
const int div = radius * 2 + 1;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@
|
||||||
#include "ui/integration.h"
|
#include "ui/integration.h"
|
||||||
|
|
||||||
#include "ui/style/style_core_custom_font.h"
|
#include "ui/style/style_core_custom_font.h"
|
||||||
|
#include "ui/gl/gl_detection.h"
|
||||||
#include "ui/text/text_entity.h"
|
#include "ui/text/text_entity.h"
|
||||||
#include "ui/basic_click_handlers.h"
|
#include "ui/basic_click_handlers.h"
|
||||||
|
#include "base/platform/base_platform_info.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
@ -19,6 +21,10 @@ Integration *IntegrationInstance = nullptr;
|
||||||
|
|
||||||
void Integration::Set(not_null<Integration*> instance) {
|
void Integration::Set(not_null<Integration*> instance) {
|
||||||
IntegrationInstance = instance;
|
IntegrationInstance = instance;
|
||||||
|
|
||||||
|
if constexpr (Platform::IsWindows()) {
|
||||||
|
GL::ConfigureANGLE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Integration &Integration::Instance() {
|
Integration &Integration::Instance() {
|
||||||
|
|
@ -31,16 +37,6 @@ bool Integration::Exists() {
|
||||||
return (IntegrationInstance != nullptr);
|
return (IntegrationInstance != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Integration::openglCheckStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Integration::openglCheckFinish() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Integration::openglLastCheckFailed() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Integration::textActionsUpdated() {
|
void Integration::textActionsUpdated() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,9 @@ public:
|
||||||
virtual void registerLeaveSubscription(not_null<QWidget*> widget) = 0;
|
virtual void registerLeaveSubscription(not_null<QWidget*> widget) = 0;
|
||||||
virtual void unregisterLeaveSubscription(not_null<QWidget*> widget) = 0;
|
virtual void unregisterLeaveSubscription(not_null<QWidget*> widget) = 0;
|
||||||
|
|
||||||
virtual void openglCheckStart();
|
|
||||||
virtual void openglCheckFinish();
|
|
||||||
[[nodiscard]] virtual bool openglLastCheckFailed();
|
|
||||||
|
|
||||||
[[nodiscard]] virtual QString emojiCacheFolder() = 0;
|
[[nodiscard]] virtual QString emojiCacheFolder() = 0;
|
||||||
|
[[nodiscard]] virtual QString openglCheckFilePath() = 0;
|
||||||
|
[[nodiscard]] virtual QString angleBackendFilePath() = 0;
|
||||||
|
|
||||||
virtual void textActionsUpdated();
|
virtual void textActionsUpdated();
|
||||||
virtual void activationFromTopPanel();
|
virtual void activationFromTopPanel();
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,6 @@ void BoxContent::setInnerTopSkip(int innerTopSkip, bool scrollBottomFixed) {
|
||||||
|
|
||||||
void BoxContent::setInnerBottomSkip(int innerBottomSkip) {
|
void BoxContent::setInnerBottomSkip(int innerBottomSkip) {
|
||||||
if (_innerBottomSkip != innerBottomSkip) {
|
if (_innerBottomSkip != innerBottomSkip) {
|
||||||
auto delta = innerBottomSkip - _innerBottomSkip;
|
|
||||||
_innerBottomSkip = innerBottomSkip;
|
_innerBottomSkip = innerBottomSkip;
|
||||||
if (_scroll && width() > 0) {
|
if (_scroll && width() > 0) {
|
||||||
updateScrollAreaGeometry();
|
updateScrollAreaGeometry();
|
||||||
|
|
|
||||||
|
|
@ -652,37 +652,6 @@ void LayerStackWidget::resizeEvent(QResizeEvent *e) {
|
||||||
updateLayerBoxes();
|
updateLayerBoxes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::showBox(
|
|
||||||
object_ptr<BoxContent> box,
|
|
||||||
LayerOptions options,
|
|
||||||
anim::type animated) {
|
|
||||||
if (options & LayerOption::KeepOther) {
|
|
||||||
if (options & LayerOption::ShowAfterOther) {
|
|
||||||
prependBox(std::move(box), animated);
|
|
||||||
} else {
|
|
||||||
appendBox(std::move(box), animated);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
replaceBox(std::move(box), animated);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayerStackWidget::replaceBox(
|
|
||||||
object_ptr<BoxContent> box,
|
|
||||||
anim::type animated) {
|
|
||||||
const auto pointer = pushBox(std::move(box), animated);
|
|
||||||
const auto removeTill = ranges::find(
|
|
||||||
_layers,
|
|
||||||
pointer,
|
|
||||||
&std::unique_ptr<LayerWidget>::get);
|
|
||||||
_closingLayers.insert(
|
|
||||||
end(_closingLayers),
|
|
||||||
std::make_move_iterator(begin(_layers)),
|
|
||||||
std::make_move_iterator(removeTill));
|
|
||||||
_layers.erase(begin(_layers), removeTill);
|
|
||||||
clearClosingLayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayerStackWidget::prepareForAnimation() {
|
void LayerStackWidget::prepareForAnimation() {
|
||||||
if (isHidden()) {
|
if (isHidden()) {
|
||||||
show();
|
show();
|
||||||
|
|
@ -789,14 +758,33 @@ void LayerStackWidget::showMainMenu(
|
||||||
}, Action::ShowMainMenu, animated);
|
}, Action::ShowMainMenu, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::appendBox(
|
void LayerStackWidget::showBox(
|
||||||
object_ptr<BoxContent> box,
|
object_ptr<BoxContent> box,
|
||||||
|
LayerOptions options,
|
||||||
anim::type animated) {
|
anim::type animated) {
|
||||||
pushBox(std::move(box), animated);
|
showLayer(
|
||||||
|
std::make_unique<BoxLayerWidget>(this, std::move(box)),
|
||||||
|
options,
|
||||||
|
animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerWidget *LayerStackWidget::pushBox(
|
void LayerStackWidget::showLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
|
LayerOptions options,
|
||||||
|
anim::type animated) {
|
||||||
|
if (options & LayerOption::KeepOther) {
|
||||||
|
if (options & LayerOption::ShowAfterOther) {
|
||||||
|
prependLayer(std::move(layer), animated);
|
||||||
|
} else {
|
||||||
|
appendLayer(std::move(layer), animated);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
replaceLayer(std::move(layer), animated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerWidget *LayerStackWidget::pushLayer(
|
||||||
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated) {
|
anim::type animated) {
|
||||||
const auto oldLayer = currentLayer();
|
const auto oldLayer = currentLayer();
|
||||||
if (oldLayer) {
|
if (oldLayer) {
|
||||||
|
|
@ -805,8 +793,7 @@ LayerWidget *LayerStackWidget::pushBox(
|
||||||
}
|
}
|
||||||
oldLayer->hide();
|
oldLayer->hide();
|
||||||
}
|
}
|
||||||
_layers.push_back(
|
_layers.push_back(std::move(layer));
|
||||||
std::make_unique<BoxLayerWidget>(this, std::move(box)));
|
|
||||||
const auto raw = _layers.back().get();
|
const auto raw = _layers.back().get();
|
||||||
initChildLayer(raw);
|
initChildLayer(raw);
|
||||||
|
|
||||||
|
|
@ -824,21 +811,43 @@ LayerWidget *LayerStackWidget::pushBox(
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::prependBox(
|
void LayerStackWidget::appendLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
|
anim::type animated) {
|
||||||
|
pushLayer(std::move(layer), animated);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerStackWidget::prependLayer(
|
||||||
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated) {
|
anim::type animated) {
|
||||||
if (_layers.empty()) {
|
if (_layers.empty()) {
|
||||||
replaceBox(std::move(box), animated);
|
replaceLayer(std::move(layer), animated);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_layers.insert(
|
_layers.insert(
|
||||||
begin(_layers),
|
begin(_layers),
|
||||||
std::make_unique<BoxLayerWidget>(this, std::move(box)));
|
std::move(layer));
|
||||||
const auto raw = _layers.front().get();
|
const auto raw = _layers.front().get();
|
||||||
raw->hide();
|
raw->hide();
|
||||||
initChildLayer(raw);
|
initChildLayer(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayerStackWidget::replaceLayer(
|
||||||
|
std::unique_ptr<LayerWidget> layer,
|
||||||
|
anim::type animated) {
|
||||||
|
const auto pointer = pushLayer(std::move(layer), animated);
|
||||||
|
const auto removeTill = ranges::find(
|
||||||
|
_layers,
|
||||||
|
pointer,
|
||||||
|
&std::unique_ptr<LayerWidget>::get);
|
||||||
|
_closingLayers.insert(
|
||||||
|
end(_closingLayers),
|
||||||
|
std::make_move_iterator(begin(_layers)),
|
||||||
|
std::make_move_iterator(removeTill));
|
||||||
|
_layers.erase(begin(_layers), removeTill);
|
||||||
|
clearClosingLayers();
|
||||||
|
}
|
||||||
|
|
||||||
bool LayerStackWidget::takeToThirdSection() {
|
bool LayerStackWidget::takeToThirdSection() {
|
||||||
return _specialLayer
|
return _specialLayer
|
||||||
? _specialLayer->takeToThirdSection()
|
? _specialLayer->takeToThirdSection()
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,10 @@ public:
|
||||||
object_ptr<BoxContent> box,
|
object_ptr<BoxContent> box,
|
||||||
LayerOptions options,
|
LayerOptions options,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
|
void showLayer(
|
||||||
|
std::unique_ptr<LayerWidget> layer,
|
||||||
|
LayerOptions options,
|
||||||
|
anim::type animated);
|
||||||
void showSpecialLayer(
|
void showSpecialLayer(
|
||||||
object_ptr<LayerWidget> layer,
|
object_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
|
|
@ -149,19 +153,19 @@ protected:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void appendBox(
|
void appendLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void prependBox(
|
void prependLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void replaceBox(
|
void replaceLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void backgroundClicked();
|
void backgroundClicked();
|
||||||
|
|
||||||
LayerWidget *pushBox(
|
LayerWidget *pushLayer(
|
||||||
object_ptr<BoxContent> box,
|
std::unique_ptr<LayerWidget> layer,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void showFinished();
|
void showFinished();
|
||||||
void hideCurrent(anim::type animated);
|
void hideCurrent(anim::type animated);
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,6 @@ void BasicWindowHelper::setupBodyTitleAreaEvents() {
|
||||||
== Qt::LeftButton)) {
|
== Qt::LeftButton)) {
|
||||||
_mousePressed = true;
|
_mousePressed = true;
|
||||||
} else if (e->type() == QEvent::MouseMove) {
|
} else if (e->type() == QEvent::MouseMove) {
|
||||||
const auto mouseEvent = static_cast<QMouseEvent*>(e.get());
|
|
||||||
if (_mousePressed
|
if (_mousePressed
|
||||||
#ifndef Q_OS_WIN // We handle fullscreen startSystemMove() only on Windows.
|
#ifndef Q_OS_WIN // We handle fullscreen startSystemMove() only on Windows.
|
||||||
&& !_window->isFullScreen()
|
&& !_window->isFullScreen()
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ HRESULT WinApiSetWindowTheme(
|
||||||
LPCWSTR pszSubAppName,
|
LPCWSTR pszSubAppName,
|
||||||
LPCWSTR pszSubIdList);
|
LPCWSTR pszSubIdList);
|
||||||
auto result = f_SetWindowTheme();
|
auto result = f_SetWindowTheme();
|
||||||
const auto loaded = base::Platform::SafeLoadLibrary(u"uxtheme.dll"_q);
|
const auto loaded = base::Platform::SafeLoadLibrary(L"uxtheme.dll");
|
||||||
base::Platform::LoadMethod(loaded, "SetWindowTheme", result);
|
base::Platform::LoadMethod(loaded, "SetWindowTheme", result);
|
||||||
return result;
|
return result;
|
||||||
}();
|
}();
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,6 @@ void colorizeImage(const QImage &src, QColor c, QImage *outResult, QRect srcRect
|
||||||
|
|
||||||
auto pattern = anim::shifted(c);
|
auto pattern = anim::shifted(c);
|
||||||
|
|
||||||
auto resultBytesPerPixel = (src.depth() >> 3);
|
|
||||||
constexpr auto resultIntsPerPixel = 1;
|
constexpr auto resultIntsPerPixel = 1;
|
||||||
auto resultIntsPerLine = (outResult->bytesPerLine() >> 2);
|
auto resultIntsPerLine = (outResult->bytesPerLine() >> 2);
|
||||||
auto resultIntsAdded = resultIntsPerLine - width * resultIntsPerPixel;
|
auto resultIntsAdded = resultIntsPerLine - width * resultIntsPerPixel;
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,6 @@ TextWithEntities PrepareRichFromRich(
|
||||||
int32 i = 0, l = preparsed.size();
|
int32 i = 0, l = preparsed.size();
|
||||||
result.entities.clear();
|
result.entities.clear();
|
||||||
result.entities.reserve(l);
|
result.entities.reserve(l);
|
||||||
const QChar s = result.text.size();
|
|
||||||
for (; i < l; ++i) {
|
for (; i < l; ++i) {
|
||||||
auto type = preparsed.at(i).type();
|
auto type = preparsed.at(i).type();
|
||||||
if (((type == EntityType::Mention || type == EntityType::MentionName) && !parseMentions) ||
|
if (((type == EntityType::Mention || type == EntityType::MentionName) && !parseMentions) ||
|
||||||
|
|
|
||||||
|
|
@ -222,8 +222,6 @@ void BlockParser::parseWords(QFixed minResizeWidth, int blockFrom) {
|
||||||
int item = -1;
|
int item = -1;
|
||||||
int newItem = eng->findItem(0);
|
int newItem = eng->findItem(0);
|
||||||
|
|
||||||
style::align alignment = eng->option.alignment();
|
|
||||||
|
|
||||||
const QCharAttributes *attributes = eng->attributes();
|
const QCharAttributes *attributes = eng->attributes();
|
||||||
if (!attributes)
|
if (!attributes)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1315,7 +1315,7 @@ QString EscapeForRichParsing(const QString &text) {
|
||||||
|
|
||||||
QString SingleLine(const QString &text) {
|
QString SingleLine(const QString &text) {
|
||||||
auto result = text;
|
auto result = text;
|
||||||
auto s = text.unicode(), ch = s, e = text.unicode() + text.size();
|
auto s = text.unicode(), e = text.unicode() + text.size();
|
||||||
|
|
||||||
// Trim.
|
// Trim.
|
||||||
while (s < e && IsTrimmed(*s)) {
|
while (s < e && IsTrimmed(*s)) {
|
||||||
|
|
@ -1405,7 +1405,6 @@ QStringList PrepareSearchWords(
|
||||||
? *SplitterOverride
|
? *SplitterOverride
|
||||||
: RegExpWordSplit(),
|
: RegExpWordSplit(),
|
||||||
base::QStringSkipEmptyParts);
|
base::QStringSkipEmptyParts);
|
||||||
auto size = list.size();
|
|
||||||
result.reserve(list.size());
|
result.reserve(list.size());
|
||||||
for (const auto &word : std::as_const(list)) {
|
for (const auto &word : std::as_const(list)) {
|
||||||
auto trimmed = word.trimmed();
|
auto trimmed = word.trimmed();
|
||||||
|
|
@ -2196,7 +2195,6 @@ EntitiesInText ConvertTextTagsToEntities(const TextWithTags::Tags &tags) {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
auto till = offset;
|
|
||||||
for (const auto &tag : tags) {
|
for (const auto &tag : tags) {
|
||||||
if (tag.offset > offset) {
|
if (tag.offset > offset) {
|
||||||
processState(State());
|
processState(State());
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,6 @@ void Widget::mouseMoveEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
const auto point = e->pos()
|
const auto point = e->pos()
|
||||||
- QPoint(_st->padding.left(), _textTop);
|
- QPoint(_st->padding.left(), _textTop);
|
||||||
const auto lines = _maxTextHeight / _st->style.font->height;
|
|
||||||
const auto state = _text.getStateElided(point, _textWidth + 1);
|
const auto state = _text.getStateElided(point, _textWidth + 1);
|
||||||
const auto was = ClickHandler::getActive();
|
const auto was = ClickHandler::getActive();
|
||||||
if (was != state.link) {
|
if (was != state.link) {
|
||||||
|
|
|
||||||
|
|
@ -564,7 +564,6 @@ void Checkbox::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
auto check = checkRect();
|
auto check = checkRect();
|
||||||
auto ms = crl::now();
|
|
||||||
auto active = _check->currentAnimationValue();
|
auto active = _check->currentAnimationValue();
|
||||||
if (isDisabled()) {
|
if (isDisabled()) {
|
||||||
p.setOpacity(_st.disabledOpacity);
|
p.setOpacity(_st.disabledOpacity);
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,6 @@
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
constexpr float64 kFadeHeight = 1. / 3;
|
|
||||||
constexpr int kFadeAlphaMax = 160;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
InnerDropdown::InnerDropdown(
|
InnerDropdown::InnerDropdown(
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,6 @@ bool IsNewline(QChar ch) {
|
||||||
auto resultLink = QString();
|
auto resultLink = QString();
|
||||||
const auto checkingLink = (tag == kTagCheckLinkMeta);
|
const auto checkingLink = (tag == kTagCheckLinkMeta);
|
||||||
const auto &text = textWithTags.text;
|
const auto &text = textWithTags.text;
|
||||||
const auto &tags = textWithTags.tags;
|
|
||||||
auto from = 0;
|
auto from = 0;
|
||||||
auto till = int(text.size());
|
auto till = int(text.size());
|
||||||
const auto adjust = [&] {
|
const auto adjust = [&] {
|
||||||
|
|
@ -167,29 +166,6 @@ bool IsNewline(QChar ch) {
|
||||||
return !CheckFullTextTag(textWithTags, tag).isEmpty();
|
return !CheckFullTextTag(textWithTags, tag).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetFullSimpleTextTag(const TextWithTags &textWithTags) {
|
|
||||||
const auto &text = textWithTags.text;
|
|
||||||
const auto &tags = textWithTags.tags;
|
|
||||||
const auto tag = (tags.size() == 1) ? tags[0] : TextWithTags::Tag();
|
|
||||||
auto from = 0;
|
|
||||||
auto till = int(text.size());
|
|
||||||
for (; from != till; ++from) {
|
|
||||||
if (!IsNewline(text[from]) && !Text::IsSpace(text[from])) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (till != from) {
|
|
||||||
if (!IsNewline(text[till - 1]) && !Text::IsSpace(text[till - 1])) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
--till;
|
|
||||||
}
|
|
||||||
return ((tag.offset <= from)
|
|
||||||
&& (tag.offset + tag.length >= till))
|
|
||||||
? (tag.id == kTagPre ? kTagCode : tag.id)
|
|
||||||
: QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
class TagAccumulator {
|
class TagAccumulator {
|
||||||
public:
|
public:
|
||||||
TagAccumulator(TextWithTags::Tags &tags) : _tags(tags) {
|
TagAccumulator(TextWithTags::Tags &tags) : _tags(tags) {
|
||||||
|
|
@ -1075,8 +1051,7 @@ void FlatInput::touchEvent(QTouchEvent *e) {
|
||||||
if (!_touchPress) return;
|
if (!_touchPress) return;
|
||||||
auto weak = MakeWeak(this);
|
auto weak = MakeWeak(this);
|
||||||
if (!_touchMove && window()) {
|
if (!_touchMove && window()) {
|
||||||
Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton);
|
QPoint mapped(mapFromGlobal(_touchStart));
|
||||||
QPoint mapped(mapFromGlobal(_touchStart)), winMapped(window()->mapFromGlobal(_touchStart));
|
|
||||||
|
|
||||||
if (_touchRightButton) {
|
if (_touchRightButton) {
|
||||||
QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart);
|
QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart);
|
||||||
|
|
@ -1114,7 +1089,6 @@ void FlatInput::finishAnimations() {
|
||||||
void FlatInput::paintEvent(QPaintEvent *e) {
|
void FlatInput::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
auto ms = crl::now();
|
|
||||||
auto placeholderFocused = _placeholderFocusedAnimation.value(_focused ? 1. : 0.);
|
auto placeholderFocused = _placeholderFocusedAnimation.value(_focused ? 1. : 0.);
|
||||||
auto pen = anim::pen(_st.borderColor, _st.borderActive, placeholderFocused);
|
auto pen = anim::pen(_st.borderColor, _st.borderActive, placeholderFocused);
|
||||||
pen.setWidth(_st.borderWidth);
|
pen.setWidth(_st.borderWidth);
|
||||||
|
|
@ -1366,7 +1340,7 @@ InputField::InputField(
|
||||||
_inner->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
_inner->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
_inner->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
_inner->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
_inner->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
|
_inner->setFrameStyle(int(QFrame::NoFrame) | QFrame::Plain);
|
||||||
_inner->viewport()->setAutoFillBackground(false);
|
_inner->viewport()->setAutoFillBackground(false);
|
||||||
|
|
||||||
_inner->setContentsMargins(0, 0, 0, 0);
|
_inner->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
@ -1694,8 +1668,7 @@ void InputField::handleTouchEvent(QTouchEvent *e) {
|
||||||
if (!_touchPress) return;
|
if (!_touchPress) return;
|
||||||
auto weak = MakeWeak(this);
|
auto weak = MakeWeak(this);
|
||||||
if (!_touchMove && window()) {
|
if (!_touchMove && window()) {
|
||||||
Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton);
|
QPoint mapped(mapFromGlobal(_touchStart));
|
||||||
QPoint mapped(mapFromGlobal(_touchStart)), winMapped(window()->mapFromGlobal(_touchStart));
|
|
||||||
|
|
||||||
if (_touchRightButton) {
|
if (_touchRightButton) {
|
||||||
QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart);
|
QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart);
|
||||||
|
|
@ -2335,9 +2308,6 @@ void InputField::onDocumentContentsChange(
|
||||||
? _realCharsAdded
|
? _realCharsAdded
|
||||||
: charsAdded;
|
: charsAdded;
|
||||||
|
|
||||||
const auto removePosition = position;
|
|
||||||
const auto removeLength = charsRemoved;
|
|
||||||
|
|
||||||
_correcting = true;
|
_correcting = true;
|
||||||
QTextCursor(document->docHandle(), 0).joinPreviousEditBlock();
|
QTextCursor(document->docHandle(), 0).joinPreviousEditBlock();
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
|
|
@ -3910,8 +3880,7 @@ void MaskedInputField::touchEvent(QTouchEvent *e) {
|
||||||
if (!_touchPress) return;
|
if (!_touchPress) return;
|
||||||
auto weak = MakeWeak(this);
|
auto weak = MakeWeak(this);
|
||||||
if (!_touchMove && window()) {
|
if (!_touchMove && window()) {
|
||||||
Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton);
|
QPoint mapped(mapFromGlobal(_touchStart));
|
||||||
QPoint mapped(mapFromGlobal(_touchStart)), winMapped(window()->mapFromGlobal(_touchStart));
|
|
||||||
|
|
||||||
if (_touchRightButton) {
|
if (_touchRightButton) {
|
||||||
QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart);
|
QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart);
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,6 @@ bool FlatLabel::eventHook(QEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlatLabel::touchEvent(QTouchEvent *e) {
|
void FlatLabel::touchEvent(QTouchEvent *e) {
|
||||||
const Qt::TouchPointStates &states(e->touchPointStates());
|
|
||||||
if (e->type() == QEvent::TouchCancel) { // cancel
|
if (e->type() == QEvent::TouchCancel) { // cancel
|
||||||
if (!_touchInProgress) return;
|
if (!_touchInProgress) return;
|
||||||
_touchInProgress = false;
|
_touchInProgress = false;
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ ScrollArea::ScrollArea(QWidget *parent, const style::ScrollArea &st, bool handle
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
setFrameStyle(QFrame::NoFrame | QFrame::Plain);
|
setFrameStyle(int(QFrame::NoFrame) | QFrame::Plain);
|
||||||
viewport()->setAutoFillBackground(false);
|
viewport()->setAutoFillBackground(false);
|
||||||
|
|
||||||
_horizontalValue = horizontalScrollBar()->value();
|
_horizontalValue = horizontalScrollBar()->value();
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,12 @@ SlideWrap<RpWidget> *SlideWrap<RpWidget>::finishAnimating() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleOn(
|
SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleOn(
|
||||||
rpl::producer<bool> &&shown) {
|
rpl::producer<bool> &&shown,
|
||||||
|
anim::type animated) {
|
||||||
std::move(
|
std::move(
|
||||||
shown
|
shown
|
||||||
) | rpl::start_with_next([this](bool shown) {
|
) | rpl::start_with_next([=](bool shown) {
|
||||||
toggle(shown, anim::type::normal);
|
toggle(shown, animated);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
finishAnimating();
|
finishAnimating();
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,9 @@ public:
|
||||||
return toggle(false, animated);
|
return toggle(false, animated);
|
||||||
}
|
}
|
||||||
SlideWrap *finishAnimating();
|
SlideWrap *finishAnimating();
|
||||||
SlideWrap *toggleOn(rpl::producer<bool> &&shown);
|
SlideWrap *toggleOn(
|
||||||
|
rpl::producer<bool> &&shown,
|
||||||
|
anim::type animated = anim::type::normal);
|
||||||
|
|
||||||
bool animating() const {
|
bool animating() const {
|
||||||
return _animation.animating();
|
return _animation.animating();
|
||||||
|
|
@ -104,8 +106,10 @@ public:
|
||||||
SlideWrap *finishAnimating() {
|
SlideWrap *finishAnimating() {
|
||||||
return chain(Parent::finishAnimating());
|
return chain(Parent::finishAnimating());
|
||||||
}
|
}
|
||||||
SlideWrap *toggleOn(rpl::producer<bool> &&shown) {
|
SlideWrap *toggleOn(
|
||||||
return chain(Parent::toggleOn(std::move(shown)));
|
rpl::producer<bool> &&shown,
|
||||||
|
anim::type animated = anim::type::normal) {
|
||||||
|
return chain(Parent::toggleOn(std::move(shown), animated));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue