void SingleSplitView::Layout()
    {
        if(GetChildViewCount() != 2)
        {
            return;
        }

        View* leading = GetChildViewAt(0);
        View* trailing = GetChildViewAt(1);

        if(!leading->IsVisible() && !trailing->IsVisible())
        {
            return;
        }

        if(width()==0 || height()==0)
        {
            // We are most likely minimized - do not touch divider offset.
            return;
        }
        else if(!trailing->IsVisible())
        {
            leading->SetBounds(0, 0, width(), height());
        }
        else if(!leading->IsVisible())
        {
            trailing->SetBounds(0, 0, width(), height());
        }
        else
        {
            if(divider_offset_ < 0)
            {
                divider_offset_ = (GetPrimaryAxisSize() - kDividerSize) / 2;
            }
            else
            {
                divider_offset_ = std::min(divider_offset_,
                    GetPrimaryAxisSize()-kDividerSize);
            }

            if(is_horizontal_)
            {
                leading->SetBounds(0, 0, divider_offset_, height());
                trailing->SetBounds(divider_offset_+kDividerSize, 0,
                    width()-divider_offset_-kDividerSize, height());
            }
            else
            {
                leading->SetBounds(0, 0, width(), divider_offset_);
                trailing->SetBounds(0, divider_offset_+kDividerSize,
                    width(), height()-divider_offset_-kDividerSize);
            }
        }

        SchedulePaint();

        // Invoke super's implementation so that the children are layed out.
        View::Layout();
    }
Example #2
0
 gfx::Size BoxLayout::GetPreferredSize(View* host)
 {
     gfx::Rect bounds;
     int position = 0;
     for(int i=0; i<host->GetChildViewCount(); ++i)
     {
         View* child = host->GetChildViewAt(i);
         if(child->IsVisible())
         {
             gfx::Size size(child->GetPreferredSize());
             if(orientation_ == kHorizontal)
             {
                 gfx::Rect child_bounds(position, 0, size.width(), size.height());
                 bounds = bounds.Union(child_bounds);
                 position += size.width();
             }
             else
             {
                 gfx::Rect child_bounds(0, position, size.width(), size.height());
                 bounds = bounds.Union(child_bounds);
                 position += size.height();
             }
             position += between_child_spacing_;
         }
     }
     gfx::Insets insets(host->GetInsets());
     return gfx::Size(
         bounds.width()+insets.width()+2*inside_border_horizontal_spacing_,
         bounds.height()+insets.height()+2*inside_border_vertical_spacing_);
 }
Example #3
0
 void BoxLayout::Layout(View* host)
 {
     gfx::Rect childArea(gfx::Rect(host->size()));
     childArea.Inset(host->GetInsets());
     childArea.Inset(inside_border_horizontal_spacing_,
         inside_border_vertical_spacing_);
     int x = childArea.x();
     int y = childArea.y();
     for(int i=0; i<host->GetChildViewCount(); ++i)
     {
         View* child = host->GetChildViewAt(i);
         if(child->IsVisible())
         {
             gfx::Rect bounds(x, y, childArea.width(), childArea.height());
             gfx::Size size(child->GetPreferredSize());
             if(orientation_ == kHorizontal)
             {
                 bounds.set_width(size.width());
                 x += size.width() + between_child_spacing_;
             }
             else
             {
                 bounds.set_height(size.height());
                 y += size.height() + between_child_spacing_;
             }
             // Clamp child view bounds to |childArea|.
             child->SetBounds(bounds.Intersect(childArea));
         }
     }
 }
Example #4
0
void ViewOwner::RenderViews()
{
	for (auto i = _views.rbegin(); i != _views.rend(); ++i)
	{
		View* view = *i;
		if (view->IsVisible())
			view->Render();
	}
}
 // LayoutManager overrides:
 virtual void Layout(View* host)
 {
     gfx::Rect bounds(host->GetContentsBounds());
     for(int i=0; i<host->child_count(); ++i)
     {
         View* child = host->child_at(i);
         // We only layout visible children, since it may be expensive.
         if(child->IsVisible() && child->bounds()!=bounds)
         {
             child->SetBoundsRect(bounds);
         }
     }
 }
Example #6
0
void
View::ResizeBy(int32 x, int32 y, BRegion* dirtyRegion)
{
    if (x == 0 && y == 0)
        return;

    fFrame.right += x;
    fFrame.bottom += y;

    if (fVisible && dirtyRegion) {
        IntRect oldBounds(Bounds());
        oldBounds.right -= x;
        oldBounds.bottom -= y;

        BRegion* dirty = fWindow->GetRegion();
        if (!dirty)
            return;

        dirty->Set((clipping_rect)Bounds());
        dirty->Include((clipping_rect)oldBounds);

        if (!(fFlags & B_FULL_UPDATE_ON_RESIZE)) {
            // the dirty region is just the difference of
            // old and new bounds
            dirty->Exclude((clipping_rect)(oldBounds & Bounds()));
        }

        InvalidateScreenClipping();

        if (dirty->CountRects() > 0) {
            if ((fFlags & B_DRAW_ON_CHILDREN) == 0) {
                // exclude children, they are expected to
                // include their own dirty regions in ParentResized()
                for (View* child = FirstChild(); child;
                        child = child->NextSibling()) {
                    if (!child->IsVisible())
                        continue;
                    IntRect previousChildVisible(
                        child->Frame() & oldBounds & Bounds());
                    if (dirty->Frame().Intersects(previousChildVisible)) {
                        dirty->Exclude((clipping_rect)previousChildVisible);
                    }
                }
            }

            ConvertToScreen(dirty);
            dirtyRegion->Include(dirty);
        }
        fWindow->RecycleRegion(dirty);
    }

    // layout the children
    for (View* child = FirstChild(); child; child = child->NextSibling())
        child->ParentResized(x, y, dirtyRegion);

    // view bitmap

    resize_frame(fBitmapDestination, fBitmapResizingMode, x, y);

    // at this point, children are at their new locations,
    // so we can rebuild the clipping
    // TODO: when the implementation of Hide() and Show() is
    // complete, see if this should be avoided
    RebuildClipping(false);
}