summaryrefslogtreecommitdiff
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
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>
-rw-r--r--include/sfx2/sidebar/FocusManager.hxx5
-rw-r--r--include/sfx2/sidebar/SidebarController.hxx4
-rw-r--r--include/sfx2/sidebar/TabBar.hxx1
-rw-r--r--sfx2/source/sidebar/FocusManager.cxx23
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx24
-rw-r--r--sfx2/source/sidebar/TabBar.cxx12
6 files changed, 54 insertions, 15 deletions
diff --git a/include/sfx2/sidebar/FocusManager.hxx b/include/sfx2/sidebar/FocusManager.hxx
index 84464c4b475f..c089419f05c8 100644
--- a/include/sfx2/sidebar/FocusManager.hxx
+++ b/include/sfx2/sidebar/FocusManager.hxx
@@ -50,7 +50,8 @@ class DeckTitleBar;
class FocusManager
{
public:
- FocusManager(const std::function<void(const Panel&)>& rShowPanelFunctor);
+ FocusManager(const std::function<void(const Panel&)>& rShowPanelFunctor,
+ const std::function<bool(const sal_Int32)> &rIsDeckOpenFunctor);
~FocusManager();
/** Forget all panels and buttons. Remove all window listeners.
@@ -63,6 +64,7 @@ public:
*/
void GrabFocus();
void GrabFocusPanel();
+ void GrabFocusButton(const sal_Int32 nIndex);
void SetDeckTitle(DeckTitleBar* pDeckTitleBar);
void SetPanels(const SharedPanelContainer& rPanels);
@@ -73,6 +75,7 @@ private:
std::vector<VclPtr<Panel> > maPanels;
std::vector<VclPtr<Button> > maButtons;
const std::function<void(const Panel&)> maShowPanelFunctor;
+ const std::function<bool(const sal_Int32)> mbIsDeckOpenFunctor;
bool mbObservingContentControlFocus;
VclPtr<vcl::Window> mpFirstFocusedContentControl;
VclPtr<vcl::Window> mpLastFocusedWindow;
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index 33cdfc395200..8274605ba03f 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -125,7 +125,7 @@ public:
/** Show only the tab bar, not the deck.
*/
- void RequestCloseDeck();
+ void RequestCloseDeck(bool bFocusMenuTab = false);
/** Open the deck area and restore the parent window to its old width.
*/
@@ -135,6 +135,8 @@ public:
*/
bool IsDeckVisible(const OUString& rsDeckId);
+ bool IsDeckOpen(const sal_Int32 nIndex = -1);
+
FocusManager& GetFocusManager() { return maFocusManager;}
ResourceManager* GetResourceManager() { return mpResourceManager.get();}
diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx
index e9ce313c6a68..e0f12a5f15ee 100644
--- a/include/sfx2/sidebar/TabBar.hxx
+++ b/include/sfx2/sidebar/TabBar.hxx
@@ -86,6 +86,7 @@ public:
void HighlightDeck (const OUString& rsDeckId);
void RemoveDeckHighlight ();
OUString const & GetDeckIdForIndex (const sal_Int32 nIndex) const;
+ sal_Int32 GetDeckIndexForId (const OUString& rsDeckId);
void ToggleHideFlag (const sal_Int32 nIndex);
void RestoreHideFlags();
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())