Пример #1
0
// ToolDraw
void
PickManipulator::ToolDraw(BView* into, BRect itemFrame)
{
	if (itemFrame.IntegerWidth() < 4)
		return;

	itemFrame.InsetBy(1, 1);
	int32 dotCount = itemFrame.IntegerHeight() / 3;

	BPoint p(itemFrame.LeftTop());
	for (int32 i = 0; i < dotCount; i++) {
		into->SetHighColor(0, 0, 0, 75);
		into->StrokeLine(p, p);
		p = p + BPoint(1, 1);
		into->SetHighColor(255, 255, 255, 200);
		into->StrokeLine(p, p);
		p = p + BPoint(-1, 2);
	}

	itemFrame.right--;
	if (itemFrame.IntegerWidth() < 6)
		return;

	p = itemFrame.RightTop();
	for (int32 i = 0; i < dotCount; i++) {
		into->SetHighColor(0, 0, 0, 75);
		into->StrokeLine(p, p);
		p = p + BPoint(1, 1);
		into->SetHighColor(255, 255, 255, 200);
		into->StrokeLine(p, p);
		p = p + BPoint(-1, 2);
	}
}
Пример #2
0
Tearoff::Tearoff(BRect frame, const char *name, MainWindow *parent, MenuName menu_name, int idx)
	: BWindow(frame, name, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0)
{
	int y = 0;
	BFont font;
	BMenu *menu;
	
	this->parent = parent;
	menu = parent->GetMenu(menu_name);
	menu->GetFont(&font);
	for(int i = 1; i < menu->CountItems(); i++) {
		BMenuItem *item = menu->ItemAt(i);
		if(item->Message()) {
			BButton *b = new BButton(BRect(0, y, frame.IntegerWidth(), y + TEAROFF_BUTTON_HEIGHT), "", item->Label(), new BMessage(item->Message()->what), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); 
			font.SetSize(TEAROFF_FONT_SIZE);
			b->SetFont(&font);
			AddChild(b);
			y = y + TEAROFF_BUTTON_HEIGHT;
		}
	}
	this->ResizeTo(frame.IntegerWidth(), y);
	this->SetTitle(menu->Name());
	this->index = idx;
	delete menu;
}
Пример #3
0
/*****************************************************************************
 * VideoWindow::SetFullScreen
 *****************************************************************************/
