Intuition window alpha masked?

4 posts / 0 new
Last post
alfkil
alfkil's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-10 22:02
Intuition window alpha masked?

I know, I know, I ask too many dumb questions here...

This time it is about windows: I want to create such a cool borderless shaped window with an alpha mask as I have seen in demos and such. How does one do that? I am pretty sure it has to do with the WA_AlphaClips and WA_AlphaHook tags in OpenWindowTags, but I don't know how to use them. For starters, there seem to be a lack of information in the docs on how to initialize the ClipRect structure. Or I could have just overlooked them. Anyway, I need something tangible, preferably a (small) piece of code to guide my way.

(And don't ask me what I am doing with it, it is totally worthless and (of course) a big (yay!) surprise ;) )

Ami603
Ami603's picture
Offline
Last seen: 5 years 11 months ago
Joined: 2011-10-11 23:11
Alfkil: I may have some

Alfkil:
I may have some example code from the earlier days of OS4 development.
Will have a look when i'm back from work.

alfkil
alfkil's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-10 22:02
Great! I'm looking forward :)

Great! I'm looking forward :)

alfkil
alfkil's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-10 22:02
Ok, figured it out

Ok, figured it out myself...

Here's my example code:

  1. /* SMGTYK v.0.1 */
  2.  
  3. #include <proto/exec.h>
  4. #include <proto/graphics.h>
  5. #include <proto/intuition.h>
  6. #include <proto/layers.h>
  7.  
  8. #include <graphics/rpattr.h>
  9.  
  10. int main()
  11. {
  12. struct Screen *wb = IIntuition->LockPubScreen("workbench");
  13. struct Layer_Info *li = &wb->LayerInfo;
  14. IIntuition->UnlockPubScreen(NULL, wb);
  15. struct ClipRect *cr = ILayers->AllocClipRect(li);
  16. cr->bounds.MinX = 0;
  17. cr->bounds.MinY = 0;
  18. cr->bounds.MaxX = 63;
  19. cr->bounds.MaxY - 63;
  20. cr->BitMap = IGraphics->AllocBitMap(64, 64, 8, BMF_CLEAR, NULL);
  21. struct RastPort alpharas;
  22. IGraphics->InitRastPort(&alpharas);
  23. alpharas.BitMap = cr->BitMap;
  24. IGraphics->SetRPAttrs(&alpharas, RPTAG_APen, 255, TAG_DONE);
  25. IGraphics->RectFill(&alpharas, 0, 0, 63, 63);
  26. int i;
  27. for(i = 0; i < 32; i++)
  28. {
  29. IGraphics->SetRPAttrs(&alpharas, RPTAG_APen, 256/32*i, TAG_DONE);
  30. IGraphics->DrawEllipse(&alpharas, 32, 32, i, i);
  31. }
  32. struct Window *win = IIntuition->OpenWindowTags(NULL,
  33. WA_Width, 64,
  34. WA_Height, 64,
  35. WA_Borderless, TRUE,
  36. WA_Activate, TRUE,
  37.  
  38. //WA_Opaqueness, 128,
  39. WA_AlphaClips, cr,
  40.  
  41. WA_IDCMP, IDCMP_MOUSEBUTTONS,
  42. TAG_DONE);
  43.  
  44.  
  45. IExec->WaitPort(win->UserPort);
  46.  
  47. IIntuition->CloseWindow(win);
  48. ILayers->FreeClipRect(li, cr);
  49.  
  50. return 0;
  51. }
Log in or register to post comments