コード例 #1
0
void 
Shelf::Draw(BView *view, int32 frame)
{
	PRINT(("%p:%s(, %d)\n", this, __FUNCTION__, frame));
	BScreenSaver::Draw(view, frame);
#if 0
	if (frame == 0) { 
		// fill with blue on first frame
		view->SetLowColor(kMediumBlue); 
		view->FillRect(view->Bounds(), B_SOLID_LOW); 

		// Set tick size to 500,000 microseconds = 0.5 second
		SetTickSize(500000);
	} else {
		// Drawing the background color every other frame to make the text blink
		if (frame % 2 == 1)
			view->SetHighColor(kWhite);
		else
			view->SetHighColor(kMediumBlue);

		view->DrawString(fLine1, fLine1Start);
		view->DrawString(fLine2, fLine2Start);
	}
#endif
}
コード例 #2
0
ファイル: Message.cpp プロジェクト: AmirAbrams/haiku
status_t 
Message::StartSaver(BView *view, bool preview)
{
	fPreview = preview;
	// Scale factor is based on the system I developed this on, in
	// other words other factors below depend on this.
	fScaleFactor = view->Bounds().Height() / 1024;

	// Get font families
	int numFamilies = count_font_families();
	for (int32 i = 0; i < numFamilies; i++) {
		font_family* family = new font_family[1];
		uint32 flags;
		if (get_font_family(i, family, &flags) == B_OK
			&& (flags & B_IS_FIXED) == 0) {
			// Do not add fixed fonts
			fFontFamilies.AddItem(family);
		} else
			delete[] family;
	}

	// Seed the random number generator
	srand((int)system_time());

	// Set tick size to 30,000,000 microseconds = 30 seconds
	SetTickSize(30000000);
	
	return B_OK;
}
コード例 #3
0
status_t
Butterfly::StartSaver(BView* view, bool preview)
{
	view->SetLowColor(0, 0, 0);
	view->FillRect(view->Bounds(), B_SOLID_LOW);
	view->SetDrawingMode(B_OP_ALPHA);
	view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
	view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
	if (!preview)
		view->SetPenSize(2.0);

	SetTickSize(20000);

	// Set fBase to a random radian value scaled by 1000. The scaling produces
	// more interesting results.
	srand48(system_time());
	fBase = drand48() * 2 * M_PI * 1000;

	// calculate transformation
	BRect bounds = view->Bounds();
	fScale = MIN(bounds.Width(), bounds.Height()) * 0.1f;
	fTrans.Set(bounds.Width() * 0.5f, bounds.Height() * 0.5f);
	fBounds = bounds;

	fLast[0] = _Iterate();
	fLast[1] = _Iterate();
	fLast[2] = _Iterate();

	return B_OK;
}
コード例 #4
0
status_t
Leaves::StartSaver(BView* view, bool preview)
{
	SetTickSize(10000000 / fDropRate);
	srand48(time(NULL));

	view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);

	return B_OK;
}
コード例 #5
0
ファイル: SlideShowSaver.cpp プロジェクト: AmirAbrams/haiku
status_t
SlideShowSaver::UpdateTickSize()
{
	// Tick size is in microseconds, but is stored in settings as
	// milliseconds
	bigtime_t ticks = static_cast<bigtime_t>
		(fSettings->SetGetInt32(SAVER_SETTING_DELAY)) * 1000;
	SetTickSize(ticks);

	return B_OK;
}
コード例 #6
0
// StartSaver
status_t
IFSSaver::StartSaver(BView *v, bool preview)
{
	display_mode mode;
	BScreen screen(B_MAIN_SCREEN_ID);
	screen.GetMode(&mode);
	float totalSize = mode.timing.h_total * mode.timing.v_total;
	float fps = mode.timing.pixel_clock * 1000.0 / totalSize;

//printf("ticks per frame: %lldµs\n", (int64)floor(1000000.0 / fps + 0.5));
	SetTickSize((int64)floor(1000000.0 / fps + 0.5));

	fIsPreview = preview;
	fBounds = v->Bounds();

	_Init(fBounds);
	fIFS->SetAdditive(fIsPreview || fAdditive);
	fIFS->SetSpeed(fSpeed);

	return B_OK;
}
コード例 #7
0
status_t
FallLeaves::StartSaver(BView* view, bool preview)
{
	BRect screenRect = view->Bounds();
	
	// Initialize the screen buffer
	fBackBitmap = new BBitmap(screenRect, B_RGBA32, true);
	fBackView = new BView(screenRect, NULL, 0, 0);

	fBackBitmap->AddChild(fBackView);
	
	if (fBackBitmap->Lock()) {
		fBackView->FillRect(fBackView->Bounds());
		fBackView->SetDrawingMode(B_OP_OVER); // Leaf transparency
		fBackBitmap->Unlock();
	}

	// Set the rate the screensaver to be updated 100 times per second
	// The argument here is in microseconds
	SetTickSize(MICROSECS_IN_SEC / TICKS_PER_SECOND);
	
	// Initialize the random number generator
	srand(system_time() % INT_MAX);
	
	// The max size of a leaf will be about 20% the
	// height of the screen
	fSize = (view->Bounds().IntegerHeight() * 2) / 10;
	
	fLeaves = new BObjectList<Leaf>();
	
	// Create some leaves
	for (int32 i = 0; i < fAmount; i++)
		fLeaves->AddItem(_CreateLeaf(view, true));
	
	// Sort the leaves by Z axis
	fLeaves->SortItems(cmpz);
	
	return B_OK;
}
コード例 #8
0
ファイル: ScreenSaver.cpp プロジェクト: AmirAbrams/haiku
void 
ScreenSaver::Draw(BView *view, int32 frame)
{
	if (frame == 0) { 
		// fill with black on first frame
		view->SetLowColor(0, 0, 0); 
		view->FillRect(view->Bounds(), B_SOLID_LOW); 
	} else {
		// erase old text on all other frames
		view->SetHighColor(0, 0, 0);
		view->DrawString(fText, BPoint(fX, fY));
	}

	// find some new text coordinates
	fX = rand() % int(fSizeX - fTextWith);
	fY = rand() % int(fSizeY - fTextHeight - (fIsPreview ? 2 : 20)) + fTextHeight;

	// draw new text
	view->SetHighColor(0, 255, 0);
	view->DrawString(fText, BPoint(fX, fY));

	// randomize time until next update (preview mode is faster)
	SetTickSize(((rand() % 4) + 1) * (fIsPreview ? 300000 : 1000000));
}
コード例 #9
0
ファイル: SimpleClock.cpp プロジェクト: AmirAbrams/haiku
status_t
Clock::StartSaver(BView *view, bool)
{
	SetTickSize(1000000);
	return B_OK;
}