void
VideoWindow::SetFullScreen(bool doIt)
{
    if (doIt)
    {
        SetLook( B_NO_BORDER_WINDOW_LOOK );
        BScreen screen( this );
        BRect rect = screen.Frame();
        Activate();
        MoveTo(0.0, 0.0);
        ResizeTo(rect.IntegerWidth(), rect.IntegerHeight());
        be_app->ObscureCursor();
        fInterfaceShowing = false;
        fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
    }
    else
    {
        SetLook( B_TITLED_WINDOW_LOOK );
        MoveTo(winSize.left, winSize.top);
        ResizeTo(winSize.IntegerWidth(), winSize.IntegerHeight());
        be_app->ShowCursor();
        fInterfaceShowing = true;
        fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN);
    }
}
Пример #4
0
status_t MesaDriver::CopyPixelsIn(BBitmap *bitmap, BPoint location)
{
	color_space scs = bitmap->ColorSpace();
	color_space dcs = m_bitmap->ColorSpace();

	if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) {
		printf("CopyPixelsIn(): incompatible color space: %s != %s\n",
			color_space_name(scs),
			color_space_name(dcs));
		return B_BAD_TYPE;
	}
	
	// debugger("CopyPixelsIn()");

	BRect sr = bitmap->Bounds();
	BRect dr = m_bitmap->Bounds();

	sr = sr & dr.OffsetBySelf(location);
	dr = sr.OffsetByCopy(-location.x, -location.y); 
	
	uint8 *ps = (uint8 *) bitmap->Bits();
	uint8 *pd = (uint8 *) m_bitmap->Bits();
	uint32 *s, *d;
	uint32 y;
	for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
		s = (uint32 *) (ps + y * bitmap->BytesPerRow());
		s += (uint32) sr.left;
		
		d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * m_bitmap->BytesPerRow());
		d += (uint32) dr.left;
		
		memcpy(d, s, dr.IntegerWidth() * 4);
	}
	return B_OK;
}
Пример #5
0
void MesaDriver::GetBufferSize(GLframebuffer * framebuffer, GLuint *width,
                            GLuint *height)
{
   GET_CURRENT_CONTEXT(ctx);
   if (!ctx)
		return;

   MesaDriver * md = (MesaDriver *) ctx->DriverCtx;
   BGLView *bglview = md->m_bglview;
   assert(bglview);

   BRect b = bglview->Bounds();
   *width = (GLuint) b.IntegerWidth() + 1; // (b.right - b.left + 1);
   *height = (GLuint) b.IntegerHeight() + 1; // (b.bottom - b.top + 1);
   md->m_bottom = (GLint) b.bottom;

   if (ctx->Visual.doubleBufferMode) {
      if (*width != md->m_width || *height != md->m_height) {
         // allocate new size of back buffer bitmap
         if (md->m_bitmap)
            delete md->m_bitmap;
         BRect rect(0.0, 0.0, *width - 1, *height - 1);
         md->m_bitmap = new BBitmap(rect, B_RGBA32);
      }
   }
   else
   {
      md->m_bitmap = NULL;
   }

   md->m_width = *width;
   md->m_height = *height;
}
Пример #6
0
ViewBuffer::ViewBuffer(BRect frame)
	:	BView(frame, "ViewBuffer", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS),
		fColumns(frame.IntegerWidth() / CHAR_WIDTH),
		fRows(frame.IntegerHeight() / CHAR_HEIGHT),
		fGlyphGrid(NULL),
		fResizeCallback(NULL),
		// initially, the cursor is hidden
		fCursorX(-1),
		fCursorY(-1)
{
	SetFont(be_fixed_font);
	
	// initialize private palette
	for (int i = 0; i < 8; i++) {
		fPalette[i].red = (sPalette32[i] >> 16) & 0xff;
		fPalette[i].green = (sPalette32[i] >> 8) & 0xff;
		fPalette[i].blue = (sPalette32[i] >> 0) & 0xff;
		fPalette[i].alpha = 0xff;
	}

	// initialize glyph grid
	uint32 size = fRows * fColumns;
	if (size > 0) {
		fGlyphGrid = new uint16[size];
		memset(fGlyphGrid, 0, size * sizeof(uint16));
	}
}
Пример #7
0
// FrameResized
void
ColorField::FrameResized(float width, float height)
{
	BRect r = _BitmapRect();
	_AllocBitmap(r.IntegerWidth() + 1, r.IntegerHeight() + 1);
	Invalidate();
}
Пример #8
0
void
PeakView::FrameResized(float width, float height)
{
	BRect bitmapFrame = _BackBitmapFrame();
	_ResizeBackBitmap(bitmapFrame.IntegerWidth() + 1, fChannelCount);
	_UpdateBackBitmap();
}
Пример #9
0
status_t
Controller::ReadBitmap(BBitmap* bitmap, bool includeCursor, BRect bounds)
{
	const bool &useDirectWindow = Settings().UseDirectWindow()
		&& fDirectWindowAvailable;
	
	if (!useDirectWindow)
		return BScreen().ReadBitmap(bitmap, includeCursor, &bounds);
		
	int32 bytesPerPixel = fDirectInfo.bits_per_pixel >> 3;
	if (bytesPerPixel <= 0)
		return B_ERROR;

	uint32 rowBytes = fDirectInfo.bytes_per_row / bytesPerPixel;
	const int32 offset = ((uint32)bounds.left +
		 ((uint32)bounds.top * rowBytes)) * bytesPerPixel;

	int32 height = bounds.IntegerHeight() + 1;
	void* from = (void*)((uint8*)fDirectInfo.bits + offset);    		
	void* to = bitmap->Bits();
	int32 bytesPerRow = bitmap->BytesPerRow();
	int32 areaSize = (bounds.IntegerWidth() + 1) * bytesPerPixel;
	for (int32 y = 0; y < height; y++) {  
		memcpy(to, from, areaSize);
	   	to = (void*)((uint8*)to + bytesPerRow);
		from = (void*)((uint8*)from + fDirectInfo.bytes_per_row);
	}
	 
	return B_OK;
}
Пример #10
0
static void testSetOriginAndScale4(BView *view, BRect frame)
{
	frame.InsetBy(2, 2);
	BPoint center = centerPoint(frame);
	
	BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2);
	view->SetOrigin(center);
	view->FillRect(r);
	
	view->SetScale(0.5);
	view->SetHighColor(kRed);
	view->FillRect(r);
	
	view->PushState();
		// 
		view->SetOrigin(center.x+1, center.y);
			// +1 to work around BeOS bug
			// where setting the origin has no
			// effect if it is the same as
			// the previous value althou
			// it is from the "outer" coordinate
			// system
		view->SetHighColor(kGreen);
		view->FillRect(r);
	view->PopState();
}
Пример #11
0
/*!	\brief Returns the frame of the specified workspace within the
		workspaces view.
*/
BRect
WorkspacesView::_WorkspaceAt(int32 i)
{
	int32 columns, rows;
	_GetGrid(columns, rows);

	BRect frame = Bounds();
	ConvertToScreen(&frame);

	int32 width = frame.IntegerWidth() / columns;
	int32 height = frame.IntegerHeight() / rows;

	int32 column = i % columns;
	int32 row = i / columns;

	BRect rect(column * width, row * height, (column + 1) * width,
		(row + 1) * height);

	rect.OffsetBy(frame.LeftTop());

	// make sure there is no gap anywhere
	if (column == columns - 1)
		rect.right = frame.right;
	if (row == rows - 1)
		rect.bottom = frame.bottom;

	return rect;
}
Пример #12
0
Size2 OS_Haiku::get_screen_size(int p_screen) const {
	// TODO: make this work with the p_screen parameter
	BScreen *screen = new BScreen(window);
	BRect frame = screen->Frame();
	delete screen;
	return Size2i(frame.IntegerWidth() + 1, frame.IntegerHeight() + 1);
}
Пример #13
0
PPSize
DisplayDevice_Haiku::getDisplayResolution() const
{
	BScreen screen;
	BRect frame = screen.Frame();
	return PPSize(frame.IntegerWidth(), frame.IntegerHeight());
}
Пример #14
0
bool
Scaler::Matches(BRect rect, bool dither) const
{
	return fRect.IntegerWidth() == rect.IntegerWidth() &&
		fRect.IntegerHeight() == rect.IntegerHeight() &&
		fDither == dither;
}
Пример #15
0
void
ShowImageWindow::_SaveWidthAndHeight()
{
	if (fNavigator.CurrentPage() != 1)
		return;

	if (fImageView->Bitmap() == NULL)
		return;

	BRect bounds = fImageView->Bitmap()->Bounds();
	int32 width = bounds.IntegerWidth() + 1;
	int32 height = bounds.IntegerHeight() + 1;

	BNode node(&fNavigator.CurrentRef());
	if (node.InitCheck() != B_OK)
		return;

	const char* kWidthAttrName = "Media:Width";
	const char* kHeightAttrName = "Media:Height";

	int32 widthAttr;
	ssize_t attrSize = node.ReadAttr(kWidthAttrName, B_INT32_TYPE, 0,
		&widthAttr, sizeof(widthAttr));
	if (attrSize <= 0 || widthAttr != width)
		node.WriteAttr(kWidthAttrName, B_INT32_TYPE, 0, &width, sizeof(width));

	int32 heightAttr;
	attrSize = node.ReadAttr(kHeightAttrName, B_INT32_TYPE, 0,
		&heightAttr, sizeof(heightAttr));
	if (attrSize <= 0 || heightAttr != height)
		node.WriteAttr(kHeightAttrName, B_INT32_TYPE, 0, &height, sizeof(height));
}
Пример #16
0
SoftPipeRenderer::SoftPipeRenderer(BGLView *view, ulong options,
		BGLDispatcher* dispatcher)
	: BGLRenderer(view, options, dispatcher),
	fBitmap(NULL),
	fDirectModeEnabled(false),
	fInfo(NULL),
	fInfoLocker("info locker"),
	fOptions(options),
	fColorSpace(B_NO_COLOR_SPACE)
{
	CALLED();
	time_t beg, end;
	beg = time(NULL);
	hsp_init(options);
	end = time(NULL);
	TRACE("hsp_init time: %f.\n", difftime(end, beg));
	BRect b = GLView()->Bounds();
	fColorSpace = B_RGBA32;
	if (fDirectModeEnabled && fInfo != NULL) {
		fColorSpace = BScreen(GLView()->Window()).ColorSpace();
	}
	int32 width = b.IntegerWidth();// + 1;
	int32 height = b.IntegerHeight();// + 1;
	TRACE("ColorSpace:\t%s\n", color_space_name(fColorSpace));
	fBitmap = new BBitmap(BRect(0.f, 0.f, width /*- 1*/, height /*- 1*/), fColorSpace);
	fWidth = width;
	fHeight = height;
	beg = time(NULL);
	fContext = hsp_create_layer_context(fBitmap, 0);
	TRACE("context:\t%d\n", (int)fContext);
	end = time(NULL);
	TRACE("hsp_create_layer_context time: %f.\n", difftime(end, beg));
	if (!hsp_get_current_context())
		LockGL();
}
Пример #17
0
//*****************************************************
void TimeBarView::Draw(BRect rect)
{
	BRect r = Bounds();
	char s[255];

	SetLowColor(Prefs.time_back_color);
	FillRect(r, B_SOLID_LOW);
	
	if (Pool.size == 0)	return;
	
	SetHighColor(64,64,64);
	StrokeLine(BPoint(r.left, r.top), BPoint(r.right, r.top));

	if (Pool.sample_type == NONE)	return;

	int32 w = r.IntegerWidth();
	int32 x = (int32)r.left;
	float b;

	BFont font;
	GetFont(&font);
	font_height fh;
	font.GetHeight(&fh);
	
	float fw = font.StringWidth(" 00:00.000 ");
//	float t = floor( Pool.l_pointer/Pool.frequency);
	float t = ( Pool.l_pointer/Pool.frequency);
	float t_add = (Pool.r_pointer - Pool.l_pointer)/(Pool.frequency*w);
	float t_marge = t_add * fw;
	float t_small_marge = t_marge/5.0f;
	float t_small_bound = t + t_small_marge;
	float t_bound = t + t_marge;

	while (w>0){
		t += t_add;

		if (t >= t_bound){
			int time = (int)((t-(int)t)*1000);
			int sec = (int)fmod(t,60);
			int min = ((int)t)/60;
			sprintf(s, "%d:%.2d.%.3d", min, sec, time);
			t_bound += t_marge;
			b = r.top + 5;
			SetHighColor(Prefs.time_text_color);
			DrawString(s, BPoint(x - font.StringWidth(s)/2.0f, r.bottom));
			SetHighColor(Prefs.time_marks_color);
			StrokeLine( BPoint( x, r.top+1 ), BPoint( x, b) );
		}else if (t >= t_small_bound){
			t_small_bound += t_small_marge;
			SetHighColor(Prefs.time_small_marks_color);
			b = r.top + 1;
			StrokeLine( BPoint( x, r.top+1 ), BPoint( x, b) );
		}
		x ++;
		w --;
	}

}
Пример #18
0
// FrameResized
void
AlphaSlider::FrameResized(float width, float height)
{
	BRect r = _BitmapRect();
	_AllocBitmap(r.IntegerWidth() + 1, r.IntegerHeight() + 1);
	_UpdateColors();
	Invalidate();
	
}
Пример #19
0
// Get total size
void wxWindowBeOS::DoGetSize(int *x, int *y) const
{
    if (m_view)
    {
        BRect bounds = m_view->bounds();
        *x = bounds.IntegerWidth();
        *y = bounds.IntegerHeight();
    }
}
Пример #20
0
void
RemoteDrawingEngine::DrawBitmap(ServerBitmap* bitmap, const BRect& _bitmapRect,
	const BRect& _viewRect, uint32 options)
{
	if (!fClippingRegion.Intersects(_viewRect))
		return;

	BRect viewRect = _viewRect;
	BRect bitmapRect = _bitmapRect;
	if (bitmapRect.IntegerWidth() == viewRect.IntegerWidth()
		&& bitmapRect.IntegerHeight() == viewRect.IntegerHeight()) {
		// unscaled bitmap we can chop off stuff we don't need
		BRegion target(viewRect);
		target.IntersectWith(&fClippingRegion);
		BRect frame = target.Frame();

		if (frame != viewRect) {
			BPoint offset = frame.LeftTop() - viewRect.LeftTop();
			viewRect = frame;
			bitmapRect = viewRect.OffsetToCopy(bitmapRect.LeftTop() + offset);
		}
	}

	UtilityBitmap* other = NULL;
	BRect bounds = bitmap->Bounds();
	BRect newBounds;
	newBounds.right
		= min_c(bounds.IntegerWidth(), bitmapRect.IntegerWidth());
	newBounds.bottom	
		= min_c(bounds.IntegerHeight(), bitmapRect.IntegerHeight());

	if (newBounds.IntegerWidth() < bounds.IntegerWidth()
		|| newBounds.IntegerHeight() < bounds.IntegerHeight()) {

		other = new(std::nothrow) UtilityBitmap(newBounds, bitmap->ColorSpace(),
			bitmap->Flags());

		if (other != NULL && other->ImportBits(bitmap->Bits(),
				bitmap->BitsLength(), bitmap->BytesPerRow(),
				bitmap->ColorSpace(), bitmapRect.LeftTop(), BPoint(0, 0),
				newBounds.IntegerWidth() + 1,
				newBounds.IntegerHeight() + 1) == B_OK) {
			bitmapRect.OffsetTo(0, 0);
			bitmap = other;
		}
	}

	// TODO: we may want to cache/checksum bitmaps
	RemoteMessage message(NULL, fHWInterface->SendBuffer());
	message.Start(RP_DRAW_BITMAP);
	message.Add(fToken);
	message.Add(bitmapRect);
	message.Add(viewRect);
	message.Add(options);
	message.AddBitmap(*bitmap);

	if (other != NULL)
		delete other;
}
void
EditButtonWindow::SetGlobalInformation(void)
{
	WrkWindow *wi;

	if (gad)
	{
		OldWindow = NULL;

		if (gad != last)
		{
			left->SetValue(gad->x);
			top->SetValue(gad->y);
			width->SetValue(gad->wi);
			height->SetValue(gad->he);

			title->SetText(&gad->Title[0]);
			name->SetText(&gad->Name[0]);
	
			derived->SetValue(gad->derived);

			switch(gad->align)
			{
				case	FOLLOW_NONE:
				case	FOLLOW_ALL:
				{
					EnableRadio(false);
				}
				break;
			
				default:
				{
					EnableRadio(true);
				}
				break;
			}
		}

		last = gad;
	}
		else
	{
		if (wi = DefWin)
		{
			BRect rct = wi->Frame();
		
			left->SetValue((int)rct.left);
			top->SetValue((int)rct.top);
			width->SetValue(rct.IntegerWidth());
			height->SetValue(rct.IntegerHeight());

			title->SetText(&wi->WTitle[0]);
			name->SetText(&wi->Name[0]);
		}	
	}
}
static cairo_rectangle_int16_t
_brect_to_cairo_rect (const BRect& rect)
{
    cairo_rectangle_int16_t retval;
    retval.x = int(rect.left + 0.5);
    retval.y = int(rect.top + 0.5);
    retval.width = rect.IntegerWidth() + 1;
    retval.height = rect.IntegerHeight() + 1;
    return retval;
}
Пример #23
0
void
FieldView::Draw(BRect update)
{
	if (fPauseMode)
	{
		SetHighColor(128,128,128);
		FillRect(Bounds());
		SetHighColor(255,255,255);
		SetDrawingMode(B_OP_ALPHA);

		BFont font;
		font.SetSize(28.0);
		font_height fh;
		font.GetHeight(&fh);
		float width = font.StringWidth(B_TRANSLATE("PAUSED"));
		SetFont(&font);
		float y = (Bounds().Height() / 3) + fh.ascent;
		DrawString(B_TRANSLATE("PAUSED"),BPoint( (Bounds().Width() - width) / 2.0,y));
		SetFont(be_plain_font);
		y += fh.descent + fh.leading + 10.0;
		width = be_plain_font->StringWidth(B_TRANSLATE("Click to resume"));
		DrawString(B_TRANSLATE("Click to resume"),BPoint( (Bounds().Width() - width) / 2.0,y));
	}
	else
	{
		// The corresponding box numbers for the update rectangle
		uint16 leftx,rightx,topy,bottomy;

		BRect r = gGameStyle->TileSize();

		// We have to do this because of a bug in BRect::Width()/Height()
		// A rect of (0,0,23,23) will return a Width/Height of 23, not 24.
		int32 tilewidth = r.IntegerWidth() + 1;
		int32 tileheight = r.IntegerHeight() + 1;
		leftx = uint16(update.left / tilewidth);
		rightx = uint16(update.right / tilewidth);
		topy = uint16(update.top / tileheight);
		bottomy = uint16(update.bottom / tileheight);

		for (uint16 y = topy; y <= bottomy; y++)
			for (uint16 x = leftx; x <= rightx; x++)
			{
				bool down = false;
				if (fTracking && fSelection.x == x && fSelection.y == y)
					down = true;
				DrawBox(x,y, down);
			}

		if (gGameState == GAME_OVER)
		{
			SetHighColor(64,64,64,72);
			FillRect(Bounds());
		}
	}
}
Пример #24
0
BBitmap*
Utility::MakeScreenshot(bool includeMouse, bool activeWindow,
	bool includeBorder) const
{
	if (wholeScreen == NULL)
		return NULL;

	BRect bounds = cursorBitmap->Bounds();
	int cursorWidth = bounds.IntegerWidth() + 1;
	int cursorHeight = bounds.IntegerHeight() + 1;

	if (includeMouse && cursorBitmap != NULL) {
		// Import the cursor bitmap into wholeScreen
		wholeScreen->ImportBits(cursorBitmap->Bits(),
			cursorBitmap->BitsLength(), cursorBitmap->BytesPerRow(),
			cursorBitmap->ColorSpace(), BPoint(0, 0), cursorPosition,
			cursorWidth, cursorHeight);

	} else if (cursorAreaBitmap != NULL) {
		// Import the cursor area bitmap into wholeScreen
		wholeScreen->ImportBits(cursorAreaBitmap->Bits(),
			cursorAreaBitmap->BitsLength(), cursorAreaBitmap->BytesPerRow(),
			cursorAreaBitmap->ColorSpace(), BPoint(0, 0), cursorPosition,
			cursorWidth, cursorHeight);
	}

	BBitmap* screenshot = NULL;

	if (activeWindow && activeWindowFrame.IsValid()) {

		BRect frame(activeWindowFrame);	
		if (includeBorder) {
			frame.InsetBy(-borderSize, -borderSize);
			frame.top -= tabFrame.bottom - tabFrame.top;
		}

		screenshot = new BBitmap(frame.OffsetToCopy(B_ORIGIN), B_RGBA32, true);

		if (screenshot->ImportBits(wholeScreen->Bits(),
			wholeScreen->BitsLength(), wholeScreen->BytesPerRow(),
			wholeScreen->ColorSpace(), frame.LeftTop(),
			BPoint(0, 0), frame.IntegerWidth() + 1,
			frame.IntegerHeight() + 1) != B_OK) {
			delete screenshot;
			return NULL;
		}

		if (includeBorder)
			_MakeTabSpaceTransparent(screenshot, frame);
	} else
		screenshot = new BBitmap(wholeScreen);

	return screenshot;
}
Пример #25
0
void 
KnobSwitch::GetPreferredSize(float *width, float *height) 
{ 
        BRect bounds; 
        if (fUpBmap) { 
                bounds = fUpBmap->Bounds(); 
        } else { 
                bounds = Bounds(); 
        } 
        *width = bounds.IntegerWidth(); 
        *height = bounds.IntegerHeight(); 
} 
Пример #26
0
IntelRenderer::IntelRenderer(BGLView *view, ulong options,
	BGLDispatcher* dispatcher)
	:
	BGLRenderer(view, options, dispatcher),
	fBitmap(NULL),
	fDirectModeEnabled(false),
	fInfo(NULL),
	fInfoLocker("info locker"),
	fOptions(options),
	fColorSpace(B_NO_COLOR_SPACE)
{
	CALLED();

	// Disable double buffer for the moment.
	options &= ~BGL_DOUBLE;

	// Initialize the "Haiku Software GL Pipe"
	time_t beg;
	time_t end;
	beg = time(NULL);
	fContextObj = new GalliumContext(options);
	end = time(NULL);
	TRACE("Haiku Intel GL Pipe initialization time: %f.\n",
		difftime(end, beg));

	// Allocate a bitmap
	BRect b = view->Bounds();
	fColorSpace = BScreen(view->Window()).ColorSpace();
	TRACE("%s: Colorspace:\t%s\n", __func__, color_space_name(fColorSpace));

	fWidth = (GLint)b.IntegerWidth();
	fHeight = (GLint)b.IntegerHeight();
	fNewWidth = fWidth;
	fNewHeight = fHeight;

	_AllocateBitmap();

	// Initialize the first "Haiku Intel GL Pipe" context
	beg = time(NULL);
	fContextID = fContextObj->CreateContext(fBitmap);
	end = time(NULL);

	if (fContextID < 0)
		ERROR("%s: There was an error creating the context!\n", __func__);
	else {
		TRACE("%s: Haiku Intel GL Pipe context creation time: %f.\n",
			__func__, difftime(end, beg));
	}

	if (!fContextObj->GetCurrentContext())
		LockGL();
}
Пример #27
0
static void testSetOriginAndScale(BView *view, BRect frame)
{
	frame.InsetBy(2, 2);
	BPoint center = centerPoint(frame);
	
	BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2);
	view->SetOrigin(center);
	view->FillRect(r);
	
	view->SetScale(0.5);
	view->SetHighColor(kRed);
	view->FillRect(r);
}
Пример #28
0
void 
OutputView::BuildCodecMenu(const media_format_family &family)
{
	Settings settings;
	BRect rect = settings.CaptureArea();//ClipFrame();
	rect.right++;
	rect.bottom++;
		
	GetCodecsForFamily(family, (const int32 &)rect.IntegerWidth(),
		(const int32 &)rect.IntegerHeight(), fCodecMenu->Menu(), fFormat);
		
	// Make the app object the menu's message target
	fCodecMenu->Menu()->SetTargetForItems(this);
}
Пример #29
0
void
ShowImageWindow::_UpdateStatusText(const BMessage* message)
{
	BString frameText;
	if (fImageView->Bitmap() != NULL) {
		BRect bounds = fImageView->Bitmap()->Bounds();
		frameText << bounds.IntegerWidth() + 1
			<< "x" << bounds.IntegerHeight() + 1;
	}
	BString pages;
	if (fNavigator.PageCount() > 1)
		pages << fNavigator.CurrentPage() << "/" << fNavigator.PageCount();
	fStatusView->Update(fNavigator.CurrentRef(), frameText, pages, fImageType,
		fImageView->Zoom());
}
Пример #30
0
/*****************************************************************************
 * VideoWindow constructor and destructor
 *****************************************************************************/
