#pragma once #include "widgets/basewidget.hpp" #include "widgets/helper/droppreview.hpp" #include "widgets/helper/notebooktab.hpp" #include "widgets/split.hpp" #include #include #include #include #include #include #include #include namespace chatterino { class ChannelManager; namespace widgets { class SplitContainer : public BaseWidget { Q_OBJECT public: SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab); ChannelManager &channelManager; std::pair removeFromLayout(Split *widget); void addToLayout(Split *widget, std::pair position = std::pair(-1, -1)); const std::vector &getChatWidgets() const; NotebookTab *getTab() const; void addChat(bool openChannelNameDialog = false); static bool isDraggingSplit; static Split *draggingSplit; static std::pair dropPosition; int currentX = 0; int currentY = 0; std::map lastRequestedY; void refreshCurrentFocusCoordinates(bool alsoSetLastRequested = false); void requestFocus(int x, int y); void updateFlexValues(); protected: virtual bool eventFilter(QObject *object, QEvent *event) override; virtual void paintEvent(QPaintEvent *) override; virtual void showEvent(QShowEvent *) override; virtual void enterEvent(QEvent *) override; virtual void leaveEvent(QEvent *) override; virtual void mouseReleaseEvent(QMouseEvent *event) override; virtual void dragEnterEvent(QDragEnterEvent *event) override; virtual void dragMoveEvent(QDragMoveEvent *event) override; virtual void dragLeaveEvent(QDragLeaveEvent *event) override; virtual void dropEvent(QDropEvent *event) override; private: struct DropRegion { QRect rect; std::pair position; DropRegion(QRect rect, std::pair position) { this->rect = rect; this->position = position; } }; NotebookTab *tab; struct { QVBoxLayout parentLayout; QHBoxLayout hbox; } ui; std::vector chatWidgets; std::vector dropRegions; NotebookPageDropPreview dropPreview; void setPreviewRect(QPoint mousePos); std::pair getChatPosition(const Split *chatWidget); Split *createChatWidget(); public: void refreshTitle(); void load(const boost::property_tree::ptree &tree); boost::property_tree::ptree save(); }; } // namespace widgets } // namespace chatterino