summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-24 22:12:37 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-04-25 08:39:38 +0200
commitfad98c8641342a77241124dd98e0cb781daef4ad (patch)
treefadb5c9694876fb03fe46a798a6a8926bf7192b5
parente1ebb5cb58edc325bb30bb5eb992665fb861960f (diff)
tdf#124572 TabBar new look, protected icon, width and height
This is the first try of a new TabBar look - borders have been removed, selected tab doesn't change the font to bold, adjustment to the selected tab line. Width and height of a tab item has been adjusted to make it better to fit the icons in and to not be so cramped. Draw "protected" status of an tab icon (in Calc) as an icon and not as a unicode glyph. Change-Id: If2ee930a573343166fbe9efcd94ae5159a620f22 Reviewed-on: https://gerrit.libreoffice.org/71238 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--sc/source/ui/view/tabview.cxx10
-rw-r--r--sd/source/ui/view/grviewsh.cxx4
-rw-r--r--svtools/inc/bitmaps.hlst2
-rw-r--r--svtools/source/control/tabbar.cxx101
4 files changed, 53 insertions, 64 deletions
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 1014de5bdfb4..95d0b9a4e876 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -62,7 +62,7 @@
#define SPLIT_MARGIN 30
#define SPLIT_HANDLE_SIZE 5
-#define WIDTH_MARGIN 5
+constexpr sal_Int32 TAB_HEIGHT_MARGIN = 10;
#define SC_ICONSIZE 36
@@ -358,7 +358,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
Size aFontSize = rStyleSettings.GetTabFont().GetFontSize();
MapMode aPtMapMode(MapUnit::MapPoint);
aFontSize = pFrameWin->LogicToPixel(aFontSize, aPtMapMode);
- sal_Int32 nTabWidth = aFontSize.Height() + WIDTH_MARGIN;
+ sal_Int32 nTabHeight = aFontSize.Height() + TAB_HEIGHT_MARGIN;
if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
{
@@ -393,7 +393,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
}
if (bHScroll)
{
- nBarY = nTabWidth;
+ nBarY = nTabHeight;
if (!mbInlineWithScrollbar)
nBarY += nScrollBarSize;
@@ -484,7 +484,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
else
{
Point aTabPoint(nPosX, nPosY + nSizeY + nScrollBarSize);
- Size aTabSize(nSizeX, nTabWidth);
+ Size aTabSize(nSizeX, nTabHeight);
lcl_SetPosSize(*pTabControl, aTabPoint, aTabSize, nTotalWidth, bLayoutRTL);
pTabControl->SetSheetLayoutRTL(bLayoutRTL);
@@ -622,7 +622,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
nSplitPosX = aViewData.GetHSplitPos();
lcl_SetPosSize( *pHSplitter,
Point(nSplitPosX, nOutPosY),
- Size( nSplitSizeX, nSplitHeight - nTabWidth ), nTotalWidth, bLayoutRTL );
+ Size(nSplitSizeX, nSplitHeight - nTabHeight), nTotalWidth, bLayoutRTL);
nLeftSize = nSplitPosX - nPosX;
nSplitPosX += nSplitSizeX;
nRightSize = nSizeX - nLeftSize - nSplitSizeX;
diff --git a/sd/source/ui/view/grviewsh.cxx b/sd/source/ui/view/grviewsh.cxx
index b31013043ba3..db9b9225efee 100644
--- a/sd/source/ui/view/grviewsh.cxx
+++ b/sd/source/ui/view/grviewsh.cxx
@@ -27,6 +27,8 @@
#include <tools/helpers.hxx>
+constexpr sal_Int32 TAB_HEIGHT_MARGIN = 10;
+
namespace sd {
GraphicViewShell::GraphicViewShell (
@@ -74,7 +76,7 @@ void GraphicViewShell::ArrangeGUIElements()
Size aSize = mpLayerTabBar->GetSizePixel();
const Size aFrameSize (GetViewFrame()->GetWindow().GetOutputSizePixel());
- aSize.setHeight( GetParentWindow()->GetFont().GetFontHeight() + 4 );
+ aSize.setHeight(GetParentWindow()->GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN);
aSize.setWidth( aFrameSize.Width() );
Point aPos (0, maViewSize.Height() - aSize.Height());
diff --git a/svtools/inc/bitmaps.hlst b/svtools/inc/bitmaps.hlst
index 27c5f85a9858..c991817439e1 100644
--- a/svtools/inc/bitmaps.hlst
+++ b/svtools/inc/bitmaps.hlst
@@ -114,6 +114,8 @@
#define BMP_FILTER "svtools/res/ed08.png"
#define BMP_HEADERFOOTER "svtools/res/ed09.png"
+#define BMP_TAB_LOCK "cmd/sc_lock.png"
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index fdc313415dd6..b67252c28e1a 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -41,80 +41,65 @@
#include <utility>
#include <vector>
#include <vcl/idle.hxx>
+#include <bitmaps.hlst>
namespace
{
-#define TABBAR_DRAG_SCROLLOFF 5
-#define TABBAR_MINSIZE 5
+constexpr sal_uInt16 TABBAR_DRAG_SCROLLOFF = 5;
+constexpr sal_uInt16 TABBAR_MINSIZE = 5;
-const sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10;
-const sal_uInt16 BUTTON_MARGIN = 6;
+constexpr sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10;
+constexpr sal_uInt16 BUTTON_MARGIN = 6;
class TabDrawer
{
private:
- TabBar& mrParent;
vcl::RenderContext& mrRenderContext;
const StyleSettings& mrStyleSettings;
tools::Rectangle maRect;
+ tools::Rectangle maLineRect;
Color maSelectedColor;
Color maCustomColor;
Color maUnselectedColor;
+public:
bool mbSelected:1;
bool mbCustomColored:1;
bool mbEnabled:1;
+ bool mbProtect:1;
-public:
- explicit TabDrawer(TabBar& rParent, vcl::RenderContext& rRenderContext)
- : mrParent(rParent)
- , mrRenderContext(rRenderContext)
+ explicit TabDrawer(vcl::RenderContext& rRenderContext)
+ : mrRenderContext(rRenderContext)
, mrStyleSettings(rRenderContext.GetSettings().GetStyleSettings())
, mbSelected(false)
, mbCustomColored(false)
, mbEnabled(false)
+ , mbProtect(false)
{
- }
-
- void drawOutputAreaBorder()
- {
- WinBits nWinStyle = mrParent.GetStyle();
-
- // draw extra line if above and below border
- if (nWinStyle & WB_BORDER)
- {
- Size aOutputSize(mrParent.GetOutputSizePixel());
- tools::Rectangle aOutRect = mrParent.GetPageArea();
- // draw border (line above and line below)
- mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
- mrRenderContext.DrawLine(aOutRect.TopLeft(), Point(aOutputSize.Width() - 1, aOutRect.Top()));
- }
}
void drawOuterFrame()
{
- mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
-
// set correct FillInBrush depending on status
if (mbSelected)
{
// Currently selected Tab
mrRenderContext.SetFillColor(maSelectedColor);
+ mrRenderContext.SetLineColor(maSelectedColor);
+ mrRenderContext.DrawRect(maRect);
+ mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
}
else if (mbCustomColored)
{
mrRenderContext.SetFillColor(maCustomColor);
+ mrRenderContext.SetLineColor(maCustomColor);
+ mrRenderContext.DrawRect(maRect);
+ mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
}
- else
- {
- mrRenderContext.SetFillColor(maUnselectedColor);
- }
-
- mrRenderContext.DrawRect(maRect);
}
void drawText(const OUString& aText)
@@ -143,27 +128,38 @@ public:
void drawColorLine()
{
- mrRenderContext.SetFillColor(maCustomColor);
- mrRenderContext.SetLineColor(maCustomColor);
-
- tools::Rectangle aLineRect(maRect.BottomLeft(), maRect.BottomRight());
- aLineRect.AdjustTop( -3 );
-
- mrRenderContext.DrawRect(aLineRect);
+ if (mbCustomColored && mbSelected)
+ {
+ mrRenderContext.SetFillColor(maCustomColor);
+ mrRenderContext.SetLineColor(maCustomColor);
+ mrRenderContext.DrawRect(maLineRect);
+ }
+ else if (mbSelected)
+ {
+ mrRenderContext.SetFillColor(mrStyleSettings.GetDarkShadowColor());
+ mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
+ mrRenderContext.DrawRect(maLineRect);
+ }
}
void drawTab()
{
drawOuterFrame();
-
- if (mbCustomColored && mbSelected)
+ drawColorLine();
+ if (mbProtect)
{
- drawColorLine();
+ BitmapEx aBitmap(BMP_TAB_LOCK);
+ Point aPosition = maRect.TopLeft();
+ aPosition.AdjustX(2);
+ aPosition.AdjustY((maRect.getHeight() - aBitmap.GetSizePixel().Height()) / 2);
+ mrRenderContext.DrawBitmapEx(aPosition, aBitmap);
}
}
void setRect(const tools::Rectangle& rRect)
{
+ maLineRect = tools::Rectangle(rRect.BottomLeft(), rRect.BottomRight());
+ maLineRect.AdjustTop(-2);
maRect = rRect;
}
@@ -241,14 +237,7 @@ struct ImplTabBarItem
OUString GetRenderText() const
{
- if (!mbProtect)
- return maText;
- else
- {
- constexpr sal_uInt32 cLockChar[] = { 0x1F512, 0x2002 }; // Lock + EN SPACE
- const OUString aLockSymbol( cLockChar, SAL_N_ELEMENTS(cLockChar));
- return aLockSymbol + maText;
- }
+ return maText;
}
};
@@ -685,7 +674,7 @@ bool TabBar::ImplCalcWidth()
// Padding is dependent on font height - bigger font = bigger padding
long nFontWidth = aFont.GetFontHeight();
- nNewWidth += nFontWidth * 2;
+ nNewWidth += nFontWidth * 5;
if (pItem->mnWidth != nNewWidth)
{
@@ -1151,13 +1140,11 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r
vcl::Font aLightFont = aFont;
aLightFont.SetWeight(WEIGHT_NORMAL);
- TabDrawer aDrawer(*this, rRenderContext);
+ TabDrawer aDrawer(rRenderContext);
aDrawer.setSelectedFillColor(aSelectColor);
aDrawer.setUnselectedFillColor(aFaceColor);
- aDrawer.drawOutputAreaBorder();
-
// Now, start drawing the tabs.
ImplTabBarItem* pItem = ImplGetLastTabBarItem(nItemCount);
@@ -1191,13 +1178,11 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r
aDrawer.setCustomColored(bCustomBgColor);
aDrawer.setEnabled(true);
aDrawer.setCustomColor(pItem->maTabBgColor);
+ aDrawer.mbProtect = pItem->mbProtect;
aDrawer.drawTab();
// actual page is drawn using a bold font
- if (bCurrent)
- rRenderContext.SetFont(aFont);
- else
- rRenderContext.SetFont(aLightFont);
+ rRenderContext.SetFont(aLightFont);
// Set the correct FillInBrush depending on status