Beispiel #1
0
void 
BackgroundImage::Show(BackgroundImageInfo *info, BView *view)
{
	BPoseView *poseView = dynamic_cast<BPoseView *>(view);
	if (poseView)
		poseView->SetWidgetTextOutline(info->fTextWidgetOutline);

	if (info->fBitmap == NULL) {
		view->ClearViewBitmap();
		view->Invalidate();
		fShowingBitmap = info;
		return;
	}
	BRect viewBounds(view->Bounds());
	BRect bitmapBounds(info->fBitmap->Bounds());
	BRect destinationBitmapBounds(bitmapBounds);

	uint32 tile = 0;
	uint32 followFlags = B_FOLLOW_TOP | B_FOLLOW_LEFT;

	// figure out the display mode and the destination bounds for the bitmap
	switch (info->fMode) {
		case kCentered:
			if (fIsDesktop) {
				destinationBitmapBounds.OffsetBy(
					(viewBounds.Width() - bitmapBounds.Width()) / 2,
					(viewBounds.Height() - bitmapBounds.Height()) / 2);
				break;
			}
			// else fall thru
		case kScaledToFit:
			if (fIsDesktop) {
				destinationBitmapBounds = viewBounds;
				followFlags = B_FOLLOW_ALL;
				break;
			}
			// else fall thru
		case kAtOffset:
			destinationBitmapBounds.OffsetTo(info->fOffset);
			break;
		case kTiled:
			if (fIsDesktop) {
				destinationBitmapBounds.OffsetBy(
					(viewBounds.Width() - bitmapBounds.Width()) / 2,
					(viewBounds.Height() - bitmapBounds.Height()) / 2);
			}
			tile = B_TILE_BITMAP;
			break;
	}
	
	// switch to the bitmap and force a redraw
	view->SetViewBitmap(info->fBitmap, bitmapBounds, destinationBitmapBounds,
		followFlags, tile);
	view->Invalidate();
	fShowingBitmap = info;
}
void
BChannelSlider::DrawThumb(BView* into, int32 channel, BPoint where,
	bool pressed)
{
	ASSERT(into != NULL);

	const BBitmap* thumb = ThumbFor(channel, pressed);
	if (thumb == NULL)
		return;

	BRect bitmapBounds(thumb->Bounds());
	where.x -= bitmapBounds.right / 2.0;
	where.y -= bitmapBounds.bottom / 2.0;


	if (be_control_look != NULL) {
		BRect rect(bitmapBounds.OffsetToCopy(where));
		rect.InsetBy(1, 1);
		rect.left = floorf(rect.left);
		rect.top = floorf(rect.top);
		rect.right = ceilf(rect.right + 0.5);
		rect.bottom = ceilf(rect.bottom + 0.5);
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		uint32 flags = 0;
		be_control_look->DrawSliderThumb(into, rect, rect, base,
			flags, Orientation());
		return;
	}


	into->PushState();

	into->SetDrawingMode(B_OP_OVER);
	into->DrawBitmapAsync(thumb, where);

	if (pressed) {
		into->SetDrawingMode(B_OP_ALPHA);

		rgb_color color = tint_color(into->ViewColor(), B_DARKEN_4_TINT);
		color.alpha = 128;
		into->SetHighColor(color);

		BRect destRect(where, where);
		destRect.right += bitmapBounds.right;
		destRect.bottom += bitmapBounds.bottom;

		into->FillRect(destRect);
	}

	into->PopState();
}
Beispiel #3
0
void 
BackgroundImage::ScreenChanged(BRect, color_space)
{
	if (!fIsDesktop || !fShowingBitmap)
		return;
	
	if (fShowingBitmap->fMode == kCentered) {
		BRect viewBounds(fView->Bounds());
		BRect bitmapBounds(fShowingBitmap->fBitmap->Bounds());
		BRect destinationBitmapBounds(bitmapBounds);
		destinationBitmapBounds.OffsetBy(
			(viewBounds.Width() - bitmapBounds.Width()) / 2,
			(viewBounds.Height() - bitmapBounds.Height()) / 2);

		fView->SetViewBitmap(fShowingBitmap->fBitmap, bitmapBounds, destinationBitmapBounds,
			B_FOLLOW_NONE, 0);
		fView->Invalidate();
	}
}
Beispiel #4
0
status_t
MediaView::SetVideoTrack(
	BDataIO       *data,
	BMediaTrack		*track,
	media_format	*format)
{
	if (fVideoTrack != NULL)
		// is it possible to have multiple video tracks?
		return (B_ERROR);

	fVideoTrack = track;

	BRect bitmapBounds(0.0, 
					   0.0, 
					   format->u.encoded_video.output.display.line_width - 1.0,
					   format->u.encoded_video.output.display.line_count - 1.0);

	fBitmap = new BBitmap(bitmapBounds,B_BITMAP_WILL_OVERLAY|B_BITMAP_RESERVE_OVERLAY_CHANNEL,B_YCbCr422);
	fUsingOverlay = true;
	if (fBitmap->InitCheck() != B_OK) {
		delete fBitmap;
		fBitmap = new BBitmap(bitmapBounds, fBitmapDepth);
		fUsingOverlay = false;
	};

	/* loop, asking the track for a format we can deal with */
	for(;;) {
		media_format mf, old_mf;

		BuildMediaFormat(fBitmap, &mf);

		old_mf = mf;
		fVideoTrack->DecodedFormat(&mf);
		if (old_mf.u.raw_video.display.format == mf.u.raw_video.display.format) {
			break;
		}

		printf("wanted cspace 0x%x, but it was reset to 0x%x\n",
			   fBitmapDepth, mf.u.raw_video.display.format);
		
		fBitmapDepth = mf.u.raw_video.display.format;
		delete fBitmap;
		fUsingOverlay = false;
		fBitmap = new BBitmap(bitmapBounds, fBitmapDepth);
	}

	media_header mh;
	bigtime_t time = fCurTime;	
	fVideoTrack->SeekToTime(&time);

	int64 dummyNumFrames = 0;
	fVideoTrack->ReadFrames((char *)fBitmap->Bits(), &dummyNumFrames, &mh);

	time = fCurTime;
	fVideoTrack->SeekToTime(&time);	

	if (fUsingOverlay) {
		overlay_restrictions r;
		fBitmap->GetOverlayRestrictions(&r);
	
		printf("Overlay limits:\n");
		printf("  Src horiz alignment  : %08x\n",r.source.horizontal_alignment);
		printf("  Src vert alignment   : %08x\n",r.source.vertical_alignment);
		printf("  Src width alignment  : %08x\n",r.source.width_alignment);
		printf("  Src height alignment : %08x\n",r.source.height_alignment);
		printf("  Src min/max          : (%d,%d)/(%d,%d)\n",r.source.min_width,r.source.min_height,
															r.source.max_width,r.source.max_height);
		printf("  Dst horiz alignment  : %08x\n",r.destination.horizontal_alignment);
		printf("  Dst vert alignment   : %08x\n",r.destination.vertical_alignment);
		printf("  Dst width alignment  : %08x\n",r.destination.width_alignment);
		printf("  Dst height alignment : %08x\n",r.destination.height_alignment);
		printf("  Dst min/max          : (%d,%d)/(%d,%d)\n",r.destination.min_width,r.destination.min_height,
															r.destination.max_width,r.destination.max_height);
		printf("  Min/max scaling      : (%f,%f)/(%f,%f)\n",r.min_width_scale,r.min_height_scale,
															r.max_width_scale,r.max_height_scale);
		rgb_color key;
		SetViewOverlay(fBitmap,bitmapBounds,VideoBounds(),&key,B_FOLLOW_ALL,
			B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL);
		SetViewColor(key);
	};

	return (B_NO_ERROR);
}