Skip to content

Commit

Permalink
Refactor|libappfw: More robust child widget virtualization for menus
Browse files Browse the repository at this point in the history
Since filtering is no longer a concern for ChildWidgetOrganizer, it
can now use simpler and more robust virtualization logic.

This corrects any issues when scrolling to arbitrary locations in
the item set. However, handling varying item heights still requires
a bit more finesse.
  • Loading branch information
skyjake committed Jun 29, 2016
1 parent 7e21f29 commit 6986ad3
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 310 deletions.
44 changes: 2 additions & 42 deletions doomsday/sdk/libappfw/include/de/framework/childwidgetorganizer.h
Expand Up @@ -76,28 +76,6 @@ class LIBAPPFW_PUBLIC ChildWidgetOrganizer
virtual void updateItemWidget(GuiWidget &widget, ui::Item const &item) = 0;
};

/**
* Filters out data items.
*/
class IFilter
{
public:
virtual ~IFilter() {}

/**
* Determines whether an item should be accepted or ignored by the organizer.
*
* @param organizer Which organizer is asking the question.
* @param data Data context.
* @param item Item to check.
*
* @return @c true to accept item, @c false to ignore it.
*/
virtual bool isItemAccepted(ChildWidgetOrganizer const &organizer,
ui::Data const &data,
ui::Item const &item) const = 0;
};

public:
ChildWidgetOrganizer(GuiWidget &container);

Expand All @@ -112,15 +90,6 @@ class LIBAPPFW_PUBLIC ChildWidgetOrganizer

IWidgetFactory &widgetFactory() const;

/**
* Sets the object that decides whether items are accepted or ignored.
*
* @param filter Filtering object.
*/
void setFilter(IFilter const &filter);

void unsetFilter();

/**
* Sets the data context of the organizer. If there was a previous context,
* all widgets created for it are deleted from the container. The widgets
Expand All @@ -140,17 +109,6 @@ class LIBAPPFW_PUBLIC ChildWidgetOrganizer

ui::Item const *findItemForWidget(GuiWidget const &widget) const;

/**
* Filters all items according to the defined IFilter. Widgets are
* created and removed as needed according to the filter.
*/
void refilter();

/**
* Number of items currently being organized. This is affected by the filtering.
*/
dsize itemCount() const;

//- Child Widget Virtualization ---------------------------------------------------------

/**
Expand All @@ -166,6 +124,8 @@ class LIBAPPFW_PUBLIC ChildWidgetOrganizer
*/
void setVirtualizationEnabled(bool enabled);

void setVirtualTopEdge(Rule const &topEdge);

void setVisibleArea(Rule const &minimum, Rule const &maximum);

bool virtualizationEnabled() const;
Expand Down

0 comments on commit 6986ad3

Please sign in to comment.