NewModelViewArchitecture

From CEGUI Wiki - Crazy Eddie's GUI System (Open Source)
Revision as of 21:29, 14 May 2014 by Timotei (Talk | contribs) (ModelIndex and ViewModel details)

Jump to: navigation, search

Homepage for the WIP Model-View architecture for CEGUI widgets!

Introduction

The new architecture aims to unify the underlying implementation of several widgets so that they will use a common base model provider. This will involve a lot of ABI and API breakage.

Proposed architecture

TODO - decide on another concepts than row/column

ModelIndex

Identifies uniquely items in the model.

Properties:

  • row : size_t
  • column : size_t
  • parent : ModelIndex
  • modelData : void * (protected)

Methods:

  • isValid

Since ModelIndex will be friend with the ViewModel, only the VM will be able to use the model data and thus prevent View(s) to use it by mistake.

ViewModel

The model for the view, that provides data like items count to the view. This is implemented by the developers that want to use this new architecture.

Structure-related methods:

  • rowCount(modelIndex)
  • columnCount(modelIndex)
  • makeIndex(row, column, parentModelIndex)
  • getParentIndex(modelIndex)

Data-provider methods:

  • getItemDisplayString(modelIndex)
  • getItemDisplayImage(modelIndex)

Events:

  • Rows/ColumnsAdded - start, count
  • Rows/ColumnsRemoved - start, count
  • Rows/ColumnsDataChanged - start, count

Affected widgets

Changed (to the new architecture) widgets

  • ComboBox + ComboDropList -> ComboView
  • Tree -> TreeView
  • ListBox -> ListView

New widgets

  • GridView
  • ListBoxWidget (combines model & view together for simple usage cases)

Removed/deprecated widgets

  • MultiColumnList (replaced by GridView)
  • ItemListbox (duplicated by ListBox)

To decide

  • ItemListBase
    • It's used in other places like: MenuBase and ScrolledItemListBase
    • Remove the other usages as well?