Possible to create a blue BOOPSI button?

5 posts / 0 new
Last post
hypex
hypex's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-09-09 16:20
Possible to create a blue BOOPSI button?

Hi guys.

So in the classic days we saw some interfaces with blue buttons. Mostly GadTools based. So I'm wondering if it's easy enough to do so with BOOPSI?

My testing says no, not easily. I've played with tags like BUTTON_BackgroundPen and BUTTON_FillPen and haven't yet got a satisfactory result.

At first any colour changed didn't make sense. I found out that calling it a pen is misleading. It doesn't infact take a pen index but a palette index. That is not the same. I found out after the fact that the pen must be looked up in the DrawInfo pen list to find the palette entry and then passed as palette entry. That's confusing and I almost found it by accident after a hunch.

So I wanted to try changing the button to FILLPEN so it had active blue colour. It changed it but it looks plain and doesn't match active fill like in windows. There is no gradient. I just want to change colour and nothng else. Can it be told to just change colour underneath and keep gradient effects?

Next I wanted to try a toggle button. So when depressed it was blue. But I couldn't get it to work. I could only get it go blue when unpressed. Can a toggle button colour be changed so it's blue when pushed in and normal when pushed out?

jabirulo
jabirulo's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2013-05-30 00:53
Re: Possible to create a blue BOOPSI button?

ok, here is an example, see if it suits your needs:

  1. ;/*
  2. gcc bluebutton.c -o bluebutton -Wall -gstabs -lauto
  3. quit
  4. */
  5.  
  6. #include <proto/exec.h>
  7. #include <proto/dos.h>
  8. #include <proto/intuition.h>
  9. #include <proto/window.h>
  10. #include <proto/layout.h>
  11.  
  12. #include <classes/window.h>
  13. #include <gadgets/layout.h>
  14. #include <gadgets/button.h>
  15.  
  16. enum {
  17. OID_MAIN = 0,
  18. OID_BUTTON,
  19. OID_LAST
  20. };
  21.  
  22. Object *obj[OID_LAST];
  23. long PenArray[2];
  24.  
  25.  
  26. int main(void)
  27. {
  28. struct Window *win;
  29. struct Screen *scr = IIntuition->LockPubScreen(NULL);
  30. struct DrawInfo *di = IIntuition->GetScreenDrawInfo(scr);
  31.  
  32. PenArray[0] = di->dri_Pens[FILLPEN];
  33. PenArray[1] = di->dri_Pens[SHINEPEN];
  34.  
  35. obj[OID_MAIN] = IIntuition->NewObject(NULL, "window.class",
  36. WA_Title, "BlueButton",
  37. WA_DragBar, TRUE,
  38. WA_CloseGadget, TRUE,
  39. WA_SizeGadget, TRUE,
  40. WA_DepthGadget, TRUE,
  41. //WA_Activate, TRUE,
  42. WINDOW_Position, WPOS_CENTERSCREEN,
  43. WINDOW_Layout, IIntuition->NewObject(NULL, "layout.gadget",
  44. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  45. LAYOUT_AddChild, obj[OID_BUTTON] = IIntuition->NewObject(NULL, "button.gadget",
  46. GA_ID, OID_BUTTON,
  47. GA_RelVerify, TRUE,
  48. GA_Text, "Blue Button",
  49. BUTTON_PushButton, TRUE,
  50. BUTTON_BackgroundPen, PenArray[0],
  51. BUTTON_FillPen, PenArray[1],
  52. TAG_DONE),
  53. TAG_DONE),
  54. TAG_DONE);
  55.  
  56. win = (struct Window *)IIntuition->IDoMethod(obj[OID_MAIN], WM_OPEN);
  57. if(win) {
  58. uint32 sigmask = 0, siggot = 0, result = 0;
  59. uint16 code = 0;
  60. BOOL done = FALSE;
  61.  
  62. IIntuition->GetAttr(WINDOW_SigMask, obj[OID_MAIN], &sigmask);
  63. while(!done) {
  64. siggot = IExec->Wait(sigmask | SIGBREAKF_CTRL_C);
  65.  
  66. if(siggot & SIGBREAKF_CTRL_C) done = TRUE;
  67.  
  68. while( (result=IIntuition->IDoMethod(obj[OID_MAIN], WM_HANDLEINPUT, &code)) ) {
  69. switch(result & WMHI_CLASSMASK) {
  70. case WMHI_CLOSEWINDOW:
  71. done = TRUE;
  72. break;
  73. case WMHI_GADGETUP:
  74. switch (result & WMHI_GADGETMASK) {
  75. case OID_BUTTON:
  76. IDOS->Printf("blue button clicked\n");
  77. break;
  78. }
  79. break;
  80. }
  81. }
  82. }
  83.  
  84. }
  85.  
  86. IIntuition->DisposeObject(obj[OID_MAIN]);
  87.  
  88. IIntuition->FreeScreenDrawInfo(scr, di);
  89. IIntuition->UnlockScreen(scr);
  90.  
  91. return RETURN_OK;
  92. }

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

hypex
hypex's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-09-09 16:20
Re: Possible to create a blue BOOPSI button?

@jabirulo

Thanks for your example jabirulo. At first I wondered how to copy with line numbers. But after I pasted only the text body had copied so that's good. :-)

I tested it out and got the same results with my code, though I didn't test using the SHINEPEN. It displayed a button with a plain blue background that when pressed was a light grey background. The gradient was missing.

So, it looks like the basic pen colour cannot be changed, without removing the gradient. I just wanted it to change base colour underneath gradient effect. I didn't notice any "new look" pen tags. So it looks like simply just changing pen colour isn't possible as it changes the look.

jabirulo
jabirulo's picture
Offline
Last seen: 1 month 1 week ago
Joined: 2013-05-30 00:53
Re: Possible to create a blue BOOPSI button?

the maybe you can try:

  1. GA_BackFill (struct Hook *)
  2. A layer backfill hook to provide a more complex
  3. background pattern. See InstallLayerHook() for
  4. more details about the backfill hook.
  5.  
  6. Defaults to NULL.

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

hypex
hypex's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-09-09 16:20
Re: Possible to create a blue BOOPSI button?

I considered that. But I would need to know exactly how to duplicate what the OS is doing. From a cursory glance it needs some layer when setting a default hook. Should be possible that way. But as always BOOPSI makes simple operations complicated. :-)

Log in or register to post comments