mirror of https://github.com/procxx/kepka.git
Preserve TopBarOverride in Info WrapWidget.
Also support better selection in info shared media. Also fix build for Xcode.
This commit is contained in:
parent
6b5e06de50
commit
5b190c5098
|
@ -32,10 +32,10 @@ template <typename Type, typename Compare = std::less<>>
|
||||||
class flat_multi_set;
|
class flat_multi_set;
|
||||||
|
|
||||||
template <typename Type, typename Compare, typename iterator_impl>
|
template <typename Type, typename Compare, typename iterator_impl>
|
||||||
class flat_multi_set_iterator_base_impl;
|
class flat_multi_set_iterator_impl;
|
||||||
|
|
||||||
template <typename Type, typename Compare, typename iterator_impl>
|
template <typename Type, typename Compare, typename iterator_impl>
|
||||||
class flat_multi_set_iterator_base_impl {
|
class flat_multi_set_iterator_impl {
|
||||||
public:
|
public:
|
||||||
using iterator_category = typename iterator_impl::iterator_category;
|
using iterator_category = typename iterator_impl::iterator_category;
|
||||||
|
|
||||||
|
@ -44,12 +44,12 @@ public:
|
||||||
using pointer = typename flat_multi_set<Type, Compare>::pointer;
|
using pointer = typename flat_multi_set<Type, Compare>::pointer;
|
||||||
using reference = typename flat_multi_set<Type, Compare>::reference;
|
using reference = typename flat_multi_set<Type, Compare>::reference;
|
||||||
|
|
||||||
flat_multi_set_iterator_base_impl(iterator_impl impl = iterator_impl())
|
flat_multi_set_iterator_impl(iterator_impl impl = iterator_impl())
|
||||||
: _impl(impl) {
|
: _impl(impl) {
|
||||||
}
|
}
|
||||||
template <typename other_iterator_impl>
|
template <typename other_iterator_impl>
|
||||||
flat_multi_set_iterator_base_impl(
|
flat_multi_set_iterator_impl(
|
||||||
const flat_multi_set_iterator_base_impl<
|
const flat_multi_set_iterator_impl<
|
||||||
Type,
|
Type,
|
||||||
Compare,
|
Compare,
|
||||||
other_iterator_impl> &other) : _impl(other._impl) {
|
other_iterator_impl> &other) : _impl(other._impl) {
|
||||||
|
@ -61,37 +61,37 @@ public:
|
||||||
pointer operator->() const {
|
pointer operator->() const {
|
||||||
return std::addressof(**this);
|
return std::addressof(**this);
|
||||||
}
|
}
|
||||||
flat_multi_set_iterator_base_impl &operator++() {
|
flat_multi_set_iterator_impl &operator++() {
|
||||||
++_impl;
|
++_impl;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
flat_multi_set_iterator_base_impl operator++(int) {
|
flat_multi_set_iterator_impl operator++(int) {
|
||||||
return _impl++;
|
return _impl++;
|
||||||
}
|
}
|
||||||
flat_multi_set_iterator_base_impl &operator--() {
|
flat_multi_set_iterator_impl &operator--() {
|
||||||
--_impl;
|
--_impl;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
flat_multi_set_iterator_base_impl operator--(int) {
|
flat_multi_set_iterator_impl operator--(int) {
|
||||||
return _impl--;
|
return _impl--;
|
||||||
}
|
}
|
||||||
flat_multi_set_iterator_base_impl &operator+=(difference_type offset) {
|
flat_multi_set_iterator_impl &operator+=(difference_type offset) {
|
||||||
_impl += offset;
|
_impl += offset;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
flat_multi_set_iterator_base_impl operator+(difference_type offset) const {
|
flat_multi_set_iterator_impl operator+(difference_type offset) const {
|
||||||
return _impl + offset;
|
return _impl + offset;
|
||||||
}
|
}
|
||||||
flat_multi_set_iterator_base_impl &operator-=(difference_type offset) {
|
flat_multi_set_iterator_impl &operator-=(difference_type offset) {
|
||||||
_impl -= offset;
|
_impl -= offset;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
flat_multi_set_iterator_base_impl operator-(difference_type offset) const {
|
flat_multi_set_iterator_impl operator-(difference_type offset) const {
|
||||||
return _impl - offset;
|
return _impl - offset;
|
||||||
}
|
}
|
||||||
template <typename other_iterator_impl>
|
template <typename other_iterator_impl>
|
||||||
difference_type operator-(
|
difference_type operator-(
|
||||||
const flat_multi_set_iterator_base_impl<
|
const flat_multi_set_iterator_impl<
|
||||||
Type,
|
Type,
|
||||||
Compare,
|
Compare,
|
||||||
other_iterator_impl> &right) const {
|
other_iterator_impl> &right) const {
|
||||||
|
@ -103,7 +103,7 @@ public:
|
||||||
|
|
||||||
template <typename other_iterator_impl>
|
template <typename other_iterator_impl>
|
||||||
bool operator==(
|
bool operator==(
|
||||||
const flat_multi_set_iterator_base_impl<
|
const flat_multi_set_iterator_impl<
|
||||||
Type,
|
Type,
|
||||||
Compare,
|
Compare,
|
||||||
other_iterator_impl> &right) const {
|
other_iterator_impl> &right) const {
|
||||||
|
@ -111,7 +111,7 @@ public:
|
||||||
}
|
}
|
||||||
template <typename other_iterator_impl>
|
template <typename other_iterator_impl>
|
||||||
bool operator!=(
|
bool operator!=(
|
||||||
const flat_multi_set_iterator_base_impl<
|
const flat_multi_set_iterator_impl<
|
||||||
Type,
|
Type,
|
||||||
Compare,
|
Compare,
|
||||||
other_iterator_impl> &right) const {
|
other_iterator_impl> &right) const {
|
||||||
|
@ -119,7 +119,7 @@ public:
|
||||||
}
|
}
|
||||||
template <typename other_iterator_impl>
|
template <typename other_iterator_impl>
|
||||||
bool operator<(
|
bool operator<(
|
||||||
const flat_multi_set_iterator_base_impl<
|
const flat_multi_set_iterator_impl<
|
||||||
Type,
|
Type,
|
||||||
Compare,
|
Compare,
|
||||||
other_iterator_impl> &right) const {
|
other_iterator_impl> &right) const {
|
||||||
|
@ -135,7 +135,7 @@ private:
|
||||||
typename OtherType,
|
typename OtherType,
|
||||||
typename OtherCompare,
|
typename OtherCompare,
|
||||||
typename other_iterator_impl>
|
typename other_iterator_impl>
|
||||||
friend class flat_multi_set_iterator_base_impl;
|
friend class flat_multi_set_iterator_impl;
|
||||||
|
|
||||||
Type &wrapped() {
|
Type &wrapped() {
|
||||||
return _impl->wrapped();
|
return _impl->wrapped();
|
||||||
|
@ -214,23 +214,6 @@ class flat_multi_set {
|
||||||
|
|
||||||
using impl = std::deque<const_wrap>;
|
using impl = std::deque<const_wrap>;
|
||||||
|
|
||||||
using iterator_base = flat_multi_set_iterator_base_impl<
|
|
||||||
Type,
|
|
||||||
Compare,
|
|
||||||
typename impl::iterator>;
|
|
||||||
using const_iterator_base = flat_multi_set_iterator_base_impl<
|
|
||||||
Type,
|
|
||||||
Compare,
|
|
||||||
typename impl::const_iterator>;
|
|
||||||
using reverse_iterator_base = flat_multi_set_iterator_base_impl<
|
|
||||||
Type,
|
|
||||||
Compare,
|
|
||||||
typename impl::reverse_iterator>;
|
|
||||||
using const_reverse_iterator_base = flat_multi_set_iterator_base_impl<
|
|
||||||
Type,
|
|
||||||
Compare,
|
|
||||||
typename impl::const_reverse_iterator>;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using value_type = Type;
|
using value_type = Type;
|
||||||
using size_type = typename impl::size_type;
|
using size_type = typename impl::size_type;
|
||||||
|
@ -238,26 +221,22 @@ public:
|
||||||
using pointer = const Type*;
|
using pointer = const Type*;
|
||||||
using reference = const Type&;
|
using reference = const Type&;
|
||||||
|
|
||||||
class iterator : public iterator_base {
|
using iterator = flat_multi_set_iterator_impl<
|
||||||
public:
|
Type,
|
||||||
using iterator_base::iterator_base;
|
Compare,
|
||||||
|
typename impl::iterator>;
|
||||||
};
|
using const_iterator = flat_multi_set_iterator_impl<
|
||||||
class const_iterator : public const_iterator_base {
|
Type,
|
||||||
public:
|
Compare,
|
||||||
using const_iterator_base::const_iterator_base;
|
typename impl::const_iterator>;
|
||||||
|
using reverse_iterator = flat_multi_set_iterator_impl<
|
||||||
};
|
Type,
|
||||||
class reverse_iterator : public reverse_iterator_base {
|
Compare,
|
||||||
public:
|
typename impl::reverse_iterator>;
|
||||||
using reverse_iterator_base::reverse_iterator_base;
|
using const_reverse_iterator = flat_multi_set_iterator_impl<
|
||||||
|
Type,
|
||||||
};
|
Compare,
|
||||||
class const_reverse_iterator : public const_reverse_iterator_base {
|
typename impl::const_reverse_iterator>;
|
||||||
public:
|
|
||||||
using const_reverse_iterator_base::const_reverse_iterator_base;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
flat_multi_set() = default;
|
flat_multi_set() = default;
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,11 @@ void TopBarOverride::setItems(SelectedItems &&items) {
|
||||||
updateControlsGeometry(width());
|
updateControlsGeometry(width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SelectedItems TopBarOverride::takeItems() {
|
||||||
|
_canDelete = false;
|
||||||
|
return std::move(_items);
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<> TopBarOverride::cancelRequests() const {
|
rpl::producer<> TopBarOverride::cancelRequests() const {
|
||||||
return rpl::merge(
|
return rpl::merge(
|
||||||
_cancel->clicks(),
|
_cancel->clicks(),
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
SelectedItems &&items);
|
SelectedItems &&items);
|
||||||
|
|
||||||
void setItems(SelectedItems &&items);
|
void setItems(SelectedItems &&items);
|
||||||
|
SelectedItems takeItems();
|
||||||
|
|
||||||
rpl::producer<> cancelRequests() const;
|
rpl::producer<> cancelRequests() const;
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,7 @@ void WrapWidget::setupTop(
|
||||||
} else {
|
} else {
|
||||||
createTopBar(section, peerId);
|
createTopBar(section, peerId);
|
||||||
}
|
}
|
||||||
|
refreshTopBarOverride();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WrapWidget::createTopBar(
|
void WrapWidget::createTopBar(
|
||||||
|
@ -234,6 +235,14 @@ void WrapWidget::refreshTopBarOverride(SelectedItems &&items) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrapWidget::refreshTopBarOverride() {
|
||||||
|
if (_topBarOverride) {
|
||||||
|
auto items = _topBarOverride->takeItems();
|
||||||
|
destroyTopBarOverride();
|
||||||
|
createTopBarOverride(std::move(items));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WrapWidget::destroyTopBarOverride() {
|
void WrapWidget::destroyTopBarOverride() {
|
||||||
if (!_topBarOverride) {
|
if (!_topBarOverride) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -192,6 +192,7 @@ private:
|
||||||
not_null<ContentMemento*> memento);
|
not_null<ContentMemento*> memento);
|
||||||
|
|
||||||
rpl::producer<SelectedItems> selectedListValue() const;
|
rpl::producer<SelectedItems> selectedListValue() const;
|
||||||
|
void refreshTopBarOverride();
|
||||||
void refreshTopBarOverride(SelectedItems &&items);
|
void refreshTopBarOverride(SelectedItems &&items);
|
||||||
void createTopBarOverride(SelectedItems &&items);
|
void createTopBarOverride(SelectedItems &&items);
|
||||||
void destroyTopBarOverride();
|
void destroyTopBarOverride();
|
||||||
|
|
|
@ -1435,7 +1435,7 @@ void ListWidget::mouseActionStart(const QPoint &screenPos, Qt::MouseButton butto
|
||||||
_pressWasInactive = _controller->window()->wasInactivePress();
|
_pressWasInactive = _controller->window()->wasInactivePress();
|
||||||
if (_pressWasInactive) _controller->window()->setInactivePress(false);
|
if (_pressWasInactive) _controller->window()->setInactivePress(false);
|
||||||
|
|
||||||
if (ClickHandler::getPressed()) {
|
if (ClickHandler::getPressed() && !hasSelected()) {
|
||||||
_mouseAction = MouseAction::PrepareDrag;
|
_mouseAction = MouseAction::PrepareDrag;
|
||||||
} else if (hasSelectedItems()) {
|
} else if (hasSelectedItems()) {
|
||||||
if (isItemUnderPressSelected()) {
|
if (isItemUnderPressSelected()) {
|
||||||
|
@ -1611,7 +1611,8 @@ void ListWidget::mouseActionFinish(const QPoint &screenPos, Qt::MouseButton butt
|
||||||
&& hasSelectedText();
|
&& hasSelectedText();
|
||||||
|
|
||||||
auto activated = ClickHandler::unpressed();
|
auto activated = ClickHandler::unpressed();
|
||||||
if (_mouseAction == MouseAction::Dragging) {
|
if (_mouseAction == MouseAction::Dragging
|
||||||
|
|| _mouseAction == MouseAction::Selecting) {
|
||||||
activated.clear();
|
activated.clear();
|
||||||
} else if (needSelectionToggle) {
|
} else if (needSelectionToggle) {
|
||||||
activated.clear();
|
activated.clear();
|
||||||
|
|
|
@ -316,12 +316,6 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
||||||
object_ptr<Ui::VerticalLayout>(parent)
|
object_ptr<Ui::VerticalLayout>(parent)
|
||||||
);
|
);
|
||||||
|
|
||||||
//result->toggleOn(rpl::combine(
|
|
||||||
// tracker.atLeastOneShownValue(),
|
|
||||||
// std::move(wrapValue),
|
|
||||||
// _isStackBottom.events(),
|
|
||||||
// $1 && ($2 != Wrap::Side || !$3)));
|
|
||||||
|
|
||||||
using ToggledData = std::tuple<bool, Wrap, bool>;
|
using ToggledData = std::tuple<bool, Wrap, bool>;
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
tracker.atLeastOneShownValue(),
|
tracker.atLeastOneShownValue(),
|
||||||
|
|
|
@ -1332,7 +1332,7 @@ HistoryTextState Link::getState(
|
||||||
}
|
}
|
||||||
for (int32 i = 0, l = _links.size(); i < l; ++i) {
|
for (int32 i = 0, l = _links.size(); i < l; ++i) {
|
||||||
if (rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width).contains(point)) {
|
if (rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width).contains(point)) {
|
||||||
return _links.at(i).lnk;
|
return ClickHandlerPtr(_links[i].lnk);
|
||||||
}
|
}
|
||||||
top += st::normalFont->height;
|
top += st::normalFont->height;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <rpl/producer.h>
|
#include <rpl/producer.h>
|
||||||
#include <xutility>
|
|
||||||
|
|
||||||
namespace rpl {
|
namespace rpl {
|
||||||
namespace details {
|
namespace details {
|
||||||
|
|
Loading…
Reference in New Issue