**** Contents
commitfd5e3501de32f082248226a0be5fb4c139e4d2a2
authordwk <dwk@b022f027-f587-4676-bc72-f0cf7b603704>
Fri, 25 Jan 2008 22:57:36 +0000 (25 22:57 +0000)
committerdwk <dwk@b022f027-f587-4676-bc72-f0cf7b603704>
Fri, 25 Jan 2008 22:57:36 +0000 (25 22:57 +0000)
treec971730b74274e633f525961601241778378dca6
parente71cda0737a5cd8de521ca43441f2c31043b250c
**** Contents
+ Widgets
    - Everything is a widget
    - Widget positions relative to parent
    - Three types of widget access
+ Images
    - Image rotation
    - SDL_Resize support begun
    - Astronomical background images
+ Loop code
    - Modular focus setting
+ etc.
    - Refactorings
    - Hacks
    - Bugs
    - Miscellaneous
    - Todo

==== WIDGETS ====

**** Everything is a widget
Made every widget be contained inside another widget: in other words, made the top element in the widget tree a widget instead of a panel.

Replaced hard-coded array indexing of xuni->gui->panel[PANEL_XXX] with calls to the new function find_panel(). In theory, except for the view code, the panels could be re-ordered with no adverse effects.

load_resource_widgets() and add_resource_widget() take a widget_t** parameter now, instead of two other ones. init_image() takes another parameter, angle.

**** Widget positions relative to parent
Now, for a widget, positions are relative to the positions of the parent widget. In other words, 50 is halfway across the parent widget, not halfway across the whole screen. (Unless the parent widget takes up the whole screen, like a panel does.)

All of the widgets that make up composite widgets now have much simpler positions, usually even (0, 0). paint_scrollbar() also no longer has to call set_widget_clip().

This only applies to X and Y-positions; widths and heights have yet to be converted.

The function responsible for these new relative positions is paint_widget(), which adds widget->base->pos.real.[xy] to widget->pos.real.[xy].

Reworked find_widget(), introducing widget_name_match() to make things easier.

**** Three types of widget access

Added a widget_t pointer to nameid (formerly name_id), and made said nameid global, hopefully temporarily -- at least in options.c. This widget pointer is initialized to zero, and set automatically by set_widget_nameid() when it finds matches.

There are three types of widget access now: by name, which is required for resource files; by id, for the evil premature optimisation that allows one to use switch statements on widgets; and by pointer, for the painting code etc.

Note: the id member of the nameid structure could be eliminated, and the index in the array used instead. This would put a tie between the wid types and the nameid initialization -- the widgets would have to be in the same order -- but this is likely going to happen anyway.

==== IMAGES ====

**** Image rotation
Added support for rotating images, including support for an <angle> XML tag. This angle can be specified in degrees or radians, according to what type is set to; radians are the default. (Strangely, however, the SDL_gfx rotation functions take degrees.)

Now, the down scrollbar image is rotated to actually point downwards. It still re-loads the same scrollbar image as up, however.

**** SDL_Resize support begun
Added experimental support for using SDL_Resize to resize images -- see image.c.

SDL_Resize seems to be quite a bit slower than SDL_gfx at the moment.

**** Astronomical background images
Downloaded some astronomical images to use as backgrounds, though they have not yet been committed to the repository, pending approval of their use. (As well as better names and locations -- perhaps they should go in a separate folder?)

==== LOOP CODE ====

**** Modular focus setting
Introduced focus_changed(), which sets smode_t::focus.

This function is called in three places: twice in loop.c, and once (new) in init_sdl(). It does not work perfectly yet, but it's certainly much better modularized than before.

==== ETC ====

**** Refactorings
Moved get_boxw() and get_boxh() out of box.c and into button.c.
----
Moved toggle_checkbox() and set_checkbox() out of graphics.c and into checkbox.c, where they really belong.
----
Moved perform_widget_click() out of graphics.c and into gui.c.
----
Reformatted paint_box_image() somewhat.
----
Added a few more calls to last_compose_widget(), along with some more references to wids for widgets, replacing hard-coded indicies.
----
Renamed the BOX and BAR scrollbar WIDs to SEEKBAR and SEEK.
----
Moved the commented-out widget backtrace printing code in loop.c into the new function print_widget_backtrace().
----
Modularized paint_menu() somewhat, introducing set_hover_visible(). This function is still dependent on the order of the widgets of the main menu.

**** Hacks
Added a hack to set_box_type() to allow textboxes to be painted as active when they are selected.
----
Set the visibility of a button's WID_BUTTON_BOX from within paint_button(), to (unsuccessfully) attempt to allow buttons to be disabled (like at the main menu).
----
Tried to make labels display a cursor when selected, for textboxes. It gets displayed, but in the wrong place.
----
angle_to_degrees() and angle_to_radians() really need their own source file -- because of dependencies, a verbatim prototype of these functions has to be used in places.

**** Bugs
Scrollbar images are the wrong size, for some reason. They appear to be the size of the listbox's scrollbar.
----
Fixed the persistent bug where the fullscreen checkbox would not uncheck when ALT-ENTER was pressed -- set_checkbox() was using ->state instead of ->style.
----
Made get_pixel() handle NULL surfaces gracefully.

**** Miscellaneous
Modified TODO slightly.
----
Re-generated the depend files.
----
Re-enabled experimental panel scrolling code.
----
Added a wid_listbox_t for listboxes.
----
Made calc.y recognize pi, for specifying angles in radians.
----
Added Doxygen documentation for render_gfx_text().
----
Changed the loading window title from "Loading" to "Loading . . .", and added a "Quitting . . ." title as well.
----
Added code in memory.c and elsewhere to count the maximum amount of memory ever allocated at one time. It's only a rough estimate, as memory used by SDL_Surfaces can only be estimated, but still quite useful.
----
Added (commented-out) code to paint lines from the four corners and the centre of the four edges of the screen to the position of the cursor.

**** Todo
The widget enum wid_*_ts are misnamed, and need to be renamed; they have little in common with the wid_ts of the menus.
38 files changed:
TODO
gui/data.xml
src/calc.c
src/calc.h
src/calc.y
src/font.c
src/game.c
src/graphics.c
src/graphics.h
src/gui.c
src/gui.h
src/loop.c
src/loop.h
src/memory.c
src/memory.h
src/menu.c
src/options.c
src/version.h
src/widget/box.c
src/widget/box.h
src/widget/button.c
src/widget/button.h
src/widget/checkbox.c
src/widget/checkbox.h
src/widget/depend
src/widget/image.c
src/widget/image.h
src/widget/label.c
src/widget/listbox.c
src/widget/listbox.h
src/widget/panel.c
src/widget/scrollbar.c
src/widget/scrollbar.h
src/widget/textbox.c
src/widget/widgets.c
src/widget/widgets.h
src/xuni.c
xuni.xml