#ifndef PEAK_VIEW_H
#define PEAK_VIEW_H
#include <View.h>
class BBitmap;
class BMessageRunner;
class PeakView : public BView {
public:
PeakView(const char* name,
bool useGlobalPulse = true,
bool displayLabels = true);
virtual ~PeakView();
virtual void MessageReceived(BMessage* message);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void MouseDown(BPoint where);
virtual void Draw(BRect area);
virtual void FrameResized(float width, float height);
virtual void Pulse();
virtual BSize MinSize();
bool IsValid() const;
void SetPeakRefreshDelay(bigtime_t delay);
void SetPeakNotificationWhat(uint32 what);
void SetChannelCount(uint32 count);
void SetMax(float max, uint32 channel);
private:
BRect _BackBitmapFrame() const;
void _ResizeBackBitmap(int32 width, int32 channels);
void _UpdateBackBitmap();
void _RenderSpan(uint8* span, uint32 width,
float current, float peak, bool overshot);
void _DrawBitmap();
private:
bool fUseGlobalPulse;
bool fDisplayLabels;
bool fPeakLocked;
bigtime_t fRefreshDelay;
BMessageRunner* fPulse;
struct ChannelInfo {
float current_max;
float last_max;
bigtime_t last_overshot_time;
};
ChannelInfo* fChannelInfos;
uint32 fChannelCount;
bool fGotData;
BBitmap* fBackBitmap;
font_height fFontHeight;
uint32 fPeakNotificationWhat;
};
#endif