info_media_inner_widget.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "ui/rp_widget.h"
  9. #include "ui/widgets/scroll_area.h"
  10. #include "base/unique_qptr.h"
  11. #include "info/media/info_media_widget.h"
  12. #include "info/media/info_media_list_widget.h"
  13. namespace Ui {
  14. class VerticalLayout;
  15. class SearchFieldController;
  16. } // namespace Ui
  17. namespace Info {
  18. class Controller;
  19. } // namespace Info
  20. namespace Info::Media {
  21. class Memento;
  22. class ListWidget;
  23. class EmptyWidget;
  24. class InnerWidget final : public Ui::RpWidget {
  25. public:
  26. InnerWidget(
  27. QWidget *parent,
  28. not_null<Controller*> controller);
  29. bool showInternal(not_null<Memento*> memento);
  30. void setIsStackBottom(bool isStackBottom) {
  31. _isStackBottom = isStackBottom;
  32. setupOtherTypes();
  33. }
  34. void saveState(not_null<Memento*> memento);
  35. void restoreState(not_null<Memento*> memento);
  36. void setScrollHeightValue(rpl::producer<int> value);
  37. rpl::producer<Ui::ScrollToRequest> scrollToRequests() const;
  38. rpl::producer<SelectedItems> selectedListValue() const;
  39. void selectionAction(SelectionAction action);
  40. ~InnerWidget();
  41. protected:
  42. int resizeGetHeight(int newWidth) override;
  43. void visibleTopBottomUpdated(
  44. int visibleTop,
  45. int visibleBottom) override;
  46. private:
  47. int recountHeight();
  48. void refreshHeight();
  49. // Allows showing additional shared media links and tabs.
  50. // Used for shared media in Saved Messages.
  51. void setupOtherTypes();
  52. void createOtherTypes();
  53. void createTypeButtons();
  54. Type type() const;
  55. object_ptr<ListWidget> setupList();
  56. const not_null<Controller*> _controller;
  57. object_ptr<Ui::VerticalLayout> _otherTypes = { nullptr };
  58. object_ptr<ListWidget> _list = { nullptr };
  59. object_ptr<EmptyWidget> _empty;
  60. bool _inResize = false;
  61. bool _isStackBottom = false;
  62. rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
  63. rpl::event_stream<rpl::producer<SelectedItems>> _selectedLists;
  64. rpl::event_stream<rpl::producer<int>> _listTops;
  65. };
  66. } // namespace Info::Media