Hi,
While trying to understand the zoom function to apply it to other GUI objects, I studied the bng and tgl objects, and in the process came up with a solution that fixed both.
For the iem_gui objects only the basic generic GUI parameters are available in a struct; x & y position coordinates, height and width. All other GUI dimensions are not accessible outside the drawing functions. The only option to get a correct zoom is to apply the zoom-factor to all appropriate dimension values in all GUI functions.
At least for bng I have this working. With some more refactoring this could be applied without adding too much to the declared mess in the objects code.
Greetings,
Fred Jan
Hi,
It is a good thing I haven't shared any of the code that should fix bang and toggle, as studying and modifying more objects revealed more situations not accounted for.
The current analysis is based on studying and modifying bang, toggle and numbox.
In the current implementation, the x and y coordinates are controlled by the system, the object width(*) and height by the iem_gui framework (controlled by the zoom message). The properties box sets the number of digits (and box width), box height and label font type, size and position. Other GUI dimensions are only present inside GUI functions and influenced by the zoom factor (via the IEMGUI_ZOOM(x) macro). The fact that the zoom status is reflected in the object state variables (x_h, x_w and x_numwidth) and that those is exposed in the properties box makes it difficult to control the behaviour. One illustration is the test scenario "open properties, zoom out, apply" used on bang or toggle.
The effects of these scenario's can be corrected with more code. But as the code is already over-complicated, a probably better solution would be to isolate the zoom factor in the GUI routines. These are the *_draw_* and the *_getrect functions. The iemgui->x_glist->gl_zoom would be the only location where the current zoom factor is present. In this model, the x_h, x_w and x_numwidth variables would not change while zooming. All zoom factoring is done in the GUI functions, when the sys_gui messages are send to the pd-core.
* for numbox the width is mainly controlled by the number of digits and the fontsize with minor corrections based om font type, object height and width settings.
basic test scenario's for zoom behaviour: - create object normal mode and zoom in, - create object zoomed mode and zoom out, - apply properties normal mode (iem_gui only), - apply properties zoomed mode (iem_gui only), - save in normal mode and load, - save in zoomed mode and load, - open properties, zoom in, apply properties (iem_gui only), - open properties, zoom out, apply properties (iem_gui only).
Greetings,
Fred Jan
On 24-11-16 20:32, Fred Jan Kraan wrote:
Hi,
While trying to understand the zoom function to apply it to other GUI objects, I studied the bng and tgl objects, and in the process came up with a solution that fixed both.
For the iem_gui objects only the basic generic GUI parameters are available in a struct; x & y position coordinates, height and width. All other GUI dimensions are not accessible outside the drawing functions. The only option to get a correct zoom is to apply the zoom-factor to all appropriate dimension values in all GUI functions.
At least for bng I have this working. With some more refactoring this could be applied without adding too much to the declared mess in the objects code.
Greetings,
Fred Jan
Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev
Hi,
Attached are the set of changed files and also as diffs to the https://github.com/pure-data/pure-data repository. It might not be pixel-perfect yet, but should be close. Also not tested outside my main platform Xubuntu 16.04. The vumeter object could use some more refactoring, as there is a lot of pixel-tweaking going on. But that can wait until the exercise is found useful.
Greetings,
Fred Jan
On 25-11-16 17:44, Fred Jan Kraan wrote:
Hi,
It is a good thing I haven't shared any of the code that should fix bang and toggle, as studying and modifying more objects revealed more situations not accounted for.
The current analysis is based on studying and modifying bang, toggle and numbox.
In the current implementation, the x and y coordinates are controlled by the system, the object width(*) and height by the iem_gui framework (controlled by the zoom message). The properties box sets the number of digits (and box width), box height and label font type, size and position. Other GUI dimensions are only present inside GUI functions and influenced by the zoom factor (via the IEMGUI_ZOOM(x) macro). The fact that the zoom status is reflected in the object state variables (x_h, x_w and x_numwidth) and that those is exposed in the properties box makes it difficult to control the behaviour. One illustration is the test scenario "open properties, zoom out, apply" used on bang or toggle.
The effects of these scenario's can be corrected with more code. But as the code is already over-complicated, a probably better solution would be to isolate the zoom factor in the GUI routines. These are the *_draw_* and the *_getrect functions. The iemgui->x_glist->gl_zoom would be the only location where the current zoom factor is present. In this model, the x_h, x_w and x_numwidth variables would not change while zooming. All zoom factoring is done in the GUI functions, when the sys_gui messages are send to the pd-core.
- for numbox the width is mainly controlled by the number of digits and
the fontsize with minor corrections based om font type, object height and width settings.
basic test scenario's for zoom behaviour:
- create object normal mode and zoom in,
- create object zoomed mode and zoom out,
- apply properties normal mode (iem_gui only),
- apply properties zoomed mode (iem_gui only),
- save in normal mode and load,
- save in zoomed mode and load,
- open properties, zoom in, apply properties (iem_gui only),
- open properties, zoom out, apply properties (iem_gui only).
Greetings,
Fred Jan
On 24-11-16 20:32, Fred Jan Kraan wrote:
Hi,
While trying to understand the zoom function to apply it to other GUI objects, I studied the bng and tgl objects, and in the process came up with a solution that fixed both.
For the iem_gui objects only the basic generic GUI parameters are available in a struct; x & y position coordinates, height and width. All other GUI dimensions are not accessible outside the drawing functions. The only option to get a correct zoom is to apply the zoom-factor to all appropriate dimension values in all GUI functions.
At least for bng I have this working. With some more refactoring this could be applied without adding too much to the declared mess in the objects code.
Greetings,
Fred Jan
Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev
Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev