sfx2/inc/sfx2/templateview.hxx | 1 sfx2/inc/sfx2/thumbnailview.hxx | 7 + sfx2/source/control/templateabstractview.cxx | 10 ++ sfx2/source/control/templateview.cxx | 16 +--- sfx2/source/control/templateview.src | 6 - sfx2/source/control/thumbnailview.cxx | 104 +++++++++++++++++++++++++-- 6 files changed, 117 insertions(+), 27 deletions(-)
New commits: commit 9296cf4088a0637f0326803fe220816ebc8daf22 Author: Cédric Bosdonnat <[email protected]> Date: Fri Mar 22 16:33:20 2013 +0100 fdo#61390: Fixed the tabstop in the TemplateView. Change-Id: I887b11646efb9a839da11cd3e20cdf7e532caf3e (cherry picked from commit 7a25aa2821ccf7318ce4a13efe171763989009d5) Reviewed-on: https://gerrit.libreoffice.org/2913 Reviewed-by: Fridrich Strba <[email protected]> Tested-by: Fridrich Strba <[email protected]> diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx index 3e2a7c8..e219905 100644 --- a/sfx2/inc/sfx2/templateview.hxx +++ b/sfx2/inc/sfx2/templateview.hxx @@ -51,7 +51,6 @@ protected: private: TemplateAbstractView* mpMasterView; - Control maButtons; PushButton maAllButton; FixedText maFTName; sal_uInt16 mnId; diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index de2091f..14ab811 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -114,7 +114,7 @@ bool ViewFilter_Keyword::operator ()(const ThumbnailViewItem *pItem) TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) : ThumbnailView(pParent,nWinStyle,bDisableTransientChildren), - mpItemView(new TemplateView(this)), + mpItemView(new TemplateView(pParent)), mbFilteredResults(false), meFilterOption(FILTER_APP_WRITER) { @@ -123,7 +123,7 @@ TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, TemplateAbstractView::TemplateAbstractView(Window *pParent, const ResId &rResId, bool bDisableTransientChildren) : ThumbnailView(pParent,rResId,bDisableTransientChildren), - mpItemView(new TemplateView(this)), + mpItemView(new TemplateView(pParent)), mbFilteredResults(false), meFilterOption(FILTER_APP_WRITER) { @@ -190,8 +190,14 @@ void TemplateAbstractView::filterTemplatesByApp (const FILTER_APPLICATION &eApp) void TemplateAbstractView::showOverlay (bool bVisible) { + Show(!bVisible); mpItemView->Show(bVisible); + mpItemView->SetPosSizePixel(GetPosPixel(), GetSizePixel()); + mpItemView->SetStyle(GetStyle()); + + mpItemView->GrabFocus(); + // Clear items is the overlay is closed. if (!bVisible) { diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index 615465d..46ebeaa 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -34,14 +34,13 @@ using namespace drawinglayer::attribute; using namespace drawinglayer::primitive2d; TemplateView::TemplateView (Window *pParent) - : ThumbnailView(pParent,WB_VSCROLL), + : ThumbnailView(pParent,WB_VSCROLL | WB_TABSTOP), mpMasterView(NULL), - maButtons(this, SfxResId(CONTROL_BUTTONS)), - maAllButton(&maButtons, SfxResId(BTN_ALL_TEMPLATES)), - maFTName(&maButtons, SfxResId(FT_NAME)), + maAllButton(this, SfxResId(BTN_ALL_TEMPLATES)), + maFTName(this, SfxResId(FT_NAME)), mnId(0) { - mnHeaderHeight = maButtons.GetSizePixel().getHeight(); + mnHeaderHeight = maAllButton.GetSizePixel().getHeight() + maAllButton.GetPosPixel().Y() * 2; maAllButton.SetStyle(maAllButton.GetStyle() | WB_FLATBUTTON); } @@ -88,13 +87,8 @@ void TemplateView::Resize() Size aWinSize = GetOutputSize(); // Set the buttons panel and buttons size - Size aPanelSize = maButtons.GetSizePixel(); - int nDeltaW = aWinSize.getWidth() - aPanelSize.getWidth(); - aPanelSize.setWidth(aWinSize.getWidth()); - maButtons.SetSizePixel(aPanelSize); - Size aNameSize = maFTName.GetSizePixel(); - aNameSize.setWidth(aNameSize.getWidth() + nDeltaW); + aNameSize.setWidth( aWinSize.getWidth() - maFTName.GetPosPixel().X()); maFTName.SetSizePixel(aNameSize); ThumbnailView::Resize(); diff --git a/sfx2/source/control/templateview.src b/sfx2/source/control/templateview.src index db4d575..8549c96 100644 --- a/sfx2/source/control/templateview.src +++ b/sfx2/source/control/templateview.src @@ -8,12 +8,6 @@ #include "templateview.hrc" -Control CONTROL_BUTTONS -{ - Size = MAP_APPFONT( 290, 17 ); - TabStop = False; -}; - PushButton BTN_ALL_TEMPLATES { Pos = MAP_APPFONT( 1, 1 ); commit 43bbcfc7a1625aa79b69c443c492f0969b31baad Author: Cédric Bosdonnat <[email protected]> Date: Fri Mar 22 11:43:11 2013 +0100 fdo#61390: simple keybard support in TemplateManager Adds support for the UP, DOWN, LEFT, RIGHT and RETURN keys in the thumbnails view but doesn't handle the modifiers yet. There are still some problems with the focus and key input outside the top level (cherry picked from commit ee819bdd2dab5756cc3bad74f24e50bd7409f308) Conflicts: sfx2/source/control/thumbnailview.cxx Change-Id: I5ba67583c835bcc00b075071411c0d6590a07f9a Reviewed-on: https://gerrit.libreoffice.org/2912 Reviewed-by: Fridrich Strba <[email protected]> Tested-by: Fridrich Strba <[email protected]> diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index efc5e78..95e6b53 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -202,6 +202,8 @@ public: void SelectItem( sal_uInt16 nItemId ); + void DeselectItem( sal_uInt16 nItemId ); + bool IsItemSelected( sal_uInt16 nItemId ) const; void deselectItem (const sal_uInt16 nItemId); @@ -239,6 +241,8 @@ public: protected: + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); virtual void MouseButtonUp( const MouseEvent& rMEvt ); @@ -272,8 +276,6 @@ protected: using Control::ImplInitSettings; using Window::ImplInit; - void calculateColumnsRows (); - void CalculateItemPositions (); SFX2_DLLPRIVATE void ImplInit(); @@ -294,6 +296,7 @@ protected: protected: ValueItemList mItemList; + ValueItemList mFilteredItemList; ///< Cache to store the filtered items ScrollBar* mpScrBar; Rectangle maItemListRect; long mnHeaderHeight; diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 63ba189..f78a308 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -214,6 +214,8 @@ void ThumbnailView::CalculateItemPositions () WinBits nStyle = GetStyle(); ScrollBar* pDelScrBar = NULL; + mFilteredItemList.clear(); + // consider the scrolling if ( nStyle & WB_VSCROLL ) ImplInitScrollBar(); @@ -298,6 +300,7 @@ void ThumbnailView::CalculateItemPositions () if (maFilterFunc(pItem)) { + mFilteredItemList.push_back(pItem); if ((nCurCount >= nFirstItem) && (nCurCount < nLastItem)) { if( !pItem->isVisible()) @@ -490,6 +493,73 @@ IMPL_LINK (ThumbnailView, OnItemSelected, ThumbnailViewItem*, pItem) return 0; } +void ThumbnailView::KeyInput( const KeyEvent& rKEvt ) +{ + // Get the last selected item in the list + size_t nLastPos = 0; + bool bFoundLast = false; + for ( long i = mFilteredItemList.size() - 1; !bFoundLast && i >= 0; --i ) + { + ThumbnailViewItem* pItem = mFilteredItemList[i]; + if ( pItem->isSelected() ) + { + nLastPos = i; + bFoundLast = true; + } + } + + KeyCode aKeyCode = rKEvt.GetKeyCode(); + ThumbnailViewItem* pNext = NULL; + switch ( aKeyCode.GetCode() ) + { + case KEY_RIGHT: + { + size_t nNextPos = nLastPos; + if ( bFoundLast && nLastPos < mFilteredItemList.size( ) - 1 ) + nNextPos = nLastPos + 1; + pNext = mFilteredItemList[nNextPos]; + } + break; + case KEY_LEFT: + { + size_t nNextPos = nLastPos; + if ( nLastPos > 0 ) + nNextPos = nLastPos - 1; + pNext = mFilteredItemList[nNextPos]; + } + break; + case KEY_DOWN: + { + size_t nNextPos = nLastPos; + if ( bFoundLast && nLastPos < mFilteredItemList.size( ) - mnCols ) + nNextPos = nLastPos + mnCols; + pNext = mFilteredItemList[nNextPos]; + } + break; + case KEY_UP: + { + size_t nNextPos = nLastPos; + if ( nLastPos >= mnCols ) + nNextPos = nLastPos - mnCols; + pNext = mFilteredItemList[nNextPos]; + } + break; + case KEY_RETURN: + { + if ( bFoundLast ) + OnItemDblClicked( mFilteredItemList[nLastPos] ); + } + default: + Control::KeyInput( rKEvt ); + } + + if ( pNext && pNext->isVisible() ) + { + deselectItems(); + SelectItem(pNext->mnId); + } +} + void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) { if ( rMEvt.IsLeft() ) @@ -500,12 +570,17 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) { if ( rMEvt.GetClicks() == 1 ) { - if (!pItem->isSelected() && !rMEvt.IsMod1()) - deselectItems( ); - pItem->setSelection(true); + if (pItem->isSelected() && rMEvt.IsMod1()) + DeselectItem( pItem->mnId ); + else + { + if (!pItem->isSelected() && !rMEvt.IsMod1()) + deselectItems( ); + SelectItem( pItem->mnId ); - bool bClickOnTitle = pItem->getTextArea().IsInside(rMEvt.GetPosPixel()); - pItem->setEditTitle(bClickOnTitle); + bool bClickOnTitle = pItem->getTextArea().IsInside(rMEvt.GetPosPixel()); + pItem->setEditTitle(bClickOnTitle); + } if (!pItem->isHighlighted()) DrawItem(pItem); @@ -851,6 +926,25 @@ void ThumbnailView::deselectItem(const sal_uInt16 nItemId) } } +void ThumbnailView::DeselectItem( sal_uInt16 nItemId ) +{ + size_t nItemPos = GetItemPos( nItemId ); + if ( nItemPos == THUMBNAILVIEW_ITEM_NOTFOUND ) + return; + + ThumbnailViewItem* pItem = mItemList[nItemPos]; + if (pItem->isSelected()) + { + mItemList[nItemPos]->setSelection(false); + maItemStateHdl.Call(mItemList[nItemPos]); + + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(); + + // TODO Trigger event in accessible object? + } +} + bool ThumbnailView::IsItemSelected( sal_uInt16 nItemId ) const { size_t nItemPos = GetItemPos( nItemId );
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
