/************************************************************************
    Configure scroll bars
************************************************************************/
void ScrolledItemListBase::configureScrollbars(const Size& doc_size)
{
    Scrollbar* v = getVertScrollbar();
    Scrollbar* h = getHorzScrollbar();

    Size render_area_size = getItemRenderArea().getSize();

    // setup the pane size
    float pane_size_w = ceguimax(doc_size.d_width, render_area_size.d_width);
    UVector2 pane_size(cegui_absdim(pane_size_w), cegui_absdim(doc_size.d_height));

    d_pane->setMinSize(pane_size);
    d_pane->setMaxSize(pane_size);
    //d_pane->setWindowSize(pane_size);

    // "fix" scrollbar visibility
    if (d_forceVScroll || doc_size.d_height > render_area_size.d_height)
    {
        v->show();
    }
    else
    {
        v->hide();
    }

    //render_area_size = getItemRenderArea().getSize();

    if (d_forceHScroll || doc_size.d_width > render_area_size.d_width)
    {
        h->show();
    }
    else
    {
        h->hide();
    }

    // get a fresh item render area
    Rect render_area = getItemRenderArea();
    render_area_size = render_area.getSize();

    // update the pane clipper area
    static_cast<ClippedContainer*>(d_pane)->setClipArea(render_area);

    // setup vertical scrollbar
    v->setDocumentSize(doc_size.d_height);
    v->setPageSize(render_area_size.d_height);
    v->setStepSize(ceguimax(1.0f, render_area_size.d_height / 10.0f));
    v->setScrollPosition(v->getScrollPosition());

    // setup horizontal scrollbar
    h->setDocumentSize(doc_size.d_width);
    h->setPageSize(render_area_size.d_width);
    h->setStepSize(ceguimax(1.0f, render_area_size.d_width / 10.0f));
    h->setScrollPosition(h->getScrollPosition());
}
Esempio n. 2
0
/*************************************************************************
	Sets up sizes and positions for attached ItemEntry children.
*************************************************************************/
void PopupMenu::layoutItemWidgets()
{
	// get render area
	Rect render_rect = getItemRenderArea();

	// get starting position
	const float x0 = PixelAligned(render_rect.d_left);
	float y0 = PixelAligned(render_rect.d_top);

	URect rect;
	UVector2 sz(cegui_absdim(PixelAligned(render_rect.getWidth())), cegui_absdim(0)); // set item width

	// iterate through all items attached to this window
	ItemEntryList::iterator item = d_listItems.begin();
	while ( item != d_listItems.end() )
	{
		// get the "optimal" height of the item and use that!
		sz.d_y.d_offset = PixelAligned((*item)->getItemPixelSize().d_height); // rounding errors ?

		// set destination rect
		rect.setPosition(UVector2(cegui_absdim(x0), cegui_absdim(y0)) );
		rect.setSize( sz );
		(*item)->setArea(rect);

		// next position
		y0 += PixelAligned(sz.d_y.d_offset + d_itemSpacing);

		item++; // next item
	}
}
Esempio n. 3
0
/*************************************************************************
	Sets up sizes and positions for attached ItemEntry children.
*************************************************************************/
void PopupMenu::layoutItemWidgets()
{
	// get render area
	Rect render_rect = getItemRenderArea();

	// get starting position
	const float x0 = render_rect.d_left+d_borderWidth;
	float y0 = render_rect.d_top+d_borderWidth;

	Rect rect;
	Size sz(render_rect.getWidth()-d_borderWidth-d_borderWidth,0); // set item width

	// iterate through all items attached to this window
	ItemEntryList::iterator item = d_listItems.begin();
	while ( item != d_listItems.end() )
	{
		// get the "optimal" height of the item and use that!
		sz.d_height = (*item)->getItemPixelSize().d_height; // fix rounding errors
		sz.d_height += d_vertPadding+d_vertPadding;

		// set destination rect
		rect.setPosition( Point(x0, y0) );
		rect.setSize( sz );
		(*item)->setRect(Absolute,rect);
		// next position
		y0 += sz.d_height + d_itemSpacing;

		item++; // next item
	}
}
Esempio n. 4
0
/*************************************************************************
	Sets up sizes and positions for attached ItemEntry children.
*************************************************************************/
void Menubar::layoutItemWidgets()
{
	Rect render_rect = getItemRenderArea();
	float x0 = PixelAligned(render_rect.d_left+d_borderWidth);
	
	Rect rect;

	ItemEntryList::iterator item = d_listItems.begin();
	while ( item != d_listItems.end() )
	{
		Size optimal = (*item)->getItemPixelSize();
		optimal.d_width += 2*d_horzPadding;
		optimal.d_height += 2*d_vertPadding;

		(*item)->setVerticalAlignment(VA_CENTRE);
		rect.setPosition( Point(x0,0) );
		rect.setSize( Size( PixelAligned(optimal.d_width), PixelAligned(optimal.d_height) ) );

		(*item)->setRect(Absolute,rect);
		
		x0 += optimal.d_width + d_itemSpacing;

		item++;
	}

}
Esempio n. 5
0
    Rectf FalagardItemListbox::getUnclippedInnerRect() const
    {
        if (!d_widgetLookAssigned)
            return d_window->getUnclippedOuterRect().get();

        Rectf lr(getItemRenderArea());
        lr.offset(d_window->getUnclippedOuterRect().get().d_min);
        return lr;
    }
