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

Post a Comment

Add a New Comment Rich Markup
   

Discussion

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>

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

 

Votes

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.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

History

No changes have been made to this item

Back to the top

Powered by Savane 3.16-a7ba.
Corresponding source code