[comp.sys.amiga.programmer] Sharing layers.library with intuition

rjc@wookumz.ai.mit.edu (Ray Cromwell) (01/11/91)

 Hi. I've been doing some experimenting lately and started designing
an alternative 'window' system to intuition. I don't intend it
as a replacement, or even to distribute it, so please no debates.
(although it would be nice to have a few alternative GUI's on the
Amiga, e.g. Xwindows, Motif)

 Ok, so what is the proper way to 'share' a screen with intuition? I
tried to do something like this:
  BOOL GetScreenData(&myscreen,sizeof(myscreen),WBENCHSCREEN,NULL);
  MyLayer=CreateUpfrontLayer(&myscreen.LayerInfo,&myscreen.BitMap,x,y,x1,y1,
    NULL);
  myrast=MyLayer->rp;

 This gets me a layer on the screen that I can render into, but it
doesn't open up 'on top of' the data and windows underneath. Instead it
'takes over' the data in that region. So my layer ends up stealing part
of the bitmap that was underneath belonging to my shell window. I realize
what I'm doing is probably considered voodoo, however, I'm only
experimenting. So how do I 'share' intuition's screen and let it know
about it? And what am I doing wrong in the above example?

  I was thinking of some neat looks for my 'simulated' windows once
I get past this hurdle, such as having the MenuBar/Menus pull down
from the window title(inside the window) instead of at the top of the screen.
(the menus would also support huge menu bars by making them superbitmaps, and
having a scrollup/down menuitem as standard. I also want to hack in some
window effects like masked windows, windows that explode/collaspe [like Mac],
and wipes/effects.)


I'd also like to report a bug in PDC. The last update causes a 
recoverable alert(under 1.3) on my system. The Alert is 00038005 which
has something to do with an OpenLibrary/MathLib (from exec/alerts.h)
I had to go back to the older version.
  Funny, PDC works fine standalone, but when launched from the CCX
frontend, it causes that alert.


For Commodore gurus, why is LayersBase only a LONG(APTR) I assumed it
would atleast keep a simple structure, say, to store its internal
damage lists? Why does graphics/intuition keep pointers laying around
to other library bases? (such as in IntuitionBase) Shouldn't
the system libraries abide the same rules we do, and open other
libraries to obtain their bases instead of performing inter-library 
rom-jumping? (ok, i'm making a huge assumption here since I haven't
disassembled them.)

Finally 2 more question. (cause I'm curious)
1)How do graphics library/icon library implement icons/bobs?
Are they layers, or are they implemented seperately?

2) In a rough estimate, how many lines of source code does
the entire OS take up? (1.3/2.0) and what compiler/system
is it developed on? Unix, Vax, or Amiga?

peter@cbmvax.commodore.com (Peter Cherna) (01/12/91)

In article <1991Jan11.001055.2055@mintaka.lcs.mit.edu> rjc@wookumz.ai.mit.edu (Ray Cromwell) writes:
>
> Hi. I've been doing some experimenting lately and started designing
>an alternative 'window' system to intuition. I don't intend it
>as a replacement, or even to distribute it, so please no debates.
>(although it would be nice to have a few alternative GUI's on the
>Amiga, e.g. Xwindows, Motif)
>
> Ok, so what is the proper way to 'share' a screen with intuition?

You cannot perform direct layers operations in an Intuition screen,
in general.  Basically, you have two choices:

1.  Create your own viewport (graphics.library equivalent of the
visible-slice of a screen), and do your own layers operations on that.

2.  Create borderless Intuition windows, and use Intuition and graphics
    rendering in those.  You can use RMBTRAP to catch menu buttons.

I will warn you that you are headed into very tricky territory, and
you'll want to be very careful about deadlocks and race conditions.

>  I was thinking of some neat looks for my 'simulated' windows once
>I get past this hurdle, such as having the MenuBar/Menus pull down
>from the window title(inside the window) instead of at the top of the screen.
>(the menus would also support huge menu bars by making them superbitmaps, and
>having a scrollup/down menuitem as standard. I also want to hack in some
>window effects like masked windows, windows that explode/collaspe [like Mac],
>and wipes/effects.)

Some of those effects have been hacked on top of Intuition, with varying
degrees of success, robustness, and compatibility.