VideoWindow::VideoWindow(int v_width, int v_height, BRect frame,
                         vout_thread_t *p_videoout)
    : BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE),
      i_width(frame.IntegerWidth()),
      i_height(frame.IntegerHeight()),
      winSize(frame),
      i_buffer(0),
      teardownwindow(false),
      fTrueWidth(v_width),
      fTrueHeight(v_height),
      fCachedFeel(B_NORMAL_WINDOW_FEEL),
      fInterfaceShowing(false),
      fInitStatus(B_ERROR),
      fSettings(new VideoSettings(*VideoSettings::DefaultSettings()))
{
    p_vout = p_videoout;

    // create the view to do the display
    view = new VLCView( Bounds(), p_vout );

    // create background view
    BView *mainView =  new BackgroundView( Bounds(), view );
    AddChild(mainView);
    mainView->AddChild(view);

    // allocate bitmap buffers
    for (int32_t i = 0; i < 3; i++)
        bitmap[i] = NULL;
    fInitStatus = _AllocateBuffers(v_width, v_height, &mode);

    // make sure we layout the view correctly
    FrameResized(i_width, i_height);

    if (fInitStatus >= B_OK && mode == OVERLAY)
    {
       overlay_restrictions r;

       bitmap[0]->GetOverlayRestrictions(&r);
       SetSizeLimits((i_width * r.min_width_scale), i_width * r.max_width_scale,
                     (i_height * r.min_height_scale), i_height * r.max_height_scale);
    }

    // vlc settings override settings from disk
    if (config_GetInt(p_vout, "fullscreen"))
        fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);

    _SetToSettings();
}