summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Gemkow <lobugs@ikr.uni-stuttgart.de>2017-08-20 21:36:14 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-09-04 02:10:20 +0200
commitabe958a713ff0c26a3f91c558a2f227c1996c592 (patch)
tree996d9839f9d036eb0ee9d78dd68c9df4fcc6bc47
parent52c25a628d6cd300a0ff29f3c31e3528e3c4f8e1 (diff)
tdf#89130 Draw: Better UI for handling layer attributes
This is a RFC to implement comment#2 in tdf#89130: Add shortcuts to change layer attributes and make the current attribute values visible in the tab layer name. Already implemented is that pressing LeftMouse+Shift toggles layer visibility. When a layer is not visible its name is displayed in blue. This patch adds that pressing LeftMouse+Ctrl toggles layer locked/unlocked and LeftMouse+Ctrl+Shift toggles layer printable/not printable. The name of a locked layer is displayed italic. The name of a nonprintable layer is underlined. This also adds an Undo action for all changes to mirror the behavior of the layer attribute change dialog box. Change-Id: I5d8fa0585d4f088768716956583e324e66e29602 Reviewed-on: https://gerrit.libreoffice.org/41366 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--include/svtools/tabbar.hxx15
-rw-r--r--sd/source/ui/dlg/LayerTabBar.cxx81
-rw-r--r--sd/source/ui/view/drviews1.cxx35
-rw-r--r--sd/source/ui/view/drviewsb.cxx13
-rw-r--r--svtools/source/control/tabbar.cxx28
5 files changed, 151 insertions, 21 deletions
diff --git a/include/svtools/tabbar.hxx b/include/svtools/tabbar.hxx
index 8cef7ff434d6..766ac7d4744f 100644
--- a/include/svtools/tabbar.hxx
+++ b/include/svtools/tabbar.hxx
@@ -52,6 +52,13 @@ Setting page bits modify the display attributes of the tab name
TPB_DISPLAY_NAME_BLUE
- Display tab name in light blue, used in draw for
invisible layers and in calc for scenario pages
+TPB_DISPLAY_NAME_ITALIC
+ - Display tab name italic, used in draw for
+ locked layers
+TPB_DISPLAY_NAME_UNDERLINE
+ - Display tab name underlined, used in draw for
+ non-printable layers
+
Handlers
-------
@@ -267,9 +274,17 @@ class Button;
#define WB_INSERTTAB ((WinBits)0x40000000)
#define WB_STDTABBAR WB_BORDER
+// Page bits
+
typedef sal_uInt16 TabBarPageBits;
#define TPB_DISPLAY_NAME_BLUE ((TabBarPageBits)0x0001)
+#define TPB_DISPLAY_NAME_ITALIC ((TabBarPageBits)0x0002)
+#define TPB_DISPLAY_NAME_UNDERLINE ((TabBarPageBits)0x0004)
+
+ // interface checks only, do not use in regular control flow
+
+#define TPB_DISPLAY_NAME_ALLFLAGS ((TabBarPageBits)(TPB_DISPLAY_NAME_BLUE | TPB_DISPLAY_NAME_ITALIC | TPB_DISPLAY_NAME_UNDERLINE))
// - TabBar-Types - used in TabBar::AllowRenaming
diff --git a/sd/source/ui/dlg/LayerTabBar.cxx b/sd/source/ui/dlg/LayerTabBar.cxx
index 5d441bc0b299..1d1aae802c41 100644
--- a/sd/source/ui/dlg/LayerTabBar.cxx
+++ b/sd/source/ui/dlg/LayerTabBar.cxx
@@ -75,7 +75,7 @@ void LayerTabBar::MouseButtonDown(const MouseEvent& rMEvt)
{
bool bSetPageID=false;
- if (rMEvt.IsLeft() && !rMEvt.IsMod1() && !rMEvt.IsMod2())
+ if (rMEvt.IsLeft() && !rMEvt.IsMod2())
{
Point aPosPixel = rMEvt.GetPosPixel();
sal_uInt16 aLayerId = GetPageId( PixelToLogic(aPosPixel) );
@@ -87,15 +87,81 @@ void LayerTabBar::MouseButtonDown(const MouseEvent& rMEvt)
bSetPageID=true;
}
- else if (rMEvt.IsShift())
+ else if (rMEvt.IsMod1() || rMEvt.IsShift())
{
- // Toggle between layer visible / hidden
+ // keyboard Shortcuts to change layer attributes
+
OUString aName(GetPageText(aLayerId));
SdrPageView* pPV = pDrViewSh->GetView()->GetSdrPageView();
- bool bVisible = pPV->IsLayerVisible(aName);
- pPV->SetLayerVisible(aName, !bVisible);
+
+ // Save old state
+
+ bool bOldPrintable = pPV->IsLayerPrintable(aName);
+ bool bOldVisible = pPV->IsLayerVisible(aName);
+ bool bOldLocked = pPV->IsLayerLocked(aName);
+
+ bool bNewPrintable = bOldPrintable;
+ bool bNewVisible = bOldVisible;
+ bool bNewLocked = bOldLocked;
+
+ if (rMEvt.IsMod1() && rMEvt.IsShift())
+ {
+ // Shift+Ctrl: Toggle between layer printable / not printable
+ bNewPrintable = !bOldPrintable;
+ pPV->SetLayerPrintable(aName, bNewPrintable);
+ }
+ else if (rMEvt.IsShift())
+ {
+ // Shift: Toggle between layer visible / hidden
+ bNewVisible = !bOldVisible;
+ pPV->SetLayerVisible(aName, bNewVisible);
+ }
+ else // if (rMEvt.IsMod1())
+ {
+ // Ctrl: Toggle between layer locked / unlocked
+ bNewLocked = !bOldLocked;
+ pPV->SetLayerLocked(aName, bNewLocked);
+ }
+
pDrViewSh->ResetActualLayer();
- pDrViewSh->GetView()->GetDoc().SetChanged();
+
+ // Add Undo action
+
+ ::sd::View* pView = pDrViewSh->GetView();
+ DrawView* pDrView = dynamic_cast<DrawView*>(pView);
+
+ SdDrawDocument& rDoc = pView->GetDoc();
+ SdrLayer* pLayer = rDoc.GetLayerAdmin().GetLayer(aName);
+
+ if (pLayer)
+ {
+ assert (pDrView && "Change layer attribute undo action is only working with a SdDrawView");
+ if(pDrView)
+ {
+ ::svl::IUndoManager* pManager = rDoc.GetDocSh()->GetUndoManager();
+ SdLayerModifyUndoAction* pAction = new SdLayerModifyUndoAction(
+ &rDoc,
+ pLayer,
+ aName,
+ pLayer->GetTitle(),
+ pLayer->GetDescription(),
+ bOldVisible,
+ bOldLocked,
+ bOldPrintable,
+ aName,
+ pLayer->GetTitle(),
+ pLayer->GetDescription(),
+ bNewVisible,
+ bNewLocked,
+ bNewPrintable
+ );
+ pManager->AddUndoAction(pAction);
+ }
+ }
+
+ // Mark document changed
+
+ pView->GetDoc().SetChanged();
}
}
@@ -249,8 +315,7 @@ void LayerTabBar::EndRenaming()
if (pLayer)
{
OUString aNewName( GetEditText() );
-
- DBG_ASSERT( pDrView, "Rename layer undo action is only working with a SdDrawView" );
+ assert (pDrView && "Rename layer undo action is only working with a SdDrawView");
if( pDrView )
{
::svl::IUndoManager* pManager = rDoc.GetDocSh()->GetUndoManager();
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index d2291058eac9..14a873323738 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -1165,32 +1165,57 @@ void DrawViewShell::ResetActualLayer()
{
pLayerBar->InsertPage(nLayerPos+1, aName);
+ // Set page bits for modified tab name display
+
TabBarPageBits nBits = 0;
SdrPageView* pPV = mpDrawView->GetSdrPageView();
- if (pPV && !pPV->IsLayerVisible(aName))
+ if (pPV)
{
- // invisible layers are displayed differently
- nBits = TPB_DISPLAY_NAME_BLUE;
+ if (!pPV->IsLayerVisible(aName))
+ {
+ nBits |= TPB_DISPLAY_NAME_BLUE;
+ }
+ if (pPV->IsLayerLocked(aName))
+ {
+ nBits |= TPB_DISPLAY_NAME_ITALIC;
+ }
+ if (!pPV->IsLayerPrintable(aName))
+ {
+ nBits |= TPB_DISPLAY_NAME_UNDERLINE;
+ }
}
+ // Save the bits
+
pLayerBar->SetPageBits(nLayerPos+1, nBits);
}
}
else
{
// don't show masterpage layer onto the page
- if ( aName != aBackgroundObjLayer )
+ if (aName != aBackgroundObjLayer)
{
pLayerBar->InsertPage(nLayerPos+1, aName);
+ // Set page bits for modified tab name display
+
TabBarPageBits nBits = 0;
if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName))
{
- // invisible layers are displayed differently
nBits = TPB_DISPLAY_NAME_BLUE;
}
+ if (mpDrawView->GetSdrPageView()->IsLayerLocked(aName))
+ {
+ nBits |= TPB_DISPLAY_NAME_ITALIC;
+ }
+ if (!mpDrawView->GetSdrPageView()->IsLayerPrintable(aName))
+ {
+ nBits |= TPB_DISPLAY_NAME_UNDERLINE;
+ }
+
+ // Save the bits
pLayerBar->SetPageBits(nLayerPos+1, nBits);
}
diff --git a/sd/source/ui/view/drviewsb.cxx b/sd/source/ui/view/drviewsb.cxx
index f6dc8f7cc7b1..877d30c8d26b 100644
--- a/sd/source/ui/view/drviewsb.cxx
+++ b/sd/source/ui/view/drviewsb.cxx
@@ -188,13 +188,24 @@ void DrawViewShell::ModifyLayer (
GetLayerTabControl()->SetPageText(nCurPage, rLayerName);
+ // Set page bits for modified tab name display
+
TabBarPageBits nBits = 0;
if (!bIsVisible)
{
- // invisible layers are presented different
nBits = TPB_DISPLAY_NAME_BLUE;
}
+ if (bIsLocked)
+ {
+ nBits |= TPB_DISPLAY_NAME_ITALIC;
+ }
+ if (!bIsPrintable)
+ {
+ nBits |= TPB_DISPLAY_NAME_UNDERLINE;
+ }
+
+ // Save the bits
GetLayerTabControl()->SetPageBits(nCurPage, nBits);
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index 8ca68320d8eb..ead6835e73c9 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -1173,7 +1173,6 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r
bool bSelected = pItem->IsSelected(pCurItem);
// We disable custom background color in high contrast mode.
bool bCustomBgColor = !pItem->IsDefaultTabBgColor() && !rStyleSettings.GetHighContrastMode();
- bool bSpecialTab = (pItem->mnBits & TPB_DISPLAY_NAME_BLUE);
OUString aText = pItem->mbShort ? rRenderContext.GetEllipsisString(pItem->maText, mnCurMaxWidth) : pItem->maText;
aDrawer.setRect(aRect);
@@ -1198,9 +1197,24 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r
else
rRenderContext.SetTextColor(aFaceTextColor);
- // This tab is "special", and a special tab needs a blue text.
- if (bSpecialTab)
+ // Special display of tab name depending on page bits
+
+ if (pItem->mnBits & TPB_DISPLAY_NAME_BLUE)
+ {
rRenderContext.SetTextColor(Color(COL_LIGHTBLUE));
+ }
+ if (pItem->mnBits & TPB_DISPLAY_NAME_ITALIC)
+ {
+ vcl::Font aSpecialFont = rRenderContext.GetFont();
+ aSpecialFont.SetItalic(FontItalic::ITALIC_NORMAL);
+ rRenderContext.SetFont(aSpecialFont);
+ }
+ if (pItem->mnBits & TPB_DISPLAY_NAME_UNDERLINE)
+ {
+ vcl::Font aSpecialFont = rRenderContext.GetFont();
+ aSpecialFont.SetUnderline(LINESTYLE_SINGLE);
+ rRenderContext.SetFont(aSpecialFont);
+ }
aDrawer.drawText(aText);
@@ -1596,10 +1610,10 @@ void TabBar::AddTabClick()
void TabBar::InsertPage(sal_uInt16 nPageId, const OUString& rText,
TabBarPageBits nBits, sal_uInt16 nPos)
{
- DBG_ASSERT( nPageId, "TabBar::InsertPage(): PageId == 0" );
- DBG_ASSERT( GetPagePos( nPageId ) == PAGE_NOT_FOUND,
- "TabBar::InsertPage(): PageId already exists" );
- DBG_ASSERT( nBits <= TPB_DISPLAY_NAME_BLUE, "TabBar::InsertPage(): nBits is wrong" );
+ DBG_ASSERT(nPageId, "TabBar::InsertPage(): PageId == 0");
+ DBG_ASSERT(GetPagePos( nPageId ) == PAGE_NOT_FOUND,
+ "TabBar::InsertPage(): PageId already exists");
+ assert ((nBits <= TPB_DISPLAY_NAME_ALLFLAGS) && "TabBar::InsertPage(): Invalid flag set in in nBits");
// create PageItem and insert in the item list
ImplTabBarItem* pItem = new ImplTabBarItem( nPageId, rText, nBits );