haiku/headers/private/shared/BarberPole.h
PulkoMandy 0ba60bc743 Move BarberPole from HaikuDepot to libshared
I want to use this in at least 2 third-party applications. I think it's
time to make it shared?

Change-Id: I855a59aab4ad6d47d77cf2901cb3dfc34c108059
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6296
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-04-29 16:11:43 +00:00

63 lines
1.3 KiB
C++

/*
* Copyright 2017 Julian Harnath <julian.harnath@rwth-aachen.de>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef BARBER_POLE_H
#define BARBER_POLE_H
#include <View.h>
#include <Polygon.h>
class BMessageRunner;
/*! Spinning barber pole progress indicator. Number and colors of the
color stripes are configurable. By default, it will be 2 colors,
chosen from the system color palette.
*/
class BarberPole : public BView {
public:
enum {
// Message codes
kRefreshMessage = 0x1001
};
public:
BarberPole(const char* name);
~BarberPole();
virtual void MessageReceived(BMessage* message);
virtual void Draw(BRect updateRect);
virtual void FrameResized(float width, float height);
virtual BSize MinSize();
void Start();
void Stop();
void SetSpinSpeed(float speed);
void SetColors(const rgb_color* colors,
uint32 numColors);
private:
void _Spin();
void _DrawSpin(BRect updateRect);
void _DrawNonSpin(BRect updateRect);
private:
bool fIsSpinning;
float fSpinSpeed;
const rgb_color* fColors;
uint32 fNumColors;
float fScrollOffset;
BPolygon fStripe;
float fStripeWidth;
uint32 fNumStripes;
};
#endif // BARBER_POLE_H