bool ScrolledItemListBase::handle_HScroll(const EventArgs& e)
{
    const WindowEventArgs& we = static_cast<const WindowEventArgs&>(e);
    Scrollbar* h = static_cast<Scrollbar*>(we.window);
    Rect render_area = getItemRenderArea();
    float newpos = -h->getScrollPosition()+render_area.d_left;
    d_pane->setXPosition(cegui_absdim(newpos));
    return true;
}
Esempio n. 7
0
    void FalagardMenubar::sizeToContent_impl(void)
    {
        Rect renderArea(getItemRenderArea());
        Rect wndArea(getAbsoluteRect());

        // get size of content
        Size sz(getContentSize());

        // calculate the full size with the frame accounted for and resize the window to this
        sz.d_width  += wndArea.getWidth() - renderArea.getWidth();
        sz.d_height += wndArea.getHeight() - renderArea.getHeight();
        setSize(Absolute,sz);
    }
Esempio n. 8
0
/************************************************************************
    Resize to fit content
************************************************************************/
void ItemListBase::sizeToContent_impl(void)
{
    Rect renderArea(getItemRenderArea());
    Rect wndArea(getArea().asAbsolute(getParentPixelSize()));

    // get size of content
    Size sz(getContentSize());

    // calculate the full size with the frame accounted for and resize the window to this
    sz.d_width  += wndArea.getWidth() - renderArea.getWidth();
    sz.d_height += wndArea.getHeight() - renderArea.getHeight();
    setSize(UVector2(cegui_absdim(sz.d_width), cegui_absdim(sz.d_height)));
}
/************************************************************************
    Get size of items
************************************************************************/
Sizef ItemListbox::getContentSize() const
{
    float h = 0;

    ItemEntryList::const_iterator i = d_listItems.begin();
    ItemEntryList::const_iterator end = d_listItems.end();
    while (i!=end)
    {
        h += (*i)->getItemPixelSize().d_height;
        ++i;
    }

    return Sizef(getItemRenderArea().getWidth(), h);
}
Esempio n. 10
0
    void FalagardPopupMenu::sizeToContent_impl(void)
    {
        Rect renderArea(getItemRenderArea());
        Rect wndArea(getAbsoluteRect());

        // get size of content
        Size sz(getContentSize());

        // calculate the full size with the frame accounted for and resize the window to this
        sz.d_width  += wndArea.getWidth() - renderArea.getWidth();
        sz.d_height += wndArea.getHeight() - renderArea.getHeight();

		sz.d_width /= System::getSingleton().getRenderer()->getSize().d_width;
		sz.d_height /= System::getSingleton().getRenderer()->getSize().d_height;

		setSize(Relative,sz);
    }
//----------------------------------------------------------------------------//
void ScrolledItemListBase::ensureItemIsVisibleHorz(const ItemEntry& item)
{
    const Rect render_area = getItemRenderArea();
    Scrollbar* const h = getHorzScrollbar();
    const float currPos = h->getScrollPosition();

    const float left =
        item.getXPosition().asAbsolute(this->getPixelSize().d_width) - currPos;
    const float right = left + item.getItemPixelSize().d_width;

    // if left is left of the view area, or if item too big, scroll item to left
    if ((left < render_area.d_left) || ((right - left) > render_area.getWidth()))
        h->setScrollPosition(currPos + left);
    // if right is right of the view area, scroll item to right of list
    else if (right >= render_area.d_right)
        h->setScrollPosition(currPos + right - render_area.getWidth());
}
//----------------------------------------------------------------------------//
void ScrolledItemListBase::ensureItemIsVisibleVert(const ItemEntry& item)
{
    const Rect render_area = getItemRenderArea();
    Scrollbar* const v = getVertScrollbar();
    const float currPos = v->getScrollPosition();

    const float top =
        item.getYPosition().asAbsolute(this->getPixelSize().d_height) - currPos;
    const float bottom = top + item.getItemPixelSize().d_height;

    // if top is above the view area, or if item is too big, scroll item to top
    if ((top < render_area.d_top) || ((bottom - top) > render_area.getHeight()))
        v->setScrollPosition(currPos + top);
    // if bottom is below the view area, scroll item to bottom of list
    else if (bottom >= render_area.d_bottom)
        v->setScrollPosition(currPos + bottom - render_area.getHeight());
}
/************************************************************************
    Initialise
************************************************************************/
void ScrolledItemListBase::initialiseComponents()
{
    // Only process the content pane if it hasn't been done in the past
    // NOTE: This ensures that a duplicate content pane is not created. An example where
    // this would be possible would be when changing the Look'N'Feel of the widget
    // (for instance an ItemListBox), an operation which would reconstruct the child components
    // of the widget by destroying the previous ones and creating new ones with the
    // new Look'N'Feel. However, since the content pane is not defined in the
    // look and feel file and thus not associated with the look'N'Feel itself
    // but instead created here manually, the destruction would not contemplate the content
    // pane itself, so when the children would be rebuilt, a duplicate content pane
    // would be attempted (and an exception would be issued).
    if(!d_pane)
    {
        // IMPORTANT:
        // we must do this before the base class handling or we'll lose the onChildRemoved subscriber!!!
        d_pane = WindowManager::getSingletonPtr()->createWindow("ClippedContainer", d_name+ContentPaneNameSuffix);

        // set up clipping
        static_cast<ClippedContainer*>(d_pane)->setClipperWindow(this);
        addChildWindow(d_pane);
    }

    // base class handling
    ItemListBase::initialiseComponents();

    // set default pane position
    Rect r = getItemRenderArea();
    d_pane->setPosition(UVector2(cegui_absdim(r.d_left),cegui_absdim(r.d_top)));

    // init scrollbars
    Scrollbar* v = getVertScrollbar();
    Scrollbar* h = getHorzScrollbar();

    v->setAlwaysOnTop(true);
    h->setAlwaysOnTop(true);

    v->subscribeEvent(Scrollbar::EventScrollPositionChanged,
        Event::Subscriber(&ScrolledItemListBase::handle_VScroll,this));
    h->subscribeEvent(Scrollbar::EventScrollPositionChanged,
        Event::Subscriber(&ScrolledItemListBase::handle_HScroll,this));

    v->hide();
    h->hide();
}
Esempio n. 14
0
/*************************************************************************
	Sets up sizes and positions for attached ItemEntry children.
*************************************************************************/
void Menubar::layoutItemWidgets()
{
	Rect render_rect = getItemRenderArea();
	float x0 = PixelAligned(render_rect.d_left);

	URect rect;

	ItemEntryList::iterator item = d_listItems.begin();
	while ( item != d_listItems.end() )
	{
		const Size optimal = (*item)->getItemPixelSize();

		(*item)->setVerticalAlignment(VA_CENTRE);
		rect.setPosition(UVector2(cegui_absdim(x0), cegui_absdim(0)) );
		rect.setSize( UVector2( cegui_absdim(PixelAligned(optimal.d_width)),
                                cegui_absdim(PixelAligned(optimal.d_height))));

		(*item)->setArea(rect);

		x0 += optimal.d_width + d_itemSpacing;
		++item;
	}

}