>For Commodore gurus, why is LayersBase only a LONG(APTR) I assumed it
>would atleast keep a simple structure, say, to store its internal
>damage lists? Why does graphics/intuition keep pointers laying around
>to other library bases? (such as in IntuitionBase) Shouldn't
>the system libraries abide the same rules we do, and open other
>libraries to obtain their bases instead of performing inter-library 
>rom-jumping? (ok, i'm making a huge assumption here since I haven't
>disassembled them.)

LayersBase (and parts or all of other library bases) are private.  This
means we don't tell you what's in there, because we don't want you reading
or writing those fields.  We have good reasons in mind, such as compatibility
and reliability.

All Amiga ROM libraries call OpenLibrary() to get library pointers.  They
do this during their "init" time.  The result of OpenLibrary() is then
stashed in the library base for reference.  That's very legal.  Remember,
for a library, its library base corresponds well to the global data area
of a regular program.  So IntuitionBase keeping a pointer to LayersBase
is the same as you defining a global called LayersBase.

>Finally 2 more question. (cause I'm curious)
>1)How do graphics library/icon library implement icons/bobs?
>Are they layers, or are they implemented seperately?

Read up about the gels subsystem of graphics in the RKMs.  Implementing
gels on a shared screen like the Workbench is tricky, and there is some
special deadlock avoidance code to help.

>2) In a rough estimate, how many lines of source code does
>the entire OS take up? (1.3/2.0) and what compiler/system
>is it developed on? Unix, Vax, or Amiga?

Here's a rough figure for Intuition, which is about 1/5 of the 2.0 ROM:
55000 lines of code, about 1.4 megabytes worth.  Since Intuition is mostly
C, it has proportionately less lines of code than other modules that
are in assembler.  No small potatoes...

Most of the modules in the ROM are compiled or can be assembled on the Amiga.
A few of the big ones are compiled on a Sun.  Porting modules
is a lot of work and tends to introduce bugs, so there is some advantage
to keeping modules Sun-built.

     Peter
