[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC] New menu design based on MVC

From: Bean
Subject: [RFC] New menu design based on MVC
Date: Thu, 25 Jun 2009 12:07:18 +0800


The current menu system is a little chaotic, the various components
are mixed together which make it difficult to maintain and extend.
Therefore, I propose a new design which seperates model, view and

Model. It's the menu items. Currently, menu are added using menuitem
statement, which is unique to sh script engine. I think it'd be
advantageous to have a scipt independent way to define menu. Also,
using configfile to define submenu is not good, as it is
difficult to implement interaction between parent and child menu, for
example, auto expand the child menu when parent is selected, or
implement a hotkey that will jump back to the top menu regardless of
the current menu level. IMO, the menu should be loaded as a whole.

The menu is tree structure, a natural way to represent it is to use
xml, for example, we may write it like this:

  <menu title="OS">
    <menu title="Windows 98" class="win98" fallback="Linux">
      root (hd0,1)
      chainloader +1
    <menu title="Linux" class="linux" lock>
      root (hd0,2)
      linux /vmlinuz
      initrd /initrd.img
  <menu title="Tools">

We can add a command load_menu to load it.

View. It's the menu viewer. Currently, the menu viewer resides in
normal.mod, but it should be placed in a standalone module. Also,
besides the current c version, we could add a new one written in lua.
LUA script is quite flexible, we can extend the function of menu
viewer without recompiling from source code.

Another improvement of menu viewer is to define the layout
dynamically, instead of hardcoding them in the source. And again, we
could utilize the xml to define the layout, perhaps something like

  <image x="0" y="0" src="background.png" />
  <menu x="100" y="100" width="200" height="200" />
  <progressbar x="0" y="400" style="circular" />

Controller. Currenlt, the controller is mixed with viewer, the
show_menu function of menu viewer takes over once it's invoked. I
think it's better to move this part out of viewer. In fact, we can
implement this using event model. The controller waits for events,
such as keyboard, timer, etc, and then dispatch them to the viewer.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]