diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 26 | ||||
-rw-r--r-- | sc/source/ui/inc/checklistmenu.hxx | 6 |
2 files changed, 31 insertions, 1 deletions
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index b12868ea2f2a..f4caff97e8ad 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -145,13 +145,31 @@ void ScCheckListMenuControl::addSeparator() IMPL_LINK(ScCheckListMenuControl, TreeSizeAllocHdl, const Size&, rSize, void) { + maAllocatedSize = rSize; + SetDropdownPos(); + if (!mnAsyncSetDropdownPosId && Application::GetToolkitName().startsWith("gtk")) + { + // for gtk retry again later in case it didn't work (wayland) + mnAsyncSetDropdownPosId = Application::PostUserEvent(LINK(this, ScCheckListMenuControl, SetDropdownPosHdl)); + } +} + +void ScCheckListMenuControl::SetDropdownPos() +{ std::vector<int> aWidths { - o3tl::narrowing<int>(rSize.Width() - (mxMenu->get_text_height() * 3) / 4 - 6) + o3tl::narrowing<int>(maAllocatedSize.Width() - (mxMenu->get_text_height() * 3) / 4 - 6) }; mxMenu->set_column_fixed_widths(aWidths); } +IMPL_LINK_NOARG(ScCheckListMenuControl, SetDropdownPosHdl, void*, void) +{ + mnAsyncSetDropdownPosId = nullptr; + SetDropdownPos(); + mxMenu->queue_resize(); +} + void ScCheckListMenuControl::CreateDropDown() { int nWidth = (mxMenu->get_text_height() * 3) / 4; @@ -458,6 +476,7 @@ ScCheckListMenuControl::ScCheckListMenuControl(weld::Widget* pParent, ScDocument , mnSelectedMenu(MENU_NOT_SELECTED) , mpDoc(pDoc) , mnAsyncPostPopdownId(nullptr) + , mnAsyncSetDropdownPosId(nullptr) , mpNotifier(pNotifier) , mbHasDates(bHasDates) , mbIsPoppedUp(false) @@ -560,6 +579,11 @@ ScCheckListMenuControl::~ScCheckListMenuControl() Application::RemoveUserEvent(mnAsyncPostPopdownId); mnAsyncPostPopdownId = nullptr; } + if (mnAsyncSetDropdownPosId) + { + Application::RemoveUserEvent(mnAsyncSetDropdownPosId); + mnAsyncSetDropdownPosId = nullptr; + } } void ScCheckListMenuControl::prepWindow() diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx index 2e6041270b5b..6a5dbceb1966 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -249,6 +249,10 @@ private: DECL_LINK(PostPopdownHdl, void*, void); + void SetDropdownPos(); + + DECL_LINK(SetDropdownPosHdl, void*, void); + private: std::unique_ptr<weld::Builder> mxBuilder; std::unique_ptr<weld::Popover> mxPopover; @@ -281,6 +285,7 @@ private: std::unique_ptr<Action> mxPopupEndAction; Config maConfig; + Size maAllocatedSize; int mnCheckWidthReq; /// matching width request for mxChecks int mnWndWidth; /// whole window width. TriState mePrevToggleAllState; @@ -290,6 +295,7 @@ private: ScDocument* mpDoc; ImplSVEvent* mnAsyncPostPopdownId; + ImplSVEvent* mnAsyncSetDropdownPosId; vcl::ILibreOfficeKitNotifier* mpNotifier; bool mbHasDates; |