BMP平台MVC的设计模式

来源:互联网 发布:张馨予淘宝店地址 编辑:程序博客网 时间:2024/06/05 05:59

这是高通BMP平台上的MVC设计模式,这个框架的核心就是以数据来驱动界面,对于做UI的朋友们来说,很有借鉴意义。

Design Patterns

  • BUIW is built using common software engineering design patterns.
  • Model-View-Controller (MVC) pattern is important to understand.
  • Other patterns used in BUIW are decorator and observer patterns.

 

 MVC模式框架图

Containers

  • A container is a collection of widgets, decorators and further sub-containers.
  • Containers keep track of relative order of widgets, their position and layout.
  • A container will handle clipping as required.
  • The top level container is called the root container.
  • Lots of different types of containers – CardContainer, GridContainer, ConstraintContainer, PropContainer, XYContainer.

 

 

Models

  • The data that drives a widget is stored within a model
  • The following models are available
  • IValueModel: A model for data that can be represented in an arbitrarily complex form
  • IListModel: A base class for IArrayModel and IVectorModel
  • IArrayModel: A model for a collection of objects of equal fixed size
  • IVectorModel: A model for a collection of objects that might be of a variable size
  • IFrameModel: Base class for IMediaFrameModel and ICameraFrameModel
  • IMediaFrameModel: Provides image frames from a video
  • ICameraFrameModel: Provides image frames from a camera
  • IInterfaceModel: Provides a model interface for objects that model their data in an interface that does not have a query interface, for example, bitmap and image widgets
  • ITextModel: Model for text strings such as in text entry
  • IMenuModel: Derived from IListModel

 

Widget View

  • Responsible for rendering the model‟s data to the display
  • Listens for model notifications
  • Sends invalidation request to parent container, so only redraws when directed
  • By letting root container redraw multiple requests can be grouped together
  • The size of the content area of the view is known as the extent
  • Be sure to set the extent
  • The full extent of widget doesn‟t have to be redrawn when the widget is invalidated