Beispiel #1
0
/** Please be sure to call this should you ever
 * override the default Draw() method.
 */
void Window::DrawViews( Rect frame )
{
    /// \todo Only update the requested frame.
    lock();
    for ( int i = 0; i < CountChildren(); i++ )
    {
        View *view = ChildAt(i);
        view->Draw( view->Bounds() );
        view->DrawChildren( view->Bounds() );
    }
    unlock();
}
int Control::CurAlpha(DisplayDirector* director)
{
	// find out where the mouse is and make sure it's in the window
	View* windowView = director->WindowView();
	BPoint mousePoint = windowView->GetMousePoint();
	if (!windowView->Bounds().BRect::Contains(mousePoint))
		return 0;

	// calculate the alpha
	BRect rect = GetRect();
	int xDistance = 0;
	if (mousePoint.x < rect.left)
		xDistance = (int) (rect.left - mousePoint.x);
	else if (mousePoint.x > rect.right)
		xDistance = (int) (mousePoint.x - rect.right);
	int yDistance = 0;
	if (mousePoint.y < rect.top)
		yDistance = (int) (rect.top - mousePoint.y);
	else if (mousePoint.y > rect.bottom)
		yDistance = (int) (mousePoint.y - rect.bottom);
	float distance = sqrt(xDistance * xDistance + yDistance * yDistance);
	if (distance > visibleZone)
		distance = visibleZone;
	float visibility = (visibleZone - distance) / visibleZone;
	return (int) (visibility * 255);
}