Kaydet (Commit) fad98c86 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

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: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst e1ebb5cb
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
#define SPLIT_MARGIN 30 #define SPLIT_MARGIN 30
#define SPLIT_HANDLE_SIZE 5 #define SPLIT_HANDLE_SIZE 5
#define WIDTH_MARGIN 5 constexpr sal_Int32 TAB_HEIGHT_MARGIN = 10;
#define SC_ICONSIZE 36 #define SC_ICONSIZE 36
...@@ -358,7 +358,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) ...@@ -358,7 +358,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
Size aFontSize = rStyleSettings.GetTabFont().GetFontSize(); Size aFontSize = rStyleSettings.GetTabFont().GetFontSize();
MapMode aPtMapMode(MapUnit::MapPoint); MapMode aPtMapMode(MapUnit::MapPoint);
aFontSize = pFrameWin->LogicToPixel(aFontSize, aPtMapMode); 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 ) if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
{ {
...@@ -393,7 +393,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) ...@@ -393,7 +393,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
} }
if (bHScroll) if (bHScroll)
{ {
nBarY = nTabWidth; nBarY = nTabHeight;
if (!mbInlineWithScrollbar) if (!mbInlineWithScrollbar)
nBarY += nScrollBarSize; nBarY += nScrollBarSize;
...@@ -484,7 +484,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) ...@@ -484,7 +484,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
else else
{ {
Point aTabPoint(nPosX, nPosY + nSizeY + nScrollBarSize); Point aTabPoint(nPosX, nPosY + nSizeY + nScrollBarSize);
Size aTabSize(nSizeX, nTabWidth); Size aTabSize(nSizeX, nTabHeight);
lcl_SetPosSize(*pTabControl, aTabPoint, aTabSize, nTotalWidth, bLayoutRTL); lcl_SetPosSize(*pTabControl, aTabPoint, aTabSize, nTotalWidth, bLayoutRTL);
pTabControl->SetSheetLayoutRTL(bLayoutRTL); pTabControl->SetSheetLayoutRTL(bLayoutRTL);
...@@ -622,7 +622,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) ...@@ -622,7 +622,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
nSplitPosX = aViewData.GetHSplitPos(); nSplitPosX = aViewData.GetHSplitPos();
lcl_SetPosSize( *pHSplitter, lcl_SetPosSize( *pHSplitter,
Point(nSplitPosX, nOutPosY), Point(nSplitPosX, nOutPosY),
Size( nSplitSizeX, nSplitHeight - nTabWidth ), nTotalWidth, bLayoutRTL ); Size(nSplitSizeX, nSplitHeight - nTabHeight), nTotalWidth, bLayoutRTL);
nLeftSize = nSplitPosX - nPosX; nLeftSize = nSplitPosX - nPosX;
nSplitPosX += nSplitSizeX; nSplitPosX += nSplitSizeX;
nRightSize = nSizeX - nLeftSize - nSplitSizeX; nRightSize = nSizeX - nLeftSize - nSplitSizeX;
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <tools/helpers.hxx> #include <tools/helpers.hxx>
constexpr sal_Int32 TAB_HEIGHT_MARGIN = 10;
namespace sd { namespace sd {
GraphicViewShell::GraphicViewShell ( GraphicViewShell::GraphicViewShell (
...@@ -74,7 +76,7 @@ void GraphicViewShell::ArrangeGUIElements() ...@@ -74,7 +76,7 @@ void GraphicViewShell::ArrangeGUIElements()
Size aSize = mpLayerTabBar->GetSizePixel(); Size aSize = mpLayerTabBar->GetSizePixel();
const Size aFrameSize (GetViewFrame()->GetWindow().GetOutputSizePixel()); const Size aFrameSize (GetViewFrame()->GetWindow().GetOutputSizePixel());
aSize.setHeight( GetParentWindow()->GetFont().GetFontHeight() + 4 ); aSize.setHeight(GetParentWindow()->GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN);
aSize.setWidth( aFrameSize.Width() ); aSize.setWidth( aFrameSize.Width() );
Point aPos (0, maViewSize.Height() - aSize.Height()); Point aPos (0, maViewSize.Height() - aSize.Height());
......
...@@ -114,6 +114,8 @@ ...@@ -114,6 +114,8 @@
#define BMP_FILTER "svtools/res/ed08.png" #define BMP_FILTER "svtools/res/ed08.png"
#define BMP_HEADERFOOTER "svtools/res/ed09.png" #define BMP_HEADERFOOTER "svtools/res/ed09.png"
#define BMP_TAB_LOCK "cmd/sc_lock.png"
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
...@@ -41,80 +41,65 @@ ...@@ -41,80 +41,65 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <vcl/idle.hxx> #include <vcl/idle.hxx>
#include <bitmaps.hlst>
namespace namespace
{ {
#define TABBAR_DRAG_SCROLLOFF 5 constexpr sal_uInt16 TABBAR_DRAG_SCROLLOFF = 5;
#define TABBAR_MINSIZE 5 constexpr sal_uInt16 TABBAR_MINSIZE = 5;
const sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10; constexpr sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10;
const sal_uInt16 BUTTON_MARGIN = 6; constexpr sal_uInt16 BUTTON_MARGIN = 6;
class TabDrawer class TabDrawer
{ {
private: private:
TabBar& mrParent;
vcl::RenderContext& mrRenderContext; vcl::RenderContext& mrRenderContext;
const StyleSettings& mrStyleSettings; const StyleSettings& mrStyleSettings;
tools::Rectangle maRect; tools::Rectangle maRect;
tools::Rectangle maLineRect;
Color maSelectedColor; Color maSelectedColor;
Color maCustomColor; Color maCustomColor;
Color maUnselectedColor; Color maUnselectedColor;
public:
bool mbSelected:1; bool mbSelected:1;
bool mbCustomColored:1; bool mbCustomColored:1;
bool mbEnabled:1; bool mbEnabled:1;
bool mbProtect:1;
public: explicit TabDrawer(vcl::RenderContext& rRenderContext)
explicit TabDrawer(TabBar& rParent, vcl::RenderContext& rRenderContext) : mrRenderContext(rRenderContext)
: mrParent(rParent)
, mrRenderContext(rRenderContext)
, mrStyleSettings(rRenderContext.GetSettings().GetStyleSettings()) , mrStyleSettings(rRenderContext.GetSettings().GetStyleSettings())
, mbSelected(false) , mbSelected(false)
, mbCustomColored(false) , mbCustomColored(false)
, mbEnabled(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() void drawOuterFrame()
{ {
mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
// set correct FillInBrush depending on status // set correct FillInBrush depending on status
if (mbSelected) if (mbSelected)
{ {
// Currently selected Tab // Currently selected Tab
mrRenderContext.SetFillColor(maSelectedColor); mrRenderContext.SetFillColor(maSelectedColor);
mrRenderContext.SetLineColor(maSelectedColor);
mrRenderContext.DrawRect(maRect);
mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
} }
else if (mbCustomColored) else if (mbCustomColored)
{ {
mrRenderContext.SetFillColor(maCustomColor); 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) void drawText(const OUString& aText)
...@@ -143,27 +128,38 @@ public: ...@@ -143,27 +128,38 @@ public:
void drawColorLine() void drawColorLine()
{ {
mrRenderContext.SetFillColor(maCustomColor); if (mbCustomColored && mbSelected)
mrRenderContext.SetLineColor(maCustomColor); {
mrRenderContext.SetFillColor(maCustomColor);
tools::Rectangle aLineRect(maRect.BottomLeft(), maRect.BottomRight()); mrRenderContext.SetLineColor(maCustomColor);
aLineRect.AdjustTop( -3 ); mrRenderContext.DrawRect(maLineRect);
}
mrRenderContext.DrawRect(aLineRect); else if (mbSelected)
{
mrRenderContext.SetFillColor(mrStyleSettings.GetDarkShadowColor());
mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
mrRenderContext.DrawRect(maLineRect);
}
} }
void drawTab() void drawTab()
{ {
drawOuterFrame(); drawOuterFrame();
drawColorLine();
if (mbCustomColored && mbSelected) 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) void setRect(const tools::Rectangle& rRect)
{ {
maLineRect = tools::Rectangle(rRect.BottomLeft(), rRect.BottomRight());
maLineRect.AdjustTop(-2);
maRect = rRect; maRect = rRect;
} }
...@@ -241,14 +237,7 @@ struct ImplTabBarItem ...@@ -241,14 +237,7 @@ struct ImplTabBarItem
OUString GetRenderText() const OUString GetRenderText() const
{ {
if (!mbProtect) return maText;
return maText;
else
{
constexpr sal_uInt32 cLockChar[] = { 0x1F512, 0x2002 }; // Lock + EN SPACE
const OUString aLockSymbol( cLockChar, SAL_N_ELEMENTS(cLockChar));
return aLockSymbol + maText;
}
} }
}; };
...@@ -685,7 +674,7 @@ bool TabBar::ImplCalcWidth() ...@@ -685,7 +674,7 @@ bool TabBar::ImplCalcWidth()
// Padding is dependent on font height - bigger font = bigger padding // Padding is dependent on font height - bigger font = bigger padding
long nFontWidth = aFont.GetFontHeight(); long nFontWidth = aFont.GetFontHeight();
nNewWidth += nFontWidth * 2; nNewWidth += nFontWidth * 5;
if (pItem->mnWidth != nNewWidth) if (pItem->mnWidth != nNewWidth)
{ {
...@@ -1151,13 +1140,11 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r ...@@ -1151,13 +1140,11 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r
vcl::Font aLightFont = aFont; vcl::Font aLightFont = aFont;
aLightFont.SetWeight(WEIGHT_NORMAL); aLightFont.SetWeight(WEIGHT_NORMAL);
TabDrawer aDrawer(*this, rRenderContext); TabDrawer aDrawer(rRenderContext);
aDrawer.setSelectedFillColor(aSelectColor); aDrawer.setSelectedFillColor(aSelectColor);
aDrawer.setUnselectedFillColor(aFaceColor); aDrawer.setUnselectedFillColor(aFaceColor);
aDrawer.drawOutputAreaBorder();
// Now, start drawing the tabs. // Now, start drawing the tabs.
ImplTabBarItem* pItem = ImplGetLastTabBarItem(nItemCount); ImplTabBarItem* pItem = ImplGetLastTabBarItem(nItemCount);
...@@ -1191,13 +1178,11 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r ...@@ -1191,13 +1178,11 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& r
aDrawer.setCustomColored(bCustomBgColor); aDrawer.setCustomColored(bCustomBgColor);
aDrawer.setEnabled(true); aDrawer.setEnabled(true);
aDrawer.setCustomColor(pItem->maTabBgColor); aDrawer.setCustomColor(pItem->maTabBgColor);
aDrawer.mbProtect = pItem->mbProtect;
aDrawer.drawTab(); aDrawer.drawTab();
// actual page is drawn using a bold font // actual page is drawn using a bold font
if (bCurrent) rRenderContext.SetFont(aLightFont);
rRenderContext.SetFont(aFont);
else
rRenderContext.SetFont(aLightFont);
// Set the correct FillInBrush depending on status // Set the correct FillInBrush depending on status
......
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