Home  
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
18 user(s) are online (11 user(s) are browsing Forums)

Members: 0
Guests: 18

more...
Support us!
Recent OS4 Files
OS4Depot.net





MUI text small & window fails to open if MUI_Text_Contents is too big
Home away from home
Joined:
2007/5/19 13:23
Posts: 2815
Hoping a MUI expert here can help with this wierd MUI4 behaviour:

If I try to open a MUI window which contains a MUI_Text object, where MUIA_Text_Contents is a very long string (probably larger than can fit the screen's width), then all the program's existing MUI windows close & reopen themselves, with all their text now extremely small (almost unreadable), and the MUI window I was trying to open will NOT be open (although the program acts like it thinks it is open). I then have to close my program using Commodity Exchange, since I cannot interact with the new window.

Ideally what I'd want to happen is that the string is just truncated to whatever will fit on the screen.

If it helps, the code for the MUI element looks something like this:
Quote:
Child, Label2(label), Child, TextObject, TextFrame, MUIA_Background,MUII_TextBack, MUIA_Text_Contents,line, MUIA_Text_SetVMax,MUI_FALSE, TAG_IGNORE,MUIV_Font_Fixed, TAG_IGNORE,0, End

_________________
Author of the PortablE programming language.
I love using Amiga OS4.1 on my A1-X1000 & Sam440
Don't forget the official support forum for OS4!
   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Quite a regular
Joined:
2010/5/16 11:20
From Grimsby, UK
Posts: 914
I've seen the 'extremely small text' exhibited in MUI before, but its a little random, if your able to consistent reproduce this I would suggest registering and reporting it on muidev.de where it will get the attention it deserves - and not here.

   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Home away from home
Joined:
2007/5/19 13:23
Posts: 2815
@djrikki
I wasn't sure if this was a MUI bug, or known behaviour, or if I was just doing something wrong.

My MUI code is dynamically generated (at runtime), but I'll see if I can recreate a small example program...

_________________
Author of the PortablE programming language.
I love using Amiga OS4.1 on my A1-X1000 & Sam440
Don't forget the official support forum for OS4!
   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Quite a regular
Joined:
2008/1/6 17:56
From Pennsylvania, USA
Posts: 773
@ChrisH
I think that's a really old bug that I encountered on my classic Amiga.

_________________
Amiga X1000 with 2GB memory & OS 4.1FE

   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Just popping in
Joined:
2009/8/30 23:10
From Lincolnshire, England.
Posts: 106
Hi ChrisH,

I can confirm that I have encountered 'extremely small text'on my classic Amiga running MUI ver 3.8 registered.

Usually after a system failure before a re-set. (Very rare).

Unfortunately I usually have to change my Font Prefs in MUI again after the re-boot.

This seems to effect IBrowse mostly.

Regards, Michael

aka rockape

_________________
"A veteran is someone who, at one point in their life wrote a blank check made payable to 'Their Country' for an amount of 'up to and including their life'.
   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Just popping in
Joined:
2007/3/23 8:11
From Rehmerloh, Germany
Posts: 188
As rockape already pointed out this is neither a bug nor feature of MUI4, but this situation has been handled in MUI3.8 and before exactly the same way. If the calculated size of the GUI is too big to fit on the screen then MUI will try to reduce the required space by reducing certain sizes (spacing, font size, etc). Of course this approach has its limitations and if the GUI is still too big after the final try the window(s) will stay closed. But the application is running nevertheless and there is no reason to quit it automatically. Having an application with no opened windows is no illegal state for MUI.

Setting MUIA_Text_SetVMax to FALSE will only affect the calculation of the required height which is of no use in this case. For a too long text line you should set MUIA_Text_SetMin to FALSE to avoid enforcing the minimum required object width to the full text width. This will allow the text object to cut off the text while still allowing the window to be fully resizable horizontally. Additionally MUIA_Text_Shorten can be set to MUIV_Text_Shorten_Cutoff. MUIV_Text_Shorten_Hide will hide the object if the text is too wide, but I doubt this is desired in your case.

_________________
Why stop it now, just when I am hating it?

Thore Böckelmann
   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Just popping in
Joined:
2009/8/30 23:10
From Lincolnshire, England.
Posts: 106
Hi Thor,

Many thanks for that information.


Regards, Michael

aka rockape

_________________
"A veteran is someone who, at one point in their life wrote a blank check made payable to 'Their Country' for an amount of 'up to and including their life'.
   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Home away from home
Joined:
2007/5/19 13:23
Posts: 2815
@tboeckel
Thanks for the advice... But unfortunately "MUIA_Text_SetMin, FALSE" causes another problem that I've previously experienced: Windows can default to a size so small that NO text is visible. That's why I didn't use this solution :(

I have run into this kind of issue before, and I've previously suggested that MUI should choose a default window size half-way between it's minimum & maximum, but I also recall that you didn't agree with that suggestion for reasons I didn't understand :-/ .

If there is really no better solution, then I might have to start manually reading & changing MUI window sizes, which seems totally against the philosophy of MUI (and might effectively prevent MUI windows from save the window size chosen by the user, since it'd be overridden each time the window is created).

"MUIV_Text_Shorten" doesn't seem to exist in my MUI3.8 autodocs, so I assume it's something new to MUI4. I'll have to see if I can find documentation for MUI4... Is it likely to solve the above problem(s)?

_________________
Author of the PortablE programming language.
I love using Amiga OS4.1 on my A1-X1000 & Sam440
Don't forget the official support forum for OS4!
   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Just popping in
Joined:
2007/3/23 8:11
From Rehmerloh, Germany
Posts: 188
@ChrisH

Quote:
I have run into this kind of issue before, and I've previously suggested that MUI should choose a default window size half-way between it's minimum & maximum, but I also recall that you didn't agree with that suggestion for reasons I didn't understand :-/ .


MUI chooses the default window size on basis of the default dimensions of all contained objects. Additionally each object has a minimum and a maximum dimension which define the limits between which the object can be resized as MUI requires it.

Quote:
If there is really no better solution, then I might have to start manually reading & changing MUI window sizes, which seems totally against the philosophy of MUI (and might effectively prevent MUI windows from save the window size chosen by the user, since it'd be overridden each time the window is created).


You couldn't be more wrong. First of all you don't have to tweak the window size, because it would be enough to create a subclass of Text.mui which sets your preferred minimum dimensions. MUI can only provide the basics, but these don't fit your needs then it is up to you to do anything that is missing.

Text.mui has calculated minimum and maximum dimensions for ages now, but no explicit default dimension. That's why setting MUIA_Text_SetMin to FALSE might let a text label default to this minimum width of zero if there is no other object which enforces a larger minimum width.

Quote:
"MUIV_Text_Shorten" doesn't seem to exist in my MUI3.8 autodocs, so I assume it's something new to MUI4. I'll have to see if I can find documentation for MUI4... Is it likely to solve the above problem(s)?


MUIA_Text_Shorten exists since MUI 3.9. You can find the full updated documentation if each and every release archive as well as the nightly build archives on http://muidev.de

I will add the default width calculation to MUI 3.9 and MUI4, but this won't help you for MUI 3.8. For that ancient version you will either have to accept how things have been working for more than 20 years by now or you implement the necessary subclass of Text.mui to do the default/minimum width calculation during MUIM_AskMinMax which fits your personal taste.

   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Home away from home
Joined:
2007/5/19 13:23
Posts: 2815
@tboeckel
I've finally fixed this issue, now that I know how to create MUI custom classes (and have mostly automated the process so I don't need to remember all that BOOPSI boiler-plate code).

What I don't understand is why the following behaviour is not the default for MUIC_Text (or at least be an option), since it's what I'd intuitively expect:

The only thing I needed to do was to sub-class MUIC_Text so that it's MinMax method contained the following lines:
Quote:
doSuperMethodA(cl, obj, msg)
msg.minmaxinfo.defwidth := msg.minmaxinfo.minwidth
msg.minmaxinfo.minwidth := 6

(That's AmigaE code, but the C equivalent should be fairly obvious.)

I did also add a New method to force MUIA_Text_SetMin to TRUE, since that's required by my code. But it's not strictly needed, since that's the default value.

The magic number "6" is what the Text class would otherwise have for minwidth, if MUIA_Text_SetMin was FALSE. Unfortunately I don't know how to calculate/deduce this, so it's hard-coded (if it causes problems then it would need to be increased). Any idea how to improve this?


Edited by ChrisH on 2015/6/16 18:45:11
Edited by ChrisH on 2015/6/16 19:07:20
Edited by ChrisH on 2015/6/16 19:11:13
Edited by ChrisH on 2015/6/16 19:11:54
Edited by ChrisH on 2015/6/16 19:13:32
Edited by ChrisH on 2015/6/16 19:16:58
Edited by ChrisH on 2015/6/16 19:19:22
Edited by ChrisH on 2015/6/16 19:30:13
Edited by ChrisH on 2015/6/16 19:31:27
Edited by ChrisH on 2015/6/16 23:36:04
_________________
Author of the PortablE programming language.
I love using Amiga OS4.1 on my A1-X1000 & Sam440
Don't forget the official support forum for OS4!
   Report Go to top

Re: MUI text small & window fails to open if MUI_Text_Contents is too big
Just popping in
Joined:
2007/3/23 8:11
From Rehmerloh, Germany
Posts: 188
@ChrisH

Quote:
What I don't understand is why the following behaviour is not the default for MUIC_Text (or at least be an option), since it's what I'd intuitively expect:


The reasons are simple:
1. compatibility to older MUI versions
2. MUI just offers the basic functionality. If this is not enough for a specific case then it is your task to enhance the behaviour to match your requirements. MUI cannot guess everything. Completely vanishing text might be desired. If Text.mui would enforce an aribtrary amount of text to remain visible it would be impossible to revert this calculation in a subclass.

Quote:
The only thing I needed to do was to sub-class MUIC_Text so that it's MinMax method contained the following lines:
Quote:
doSuperMethodA(cl, obj, msg)
msg.minmaxinfo.defwidth := msg.minmaxinfo.minwidth
msg.minmaxinfo.minwidth := 6


(That's AmigaE code, but the C equivalent should be fairly obvious.)

I did also add a New method to force MUIA_Text_SetMin to TRUE, since that's required by my code. But it's not strictly needed, since that's the default value.

The magic number "6" is what the Text class would otherwise have for minwidth, if MUIA_Text_SetMin was FALSE. Unfortunately I don't know how to calculate/deduce this, so it's hard-coded (if it causes problems then it would need to be increased).


You definitely failed to read and understand the file MUIdev.guide. Please reread it from top to bottom, especially the section about the MUIM_AskMinMax method. It clearly states that the custom dimension values of your class are to be added, not just set. Adding is necessary, because at the time the MUIM_AskMinMax method reaches your class at least Area.mui (the superclass of Text.mui) and Text.mui already have added up their size requirements. Area.mui fills in any size requirements due a frame (frame size + spacing) and Text.mui fills in the size requirements due to the text size, depending on the values of MUIA_Text_SetMin/Max. Then it is your task to enlarge the sizes according to your class' personal requirements.

The value 6 you are seeing is the summed up size requirement of your class' superclasses, namely Text.mui and Area.mui. Most probably you have set a visible frame. I'd guess it is a frame that is configured to have a frame size of 1 pixel plus a horizontal spacing of 2 pixels on both sides (or vice versa). Due to MUIA_Text_SetMin being FALSE Text.mui will add 0 to the minimum width in its MUIM_AskMinMax method. All this sums up to the value of 6. It is a bad idea to override this value by any other fixed artificial value, because this effectively makes the user's frame configuration void. In the worst case this might cause unwanted graphical corruption, because Text.mui's MUIM_Draw method might draw outside the desired area or at least it might ignore some certain frame spacing settings, because it doesn't know about your aritifically restricted minimum width.

If you want a text object which is able to shorten its contents but which does not allow the text to become completely invisible, then all you need to do is to set MUIA_Text_SetMin to FALSE and add an arbitrary small value to MinMaxInfo->MinWidth to ensure that the object cannot become smaller than that size while a possible frame is still correctly respected with its size and spacing. For example something like this:
Quote:
DoSuperMethodA(cl, obj, msg);
msg->MinMaxInfo->MinWidth += 6;


This will leave at least 6 pixels for the text to be displayed and will correctly respect any frame being set for the object. But I must add that such a fixed minimum size is still a bad idea, because depending on the user's font settings these artifical 6 pixels might still not be enough to display even a single character.

MUI4 offers the MUIM_TextDim method to calculate the dimension of arbitrary strings depending on the object's font settings. The returned 32bit value contains the width in the lower 16 bits and the height in the upper 16 bits. The next nightly build of MUI4 will also contain the two DIM2WDTH/HEIGHT macros to extract the values in a convenient fashion. So better use MUIM_TextDim to calculate the width of a commonly fairly wide character (i.e. "W" or "M") and add the calculated width as the additional minimum width requirement within your MUIM_AskMinMax method:
Quote:
ULONG dim;
DoSuperMethodA(cl, obj, msg);
// calculate the dimension of the character "W" using the object's current font settings
dim = DoMethod(obj, MUIM_TextDim, "W", -1, NULL, 0);
msg->MinMaxInfo->MinWidth += DIM2WIDTH(dim);

This will ensure that at least the widest character will remain visible while more narrow characters might fit.

   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2014 The XOOPS Project