Skip to content

Commit

Permalink
Refactor: UIWidgets should not translate to screen space geometry origin
Browse files Browse the repository at this point in the history
Translating a widget to this origin is the job of the owner/parent widget
not of the widget itself. Reworked drawing algorithm moving this logic
into the correct place.

Note that widgets may still be passed a local offset (relative to their
aligned origin).
  • Loading branch information
danij-deng committed Dec 20, 2011
1 parent bd8c7ce commit d539f23
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 66 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/hu_automap.h
Expand Up @@ -146,7 +146,7 @@ void UIAutomap_Rebuild(uiwidget_t* obj);
void UIAutomap_ClearLists(uiwidget_t* obj);
void UIAutomap_Reset(uiwidget_t* obj);

void UIAutomap_Drawer(uiwidget_t* obj, const Point2Raw* origin);
void UIAutomap_Drawer(uiwidget_t* obj, const Point2Raw* offset);

boolean UIAutomap_Open(uiwidget_t* obj, boolean yes, boolean fast);
void UIAutomap_Ticker(uiwidget_t* obj, timespan_t ticLength);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/hu_chat.h
Expand Up @@ -80,7 +80,7 @@ int UIChat_Responder(uiwidget_t* obj, event_t* ev);
int UIChat_CommandResponder(uiwidget_t* obj, menucommand_e cmd);

/// Draw this widget.
void UIChat_Drawer(uiwidget_t* obj, const Point2Raw* origin);
void UIChat_Drawer(uiwidget_t* obj, const Point2Raw* offset);

/// Calculate the "physical" dimensions of this widget in fixed-pixels.
void UIChat_UpdateGeometry(uiwidget_t* obj);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/hu_lib.h
Expand Up @@ -761,7 +761,7 @@ typedef struct uiwidget_s {
float opacity;

void (*updateGeometry) (struct uiwidget_s* obj);
void (*drawer) (struct uiwidget_s* obj, const Point2Raw* origin);
void (*drawer) (struct uiwidget_s* obj, const Point2Raw* offset);
void (*ticker) (struct uiwidget_s* obj, timespan_t ticLength);

void* typedata;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/hu_log.h
Expand Up @@ -84,7 +84,7 @@ typedef struct {
void UILog_Ticker(uiwidget_t* obj, timespan_t ticLength);

/// Draw this message log widget.
void UILog_Drawer(uiwidget_t* obj, const Point2Raw* origin);
void UILog_Drawer(uiwidget_t* obj, const Point2Raw* offset);

/// Calculate the "physical" dimensions of this widget.
void UILog_UpdateGeometry(uiwidget_t* obj);
Expand Down
10 changes: 6 additions & 4 deletions doomsday/plugins/common/src/hu_automap.c
Expand Up @@ -1380,9 +1380,9 @@ void UIAutomap_Rebuild(uiwidget_t* obj)
/**
* Render the automap view window for the specified player.
*/
void UIAutomap_Drawer(uiwidget_t* obj, const Point2Raw* origin)
void UIAutomap_Drawer(uiwidget_t* obj, const Point2Raw* offset)
{
static int updateWait = 0;
static int updateWait = 0; /// \fixme should be an instance var of UIAutomap

guidata_automap_t* am = (guidata_automap_t*)obj->typedata;
const float alpha = uiRendState->pageAlpha;
Expand All @@ -1399,15 +1399,17 @@ void UIAutomap_Drawer(uiwidget_t* obj, const Point2Raw* origin)

// Freeze the lists if the map is fading out from being open, or for debug.
if((++updateWait % 10) && am->constructMap && !freezeMapRLs && UIAutomap_Active(obj))
{ // Its time to rebuild the automap object display lists.
{
// Its time to rebuild the automap object display lists.
compileObjectLists(obj);
}

// Setup for frame.
setupGLStateForMap(obj);

DGL_MatrixMode(DGL_PROJECTION);
DGL_Translatef(UIWidget_Geometry(obj)->origin.x + UIWidget_Geometry(obj)->size.width / 2, UIWidget_Geometry(obj)->origin.y + UIWidget_Geometry(obj)->size.height / 2, 0);
DGL_Translatef(UIWidget_Geometry(obj)->origin.x + UIWidget_Geometry(obj)->size.width / 2,
UIWidget_Geometry(obj)->origin.y + UIWidget_Geometry(obj)->size.height / 2, 0);
DGL_Rotatef(angle, 0, 0, 1);
DGL_Scalef(1, -1, 1);
DGL_Scalef(am->scaleMTOF, am->scaleMTOF, 1);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/hu_chat.c
Expand Up @@ -351,7 +351,7 @@ int UIChat_CommandResponder(uiwidget_t* obj, menucommand_e cmd)
}
}

void UIChat_Drawer(uiwidget_t* obj, const Point2Raw* origin)
void UIChat_Drawer(uiwidget_t* obj, const Point2Raw* offset)
{
//guidata_chat_t* chat = (guidata_chat_t*)obj->typedata;
const float textAlpha = uiRendState->pageAlpha * cfg.hudColor[3];
Expand All @@ -364,7 +364,7 @@ void UIChat_Drawer(uiwidget_t* obj, const Point2Raw* origin)

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
DGL_Translatef(origin->x, origin->y, 0);
if(offset) DGL_Translatef(offset->x, offset->y, 0);
DGL_Scalef(cfg.msgScale, cfg.msgScale, 1);

FR_SetFont(obj->font);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/hu_log.c
Expand Up @@ -289,7 +289,7 @@ void UILog_Ticker(uiwidget_t* obj, timespan_t ticLength)
}
}

void UILog_Drawer(uiwidget_t* obj, const Point2Raw* origin)
void UILog_Drawer(uiwidget_t* obj, const Point2Raw* offset)
{
guidata_log_t* log = (guidata_log_t*)obj->typedata;
const int alignFlags = ALIGN_TOP| ((cfg.msgAlign == 0)? ALIGN_LEFT : (cfg.msgAlign == 2)? ALIGN_RIGHT : 0);
Expand All @@ -311,7 +311,7 @@ void UILog_Drawer(uiwidget_t* obj, const Point2Raw* origin)

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
DGL_Translatef(origin->x, origin->y, 0);
if(offset) DGL_Translatef(offset->x, offset->y, 0);
DGL_Scalef(cfg.msgScale, cfg.msgScale, 1);

firstMsg = firstPVisMsg = UILog_FirstPVisMessageIdx(obj);
Expand Down

0 comments on commit d539f23

Please sign in to comment.