Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
121 user(s) are online (110 user(s) are browsing Forums)

Members: 2
Guests: 119

Cap, VooDoo, more...

Support us!

Headlines

 
  Register To Post  

Gradientslider
Supreme Council
Supreme Council


See User information
Anyone got an example of a colorwheel linked up with a gradient slider?

I've managed to create both, and specified WHEEL_GradientSlider but they don't seem to link up. The background of the gradientslider remains gray without any gradient in sight.

Edit: When setting the GRAD_PenArray argument on the Gradient slider, it does render a gradient, BUT it doesn't update when changing colors in the color wheel.


Edited by orgin on 2009/4/12 8:42:28
Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Gradientslider
Supreme Council
Supreme Council


See User information
@orgin

Ohh well, I've solved it by keeping track of the colors myself via IDCMP_INTUITICKS.

I'll post the code for a complete color selector requester once I finish off two small details.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Gradientslider
Supreme Council
Supreme Council


See User information
okey here it is:

void ColorRequester(struct Window *winuint32 *reduint32 *greenuint32 *blue)
{
 
BOOL close FALSE;
 
UWORD code;
 
ULONG eid;
 
ULONG wait,prq;

 
uint32 lred=*redlgreen=*greenlblue=*blue;  // Currently selected color
 
uint32 llred=0llgreen=0llblue=0// Color selected last iteration
 
uint32 sred=0,sgreen=0,sblue=0// slider positions last iteration

 
Object *reqobj;
 
struct Window *req;

 
struct MsgPort *appport IExec->CreateMsgPort();
 
struct Screen *appscreen IIntuition->LockPubScreen(NULL);

 
// Gadgets
 
enum
 
{
  
GID_REQ_MAIN=0,
  
GID_REQ_WHEEL,
  
GID_REQ_SLIDER,
  
GID_REQ_NEWPEN,
  
GID_REQ_OLDPEN,
  
GID_REQ_REDSLIDER,
  
GID_REQ_GREENSLIDER,
  
GID_REQ_BLUESLIDER,
  
GID_REQ_SELECT,
  
GID_REQ_CANCEL,
  
GID_REQ_END
 
};
 
 
struct Gadget *gadgets[GID_REQ_END];
 
 
// Pen storage
 
uint16 Pen[3];      // For brightness slider
 
uint16 PenRed[3];   // For red slider
 
uint16 PenGreen[3]; // For green slider
 
uint16 PenBlue[3];  // For blue slider
 
uint16 OldPen;      // For old color button
 
uint16 NewPen;      // For new color button

 // Color for old pen button
 
OldPen IGraphics->ObtainPen(
  
appscreen->ViewPort.ColorMap, -1
   *
red,
   *
green,
   *
blue,
   
PENF_EXCLUSIVE);
 
 
// Color for new pen button
 
NewPen IGraphics->ObtainPen(
  
appscreen->ViewPort.ColorMap, -1,
   *
red,
   *
green,
   *
blue,
   
PENF_EXCLUSIVE);
   
 
// Brightness slider
 
Pen[0] = IGraphics->ObtainPen(
  
appscreen->ViewPort.ColorMap, -1,
   
0xffffffff,
   
0xffffffff,
   
0xffffffff,
   
PENF_EXCLUSIVE);
 
Pen[1] = IGraphics->ObtainPen(
  
appscreen->ViewPort.ColorMap, -1
   
0x00000000,
   
0x00000000,
   
0x00000000,
   
PENF_EXCLUSIVE);
 
Pen[2]=~0;

 
//Red Slider
 
PenRed[1] = IGraphics->ObtainPen(
  
appscreen->ViewPort.ColorMap, -1,
   
0xffffffff0,
   
PENF_EXCLUSIVE);
 
PenRed[0] = Pen[1];
 
PenRed[2]=~0;

 
//Green Slider
 
PenGreen[1] = IGraphics->ObtainPen(
  
appscreen->ViewPort.ColorMap, -1,
   
00xffffffff0,
   
PENF_EXCLUSIVE);
 
PenGreen[0] = Pen[1];
 
PenGreen[2]=~0;
 
 
//Blue Slider
 
PenBlue[1] = IGraphics->ObtainPen(
  
appscreen->ViewPort.ColorMap, -1,
   
000xffffffff,
   
PENF_EXCLUSIVE);
 
PenBlue[0] = Pen[1];
 
PenBlue[2]=~0;


 
// Allocate brightness gradient slider.
 
gadgets[GID_REQ_SLIDER] = GradientObject,
   
PGA_FreedomLORIENT_VERT,
   
GRAD_PenArrayPen,
  
End;

 
reqobj WindowObject,
  
WA_Height,160,
  
WA_Width160,
  
WA_SizeGadgetTRUE,
  
WA_DragBarTRUE,
  
WA_DepthGadgetTRUE,
  
WA_CloseGadgetTRUE,
  
WA_ActivateTRUE,
  
WA_AutoAdjustTRUE,
  
WA_Title"Select color",
  
WA_ScreenTitle, (STRPTR)ILocale->GetCatalogStr(Catalog,LOCALE_TITLE_WINDOWSCREEN2,LOCALE_TITLE_WINDOWSCREEN2_STR),
  
WA_PubScreenappscreen,
  
WA_IDCMPIDCMP_INTUITICKS,
  
WINDOW_RefWindowwin,
  
WINDOW_PositionWPOS_CENTERWINDOW,
  
WINDOW_GadgetHelpFALSE,
  
WINDOW_IconifyGadgetFALSE,
  
WINDOW_SharedPortappport,
  
WINDOW_ParentGroupgadgets[GID_REQ_MAIN] = VGroupObject,

  
LAYOUT_AddChildVGroupObject,
    
LAYOUT_BevelStyleBVS_GROUP,
    
LAYOUT_Label"Select Color",
    
    
LAYOUT_AddChildHGroupObject,
    
     
LAYOUT_AddChildHGroupObject,

      
LAYOUT_AddChildgadgets[GID_REQ_WHEEL] = ColorWheelObject,
       
GA_IDGID_REQ_WHEEL,
       
WHEEL_Red, *red,
       
WHEEL_Green, *green,
       
WHEEL_Blue, *blue,
       
WHEEL_Screenappscreen,
       
WHEEL_GradientSlider,gadgets[GID_REQ_SLIDER],
      
ColorWheelEnd
     
      
LAYOUT_AddChildgadgets[GID_REQ_SLIDER],

      
LAYOUT_AddChildgadgets[GID_REQ_NEWPEN] = ButtonObject,
      
GA_IDGID_REQ_NEWPEN,
        
BUTTON_BackgroundPenNewPen,
       
GA_RelVerifyTRUE,
      
ButtonEnd,

      
LAYOUT_AddChildgadgets[GID_REQ_OLDPEN] = ButtonObject,
       
GA_IDGID_REQ_OLDPEN,
       
BUTTON_BackgroundPenOldPen,
       
GA_RelVerifyTRUE,
      
ButtonEnd,

     
LayoutEnd,
    
LayoutEnd,

    
LAYOUT_AddChildVGroupObject,
     
LAYOUT_FixedVertFALSE,

     
LAYOUT_AddChildgadgets[GID_REQ_REDSLIDER] = GradientObject,
      
GA_IDGID_REQ_REDSLIDER,
      
PGA_FreedomLORIENT_HORIZ,
      
GRAD_PenArrayPenRed,
      
GRAD_CurVal, *red>>16,
      
GRAD_MaxVal0xFFFF,
     
End,

     
LAYOUT_AddChildgadgets[GID_REQ_GREENSLIDER] = GradientObject,
      
GA_IDGID_REQ_GREENSLIDER,
      
PGA_FreedomLORIENT_HORIZ,
      
GRAD_PenArrayPenGreen,
      
GRAD_CurVal, *green>>16,
      
GRAD_MaxVal0xFFFF,
     
End,

     
LAYOUT_AddChildgadgets[GID_REQ_BLUESLIDER] = GradientObject,
      
GA_IDGID_REQ_BLUESLIDER,
      
PGA_FreedomLORIENT_HORIZ,
      
GRAD_PenArrayPenBlue,
      
GRAD_CurVal, *blue>>16,
      
GRAD_MaxVal0xFFFF,
     
End,

    
LayoutEnd,
   
LayoutEnd,

   
LAYOUT_AddChildHGroupObject,
    
LAYOUT_FixedVertFALSE,

    
LAYOUT_AddChildHGroupObject,
     
LAYOUT_FixedHorizFALSE,
     
LAYOUT_HorizAlignmentLALIGN_LEFT
     
LAYOUT_AddChildgadgets[GID_REQ_SELECT] = ButtonObject,
      
GA_IDGID_REQ_SELECT,
      
GA_RelVerifyTRUE,
      
GA_Text,"Select",
     
ButtonEnd,
    
LayoutEnd,

    
LAYOUT_AddChildHGroupObject,
     
LAYOUT_FixedHorizFALSE,
     
LAYOUT_HorizAlignmentLALIGN_RIGHT
     
LAYOUT_AddChildgadgets[GID_REQ_CANCEL] = ButtonObject,
      
GA_IDGID_REQ_CANCEL,
      
GA_RelVerifyTRUE,
      
GA_Text,"Cancel",
     
ButtonEnd,
    
LayoutEnd,
   
LayoutEnd,

  
LayoutEnd,
  
EndWindow;
 
 if(
reqobj!=0)
 {
  
IIntuition->SetWindowAttrs(winWA_BusyPointerTRUETAG_DONE);
  
req = (struct Window *) RA_OpenWindow(reqobj);
 
  
prq = (1L << appport->mp_SigBit);
 
  while(!
close)
  {
   
wait IExec->WaitSIGBREAKF_CTRL_C  prq);
   if ( 
wait prq )
   {
    while((
eid RA_HandleInput(reqobj, &code)) != WMHI_LASTMSG)
    {
     switch(
eid WMHI_CLASSMASK)
     {
      case 
WMHI_GADGETUP:
       switch(
eid WMHI_GADGETMASK)
       {
        case 
GID_REQ_CANCEL:
         
close=TRUE;
         break;
        case 
GID_REQ_SELECT// New color selected
         
close=TRUE;
         
IIntuition->GetAttrs(gadgets[GID_REQ_WHEEL],WHEEL_Red,red,TAG_DONE);
         
IIntuition->GetAttrs(gadgets[GID_REQ_WHEEL],WHEEL_Green,green,TAG_DONE);
         
IIntuition->GetAttrs(gadgets[GID_REQ_WHEEL],WHEEL_Blue,blue,TAG_DONE);
         break;
        case 
GID_REQ_OLDPEN// Change back to old color
         
IIntuition->SetGadgetAttrs(gadgets[GID_REQ_WHEEL],req,NULL,
          
WHEEL_Red, *red,
          
WHEEL_Green, *green,
          
WHEEL_Blue, *blue,
          
TAG_DONE);
         break;
       }
       break;
      case 
WMHI_CLOSEWINDOW:
       
close TRUE;
       break;
      case 
WMHI_RAWKEY:
       switch(
code)
       {
        case 
69:
         
close TRUE;
         break;
       }
       break;
      case 
WMHI_INTUITICK:
       {
        
BOOL redselgreenselbluesel// Check if any of the rgb sliders are selected
        
IIntuition->GetAttrs(gadgets[GID_REQ_REDSLIDER],GA_Selected,&redsel,TAG_DONE);
        
IIntuition->GetAttrs(gadgets[GID_REQ_GREENSLIDER],GA_Selected,&greensel,TAG_DONE);
        
IIntuition->GetAttrs(gadgets[GID_REQ_BLUESLIDER],GA_Selected,&bluesel,TAG_DONE);
       
        if(
redsel || greensel || bluesel)
        { 
// yepp, rgb sliders are selected
         
uint32 redvalgreenvalblueval;
         
IIntuition->GetAttrs(gadgets[GID_REQ_REDSLIDER],GRAD_CurVal, &redval,TAG_DONE);
         
IIntuition->GetAttrs(gadgets[GID_REQ_GREENSLIDER],GRAD_CurVal, &greenval,TAG_DONE);
         
IIntuition->GetAttrs(gadgets[GID_REQ_BLUESLIDER],GRAD_CurVal, &blueval,TAG_DONE);
         
lred redval<<16;
         
lgreen greenval<<16;
         
lblue blueval<<16;
         
IIntuition->SetGadgetAttrs(gadgets[GID_REQ_WHEEL],req,NULL,
          
WHEEL_Redlred,
          
WHEEL_Greenlgreen,
          
WHEEL_Bluelblue,
          
TAG_DONE);
         
sred redval;
         
sgreen greenval;
         
sblue blueval;
        }
        else 
// Check if colorwheel or gradient slider is affecting color
        
{
         
IIntuition->GetAttrs(gadgets[GID_REQ_WHEEL],WHEEL_Red,&lred,TAG_DONE);
         
IIntuition->GetAttrs(gadgets[GID_REQ_WHEEL],WHEEL_Green,&lgreen,TAG_DONE);
         
IIntuition->GetAttrs(gadgets[GID_REQ_WHEEL],WHEEL_Blue,&lblue,TAG_DONE);

         if(
llred!=lred || llgreen!=lgreen || llblue!=lblue// Only update when changed
         
{
          
IIntuition->SetGadgetAttrs(gadgets[GID_REQ_REDSLIDER],req,NULLGRAD_CurVallred>>16TAG_DONE);
          
IIntuition->SetGadgetAttrs(gadgets[GID_REQ_GREENSLIDER],req,NULLGRAD_CurVallgreen>>16TAG_DONE);
          
IIntuition->SetGadgetAttrs(gadgets[GID_REQ_BLUESLIDER],req,NULLGRAD_CurVallblue>>16TAG_DONE);
          
sred lred>>16// Keep track of slider values
          
sgreen lgreen>>16;
          
sblue lblue>>16;
         }
         else
         {
          
uint32 redvalgreenvalblueval;
           
IIntuition->GetAttrs(gadgets[GID_REQ_REDSLIDER],GRAD_CurVal, &redval,TAG_DONE);
           
IIntuition->GetAttrs(gadgets[GID_REQ_GREENSLIDER],GRAD_CurVal, &greenval,TAG_DONE);
           
IIntuition->GetAttrs(gadgets[GID_REQ_BLUESLIDER],GRAD_CurVal, &blueval,TAG_DONE);

          if(
redval!=sred || greenval!=sgreen || blueval!=sblue// Has rgb sliders been clicked?
          
{
           
lred redval<<16;
           
lgreen greenval<<16;
           
lblue blueval<<16;
           
IIntuition->SetGadgetAttrs(gadgets[GID_REQ_WHEEL],req,NULL,
            
WHEEL_Redlred,
            
WHEEL_Greenlgreen,
            
WHEEL_Bluelblue,
            
TAG_DONE);
           
sred redval// Keep track of slider values
           
sgreen greenval;
           
sblue blueval;
          }
         }
        }

        if(
llred!=lred || llgreen!=lgreen || llblue!=lblue// Only update when changed
        
{
         
IGraphics->ReleasePen(appscreen->ViewPort.ColorMap,NewPen);
         
NewPen IGraphics->ObtainPen(
          
appscreen->ViewPort.ColorMap, -1,
          
lred,
          
lgreen,
          
lblue,
          
PENF_EXCLUSIVE);
          
         
IIntuition->RefreshGadgetsgadgets[GID_REQ_NEWPEN], reqNULL );
         
IIntuition->RefreshGadgetsgadgets[GID_REQ_OLDPEN], reqNULL );
         
         
llred lred;
         
llgreen lgreen;
         
llblue lblue;
        }
       }
       break;
     }
    }
   }
  }
  
IIntuition->SetWindowAttrs(winWA_BusyPointerFALSETAG_DONE);
  
IIntuition->DisposeObject(reqobj);
 }
 
 
// Clean up
 
IIntuition->UnlockPubScreen(NULL,appscreen);
 
IExec->DeleteMsgPort(appport);
 
 
// Release pens
 
IGraphics->ReleasePen(appscreen->ViewPort.ColorMap,Pen[0]);
 
IGraphics->ReleasePen(appscreen->ViewPort.ColorMap,Pen[1]);
 
IGraphics->ReleasePen(appscreen->ViewPort.ColorMap,NewPen);
 
IGraphics->ReleasePen(appscreen->ViewPort.ColorMap,OldPen);
 
IGraphics->ReleasePen(appscreen->ViewPort.ColorMap,PenRed[1]);
 
IGraphics->ReleasePen(appscreen->ViewPort.ColorMap,PenGreen[1]);
 
IGraphics->ReleasePen(appscreen->ViewPort.ColorMap,PenBlue[1]);
}


Edited by orgin on 2009/4/12 12:09:42
Edited by orgin on 2009/4/12 12:15:41
Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: Gradientslider
Not too shy to talk
Not too shy to talk


See User information
@orgin

I can't check right now, but IIRC PNGer used notification for the gradient slider. The source is included with it.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project