--
     Peter Cherna, Software Engineer, Commodore-Amiga, Inc.
     {uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"Oh, PIN-compatible!  I thought you wanted me to make it IN-compatible!"

peter@cbmvax.commodore.com (Peter Cherna) (01/12/91)

In article <1991Jan11.233104.26795@mintaka.lcs.mit.edu> rjc@wookumz.ai.mit.edu (Ray Cromwell) writes:
>  One question however, if I set the Text in NewWindow to NULL will
>intuition still render the titlebar? (and wipe out anything I have drawm
>there?)

A borderless window with no system gadget (none of WINDOWSIZING, WINDOWDEPTH,
etc.) and a NULL title has no border at all.

     Peter
--
     Peter Cherna, Software Engineer, Commodore-Amiga, Inc.
     {uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"Oh, PIN-compatible!  I thought you wanted me to make it IN-compatible!"

tmb@davinci.acc.Virginia.EDU (Thomas M. Breeden) (01/17/91)

In article <17398@cbmvax.commodore.com> peter@cbmvax.commodore.com (Peter Cherna) writes:
>In article <1991Jan11.001055.2055@mintaka.lcs.mit.edu> rjc@wookumz.ai.mit.edu (Ray Cromwell) writes:
>>
>> Ok, so what is the proper way to 'share' a screen with intuition?
>
>You cannot perform direct layers operations in an Intuition screen,
>in general.  Basically, you have two choices:
>
>1.  Create your own viewport (graphics.library equivalent of the
>visible-slice of a screen), and do your own layers operations on that.
>
>2.  Create borderless Intuition windows, and use Intuition and graphics
>    rendering in those.  You can use RMBTRAP to catch menu buttons.
>
>I will warn you that you are headed into very tricky territory, and
>you'll want to be very careful about deadlocks and race conditions.
>
>--
>     Peter Cherna, Software Engineer, Commodore-Amiga, Inc.
>     {uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com

A related question:

Is it in the same tricky territory to attempt to add a clipping
rectangle within an Intuition window?

The "Layers library" section of RKM is not yet real clear to me
on clipping, but could you AndRectangle (func name?) to something
extracted from the Intuition window (screen?) structure?
Can you avoid doing it between BeginRefresh and AndRefresh as
warned by RKM?

Tom Breeden
tmb@virginia.EDU  -->> Internet
tmb@virginia      -->> BITNET


            - Tom Breeden
              tmb@virginia.EDU      -> Internet
              tmb@virginia          -> BITNET

peter@cbmvax.commodore.com (Peter Cherna) (01/17/91)

In article <1991Jan16.162030.7783@murdoch.acc.Virginia.EDU> tmb@davinci.acc.Virginia.EDU (Thomas M. Breeden) writes:
>Is it in the same tricky territory to attempt to add a clipping
>rectangle within an Intuition window?

No.  It's actually fairly easy.  See layers.library/InstallClipRegion().
Here's a cheap simple example, with no guarantees :-)

    
    if ( myregion = NewRegion() )
	{
	/* myrect describes the rectangle you want to contain rendering
	 * inside of.  Use region operations to build this.
	 */
	OrRectRegion(myregion, &myrect);

	/* Install the region.  All YOUR rendering will be constrained,
	 * such as graphics calls, PrintIText(), DrawImage() etc.
	 * Don't try to constrain Intuition's own rendering of borders,
	 * gadgets, etc.  They happen everywhere.
	 */
	ocr = InstallClipRegion(win->RPort->Layer, myregion);

	DrawImage(win->RPort, myimage, left, top);

	/* Remove your region */
	InstallClipRegion(win->RPort->Layer, ocr);
	DisposeRegion(myregion);
	}
    }


>            - Tom Breeden
>              tmb@virginia.EDU      -> Internet
>              tmb@virginia          -> BITNET


     Peter
--
     Peter Cherna, Software Engineer, Commodore-Amiga, Inc.
     {uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"Oh, PIN-compatible!  I thought you wanted me to make it IN-compatible!"

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (01/18/91)

In article <17689@cbmvax.commodore.com> peter@cbmvax.commodore.com (Peter Cherna) writes:
>In article <1991Jan16.162030.7783@murdoch.acc.Virginia.EDU> tmb@davinci.acc.Virginia.EDU (Thomas M. Breeden) writes:
>>Is it in the same tricky territory to attempt to add a clipping
>>rectangle within an Intuition window?
>
>No.  It's actually fairly easy.  See layers.library/InstallClipRegion().
>Here's a cheap simple example, with no guarantees :-)
>    
>   if ( myregion = NewRegion() )
 [ . . . ]
>   OrRectRegion(myregion, &myrect);

Be sure that you check the return codes of these routines!  They can
run out of memory and fail.  Note that the RKM example code (in the
layers chapter of Libs&Devs) does not properly check the returns (we
all make mistakes.  ;-)
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky

markv@kuhub.cc.ukans.edu (05/05/91)

In article <1991Jan11.233104.26795@mintaka.lcs.mit.edu>, rjc@wookumz.ai.mit.edu (Ray Cromwell) writes:
>   One question however, if I set the Text in NewWindow to NULL will
> intuition still render the titlebar? (and wipe out anything I have drawm
> there?)

Since this is your own screen, one sure fire way to shut up the title
bar, is to say:

	struct Screen	*MyScreen;
        /*...*lots* of code...*/
	ShowTitle(MyScreen, FALSE);

This will completely kibosh any rendering in the Bar Layer of the
sreen, including front/back gadgets.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mark Gooderum			Only...		\    Good Cheer !!!
Academic Computing Services	       ///	  \___________________________
University of Kansas		     ///  /|         __    _
Bix:	  mgooderum	      \\\  ///  /__| |\/| | | _   /_\  makes it
Bitnet:   MARKV@UKANVAX		\/\/  /    | |  | | |__| /   \ possible...
Internet: markv@kuhub.cc.ukans.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (05/06/91)

In article <1991May4.192226.30387@kuhub.cc.ukans.edu> markv@kuhub.cc.ukans.edu writes:
>In article <1991Jan11.233104.26795@mintaka.lcs.mit.edu>, rjc@wookumz.ai.mit.edu (Ray Cromwell) writes:
>>   One question however, if I set the Text in NewWindow to NULL will
>> intuition still render the titlebar? (and wipe out anything I have drawm
>> there?)
>
>Since this is your own screen, one sure fire way to shut up the title
>bar, is to say:
>
>	struct Screen	*MyScreen;
>        /*...*lots* of code...*/
>	ShowTitle(MyScreen, FALSE);
>
>This will completely kibosh any rendering in the Bar Layer of the
>sreen, including front/back gadgets.

This has nothing to do with the thread.  The problem was that a window's
title bar was still appearing in a borderless window even though the
window's title was set to NULL.  It turns out that the window's title
was set to "" (the null string) rather than NULL (the null pointer).

ShowTitle() hides the screen's title bar.  It allows the application to
place the screen's title bar either in front of or behind any backdrop
windows that are open on the screen.
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky