Kaydet (Commit) abe958a7 authored tarafından Ulrich Gemkow's avatar Ulrich Gemkow Kaydeden (comit) Thorsten Behrens

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/41366Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 52c25a62
......@@ -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
......
......@@ -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();
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment