Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: Kronos on August 24, 2003, 11:14:47 AM

Title: MUI for dummies
Post by: Kronos on August 24, 2003, 11:14:47 AM
I just started learning how to code for MUI, but ran into some probs about gadget-layout.

While I managed to fiddle most of it to look allmost like I wanted, it is the string-gadgets
that still give me a severe headache.

There 2 of them in a HGroup together with an selfmade BOOPSI-gagdets
(and no that ain't the prob here) which will be used to display the current cursor-pos
(this can be float-numbers so an integer-gadget wouldn't do).

The problem is that I can't get them to stay the right size. They are either spread all
over the window, or cramped into o9ne edge, when all I want them to do is to stay
on the right and just as big to display 6 chars (as long as possible).

MUIA_String_Maxlen seems to have no effect, and just forcing one width doesn't
seem right as you never know wether the user may prefer to use a font 50 pixels wide  ;-)

Any suggestions ?

Oh and expect this thread to go on as I only got the GUI showing up, but have yet to
find out how to connect that to the rest of the program  :-o  :-D
Title: Re: MUI for dummies
Post by: on August 24, 2003, 11:24:10 AM
Grid it out on paper! :)

Work out where you need your "spacing" to go, and add "HSpace(0)" and "VSpace(0)" to the GUI init code.. this will basically fill in parts of the grid, the same way HTML table "colspan" etc. does.

Aaaanyway. Want to show us the code? It'd be easier to see any mistakes that way. You might be doing something obviously wrong.
Title: Re: MUI for dummies
Post by: Kronos on August 24, 2003, 11:34:43 AM
The code ? You want to see the code ? Believe me you can't handle the code ...... ;-)

The spaces aren't the prob here, but how to get the gadget to be just wide enough
to hold 6 chars of the given font. I would't mind a few extra pixels to cater for non-
proportinal fonts or so.


Filling in some HSpaces doesn't really help, as the gadgets still rezize like wild when
the window is resized.
Title: Re: MUI for dummies
Post by: blubbe on August 24, 2003, 11:44:23 AM
It could possibly be solved by fiddling wtih
MUIA_Weight, weight

I havent been able to get stringgadgets to have
fixed size myself.

But as has been said, it would help to see the code.

Edit..

Try a combination of "MUIA_Weight, weight" for the
string(s) and Put RectangleObjects before/and/or/after the stringobject.

For example, to align a gadget to the right
HGroup,
Child, RectangleObject, MUIA_Weight, 75, End,
Child, StringObject,...,MUIA_Weight, 25, End,
End,


Title: Re: MUI for dummies
Post by: Kronos on August 24, 2003, 11:58:04 AM
"weight" doesn't help either as it will only result in the string-gadgets exploding on a big window,
or being cramped on smaller one.

Seems that I will have to force one size with MUIA_Width and MUIA_MaxWidth
based on the current font and change it whenever the font is changed ....
Title: Re: MUI for dummies
Post by: Gelb on August 24, 2003, 12:07:04 PM
You might want to use something like MUIA_FixWidthTxt , "123456"
Title: Re: MUI for dummies
Post by: itix on August 24, 2003, 12:13:48 PM
Use tag MUIA_FixWidthTxt. For example

str = StringObject, MUIA_FixWidthTxt, "0000000", End;

Note 7 characters there: one is for cursor. And use characters which are wide by nature (read MUI_Area.doc and you understand why).
Title: Re: MUI for dummies
Post by: Kronos on August 24, 2003, 12:21:15 PM
Thanks, thats it .....

be prepared for round 2 to follow  :-P
Title: Re: MUI for dummies
Post by: GadgetMaster on August 24, 2003, 01:13:55 PM
@itix

You seem to be very knowledgable with Amiga programming.

Do you program full time for the Amiga or is it just a hobby?

Just curious. :-)
Title: Re: MUI for dummies
Post by: GadgetMaster on August 24, 2003, 01:17:21 PM
Sorry OT

@Kronos

RE: your sig

Gimme the Prize - Kurgan's Theme from Queen's Album, A kind of magic, featuring the soundtrack from the first Highlander movie

Any prizes for getting that correct ??? :-P
Title: Re: MUI for dummies
Post by: blubbe on August 24, 2003, 03:18:58 PM
Ok, I have a problem getting images to work:

------------------
Child, ImageObject, MUIA_Background,      MUII_BACKGROUND,
MUIA_Image_Spec, '5:neversleep.gif', End,
-------------------

I get an empty gadget. Snoopdos reports nothing funny. (file is found and loaded with datatypes)
I have snipped away some other code  like a few gadgets (they work).

Should there be additional tags or something ?
Title: Re: MUI for dummies
Post by: downix on August 24, 2003, 05:03:42 PM
@Kronos

Actually Neko and I have been discussing co-writing a book for learning MUI.  If you'd like, can we pick your head on what areas need more clarity, and what not.
Title: Re: MUI for dummies
Post by: GadgetMaster on August 24, 2003, 05:20:59 PM
Quote

downix wrote:
@Kronos

Actually Neko and I have been discussing co-writing a book for learning MUI.  If you'd like, can we pick your head on what areas need more clarity, and what not.


How about publishing a few beginner tutorials here on Amiga.Org ?
Title: Re: MUI for dummies
Post by: Kronos on August 24, 2003, 05:23:54 PM
@Downix

Sounds nice, and here are some things I'm still stumbling on about:

