summaryrefslogtreecommitdiff
path: root/sd
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 /sd
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>
Diffstat (limited to 'sd')
-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
3 files changed, 115 insertions, 14 deletions
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);