On 12/06/2015 at 13:46, xxxxxxxx wrote:
I had my plugin working fine, and I thought I would test it on a mac.
All the spacing for my layout was changed. Argh...
I tracked the problem down to the fact that the mac had a different 'GUI Font'.
Since the user can have the font set to whatever they want, how am I supposed to insure that my plugin's layout is spaced correctly on any system?
Moreover, changing the font is changing the spacing on a:
that doesn't have any text on it!
On 15/06/2015 at 07:40, xxxxxxxx wrote:
actually the C4D GUI was never designed to be pixel perfect equivalent on every OS. Quite the opposite, it's supposed to adapt to the user changing his layout dynamically and to provide a identical user experience on different operating systems. When designing a plugin's GUI you should keep this in mind.
This does not mean, we want to ignore your problem. Perhaps you can show us some screenshots? To be honest without it's a bit hard to understand, where the actual problem lies and if we may be able to provide a workaround.
On 20/06/2015 at 13:32, xxxxxxxx wrote:
I understand. I'm used to perfectly aligning everything in my programs, so accepting this approach towards a UI has been frustrating. The biggest hurdle is to work around the fact that you let users set the UI font to anything in C4D. That is a pain.
For users that are having issues with this, I worked out a system that lets you adjust your 'GeUserArea' to whatever the user sets their font to.
It works like this:
#----Adjust the size of the 'UserArea' to accomodate different fonts.
current_width = user_area_info_box.DrawGetTextWidth('abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ')
print current_width # 331
baseline_width = 331 # Calculated with the font 'Segoe UI' which was used with initial design.
user_area_info_box.font_width_factor = current_width / float(baseline_width)
user_area_info_box.txt_height = user_area_info_box.DrawGetFontHeight()
# Limit the range of the adjustment with 'min' and 'max' for crazy fonts.
width = min(max(int(round(user_area_info_box.font_width_factor * 435 )) , 350), 700) # 435 was the design-time width.
Then, resize the box like this:
def ScaleInfoBox(width) :
# Calculate a height adjustment, if needed, a similar way using 'user_area_info_box.txt_height'
height = 200
InfoBox.width = width
InfoBox.height = height
user_area_info_box = InfoBox(None) 'InfoBox' is the class name for the 'GeUserArea'.
# This function was used initially to add the 'UserArea' to the dialog.
def LayoutInfoBox(self) : # 'self' is the dialog.
The works well to adjust the width of a 'GeUserArea' to different user fonts.
Hope it helps save someone some time.