Пример #1
0
void
WorkspacesWindow::Zoom(BPoint origin, float width, float height)
{
	BScreen screen;
	float screenWidth = screen.Frame().Width();
	float screenHeight = screen.Frame().Height();
	float aspectRatio = screenWidth / screenHeight;

	uint32 columns, rows;
	BPrivate::get_workspaces_layout(&columns, &rows);

	float workspaceWidth = screenWidth / 10;
	float workspaceHeight = workspaceWidth / aspectRatio;

	width = floor(workspaceWidth * columns);
	height = floor(workspaceHeight * rows);

	float tabHeight = Frame().top - DecoratorFrame().top;

	while (width + 2 * kScreenBorderOffset > screenWidth
		|| height + 2 * kScreenBorderOffset + tabHeight > screenHeight) {
		width = floor(0.95 * width);
		height = floor(0.95 * height);
	}

	ResizeTo(width, height);

	origin = screen.Frame().RightBottom();
	origin.x -= kScreenBorderOffset + width;
	origin.y -= kScreenBorderOffset + height;

	MoveTo(origin);
}
void
NotificationWindow::SetPosition()
{
	Layout(true);

	BRect bounds = DecoratorFrame();
	float width = Bounds().Width() + 1;
	float height = Bounds().Height() + 1;

	float leftOffset = Frame().left - bounds.left;
	float topOffset = Frame().top - bounds.top + 1;
	float rightOffset = bounds.right - Frame().right;
	float bottomOffset = bounds.bottom - Frame().bottom;
		// Size of the borders around the window
	
	float x = Frame().left, y = Frame().top;
		// If we can't guess, don't move...

	BDeskbar deskbar;
	BRect frame = deskbar.Frame();

	switch (deskbar.Location()) {
		case B_DESKBAR_TOP:
			// Put it just under, top right corner
			y = frame.bottom + topOffset;
			x = frame.right - width + rightOffset;
			break;
		case B_DESKBAR_BOTTOM:
			// Put it just above, lower left corner
			y = frame.top - height - bottomOffset;
			x = frame.right - width + rightOffset;
			break;
		case B_DESKBAR_RIGHT_TOP:
			x = frame.left - width - rightOffset;
			y = frame.top - topOffset;
			break;
		case B_DESKBAR_LEFT_TOP:
			x = frame.right + leftOffset;
			y = frame.top - topOffset;
			break;
		case B_DESKBAR_RIGHT_BOTTOM:
			y = frame.bottom - height + bottomOffset;
			x = frame.left - width - rightOffset;
			break;
		case B_DESKBAR_LEFT_BOTTOM:
			y = frame.bottom - height + bottomOffset;
			x = frame.right + leftOffset;
			break;
		default:
			break;
	}

	MoveTo(x, y);
}
Пример #3
0
void
NotificationWindow::SetPosition()
{
	Layout(true);

	BRect bounds = DecoratorFrame();
	float width = Bounds().Width() + 1;
	float height = Bounds().Height() + 1;

	float leftOffset = Frame().left - bounds.left;
	float topOffset = Frame().top - bounds.top + 1;
	float rightOffset = bounds.right - Frame().right;
	float bottomOffset = bounds.bottom - Frame().bottom;
		// Size of the borders around the window

	float x = Frame().left;
	float y = Frame().top;
		// If we cant guess, don't move...
	BPoint location(x, y);

	BDeskbar deskbar;

	// If notification and deskbar position are same
	// then follow deskbar position
	uint32 position = (is_overlapping(deskbar.Location(), fPosition))
			? B_FOLLOW_DESKBAR
			: fPosition;


	if (position == B_FOLLOW_DESKBAR) {
		BRect frame = deskbar.Frame();
		switch (deskbar.Location()) {
			case B_DESKBAR_TOP:
				// In case of overlapping here or for bottom
				// use user's notification position
				y = frame.bottom + topOffset;
				x = (fPosition == (B_FOLLOW_LEFT | B_FOLLOW_TOP))
					? frame.left + rightOffset
					: frame.right - width + rightOffset;
				break;
			case B_DESKBAR_BOTTOM:
				y = frame.top - height - bottomOffset;
				x = (fPosition == (B_FOLLOW_LEFT | B_FOLLOW_BOTTOM))
					? frame.left + rightOffset
					: frame.right - width + rightOffset;
				break;
			case B_DESKBAR_RIGHT_TOP:
				y = frame.top - topOffset + 1;
				x = frame.left - width - rightOffset;
				break;
			case B_DESKBAR_LEFT_TOP:
				y = frame.top - topOffset + 1;
				x = frame.right + leftOffset;
				break;
			case B_DESKBAR_RIGHT_BOTTOM:
				y = frame.bottom - height + bottomOffset;
				x = frame.left - width - rightOffset;
				break;
			case B_DESKBAR_LEFT_BOTTOM:
				y = frame.bottom - height + bottomOffset;
				x = frame.right + leftOffset;
				break;
			default:
				break;
		}
		location = BPoint(x, y);
	} else if (position == (B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM)) {
		location = BScreen().Frame().RightBottom();
		location -= BPoint(width, height);
	} else if (position == (B_FOLLOW_LEFT | B_FOLLOW_BOTTOM)) {
		location = BScreen().Frame().LeftBottom();
		location -= BPoint(0, height);
	} else if (position == (B_FOLLOW_RIGHT | B_FOLLOW_TOP)) {
		location = BScreen().Frame().RightTop();
		location -= BPoint(width, 0);
	} else if (position == (B_FOLLOW_LEFT | B_FOLLOW_TOP)) {
		location = BScreen().Frame().LeftTop();
	}

	MoveTo(location);
}