How does the whole  notifying work, and how do I make my prog react on normal
events (other than gadgets).

How does one avoid getting an unresponsive GUI while the prog does something else.

How do I convert a normal Amiga-app with an event-loop into something MUI ?

Is there a save way to do draw into a window/MUI-object outside a Draw-event
(that just wouldn't be good for my proggy) ? And how does one create such a
object for personal use ?

I allready did a quick scan over the doku, and found hints for most of the probs, but help
on those is still much welcomed.


@Gadget
Prize ? Didn't you read ? I get the prize !!!  :-D
Title: Re: MUI for dummies
Post by: itix on August 24, 2003, 06:51:54 PM
Quote

Is there a save way to do draw into a window/MUI-object outside a Draw-event
(that just wouldn't be good for my proggy) ?


You can draw only inside MUIM_Draw because:

 - your object may belong to virtual group and needs clipping (MUI installs this automatically for MUIM_Draw)

 - your application can be hidden (in the iconified state) at anytime and thus _rp(obj) is not always valid.

 - your object could be hidden for some reason (page and register groups)
Title: Re: MUI for dummies
Post by: Kronos on August 24, 2003, 07:04:15 PM
@itix

Yes, I know that  :-P

But all that wouldn't be a real prob for my aim.

a) The object will never be in a virtual group as it supposed to show the actual stuff
the user is working with it. And I don't plan to add any virtual groups to the main win.

b) I would only need that "direct" draw when reacting an mo9usemove or
mousebutton events over said object. Won't happen when it is iconified.

c) I won't use register-groups either (in the main win).

The prob is like that :

On every mouseevent the figure is drawn using COMPLEMENT mode.

When it is finished it is drawn with JAM1.

Whenever a refresh is needed a full redraw of all figures is been done (that would be
o.k. with MUIM_Draw), but I don't see how I could do that for the construction phase,
without hitting a severe performance-penalty and/or much more work for me.

So what side effects do I have to fear when I bend/break the rules on this one ? :-o
Title: Re: MUI for dummies
Post by: itix on August 24, 2003, 08:11:43 PM
I think you just want draw new parts of your objects without full redraw? Then you could do something like this:

 data->DrawCommand = MY_OWN_DRAW_COMMAND;
 MUI_Redraw(obj, MADF_DRAWUPDATE);

And then in your MUIM_Draw method:

MyDraw()
{
  DoSuperMethod();

  if (msg->flags & MADF_DRAWUPDATE)
  {
     switch (data->DrawCommand)
     {
        /* UPDATE PARTS YOU WANT TO */
     }
  }
  else
  {
     /* FULL REDRAW */
  }
}

(I hope I got your problem right.. :-) )

As far as I know there arent problems for direct draw if it is really limited and you know what you are doing. But you never know what Stuntzi does for the next MUI release. Your code could fail in the future.

Title: Re: MUI for dummies
Post by: Kronos on August 24, 2003, 08:15:48 PM
/me beats Stunzi with a stick  :-o

I'll see what I can do on that next week or so when I start on actually connecting
the prog to the GUI.
Title: Re: MUI for dummies
Post by: DethKnight on August 24, 2003, 09:51:47 PM
Quote
what areas need more clarity, and what not.

 
for me, all of it, the config for 3.8 has way too much "info/config/options" at once.
this is why is haven't adjusted ANY setting in it since the day I bought the key.

I'm sure I could figure it out, but I've time to waste elsewhere
Title: Re: MUI for dummies
Post by: Kronos on August 28, 2003, 07:11:05 PM
Round 2 is opened ......


How the h'** do I get the actual Window from my MUI-object ???

thought it should have been this:
struct Window *win;
DoMethod(obj,MUIA_Window,&win);


But when I try to draw something into the RPort of that window, I get massive
slowdowns and crashes. Drawing after assigning rp tp _rp(obj) does work, but this
ain't a option, sice I want to call a function which expects Window*, and doesn't
know nothing about MUI.
Title: Re: MUI for dummies
Post by: lempkee on August 28, 2003, 08:17:37 PM
i post this in favor for a friend.

he told me to say this:

 reply to read the bottom of libraries/mui.h
 
and that i should mention _window( Object* )





reading the dev docs is a pain i know so much :)

cheers
Title: Re: MUI for dummies
Post by: Kronos on August 28, 2003, 08:34:41 PM
Quote

and that i should mention _window( Object* )


Ah..... that helped.

Quote
reading the dev docs is a pain i know so much :)


Well I did read the docs, and that was where the trouble started ....  :-o
Title: Re: MUI for dummies
Post by: blubbe on August 30, 2003, 04:34:23 AM
I found this was an old question threw some googleing.. The solution was said to be use
MUIA_FixWidth, MUIA_FixHeight (Because
ImageObject has some boopsi limitations
(compared to MUI) and has to be told the size of the image at creation time.
But.. still no luck, still getting an empty gadget.
Title: Re: MUI for dummies
Post by: itix on August 30, 2003, 11:36:58 AM
Quote

How the h'** do I get the actual Window from my MUI-object ???

thought it should have been this:
struct Window *win;
DoMethod(obj,MUIA_Window,&win);


MUIA_Window is an attribute. You can read attributes by calling GetAttr() from Intuition:

GetAttr(MUIA_Window, obj, &x);

And few warnings:

 - MUIA_Window is only valid when the window is opened
 - MUIA_Window is an area class tag. Use MUIA_Window_Window for window objects.