Request for additional tag for page.gadget

AmigaOS users can make feature requests in this forum.
Post Reply
User avatar
OldFart
Posts: 109
Joined: Tue Jul 12, 2011 3:56 pm
Location: Groningen, Netherlands

Request for additional tag for page.gadget

Post by OldFart »

Hi,

Would it be possible to add a tag to the page.gadget's array of tags?
Tag in question: PAGE_AddHead.
Functionally identical to PAGE_Add, with the difference that the specified page is added at the head of page.gadget's internal list, in contrast with PAGE_Add, where the page is added to the list's tail.
For reasons of consistency (and clarity) PAGE_Add could then have a synonym with PAGE_AddTail, this latter being not much more then an update of the SDK.

OldFart
X5000, stored.
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
Dead MicroA1
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb, 5B
OrangePi 5+ 8Gb
ACER Aspire Windows 10
User avatar
trixie
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 414
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Request for additional tag for page.gadget

Post by trixie »

@OldFart

For a static building of pages in a layout, PAGE_AddHead doesn't make much sense, because you can always add to the top the page you want at the top :-) Dynamic page arrangement is a different story, but page.gadget seems to lack an API for that - something along the lines of the LM_ADDCHILD / LM_REMOVECHILD methods in layout.gadget.
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
OldFart
Posts: 109
Joined: Tue Jul 12, 2011 3:56 pm
Location: Groningen, Netherlands

Re: Request for additional tag for page.gadget

Post by OldFart »

@trixie,

In my recently published version of 'HexView', I have a.o. applied both a pag.gadget and a chooser.gadget, the latter controling the first. The chooser.gadget shows its labels in a fashion of the last label entered is at the top (head) of the list. However, to obtain congruency between both gadgets in terms of order of addition, I need to add pages at the top of the list.

Currently this code code is applied to achieve that goal:

Code: Select all

            {
             IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_ChooseEntry, ACTIVEWOID), CHOOSER_Labels, (Tag)LABELS_DETACHED, TAG_END);

              /*
              ** As adding a page to a page gadget allows only to
              ** do this at the page's internal list's tail,
              ** measurements have to be taken to circumvent this
              ** when pages have to be added at that list's head.
              ** This is achieved by first removing all existing
              ** pages from the gadget's list one-by-one and subsequently
              ** adding the new page at the list's tail, as that's the
              ** only possibility, and finally adding them at the
              ** list's tail again. This will effectively put the
              ** newly added page at the top of the list.
              ** Cumbersome, but hey! it works.
              */

              {
               struct EntryData *EntryData;
               struct Node *ChooserNode = IExec->GetHead((__GD)->gd_ChooserList);

               /*
               ** For starters, remove all existing pages
               ** from the page gadget's internal list:
               ** (Don't worry: they are restored later on
               **  from the Chooser's list...)
               */
               while (ChooserNode != NULL)
                {
                 IChooser->GetChooserNodeAttrs(ChooserNode, CNA_UserData, &EntryData, TAG_END);
                 IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_Page, ACTIVEWOID), PAGE_Remove, (Tag)EntryData->ed_PageObject, TAG_END);

                 ChooserNode = IExec->GetSucc(ChooserNode);
                }

               /*
               ** Now add the newly created ChooserNode to the chooser's
               ** list and subsequently the corresponding new page at
               ** the (tail of the) page gadget's internal list:
               */

               ChooserNode = IExec->GetHead((__GD)->gd_ChooserList);
               IExec->AddHead((__GD)->gd_ChooserList, (__ED)->ed_ChooserNode);
               IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_Page, ACTIVEWOID), PAGE_Add      , (Tag)(__ED)->ed_PageObject
                                                                              , PAGE_NoDispose, (Tag)TRUE
                                                                              , TAG_END);

               /*
               ** And finally restore the page gadget's list
               ** by adding all pages again at the list's tail:
               */
               while (ChooserNode != NULL)
                {
                 IChooser->GetChooserNodeAttrs(ChooserNode, CNA_UserData, (Tag)&EntryData, TAG_END);
                 IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_Page, ACTIVEWOID), PAGE_Add      , (Tag)EntryData->ed_PageObject
                                                                                , PAGE_NoDispose, (Tag)TRUE
                                                                                , TAG_END);

                 ChooserNode = IExec->GetSucc(ChooserNode);
                }
 
               IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_Page, ACTIVEWOID), PAGE_Current, (Tag)1, TAG_END);

               ILayout->RethinkLayout    (_SetGadTarget(GOID_Page, ACTIVEWOID), TRUE);
               IIntuition->RefreshGList  (_SetGadTarget(GOID_Page, ACTIVEWOID), 1);
              }

             (__GD)->gd_LabelCount++;

             IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_ChooseEntry, ACTIVEWOID), CHOOSER_Labels  , (Tag)(__GD)->gd_ChooserList
                                                                                   , CHOOSER_Selected, (Tag)0 
                                                                                   , GA_Disabled     , (Tag)FALSE
                                                                                   , GA_HintInfo     , (Tag)(__ED)->ed_HintInfo
                                                                                   , TAG_END);

             IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_NextEntry   , ACTIVEWOID), GA_Disabled   , (Tag)TRUE                         , TAG_END);
             IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_CurrentEntry, ACTIVEWOID), BUTTON_Integer, (Tag)1                            , TAG_END);
             IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_RemEntry    , ACTIVEWOID), GA_Disabled   , (Tag)((__GD)->gd_LabelCount == 0) , TAG_END);
             IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_PrevEntry   , ACTIVEWOID), GA_Disabled   , (Tag)((__GD)->gd_LabelCount  < 2) , TAG_END);

             Success = TRUE;
            }
           _ElseError("Alloc ChooserNode");
Huge parts could be circumvented when pages could be added to the head of page.gadget's list, hence my request.

OldFart
X5000, stored.
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
Dead MicroA1
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb, 5B
OrangePi 5+ 8Gb
ACER Aspire Windows 10
Post Reply