[Libreoffice-commits] core.git: include/vcl sfx2/source vcl/source

Akshay Deep akshaydeepiitr at gmail.com
Thu Jun 23 07:09:36 UTC 2016


 include/vcl/button.hxx               |    1 +
 include/vcl/menubtn.hxx              |   10 ++++++++++
 sfx2/source/dialog/backingwindow.cxx |   12 +++++++++++-
 sfx2/source/dialog/backingwindow.hxx |    6 +++---
 vcl/source/control/button.cxx        |   20 +++++++++++++++-----
 vcl/source/control/menubtn.cxx       |   18 ++++++++++++++++++
 6 files changed, 58 insertions(+), 9 deletions(-)

New commits:
commit 596065ff05165f5b59cfcfdcee09166931455e19
Author: Akshay Deep <akshaydeepiitr at gmail.com>
Date:   Sun Jun 19 14:38:54 2016 +0530

    GSoC tdf#87697 START CENTER: Indicate selected thumbnailview
    
    Added new "Active" state to PushButton class
    Active state used in MenuToggleButton class.
    
    Active => Pressed + Flyover
    
    When hovered in Active state, Active => Flyover only
    
    Change-Id: Iece1550b6d742a7ab3c9f4c7516ec855e1a1b6ef
    Reviewed-on: https://gerrit.libreoffice.org/26470
    Reviewed-by: Akshay Deep <akshaydeepiitr at gmail.com>
    Tested-by: Akshay Deep <akshaydeepiitr at gmail.com>

diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx
index 0fb7c98..a020bd6 100644
--- a/include/vcl/button.hxx
+++ b/include/vcl/button.hxx
@@ -120,6 +120,7 @@ protected:
     PushButtonDropdownStyle mnDDStyle;
     bool            mbPressed;
     bool            mbInUserDraw;
+    bool            mbIsActive;
 
     SAL_DLLPRIVATE void            ImplInitPushButtonData();
     SAL_DLLPRIVATE WinBits         ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle );
diff --git a/include/vcl/menubtn.hxx b/include/vcl/menubtn.hxx
index 8d8438f..0e57668 100644
--- a/include/vcl/menubtn.hxx
+++ b/include/vcl/menubtn.hxx
@@ -78,6 +78,16 @@ public:
     void            SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; }
 };
 
+
+class VCL_DLLPUBLIC MenuToggleButton : public MenuButton
+{
+public:
+    explicit        MenuToggleButton( vcl::Window* pParent, WinBits nStyle = 0 );
+    virtual         ~MenuToggleButton();
+
+    void            SetActive( bool bSel );
+};
+
 #endif // INCLUDED_VCL_MENUBTN_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index 9c054d5..ef27a2d 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -256,6 +256,7 @@ void BackingWindow::initControls()
     mpAllRecentThumbnails->mnFileTypes |= TYPE_OTHER;
     mpAllRecentThumbnails->Reload();
     mpAllRecentThumbnails->ShowTooltips( true );
+    mpRecentButton->SetActive(true);
 
     //initialize Template view
     mpLocalView->SetStyle( mpLocalView->GetStyle() | WB_VSCROLL);
@@ -345,7 +346,7 @@ void BackingWindow::setupButton( PushButton* pButton )
     pButton->SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
 }
 
-void BackingWindow::setupButton( MenuButton* pButton )
+void BackingWindow::setupButton( MenuToggleButton* pButton )
 {
     vcl::Font aFont(pButton->GetSettings().GetStyleSettings().GetPushButtonFont());
     aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * fMultiplier));
@@ -595,6 +596,9 @@ IMPL_LINK_TYPED( BackingWindow, ClickHdl, Button*, pButton, void )
         mpLocalView->Hide();
         mpAllRecentThumbnails->Show();
         mpAllRecentThumbnails->GrabFocus();
+        mpRecentButton->SetActive(true);
+        mpTemplateButton->SetActive(false);
+        mpTemplateButton->Invalidate();
     }
     else if( pButton == mpTemplateButton )
     {
@@ -604,6 +608,9 @@ IMPL_LINK_TYPED( BackingWindow, ClickHdl, Button*, pButton, void )
         mpLocalView->Show();
         mpLocalView->reload();
         mpLocalView->GrabFocus();
+        mpRecentButton->SetActive(false);
+        mpRecentButton->Invalidate();
+        mpTemplateButton->SetActive(true);
     }
 }
 
@@ -654,6 +661,9 @@ IMPL_LINK_TYPED( BackingWindow, MenuSelectHdl, MenuButton*, pButton, void )
         mpLocalView->Show();
         mpLocalView->reload();
         mpLocalView->GrabFocus();
+        mpRecentButton->SetActive(false);
+        mpTemplateButton->SetActive(true);
+        mpRecentButton->Invalidate();
     }
 }
 
diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx
index 4c80c9f..499d8b3 100644
--- a/sfx2/source/dialog/backingwindow.hxx
+++ b/sfx2/source/dialog/backingwindow.hxx
@@ -59,9 +59,9 @@ class BackingWindow : public vcl::Window, public VclBuilderContainer
     css::uno::Reference<css::datatransfer::dnd::XDropTargetListener> mxDropTargetListener;
 
     VclPtr<PushButton> mpOpenButton;
-    VclPtr<MenuButton> mpRecentButton;
+    VclPtr<MenuToggleButton> mpRecentButton;
     VclPtr<PushButton> mpRemoteButton;
-    VclPtr<MenuButton> mpTemplateButton;
+    VclPtr<MenuToggleButton> mpTemplateButton;
 
     VclPtr<FixedText>  mpCreateLabel;
 
@@ -93,7 +93,7 @@ class BackingWindow : public vcl::Window, public VclBuilderContainer
     std::unique_ptr<svt::AcceleratorExecute> mpAccExec;
 
     void setupButton(PushButton* pButton);
-    void setupButton(MenuButton* pButton);
+    void setupButton(MenuToggleButton* pButton);
 
     void dispatchURL(const OUString& i_rURL,
                      const OUString& i_rTarget = OUString("_default"),
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 0e4dc5b..3c53cbb 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -642,6 +642,7 @@ void PushButton::ImplInitPushButtonData()
     meState         = TRISTATE_FALSE;
     meSaveValue     = TRISTATE_FALSE;
     mnDDStyle       = PushButtonDropdownStyle::NONE;
+    mbIsActive    = false;
     mbPressed       = false;
     mbInUserDraw    = false;
 }
@@ -951,7 +952,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext)
     bool bNativeOK = false;
 
     // adjust style if button should be rendered 'pressed'
-    if (mbPressed)
+    if (mbPressed || mbIsActive)
         nButtonStyle |= DrawButtonFlags::Pressed;
 
     // TODO: move this to Window class or make it a member !!!
@@ -1004,7 +1005,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext)
                 ImplControlValue aControlValue;
                 ControlState nState = ControlState::NONE;
 
-                if (mbPressed)
+                if (mbPressed || mbIsActive)
                     nState |= ControlState::PRESSED;
                 if (ImplGetButtonState() & DrawButtonFlags::Pressed)
                     nState |= ControlState::PRESSED;
@@ -1018,6 +1019,12 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext)
                 if (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()))
                     nState |= ControlState::ROLLOVER;
 
+                if ( IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()) && mbIsActive)
+                {
+                    nState |= ControlState::ROLLOVER;
+                    nButtonStyle &= ~DrawButtonFlags::Pressed;
+                }
+
                 bNativeOK = rRenderContext.DrawNativeControl(aCtrlType, ControlPart::ButtonDown, aInRect, nState,
                                                              aControlValue, OUString());
             }
@@ -1027,7 +1034,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext)
     if (bNativeOK)
         return;
 
-    bool bRollOver = IsMouseOver() && aInRect.IsInside(GetPointerPosPixel());
+    bool bRollOver = (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()));
     bool bDrawMenuSep = true;
     if (GetStyle() & WB_FLATBUTTON)
     {
@@ -1040,7 +1047,7 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext)
         Rectangle aCtrlRegion(aInRect);
         ControlState nState = ControlState::NONE;
 
-        if (mbPressed || IsChecked())
+        if (mbPressed || IsChecked() || mbIsActive)
             nState |= ControlState::PRESSED;
         if (ImplGetButtonState() & DrawButtonFlags::Pressed)
             nState |= ControlState::PRESSED;
@@ -1051,9 +1058,12 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext)
         if (Window::IsEnabled())
             nState |= ControlState::ENABLED;
 
-        if (bRollOver)
+        if (bRollOver || mbIsActive)
             nState |= ControlState::ROLLOVER;
 
+        if (mbIsActive && bRollOver)
+            nState &= ~ControlState::PRESSED;
+
         if (GetStyle() & WB_BEVELBUTTON)
             aControlValue.mbBevelButton = true;
 
diff --git a/vcl/source/control/menubtn.cxx b/vcl/source/control/menubtn.cxx
index 702d720..918e10b 100644
--- a/vcl/source/control/menubtn.cxx
+++ b/vcl/source/control/menubtn.cxx
@@ -168,4 +168,22 @@ void MenuButton::SetPopupMenu( PopupMenu* pNewMenu )
     mpMenu = pNewMenu;
 }
 
+//class MenuToggleButton ----------------------------------------------------
+
+MenuToggleButton::MenuToggleButton( vcl::Window* pParent, WinBits nWinBits )
+    : MenuButton( pParent, nWinBits )
+{
+}
+
+MenuToggleButton::~MenuToggleButton()
+{
+    disposeOnce();
+}
+
+void MenuToggleButton::SetActive( bool bSel )
+{
+    mbIsActive = bSel;
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list