Difference between revisions of "GUI Themes/TODO"

From ScummVM :: Wiki
Jump to navigation Jump to search
(fixes link to mockups.)
m (New GUI moved to GUI TODO: renaming for move-in of TODO from GUI Themes)

Revision as of 15:13, 25 April 2006

We plan to implement a new GUI look & feel in ScummVM, roughly based on the new look of our web site.

Current state

No real coding (besides some quick and dirty proof-of-concept hacks) has been done yet. Some concept drafts of the new look can be found here: http://www.thekrest.de/wip/scummvm/


Ideas & plans

The new GUI will rely on bitmaps / pixmaps for drawing the GUI widgets, like buttons, edit fields, tabs etc. This poses various problems and challenges but also some nice benefits (besides the obvious one, the improved look and feel :-).

Some random thoughts, ideas and statements:

  • Using pixmaps has the drawback of taking more memory, and possibly more CPU power. So as a fallback, it would be good if we could still work w/o the pixmaps (possibly reverting to the current UI).
  • To make that easy, use a kind of "ThemeManager" or "AppearanceManager", which is used by widgets to render themselves
  • This means we should try to seperate widget logic (what happens if a click occurs, managing data contained in the widget etc.) from widget drawing as much as possible. Ideally, widgets only know how to react to events etc. and whenever they need to draw something, they invoke suitable methods of the AppearanceManager
  • We'd provide two basic apperances: The current one, re-tooled to use a special AppearanceManager "plugin"/"module", and a new one, which uses pixmaps to render all widgets. Care should be taken to make it possible to add new ones or disable the pixmap based ones (for ports that are low on memory)
  • Anti-aliased fonts: Some of the concept drafts use anti-aliased fonts; while that looks nice and nifty, it also adds a lot to the complexity of text rendering. For now we'll try to work without it.
  • Image data can both be stored in external files as well as be compiled into the executable, or generated on-the-fly. To this end, we have a ImageManager class which helps separate the code using image data from the code used to loading the image data.
  • We should support all our primary resolutions: 320x200, 320x240, 640x400, 640x480. Ideally, we should support all resolutions (not just the ones I mentioned). Also, ideally every theme should support all, but if that is not possible, at least we should smoothly degrade to another theme (e.g. the 'classic' theme which doesn't use pixmaps to render itself), instead of e.g. crashing
  • ...

Customizability

We have been asked several times in the past to offer skinning support in ScummVM. With the new GUI code, this would be possible...

However, I (Fingolfin) think that this is a bad idea, and currently am opposed to this. IMHO, skinning is an excuse for not being able / willing to design a proper, nice, and usable default UI for your application (and in fact, the first famous skinable app, a certain MP3 player you may know, added skins precisely because of this).

Actually, "opposed" may not be the right word: I think that skinning should be very last thing we worry about. If we can add skinning w/o much hassle, w/o wasting resources that could otherwise be used to design and implement a great new default UI, we can consider it. But I am not willing to compromise our code design or the quality of the new GUI just to allow for skinning. I want ScummVM to look good and be easy to use "out of the box", this is the first (and the second and third :-) priority, IMNSHO...


Data formats

We probably will use BMP as the format for our pixmaps, optionally compressed using zlib / gzip. Reason: It's very easy to read BMPs (or at least certain BMPs, we don't have to implement a fully generic BMP loader), and we already use zlib. So this causes the least overhead (compared to using e.g. libpng for PNG support), and the resulting file sizes are not much bigger than those of PNGs.

It will also be possible to integrate pixmaps into the array, in the form of global/static arrays. We'll probably provide a tool that takes a BMP and generates a C++ source file from it. Note that here, zlib compression can be used, too (to reduce the size of the ScummVM binary).

Some pages that contain information about the BMP format:

The BMP "standard" doesn't really cover 16 bit data (the bit depth normally used by ScummVM). Sometimes, 15 and 16 are used to indicate 555 and 565 mode.

Some components of the new GUI code

ImageManager / GraphicsManager (singleton)

  • a singleton (?) which manages a set of graphic objects
  • client code can register graphics by name / ID
 imageMan->registerGraphic("button_leftSide", surface);
  • client code can query for a graphic by a name and/or an ID
 surface = imageMan->getGraphic("button_leftSide");
  • data stored/returned as a Graphics::Surface
  • client code must unregister images when the corresponding surface is deleted, else crashes may occur!
  • The idea of being able to "register" images is that it makes it possible to load image data both from files and from static arrays, as part of the executable
  • If an image is request which has not been registered, the ImageManager will search for image files matching the name, e.g. in the above example it might search for
 button_leftSide.bmp
 button_leftSide.bmp.gz

The precise list of supported file types could be hardcoded (easier to write, maintain, port, takes up less resources, but also is less flexible); or we could make it plugable so that arbitrary formats can be supported. My oppinion: Let's start simple, if we need multiple formats we already have an abstraction layer in place and can safely rewrite the internals of ImageManager later on


ImageLoader / ImageDecoder

Not sure whether we really need this class; it could encapsulate the code used to load & decode BMPs, and would in the future allow loading other formats, too (if desired), like PNG


AppearanceManager

This could be a very simple singleton which only manages a list of "Appearances" or "Themes". The real work would be then done by instances / subclasses of GUI::Theme or so...

 class Theme {
 public:
    virtual int getButtonHeight();
    virtual void drawButton(Rect r, String label);
    virtual void drawDialogBackground(Rect r);
    virtual void drawCheckbox(Rect r, String label, bool checked);
    ...
  };


Widget

We need to modify all Widget subclasses to use the active Theme to draw themselves.



How to render widgets

TODO: Include graphics in each subsection to demonstrate how the corresponding widget would look

Dialog background

TODO


Dialog tabs

TODO


Buttons

We should limit ourselves to buttons of a single height, that makes UI design more consistent, and rendering them simpler. To render a button using pixmaps, one needs at least three pixmaps: one of the left border, one for the right border, and one (which can be replicated and tiled) for the middle part. To draw a button, you first place the left/right borders, then tile the middle image, and finally render the label atop it.

One needs different pixmaps for the basic states a button can be in: Normal, pressed/clicked, disabled.

The slow way is to do all of this every time the button is drawn. The fast (but memory intensive) way is to cache the button in a graphic surface (all of its three states). We only generate the cached version of the button once it is used (e.g. a disabled button doesn't need to cache the normal/clicked version)


Checkboxes

TODO


Slider

TODO


Popup buttons

TODO


Lists

TODO


Scrollbars

TODO -- concept art is missing, too


Input fields

TODO


Radio buttons

TODO -- this widget actually doesn't exist currently