mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Moved out setup of top and bottom scroll shadows to separated file.
This commit is contained in:
@@ -37,13 +37,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/chat/attach/attach_single_file_preview.h"
|
||||
#include "ui/chat/attach/attach_single_media_preview.h"
|
||||
#include "ui/controls/emoji_button.h"
|
||||
#include "ui/effects/scroll_content_shadow.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "window/window_session_controller.h"
|
||||
@@ -125,9 +125,7 @@ EditCaptionBox::EditCaptionBox(
|
||||
PrepareEditText(item)))
|
||||
, _emojiToggle(base::make_unique_q<Ui::EmojiButton>(
|
||||
this,
|
||||
st::boxAttachEmoji))
|
||||
, _topShadow(base::make_unique_q<Ui::FadeShadow>(this))
|
||||
, _bottomShadow(base::make_unique_q<Ui::FadeShadow>(this)) {
|
||||
st::boxAttachEmoji)) {
|
||||
Expects(item->media() != nullptr);
|
||||
Expects(item->media()->allowsEditCaption());
|
||||
|
||||
@@ -151,7 +149,7 @@ void EditCaptionBox::prepare() {
|
||||
|
||||
rebuildPreview();
|
||||
setupEditEventHandler();
|
||||
setupShadows();
|
||||
SetupShadowsToScrollContent(this, _scroll, _contentHeight.events());
|
||||
|
||||
setupControls();
|
||||
setupPhotoEditorEventHandler();
|
||||
@@ -282,31 +280,6 @@ void EditCaptionBox::setupField() {
|
||||
_field->setTextCursor(cursor);
|
||||
}
|
||||
|
||||
void EditCaptionBox::setupShadows() {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
const auto _topShadow = Ui::CreateChild<Ui::FadeShadow>(this);
|
||||
const auto _bottomShadow = Ui::CreateChild<Ui::FadeShadow>(this);
|
||||
_scroll->geometryValue(
|
||||
) | rpl::start_with_next([=](const QRect &geometry) {
|
||||
_topShadow->resizeToWidth(geometry.width());
|
||||
_topShadow->move(
|
||||
geometry.x(),
|
||||
geometry.y());
|
||||
_bottomShadow->resizeToWidth(geometry.width());
|
||||
_bottomShadow->move(
|
||||
geometry.x(),
|
||||
geometry.y() + geometry.height() - st::lineWidth);
|
||||
}, _topShadow->lifetime());
|
||||
|
||||
_topShadow->toggleOn(_scroll->scrollTopValue() | rpl::map(_1 > 0));
|
||||
_bottomShadow->toggleOn(rpl::combine(
|
||||
_scroll->scrollTopValue(),
|
||||
_scroll->heightValue(),
|
||||
_contentHeight.events(),
|
||||
_1 + _2 < _3));
|
||||
}
|
||||
|
||||
void EditCaptionBox::setupControls() {
|
||||
auto hintLabelToggleOn = _previewRebuilds.events_starting_with(
|
||||
{}
|
||||
|
@@ -27,7 +27,6 @@ class AbstractSinglePreview;
|
||||
class InputField;
|
||||
class EmojiButton;
|
||||
class VerticalLayout;
|
||||
class FadeShadow;
|
||||
enum class AlbumType;
|
||||
} // namespace Ui
|
||||
|
||||
@@ -51,7 +50,6 @@ private:
|
||||
void rebuildPreview();
|
||||
void setupEditEventHandler();
|
||||
void setupPhotoEditorEventHandler();
|
||||
void setupShadows();
|
||||
void setupField();
|
||||
void setupControls();
|
||||
|
||||
@@ -81,7 +79,6 @@ private:
|
||||
const base::unique_qptr<Ui::ScrollArea> _scroll;
|
||||
const base::unique_qptr<Ui::InputField> _field;
|
||||
const base::unique_qptr<Ui::EmojiButton> _emojiToggle;
|
||||
const base::unique_qptr<Ui::FadeShadow> _topShadow, _bottomShadow;
|
||||
|
||||
base::unique_qptr<Ui::AbstractSinglePreview> _content;
|
||||
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
||||
|
@@ -23,11 +23,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "settings/settings_common.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/chat/chat_theme.h"
|
||||
#include "ui/effects/scroll_content_shadow.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "window/window_session_controller.h"
|
||||
@@ -373,37 +373,6 @@ void AddMessage(
|
||||
}, widget->lifetime());
|
||||
}
|
||||
|
||||
void SetupShadows(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<Ui::ScrollArea*> scroll,
|
||||
not_null<Ui::RpWidget*> inner) {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
const auto topShadow = Ui::CreateChild<Ui::FadeShadow>(parent.get());
|
||||
const auto bottomShadow = Ui::CreateChild<Ui::FadeShadow>(parent.get());
|
||||
scroll->geometryValue(
|
||||
) | rpl::start_with_next_done([=](const QRect &geometry) {
|
||||
topShadow->resizeToWidth(geometry.width());
|
||||
topShadow->move(
|
||||
geometry.x(),
|
||||
geometry.y());
|
||||
bottomShadow->resizeToWidth(geometry.width());
|
||||
bottomShadow->move(
|
||||
geometry.x(),
|
||||
geometry.y() + geometry.height() - st::lineWidth);
|
||||
}, [t = Ui::MakeWeak(topShadow), b = Ui::MakeWeak(bottomShadow)] {
|
||||
Ui::DestroyChild(t.data());
|
||||
Ui::DestroyChild(b.data());
|
||||
}, topShadow->lifetime());
|
||||
|
||||
topShadow->toggleOn(scroll->scrollTopValue() | rpl::map(_1 > 0));
|
||||
bottomShadow->toggleOn(rpl::combine(
|
||||
scroll->scrollTopValue(),
|
||||
scroll->heightValue(),
|
||||
inner->heightValue(),
|
||||
_1 + _2 < _3));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void ReactionsSettingsBox(
|
||||
@@ -503,7 +472,10 @@ void ReactionsSettingsBox(
|
||||
}
|
||||
check->raise();
|
||||
|
||||
SetupShadows(scrollContainer, scroll, buttonsContainer);
|
||||
Ui::SetupShadowsToScrollContent(
|
||||
scrollContainer,
|
||||
scroll,
|
||||
buttonsContainer->heightValue());
|
||||
|
||||
box->setTitle(tr::lng_settings_chat_reactions_title());
|
||||
box->setWidth(st::boxWideWidth);
|
||||
|
@@ -26,11 +26,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/mime_type.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/effects/scroll_content_shadow.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/chat/attach/attach_prepare.h"
|
||||
#include "ui/chat/attach/attach_send_files_way.h"
|
||||
@@ -312,34 +312,6 @@ void SendFilesBox::enqueueNextPrepare() {
|
||||
});
|
||||
}
|
||||
|
||||
void SendFilesBox::setupShadows() {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
const auto topShadow = Ui::CreateChild<Ui::FadeShadow>(this);
|
||||
const auto bottomShadow = Ui::CreateChild<Ui::FadeShadow>(this);
|
||||
_scroll->geometryValue(
|
||||
) | rpl::start_with_next_done([=](const QRect &geometry) {
|
||||
topShadow->resizeToWidth(geometry.width());
|
||||
topShadow->move(
|
||||
geometry.x(),
|
||||
geometry.y());
|
||||
bottomShadow->resizeToWidth(geometry.width());
|
||||
bottomShadow->move(
|
||||
geometry.x(),
|
||||
geometry.y() + geometry.height() - st::lineWidth);
|
||||
}, [t = Ui::MakeWeak(topShadow), b = Ui::MakeWeak(bottomShadow)] {
|
||||
Ui::DestroyChild(t.data());
|
||||
Ui::DestroyChild(b.data());
|
||||
}, topShadow->lifetime());
|
||||
|
||||
topShadow->toggleOn(_scroll->scrollTopValue() | rpl::map(_1 > 0));
|
||||
bottomShadow->toggleOn(rpl::combine(
|
||||
_scroll->scrollTopValue(),
|
||||
_scroll->heightValue(),
|
||||
_inner->heightValue(),
|
||||
_1 + _2 < _3));
|
||||
}
|
||||
|
||||
void SendFilesBox::prepare() {
|
||||
_send = addButton(
|
||||
(_sendType == Api::SendType::Normal
|
||||
@@ -359,7 +331,7 @@ void SendFilesBox::prepare() {
|
||||
setupSendWayControls();
|
||||
preparePreview();
|
||||
initPreview();
|
||||
setupShadows();
|
||||
SetupShadowsToScrollContent(this, _scroll, _inner->heightValue());
|
||||
|
||||
boxClosing() | rpl::start_with_next([=] {
|
||||
if (!_confirmed && _cancelledCallback) {
|
||||
|
@@ -123,7 +123,6 @@ private:
|
||||
void refreshControls();
|
||||
void setupSendWayControls();
|
||||
void setupCaption();
|
||||
void setupShadows();
|
||||
|
||||
void setupEmojiPanel();
|
||||
void updateSendWayControlsVisibility();
|
||||
|
Reference in New Issue
Block a user