From 4a819f03a40d0a402fda465dc3656cfe53317384 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 18 Jun 2017 02:32:32 +0300 Subject: Fix asserts in browserbox on resize. --- src/gui/widgets/browserbox.cpp | 7 +++++++ src/gui/widgets/browserbox.h | 10 +++++++--- src/gui/widgets/tabs/chat/chattab.cpp | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index f9ad9fc83..a4f6de473 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -65,6 +65,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const std::string &skin) : Widget(widget), MouseListener(), + WidgetListener(), mTextRows(), mTextRowLinksCount(), mLineParts(), @@ -98,6 +99,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, setFocusable(true); addMouseListener(this); + addWidgetListener(this); mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND); @@ -954,3 +956,8 @@ void BrowserBox::selectSelection() mLinkHandler->handleLink(mLinks[CAST_SIZE(mSelectedLink)].link, nullptr); } + +void BrowserBox::widgetResized(const Event &event A_UNUSED) +{ + updateHeight(); +} diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index aa5a70b0e..a80729cb5 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -24,8 +24,6 @@ #ifndef GUI_WIDGETS_BROWSERBOX_H #define GUI_WIDGETS_BROWSERBOX_H -#include "listeners/mouselistener.h" - #include "enums/simpletypes/opaque.h" #include "enums/gui/browserboxmode.h" @@ -36,6 +34,9 @@ #include "gui/widgets/linepart.h" #include "gui/widgets/widget.h" +#include "listeners/mouselistener.h" +#include "listeners/widgetlistener.h" + #include "localconsts.h" class LinkHandler; @@ -45,7 +46,8 @@ class LinkHandler; * parent conteiner. */ class BrowserBox final : public Widget, - public MouseListener + public MouseListener, + public WidgetListener { public: /** @@ -155,6 +157,8 @@ class BrowserBox final : public Widget, void selectSelection(); + void widgetResized(const Event &event) override final; + private: int calcHeight() A_WARN_UNUSED; diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index fc2f09350..d311ea83f 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -94,6 +94,7 @@ ChatTab::ChatTab(const Widget2 *const widget, if (chatWindow != nullptr) chatWindow->addTab(this); + mTextOutput->updateHeight(); } ChatTab::~ChatTab() -- cgit v1.2.3-60-g2f50