mainParaGUI - Support: sr #102337, auto-resize for widgets

 
 

sr #102337: auto-resize for widgets

Submitter:  Matt Perry <mpComplete>
Submitted:  Fri 08 Aug 2003 12:09:43 AM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  2 - Minor Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 08 Aug 2003 12:09:43 AM UTC, original submission:  


I'm writing a game in ParaGUI, and I've found it very
useful to be able to resize widgets automatically.  I
have a parent widget that takes up the whole screen,
and child widgets are embedded in it.  When I resize
the screen, I call widget_zoom() on my parent widget,
and it automatically resizes every widget on the
screen.  I've posted it here in case anyone might find
it useful (maybe even to be included in ParaGUI?).
It's not perfect - rounding errors accumulate if you
resize too much, and things look a little off.  But it
serves pretty well in normal use.

void widget_zoom(PG_Widget *widget, double zoomx,
double zoomy)
{
    int px=0, py=0;

    if (widget->GetParent()) {
px = widget->GetParent()->x;
py = widget->GetParent()->y;
    }

    PG_Rect r(
    px + int((widget->x-px) * zoomx + 0.5),
    py + int((widget->y-py) * zoomy + 0.5),
    int(widget->w * zoomx + 0.5),
    int(widget->h * zoomy + 0.5));

    widget->MoveRect(r.x, r.y);
    widget->SizeWidget(r.w, r.h);

    PG_RectList *children = widget->GetChildList();
    if (children) {
PG_RectList::iterator it;
for (it = children->begin(); it != children->end();
it++) {
    widget_zoom(*it, zoomx, zoomy);
}
    }
}

Matt Perry <mpComplete>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

No changes have been made to this item

Back to the top

Powered by Savane 3.13-cf05.
Corresponding source code