diff options
author | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-12-06 13:30:53 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat@free.fr> | 2012-12-10 16:11:56 +0100 |
commit | 99584c777f0d795644cfa04f16c4bd526cebd052 (patch) | |
tree | 7ca3fa4ce7fe8e1129524215c7e6cf4e4c6cd2a5 /sfx2/source/control | |
parent | 35a19a8f048d282bf5389e9497f89d2b9dba1fe6 (diff) |
Revert "Template Manager: ban double-click"
This reverts commit 5487769838570ba5f1b35529689321e1842bae31.
Come back to a more consistant UI:
- single click for selection. CTRL modifier for multi-selection
- double click for action
- removed item's checkbox
- get rid of the selection mode
- no hover on items
Change-Id: I82863c77ed6a45410242a244545505a5b898ba56
Diffstat (limited to 'sfx2/source/control')
-rw-r--r-- | sfx2/source/control/templateabstractview.cxx | 38 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 11 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalviewitem.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/control/templateremoteview.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/control/templateremoteviewitem.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/control/templatesearchview.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/templateview.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/control/templateviewitem.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailview.cxx | 125 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailviewitem.cxx | 47 |
10 files changed, 41 insertions, 212 deletions
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index dd004490659a..5d5cd3ea1970 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -59,20 +59,16 @@ bool ViewFilter_Keyword::operator ()(const ThumbnailViewItem *pItem) TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) : ThumbnailView(pParent,nWinStyle,bDisableTransientChildren), - mpItemView(new TemplateView(this)), - mbInSelectionModeHdl(false) + mpItemView(new TemplateView(this)) { mpItemView->setItemStateHdl(LINK(this,TemplateAbstractView,OverlayItemStateHdl)); - mpItemView->setSelectionModeHdl(LINK(this,TemplateAbstractView,OverlaySelectionModeHdl)); } TemplateAbstractView::TemplateAbstractView(Window *pParent, const ResId &rResId, bool bDisableTransientChildren) : ThumbnailView(pParent,rResId,bDisableTransientChildren), - mpItemView(new TemplateView(this)), - mbInSelectionModeHdl(false) + mpItemView(new TemplateView(this)) { mpItemView->setItemStateHdl(LINK(this,TemplateAbstractView,OverlayItemStateHdl)); - mpItemView->setSelectionModeHdl(LINK(this,TemplateAbstractView,OverlaySelectionModeHdl)); } TemplateAbstractView::~TemplateAbstractView () @@ -124,9 +120,9 @@ void TemplateAbstractView::filterTemplatesByKeyword(const OUString &rKeyword) mpItemView->filterItems(ViewFilter_Keyword(rKeyword)); } -void TemplateAbstractView::setOverlayClickHdl(const Link &rLink) +void TemplateAbstractView::setOverlayDblClickHdl(const Link &rLink) { - mpItemView->setClickHdl(rLink); + mpItemView->setDblClickHdl(rLink); } void TemplateAbstractView::setOverlayCloseHdl(const Link &rLink) @@ -287,36 +283,10 @@ void TemplateAbstractView::DrawItem(ThumbnailViewItem *pItem) ThumbnailView::DrawItem(pItem); } -void TemplateAbstractView::OnSelectionMode (bool bMode) -{ - if (!mbInSelectionModeHdl) - { - if (mpItemView->IsVisible()) - { - mbSelectionMode = bMode; - mpItemView->setSelectionMode(bMode); - } - else - ThumbnailView::OnSelectionMode(bMode); - } -} - IMPL_LINK(TemplateAbstractView, OverlayItemStateHdl, const ThumbnailViewItem*, pItem) { maOverlayItemStateHdl.Call((void*)pItem); return 0; } -IMPL_LINK(TemplateAbstractView, OverlaySelectionModeHdl, bool*, pMode) -{ - mbInSelectionModeHdl = true; - setSelectionMode(*pMode); - if (!*pMode) - { - deselectOverlayItems(); - } - mbInSelectionModeHdl = false; - return 0; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 15e3b8dfa99d..b261e34aceb4 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -128,7 +128,7 @@ void TemplateLocalView::Populate () aRegionName += "..."; } - TemplateLocalViewItem* pItem = new TemplateLocalViewItem( *this, this ); + TemplateLocalViewItem* pItem = new TemplateLocalViewItem( *this ); pItem->mnId = i+1; pItem->maTitle = aRegionName; pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected)); @@ -224,8 +224,6 @@ void TemplateLocalView::showOverlay (bool bVisible) } mpItemView->Clear(); - - setSelectionMode(mbSelectionMode); } } @@ -278,7 +276,7 @@ sal_uInt16 TemplateLocalView::createRegion(const OUString &rName) aRegionName += "..."; } - TemplateLocalViewItem* pItem = new TemplateLocalViewItem( *this, this ); + TemplateLocalViewItem* pItem = new TemplateLocalViewItem( *this ); pItem->mnId = nRegionId+1; pItem->maTitle = aRegionName; pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected)); @@ -702,7 +700,7 @@ bool TemplateLocalView::isTemplateNameUnique(const sal_uInt16 nRegionItemId, con return true; } -void TemplateLocalView::OnItemClicked (ThumbnailViewItem *pRegionItem) +void TemplateLocalView::OnItemDblClicked (ThumbnailViewItem *pRegionItem) { // Fill templates sal_uInt16 nRegionId = pRegionItem->mnId-1; @@ -711,9 +709,6 @@ void TemplateLocalView::OnItemClicked (ThumbnailViewItem *pRegionItem) mpItemView->setName(mpDocTemplates->GetRegionName(nRegionId)); mpItemView->InsertItems(static_cast<TemplateLocalViewItem*>(pRegionItem)->maTemplates); - if (mbSelectionMode) - mpItemView->setSelectionMode(true); - mpItemView->filterItems(ViewFilter_Application(meFilterOption)); showOverlay(true); diff --git a/sfx2/source/control/templatelocalviewitem.cxx b/sfx2/source/control/templatelocalviewitem.cxx index 7ba11837de06..544b86a4a81c 100644 --- a/sfx2/source/control/templatelocalviewitem.cxx +++ b/sfx2/source/control/templatelocalviewitem.cxx @@ -26,8 +26,8 @@ using namespace basegfx::tools; using namespace drawinglayer::attribute; using namespace drawinglayer::primitive2d; -TemplateLocalViewItem::TemplateLocalViewItem (ThumbnailView &rView, Window *pParent) - : ThumbnailViewItem(rView,pParent) +TemplateLocalViewItem::TemplateLocalViewItem (ThumbnailView &rView) + : ThumbnailViewItem(rView) { } @@ -137,9 +137,6 @@ void TemplateLocalViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *p Color(COL_BLACK).getBColor() ) ); pProcessor->process(aSeq); - - if (mbMode || mbHover || mbSelected) - mpSelectBox->Paint(maDrawArea); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/templateremoteview.cxx b/sfx2/source/control/templateremoteview.cxx index 776bab1513e2..24ee41d36542 100644 --- a/sfx2/source/control/templateremoteview.cxx +++ b/sfx2/source/control/templateremoteview.cxx @@ -78,7 +78,7 @@ void TemplateRemoteView::Populate() for (sal_Int32 i = 0; i < aUrls.getLength() && i < aNames.getLength(); ++i) { - TemplateRemoteViewItem *pItem = new TemplateRemoteViewItem(*this,this); + TemplateRemoteViewItem *pItem = new TemplateRemoteViewItem(*this); pItem->mnId = i+1; pItem->maTitle = aNames[i]; @@ -107,8 +107,6 @@ void TemplateRemoteView::showOverlay (bool bVisible) if (!bVisible) { mpItemView->Clear(); - - setSelectionMode(mbSelectionMode); } } @@ -261,7 +259,7 @@ bool TemplateRemoteView::insertRepository(const OUString &rName, const OUString return false; } - TemplateRemoteViewItem *pItem = new TemplateRemoteViewItem(*this,this); + TemplateRemoteViewItem *pItem = new TemplateRemoteViewItem(*this); pItem->mnId = maRepositories.size()+1; pItem->maTitle = rName; diff --git a/sfx2/source/control/templateremoteviewitem.cxx b/sfx2/source/control/templateremoteviewitem.cxx index cb6de5e7c029..626786f84794 100644 --- a/sfx2/source/control/templateremoteviewitem.cxx +++ b/sfx2/source/control/templateremoteviewitem.cxx @@ -9,8 +9,8 @@ #include <sfx2/templateremoteviewitem.hxx> -TemplateRemoteViewItem::TemplateRemoteViewItem (ThumbnailView &rView, Window *pParent) - : ThumbnailViewItem(rView,pParent) +TemplateRemoteViewItem::TemplateRemoteViewItem (ThumbnailView &rView) + : ThumbnailViewItem(rView) { } diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index 24554fb00905..775abbc09d4b 100644 --- a/sfx2/source/control/templatesearchview.cxx +++ b/sfx2/source/control/templatesearchview.cxx @@ -25,7 +25,7 @@ void TemplateSearchView::AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sa const OUString &rPath, const BitmapEx &rImage) { - TemplateSearchViewItem *pItem = new TemplateSearchViewItem(*this,this); + TemplateSearchViewItem *pItem = new TemplateSearchViewItem(*this); pItem->mnId = nItemId; pItem->mnIdx = nIdx; pItem->mnRegionId = nRegionId; diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx index 1156fa82b79e..0892a158e0bc 100644 --- a/sfx2/source/control/templateview.cxx +++ b/sfx2/source/control/templateview.cxx @@ -108,7 +108,7 @@ void TemplateView::InsertItems (const std::vector<TemplateItemProperties> &rTemp { for (size_t i = 0, n = rTemplates.size(); i < n; ++i ) { - TemplateViewItem *pItem = new TemplateViewItem(*this,this); + TemplateViewItem *pItem = new TemplateViewItem(*this); const TemplateItemProperties *pCur = &rTemplates[i]; pItem->mnId = pCur->nId; @@ -208,9 +208,9 @@ void TemplateView::MouseButtonDown (const MouseEvent &rMEvt) ThumbnailView::MouseButtonDown(rMEvt); } -void TemplateView::OnItemClicked(ThumbnailViewItem *pItem) +void TemplateView::OnItemDblClicked(ThumbnailViewItem *pItem) { - maClickHdl.Call(pItem); + maDblClickHdl.Call(pItem); } IMPL_LINK_NOARG(TemplateView, ChangeNameHdl) diff --git a/sfx2/source/control/templateviewitem.cxx b/sfx2/source/control/templateviewitem.cxx index 2c27e5f7b16b..e2abf71a8ca2 100644 --- a/sfx2/source/control/templateviewitem.cxx +++ b/sfx2/source/control/templateviewitem.cxx @@ -27,8 +27,8 @@ using namespace basegfx::tools; using namespace drawinglayer::attribute; using namespace drawinglayer::primitive2d; -TemplateViewItem::TemplateViewItem (ThumbnailView &rView, Window *pParent) - : ThumbnailViewItem(rView,pParent) +TemplateViewItem::TemplateViewItem (ThumbnailView &rView) + : ThumbnailViewItem(rView) { } @@ -136,9 +136,6 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces } pProcessor->process(aSeq); - - if (mbMode || mbHover || mbSelected) - mpSelectBox->Paint(maDrawArea); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 32571b78d07a..db8d6261da8f 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -98,7 +98,6 @@ void ThumbnailView::ImplInit() mnSpacing = 0; mbScroll = false; mbHasVisibleItems = false; - mbSelectionMode = false; maFilterFunc = ViewFilterAll(); maColor = GetSettings().GetStyleSettings().GetFieldColor(); @@ -197,21 +196,7 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem) } } -void ThumbnailView::OnSelectionMode (bool bMode) -{ - if ( !bMode ) - deselectItems(); - - for (size_t i = 0, n = mItemList.size(); i < n; ++i) - { - mItemList[i]->setSelectionMode(bMode); - - if (mItemList[i]->isVisible()) - DrawItem(mItemList[i]); - } -} - -void ThumbnailView::OnItemClicked (ThumbnailViewItem*) +void ThumbnailView::OnItemDblClicked (ThumbnailViewItem*) { } @@ -508,51 +493,40 @@ IMPL_LINK (ThumbnailView, OnItemSelected, ThumbnailViewItem*, pItem) void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) { - bool bProcessClick = rMEvt.IsLeft(); - - if ( rMEvt.IsRight( ) ) - { - // Set selection mode with right click - if (!mbSelectionMode) - { - setSelectionMode( true ); - bProcessClick = true; - } - } - - if ( bProcessClick ) + if ( rMEvt.IsLeft() ) { ThumbnailViewItem* pItem = ImplGetItem( ImplGetItem( rMEvt.GetPosPixel() ) ); if (pItem && pItem->isVisible()) { - if ( !rMEvt.IsMod2() ) + if ( rMEvt.GetClicks() == 1 ) { - if ( rMEvt.GetClicks() == 1 ) - { - if (mbSelectionMode) - { - pItem->setSelection(!pItem->isSelected()); + if (!pItem->isSelected() && !rMEvt.IsMod1()) + deselectItems( ); + pItem->setSelection(!pItem->isSelected()); - if (!pItem->isHighlighted()) - DrawItem(pItem); + if (!pItem->isHighlighted()) + DrawItem(pItem); - maItemStateHdl.Call(pItem); - } - else - { - Rectangle aRect(pItem->getDrawArea()); - aRect.SetSize(Size(mnItemWidth,mnThumbnailHeight)); + maItemStateHdl.Call(pItem); + } + else if ( rMEvt.GetClicks() == 2 ) + { + // The mouse button down event 1 click right before is pointless + pItem->setSelection(!pItem->isSelected()); + maItemStateHdl.Call(pItem); - if (!mbSelectionMode && aRect.IsInside(rMEvt.GetPosPixel())) - OnItemClicked(pItem); - } - } + Rectangle aRect(pItem->getDrawArea()); + aRect.SetSize(Size(mnItemWidth,mnThumbnailHeight)); + + if (aRect.IsInside(rMEvt.GetPosPixel())) + OnItemDblClicked(pItem); } return; } } + Control::MouseButtonDown( rMEvt ); } @@ -561,56 +535,6 @@ void ThumbnailView::MouseButtonUp( const MouseEvent& rMEvt ) Control::MouseButtonUp( rMEvt ); } -void ThumbnailView::MouseMove( const MouseEvent& rMEvt ) -{ - ThumbnailViewItem* pItem = ImplGetItem( ImplGetItem( rMEvt.GetPosPixel() ) ); - - if (pItem) - { - if (mnHighItemId != pItem->mnId && pItem->isVisible()) - { - size_t nPos = GetItemPos(mnHighItemId); - - if (nPos != THUMBNAILVIEW_ITEM_NOTFOUND) - { - ThumbnailViewItem *pOld = mItemList[nPos]; - - pOld->setHighlight(false); - - if (!pOld->isSelected()) - DrawItem(pOld); - } - - mnHighItemId = pItem->mnId; - pItem->setHighlight(true); - - if (!pItem->isSelected()) - DrawItem(pItem); - } - } - else - { - if (mnHighItemId) - { - size_t nPos = GetItemPos(mnHighItemId); - - if (nPos != THUMBNAILVIEW_ITEM_NOTFOUND) - { - ThumbnailViewItem *pOld = mItemList[nPos]; - - pOld->setHighlight(false); - - if (!pOld->isSelected()) - DrawItem(pOld); - } - - mnHighItemId = 0; - } - } - - Control::MouseMove( rMEvt ); -} - void ThumbnailView::Command( const CommandEvent& rCEvt ) { if ( (rCEvt.GetCommand() == COMMAND_WHEEL) || @@ -1049,13 +973,6 @@ long ThumbnailView::GetScrollWidth() const return 0; } -void ThumbnailView::setSelectionMode (bool mode) -{ - mbSelectionMode = mode; - OnSelectionMode(mode); - maSelectionModeHdl.Call(&mode); -} - void ThumbnailView::filterItems (const boost::function<bool (const ThumbnailViewItem*) > &func) { mnFirstLine = 0; // start at the top of the list instead of the current position diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index 57041ce59970..2410922b5f4d 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -41,18 +41,14 @@ using namespace ::com::sun::star; using namespace drawinglayer::attribute; using namespace drawinglayer::primitive2d; -ThumbnailViewItem::ThumbnailViewItem(ThumbnailView &rView, Window *pParent) +ThumbnailViewItem::ThumbnailViewItem(ThumbnailView &rView) : mrParent(rView) , mnId(0) , mbVisible(true) , mbSelected(false) , mbHover(false) , mpxAcc(NULL) - , mbMode(false) - , mpSelectBox(new CheckBox(pParent,WB_HIDE | WB_NOPOINTERFOCUS)) { - mpSelectBox->SetSizePixel(Size(20,20)); - mpSelectBox->SetClickHdl(LINK(this,ThumbnailViewItem,OnClick)); } ThumbnailViewItem::~ThumbnailViewItem() @@ -62,37 +58,21 @@ ThumbnailViewItem::~ThumbnailViewItem() static_cast< ThumbnailViewItemAcc* >( mpxAcc->get() )->ParentDestroyed(); delete mpxAcc; } - - delete mpSelectBox; } void ThumbnailViewItem::show (bool bVisible) { mbVisible = bVisible; - - if (mbMode) - mpSelectBox->Show(bVisible); - else if (!bVisible) - mpSelectBox->Show(bVisible); - else if (mbSelected) - mpSelectBox->Show(bVisible); } void ThumbnailViewItem::setSelection (bool state) { mbSelected = state; - mpSelectBox->SetState(state ? STATE_CHECK : STATE_NOCHECK); - - if (!isHighlighted()) - mpSelectBox->Show(state); } void ThumbnailViewItem::setHighlight (bool state) { mbHover = state; - - if (!isSelected()) - mpSelectBox->Show(state); } uno::Reference< accessibility::XAccessible > ThumbnailViewItem::GetAccessible( bool bIsTransientChildrenDisabled ) @@ -131,20 +111,6 @@ void ThumbnailViewItem::calculateItemsPosition (const long nThumbnailHeight, con aPos.Y() = aPos.Y() + aTextDev.getTextHeight() + (nDisplayHeight - aTextDev.getTextHeight())/2; aPos.X() = maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maTitle,0,nMaxTextLenght))/2; maTextPos = aPos; - - // Calculate checkbox position - aPos.Y() -= aTextDev.getTextHeight(); - aPos.X() = maDrawArea.Left() + 15; - - mpSelectBox->SetPosPixel(aPos); -} - -void ThumbnailViewItem::setSelectionMode (bool mode) -{ - mbMode = mode; - - if (!mbHover && !mbSelected && mbVisible) - mpSelectBox->Show(mode); } void ThumbnailViewItem::setSelectClickHdl (const Link &link) @@ -210,9 +176,6 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc Color(COL_BLACK).getBColor() ) ); pProcessor->process(aSeq); - - if (mbMode || mbHover || mbSelected) - mpSelectBox->Paint(maDrawArea); } drawinglayer::primitive2d::BorderLinePrimitive2D* @@ -223,14 +186,6 @@ ThumbnailViewItem::createBorderLine (const basegfx::B2DPoint &rStart, const base false,STYLE_SOLID); } -IMPL_LINK (ThumbnailViewItem, OnClick, CheckBox*, ) -{ - mbSelected = mpSelectBox->GetState() == STATE_CHECK; - mpSelectBox->Invalidate(); - maClickHdl.Call(this); - return 0; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |