Example #1
0
//----------------------------------------------------------------------------//
void FalagardListView::createRenderGeometry(ListView* list_view)
{
    Rectf items_area(getViewRenderArea());
    glm::vec2 item_pos(getItemRenderStartPosition(list_view, items_area));

    for (size_t i = 0; i < list_view->getItems().size(); ++i)
    {
        ListViewItemRenderingState* item = list_view->getItems().at(i);
        RenderedString& rendered_string = item->d_string;
        Sizef size(item->d_size);

        size.d_width = std::max(items_area.getWidth(), size.d_width);

        Rectf item_rect;
        item_rect.left(item_pos.x);
        item_rect.top(item_pos.y);
        item_rect.setSize(size);

        if (!item->d_icon.empty())
        {
            Image& img = ImageManager::getSingleton().get(item->d_icon);

            Rectf icon_rect(item_rect);
            icon_rect.setWidth(size.d_height);
            icon_rect.setHeight(size.d_height);

            Rectf icon_clipper(icon_rect.getIntersection(items_area));

            ImageRenderSettings renderSettings(
                icon_rect, &icon_clipper,
                true, ICON_COLOUR_RECT, 1.0f);

            auto imgGeomBuffers = img.createRenderGeometry(renderSettings);

            list_view->appendGeometryBuffers(imgGeomBuffers);

            item_rect.left(item_rect.left() + icon_rect.getWidth());
        }

        Rectf item_clipper(item_rect.getIntersection(items_area));

        createRenderGeometryAndAddToItemView(list_view, rendered_string, item_rect,
            list_view->getFont(), &item_clipper, item->d_isSelected);

        item_pos.y += size.d_height;
    }
}
//----------------------------------------------------------------------------//
void FalagardTreeView::render()
{
    const WidgetLookFeel& wlf = getLookNFeel();
    TreeView* tree_view = getView();

    tree_view->prepareForRender();

    bool has_focused_state =
        tree_view->isFocused() && wlf.isStateImageryPresent("EnabledFocused");
    const StateImagery* imagery = &wlf.getStateImagery(
        tree_view->isEffectiveDisabled() ? "Disabled" :
            (has_focused_state ? "EnabledFocused" : "Enabled"));
    imagery->render(*tree_view);

    Rectf items_area(getViewRenderArea());
    glm::vec2 item_pos(getItemRenderStartPosition(tree_view, items_area));
    renderTreeItem(tree_view, items_area, item_pos, &tree_view->getRootItemState(), 0);
}