summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2018-08-26 18:01:09 -0800
committerCaolán McNamara <caolanm@redhat.com>2018-08-29 16:38:28 +0200
commit2c92b886b7538c4786a4d9a33cbcfe694daf1f62 (patch)
tree618e2aec5e5e37f6798035c10790ec75254ec3dc /sfx2
parent17d8f6b0d78c11ac40a335917b3576f13d1e1b9d (diff)
tdf#119461 Fix focus hidden on deck collapse
Makes Space key behavior the same as mouse click. Focus remains on the tab button when the deck collapses. Makes Enter key never collapses the deck but to open if collapsed and always place focus on the first panel title. Change-Id: Id6d7624e88b421dcfc62f3d0e79986f10c76a65d Reviewed-on: https://gerrit.libreoffice.org/59616 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/sidebar/FocusManager.cxx23
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx24
-rw-r--r--sfx2/source/sidebar/TabBar.cxx12
3 files changed, 46 insertions, 13 deletions
diff --git a/sfx2/source/sidebar/FocusManager.cxx b/sfx2/source/sidebar/FocusManager.cxx
index acdb50f7739c..244291240e7b 100644
--- a/sfx2/source/sidebar/FocusManager.cxx
+++ b/sfx2/source/sidebar/FocusManager.cxx
@@ -35,11 +35,13 @@ FocusManager::FocusLocation::FocusLocation (const PanelComponent eComponent, con
{
}
-FocusManager::FocusManager(const std::function<void(const Panel&)>& rShowPanelFunctor)
+FocusManager::FocusManager(const std::function<void(const Panel&)>& rShowPanelFunctor,
+ const std::function<bool(const sal_Int32)>& rIsDeckOpenFunctor)
: mpDeckTitleBar(),
maPanels(),
maButtons(),
maShowPanelFunctor(rShowPanelFunctor),
+ mbIsDeckOpenFunctor(rIsDeckOpenFunctor),
mbObservingContentControlFocus(false),
mpFirstFocusedContentControl(nullptr),
mpLastFocusedWindow(nullptr)
@@ -61,6 +63,11 @@ void FocusManager::GrabFocusPanel()
FocusPanel(0, false);
}
+void FocusManager::GrabFocusButton(const sal_Int32 nIndex)
+{
+ FocusButton(nIndex);
+}
+
void FocusManager::Clear()
{
SetDeckTitle(nullptr);
@@ -275,10 +282,13 @@ void FocusManager::FocusButton (const sal_Int32 nButtonIndex)
void FocusManager::ClickButton (const sal_Int32 nButtonIndex)
{
- maButtons[nButtonIndex]->Click();
+ if (mbIsDeckOpenFunctor)
+ {
+ if (!mbIsDeckOpenFunctor(-1) || !mbIsDeckOpenFunctor(nButtonIndex-1))
+ maButtons[nButtonIndex]->Click();
+ }
if (nButtonIndex > 0)
- if ( ! maPanels.empty())
- FocusPanel(0, true);
+ FocusPanel(0, true);
maButtons[nButtonIndex]->GetParent()->Invalidate();
}
@@ -379,11 +389,6 @@ void FocusManager::HandleKeyEvent (
maPanels[aLocation.mnIndex]->SetExpanded( ! maPanels[aLocation.mnIndex]->IsExpanded());
break;
- case PC_TabBar:
- // Activate the button.
- ClickButton(aLocation.mnIndex);
- break;
-
default:
break;
}
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index ba7b12167a30..fc9526f25207 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -109,7 +109,8 @@ SidebarController::SidebarController (
mbIsDeckOpen(),
mbFloatingDeckClosed(!pParentWindow->IsFloatingMode()),
mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()),
- maFocusManager([this](const Panel& rPanel){ return this->ShowPanel(rPanel); }),
+ maFocusManager([this](const Panel& rPanel){ return this->ShowPanel(rPanel); },
+ [this](const sal_Int32 nIndex){ return this->IsDeckOpen(nIndex); }),
mxReadOnlyModeDispatch(),
mbIsDocumentReadOnly(false),
mpSplitWindow(nullptr),
@@ -1105,13 +1106,18 @@ IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu, bool)
return true;
}
-void SidebarController::RequestCloseDeck()
+void SidebarController::RequestCloseDeck(bool bFocusMenuTab)
{
mbIsDeckRequestedOpen = false;
UpdateDeckOpenState();
- // remove highlight from TabBar, because Deck will be closed
- mpTabBar->RemoveDeckHighlight();
+ if (mpCurrentDeck.get())
+ {
+ sal_Int32 nIndex(bFocusMenuTab ? 0 : mpTabBar->GetDeckIndexForId(mpCurrentDeck->GetId()));
+ maFocusManager.GrabFocusButton(nIndex);
+ }
+ else
+ mpTabBar->RemoveDeckHighlight();
}
void SidebarController::RequestOpenDeck()
@@ -1120,6 +1126,16 @@ void SidebarController::RequestOpenDeck()
UpdateDeckOpenState();
}
+bool SidebarController::IsDeckOpen(const sal_Int32 nIndex)
+{
+ if (nIndex >= 0)
+ {
+ OUString asDeckId(mpTabBar->GetDeckIdForIndex(nIndex));
+ return IsDeckVisible(asDeckId);
+ }
+ return mbIsDeckOpen && mbIsDeckOpen.get();
+}
+
bool SidebarController::IsDeckVisible(const OUString& rsDeckId)
{
return mbIsDeckOpen && mbIsDeckOpen.get() && msCurrentDeckId == rsDeckId;
diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index a36a7f9306a9..9487e8079c7c 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -301,6 +301,18 @@ OUString const & TabBar::GetDeckIdForIndex (const sal_Int32 nIndex) const
return maItems[nIndex].msDeckId;
}
+sal_Int32 TabBar::GetDeckIndexForId (const OUString& rsDeckId)
+{
+ sal_Int32 nIndex(1);
+ for (auto const& item : maItems)
+ {
+ if (item.msDeckId == rsDeckId)
+ return nIndex;
+ nIndex++;
+ }
+ return 0;
+}
+
void TabBar::ToggleHideFlag (const sal_Int32 nIndex)
{
if (nIndex<0 || static_cast<size_t>(nIndex) >= maItems.size())