[haiku-commits] haiku: hrev53342 - src/apps/haikudepot/ui_generic

  • From: Andrew Lindesay <apl@xxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 5 Aug 2019 03:39:44 -0400 (EDT)

hrev53342 adds 1 changeset to branch 'master'
old head: 719cfad7fd6da76610f7869f9ef93828804a083f
new head: 02e836dc3c3850e5f3d00bf6b85563d3900c6ec8
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=02e836dc3c38+%5E719cfad7fd6d

----------------------------------------------------------------------------

02e836dc3c38: HaikuDepot: Barber Pole Idle Appearance
  
  This change renders a striped background in the
  'barber pole' in HaikuDepot application when it is
  idle.  This makes the 'barber pole' easier to use
  in situations where the space that the UI control
  takes up should not be blank.  The logic for the
  striped background is from the 'drivesetup'
  application.
  
  Change-Id: I87791c70b4d1a21d91e661433d6c940ca69ece87
  Reviewed-on: https://review.haiku-os.org/c/1674
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

                                    [ Andrew Lindesay <apl@xxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53342
Commit:      02e836dc3c3850e5f3d00bf6b85563d3900c6ec8
URL:         https://git.haiku-os.org/haiku/commit/?id=02e836dc3c38
Author:      Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Date:        Sat Aug  3 11:13:21 2019 UTC

----------------------------------------------------------------------------

2 files changed, 70 insertions(+), 33 deletions(-)
src/apps/haikudepot/ui_generic/BarberPole.cpp | 100 +++++++++++++++-------
src/apps/haikudepot/ui_generic/BarberPole.h   |   3 +-

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/ui_generic/BarberPole.cpp 
b/src/apps/haikudepot/ui_generic/BarberPole.cpp
index 00318c7c3e..9319757ca5 100644
--- a/src/apps/haikudepot/ui_generic/BarberPole.cpp
+++ b/src/apps/haikudepot/ui_generic/BarberPole.cpp
@@ -183,39 +183,67 @@ BarberPole::MessageReceived(BMessage* message)
 void
 BarberPole::Draw(BRect updateRect)
 {
+       if (fIsSpinning)
+               _DrawSpin(updateRect);
+       else
+               _DrawNonSpin(updateRect);
+}
 
-       if (fIsSpinning) {
-               // Draw color stripes
-               float position = -fStripeWidth * (fNumColors + 0.5) + 
fScrollOffset;
-                       // Starting position: beginning of the second color 
cycle
-                       // The + 0.5 is so we start out without a partially 
visible stripe
-                       // on the left side (makes it simpler to loop)
-               BRect bounds = Bounds();
-               bounds.InsetBy(-2, -2);
-               be_control_look->DrawStatusBar(this, bounds, updateRect,
-                       ui_color(B_PANEL_BACKGROUND_COLOR), 
ui_color(B_STATUS_BAR_COLOR),
-                       bounds.Width());
-               SetDrawingMode(B_OP_ALPHA);
-               uint32 colorIndex = 0;
-               for (uint32 i = 0; i < fNumStripes; i++) {
-                       SetHighColor(fColors[colorIndex]);
-                       colorIndex++;
-                       if (colorIndex >= fNumColors)
-                               colorIndex = 0;
-
-                       BRect stripeFrame = fStripe.Frame();
-                       fStripe.MapTo(stripeFrame,
-                               stripeFrame.OffsetToCopy(position, 0.0));
-                       FillPolygon(&fStripe);
-
-                       position += fStripeWidth;
-               }
-               SetDrawingMode(B_OP_COPY);
-               // Draw box around it
-               bounds = Bounds();
-               be_control_look->DrawBorder(this, bounds, updateRect,
-                       ui_color(B_PANEL_BACKGROUND_COLOR), B_PLAIN_BORDER);
+
+void
+BarberPole::_DrawSpin(BRect updateRect)
+{
+       // Draw color stripes
+       float position = -fStripeWidth * (fNumColors + 0.5) + fScrollOffset;
+               // Starting position: beginning of the second color cycle
+               // The + 0.5 is so we start out without a partially visible 
stripe
+               // on the left side (makes it simpler to loop)
+       BRect bounds = Bounds();
+       bounds.InsetBy(-2, -2);
+       be_control_look->DrawStatusBar(this, bounds, updateRect,
+               ui_color(B_PANEL_BACKGROUND_COLOR), 
ui_color(B_STATUS_BAR_COLOR),
+               bounds.Width());
+       SetDrawingMode(B_OP_ALPHA);
+       uint32 colorIndex = 0;
+       for (uint32 i = 0; i < fNumStripes; i++) {
+               SetHighColor(fColors[colorIndex]);
+               colorIndex++;
+               if (colorIndex >= fNumColors)
+                       colorIndex = 0;
+
+               BRect stripeFrame = fStripe.Frame();
+               fStripe.MapTo(stripeFrame,
+                       stripeFrame.OffsetToCopy(position, 0.0));
+               FillPolygon(&fStripe);
+
+               position += fStripeWidth;
        }
+
+       SetDrawingMode(B_OP_COPY);
+       // Draw box around it
+       bounds = Bounds();
+       be_control_look->DrawBorder(this, bounds, updateRect,
+               ui_color(B_PANEL_BACKGROUND_COLOR), B_PLAIN_BORDER);
+}
+
+
+/*! This will show something in the place of the spinner when there is no
+    spinning going on.  The logic to render the striped background comes
+    from the 'drivesetup' application.
+*/
+
+void
+BarberPole::_DrawNonSpin(BRect updateRect)
+{
+       // approach copied from the DiskSetup application.
+       static const pattern kStripes = { { 0xc7, 0x8f, 0x1f, 0x3e, 0x7c,
+               0xf8, 0xf1, 0xe3 } };
+       BRect bounds = Bounds();
+       SetHighUIColor(B_PANEL_BACKGROUND_COLOR, B_DARKEN_1_TINT);
+       SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
+       FillRect(bounds, kStripes);
+       be_control_look->DrawBorder(this, bounds, updateRect,
+               ui_color(B_PANEL_BACKGROUND_COLOR), B_PLAIN_BORDER);
 }
 
 
@@ -259,7 +287,15 @@ BarberPole::FrameResized(float width, float height)
 BSize
 BarberPole::MinSize()
 {
-       return BSize(50, 5);
+       BSize result = BView::MinSize();
+
+       if (result.width < 50)
+               result.SetWidth(50);
+
+       if (result.height < 5)
+               result.SetHeight(5);
+
+       return result;
 }
 
 
diff --git a/src/apps/haikudepot/ui_generic/BarberPole.h 
b/src/apps/haikudepot/ui_generic/BarberPole.h
index cfd98a627c..23edb8fb6c 100644
--- a/src/apps/haikudepot/ui_generic/BarberPole.h
+++ b/src/apps/haikudepot/ui_generic/BarberPole.h
@@ -44,7 +44,8 @@ public:
 
 private:
                        void                            _Spin();
-
+                       void                            _DrawSpin(BRect 
updateRect);
+                       void                            _DrawNonSpin(BRect 
updateRect);
 private:
                        bool                            fIsSpinning;
                        float                           fSpinSpeed;


Other related posts:

  • » [haiku-commits] haiku: hrev53342 - src/apps/haikudepot/ui_generic - Andrew Lindesay