Skip to content

Commit

Permalink
Add Barberpole.{h.cpp} from BarberPole1.0.zip
Browse files Browse the repository at this point in the history
Got the file from https://pulkomandy.tk/~beosarchive/.

Changes to that:

* Renamed BarberPole.cc -> BarberPole.cpp..
* Removed include for "Colors.h", no idea where that comes from
  and doesn't seems actually needed.
* Added default value for the flag constructor parameter.
  Not sure if the value is correct, but prevents compile errors
  for now.
  • Loading branch information
OscarL committed Sep 13, 2023
1 parent db78755 commit a01ad03
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
64 changes: 64 additions & 0 deletions Common/Support/BarberPole.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "BarberPole.h"


BarberPole::BarberPole(BRect pRect, const char *pName, uint32 resizingMode, uint32 flags, int pDirection)
: BView(pRect, pName, resizingMode, flags) {

spinning_thread_id = spawn_thread(spinningThread, pName, B_DISPLAY_PRIORITY, this);
is_running = false;
direction = pDirection;
};

BarberPole::~BarberPole(){
kill_thread(spinning_thread_id);
}

void BarberPole::Start(){
resume_thread(spinning_thread_id);
is_running = true;
}

void BarberPole::Stop(){
suspend_thread(spinning_thread_id);
is_running = false;
}

bool BarberPole::IsRunning(){
return is_running;
}

int32 BarberPole::spinningThread(void *data){
BarberPole *lBarberPole = (BarberPole*)data;
pattern lStripes;

lStripes.data[0] = 0x0f;
lStripes.data[1] = 0x1e;
lStripes.data[2] = 0x3c;
lStripes.data[3] = 0x78;
lStripes.data[4] = 0xf0;
lStripes.data[5] = 0xe1;
lStripes.data[6] = 0xc3;
lStripes.data[7] = 0x87;

while(1==1){
lBarberPole->LockLooper();
lBarberPole->FillRect(lBarberPole->Bounds(), lStripes);
lBarberPole->UnlockLooper();

if(lBarberPole->direction == FROM_RIGHT_TO_LEFT){
uchar tmp = lStripes.data[0];
for (int j = 0; j < 7; ++j) {
lStripes.data[j] = lStripes.data[j+1];
}
lStripes.data[7] = tmp;
} else {
uchar tmp = lStripes.data[7];
for (int j = 7; j > 0; --j) {
lStripes.data[j] = lStripes.data[j-1];
}
lStripes.data[0] = tmp;

}
snooze(25000);
}
};
28 changes: 28 additions & 0 deletions Common/Support/BarberPole.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef _BARBERPOLE_H_
#define _BARBERPOLE_H_

#include <View.h>

const int FROM_RIGHT_TO_LEFT = 0;
const int FROM_LEFT_TO_RIGHT = 1;

class BarberPole : public BView {
public:
BarberPole(BRect pRect, const char *pName, uint32 resizingMode, uint32 flags = 0, int pDirection = FROM_LEFT_TO_RIGHT);
~BarberPole();

void Start();
void Stop();

bool IsRunning();

protected:
thread_id spinning_thread_id;
bool is_running;

private:
int direction;
static int32 spinningThread(void *data);
};

#endif
15 changes: 15 additions & 0 deletions Common/Support/BarberPole.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Dortmund, Germany.
December, 12th 1998

BarberPole is a little class, that shows this little spinning barber pole, you probably know from Net+ or the Tracker.

This is V1.0 and should compile on both x86 and PPC, although I currently haven't tested it on PPC. If you want to set the color of the pole, do it by using

myBarberPol->SetHighColor(...)
and
myBarberPole->SetLowColor(...)

BarberPole is Freeware. If you made any changes, please report it to me, so I could update it.

dirk116@wallace.free.de // Member of DeBUG - German Be User Group
// http://www.BeUserGroup.de

0 comments on commit a01ad03

Please sign in to comment.