Alternative color pickers?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/11/2009 at 14:12, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   11 
Platform:   Windows  ;   Mac OSX  ; 
Language(s) :   C.O.F.F.E.E  ;  C++  ;  XPRESSO  ;

---------
I was wondering whether the SDK contained the info needed to replace the standard C4D color picker with an alternative?

After being spoiled using Jovian Color Picker on Lightwave3D, I really wanted to look at replacing the standard color picker with one that supported libraries, etc. or at least gave me access to the native MacOSX color picker (which allows plugin extensions itself). However, I didn't see anything in the R11 or R11.5 SDKs which enabled replacing the C4D color picker.

Is it even possible? If so, where are the associated hooks documented? What all needs to be provided by a color picker plugin?

If it isn't currently possible, can such functionality be added to a future version of the SDK? The C4D color picker, while adequate for basic tasks, is really missing a lot of functionality in terms of specific swatch libraries (say for PANTONE colors, etc.), color mixing and picking, and so forth that are available in other apps. This seems like one area where C4D is "behind the curve", and allowing devs to replace the standard picker would be very useful, IMO.

As another example, right now it is very difficult to maintain a linear workflow when the only way to pick colors involves an on-screen (and therefore gamma-adjusted) color picker which doesn't allow for automatic "de-correction" of selected colors back to linear gamma. It would be trivial to add this functionality, but as far as I can tell, there are no hooks whatsoever to even post-process color selection operations.

Changes requested (if not present already) :

1. Ability to completely replace color picker, with Preferences setting for user to choose default picker (ideally allowing choice of "C4D Standard", "OS Native" (maybe not on Windows, but useful on Mac), and whatever user-installed variants exist.

2. Hooks to pre- and post-process color information being handed into and returned by whatever color picker is in use. This would allow for "linear workflow" plugins that compensated for screen gamma, for example.

3. Ability to provide installable panes that attach to the "C4D Standard" color picker. This would allow developer to add support for swatch libraries, color mixers, etc. without requiring complete replacement of the standard color picker. User-installed panes would need access to contents of standard picker, and to be able to change the color represented by it from within installed panes.

If these kinds of hooks and replacement abilities already exist in the SDK, can someone point me to the plugin type needed to do such things?

Thanks!

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/11/2009 at 06:02, xxxxxxxx wrote:

You can choose to use the system color if you prefer. There's a setting in CINEMA 4D's preferences Units->Use System Color Picker. Maybe also check out all the other options for the CINEMA 4D color picker. I find it actually quite powerful.

As for your question, yes there is hook to replace the color picker.

Please have a look at the following example:

  
#include "c4d.h"  
#include "c4d_symbols.h"  
  
//////////////////////////////////////////////////////////////////////////  
  
#define COLORPICKER_ID    1018404  
  
class ColorPickerDialog : public GeDialog  
{  
private:  
  DescriptionCustomGui    *gad;  
public:  
  
  ColorPickerDialog(Vector *color) { m_pColor=color; }  
  
  virtual Bool CreateLayout(void);  
  virtual Bool InitValues(void);  
  virtual Bool Command(LONG id,const BaseContainer &msg);  
  virtual Bool CoreMessage(LONG id,const BaseContainer &msg);  
  virtual LONG Message(const BaseContainer& msg, BaseContainer& result);  
  
  BaseContainer m_Settings;  
  BasePlugin *m_pPlugin;  
  Vector *m_pColor;  
};  
  
//////////////////////////////////////////////////////////////////////////  
  
#define IDC_COLOR    1000  
  
Bool ColorPickerDialog::CreateLayout(void)  
{  
  BaseContainer *wprefs=GetWorldContainerInstance();  
  
  m_Settings=wprefs->GetContainer(COLORPICKER_ID);  
  
  if (!GeDialog::CreateLayout()) return FALSE;  
  
  SetTitle(GeLoadString(IDS_COLORPICKER_NAME));  
  
  GroupBegin(0,BFH_SCALEFIT|BFV_SCALEFIT,1,2,String(),0);  
  
      AddColorChooser(IDC_COLOR,BFH_SCALEFIT,0,0,DR_COLORFIELD_NO_BRIGHTNESS);  
      AddDlgGroup(DLG_OK|DLG_CANCEL);  
        
  GroupEnd();  
  
  //////////////////////////////////////////////////////////////////////////  
    
  BaseContainer *bc=m_Settings.GetContainerInstance(BFM_COLORCHOOSER_PARENTMESSAGE);  
  if (!bc)  
  {  
      BaseContainer m;  
  
      m.SetLong(BFM_COLORCHOOSER_SYSTEM   ,wprefs->GetLong(WPREF_COLOR_SYSTEM_BP));  
      m.SetLong(BFM_COLORCHOOSER_RGB_RANGE,wprefs->GetLong(WPREF_COLOR_RGBRANGE));  
      m.SetLong(BFM_COLORCHOOSER_H_RANGE  ,wprefs->GetLong(WPREF_COLOR_HRANGE));  
      m.SetLong(BFM_COLORCHOOSER_SV_RANGE ,wprefs->GetLong(WPREF_COLOR_SVRANGE));  
      m.SetLong(BFM_COLORCHOOSER_QUICKSTORE,wprefs->GetLong(WPREF_COLOR_QUICK_BP));  
      m.SetLong(BFM_COLORCHOOSER_MIXINGPANEL,wprefs->GetLong(WPREF_COLOR_MIX_BP));  
  
      m_Settings.SetContainer(BFM_COLORCHOOSER_PARENTMESSAGE,m);  
      bc = m_Settings.GetContainerInstance(BFM_COLORCHOOSER_PARENTMESSAGE);  
      if (!bc) return FALSE;  
  }  
    
  BaseContainer col(BFM_COLORCHOOSER);  
  
  col.SetLong(BFM_COLORCHOOSER_SYSTEM   ,bc->GetLong(BFM_COLORCHOOSER_SYSTEM   ));  
  col.SetLong(BFM_COLORCHOOSER_RGB_RANGE,bc->GetLong(BFM_COLORCHOOSER_RGB_RANGE));  
  col.SetLong(BFM_COLORCHOOSER_H_RANGE  ,bc->GetLong(BFM_COLORCHOOSER_H_RANGE  ));  
  col.SetLong(BFM_COLORCHOOSER_SV_RANGE ,bc->GetLong(BFM_COLORCHOOSER_SV_RANGE ));  
  col.SetLong(BFM_COLORCHOOSER_QUICKSTORE,bc->GetLong(BFM_COLORCHOOSER_QUICKSTORE));  
  col.SetLong(BFM_COLORCHOOSER_MIXINGPANEL,bc->GetLong(BFM_COLORCHOOSER_MIXINGPANEL));  
  
  col.SetLong(BFM_COLORCHOOSER_SYSTEMMESSAGE,TRUE);  
  
  SendMessage(IDC_COLOR,col);  
  
  return TRUE;  
}  
  
Bool ColorPickerDialog::InitValues(void)  
{  
  SetColorField(IDC_COLOR,*m_pColor,1.0,1.0,0);  
  
  if (!GeDialog::InitValues()) return FALSE;  
  return TRUE;  
}  
  
Bool ColorPickerDialog::Command(LONG id,const BaseContainer &msg)  
{  
  switch (id)  
  {  
  case DLG_OK:  
      {  
          Real b;  
          GetColorField(IDC_COLOR,*m_pColor,b);  
  
          BaseContainer *wprefs=GetWorldContainerInstance();  
          wprefs->SetContainer(COLORPICKER_ID,m_Settings);  
  
          Close();  
      }  
      return TRUE;  
  case DLG_CANCEL:  
      Close();  
      return TRUE;  
  }  
  return GeDialog::Command(id,msg);  
}  
  
Bool ColorPickerDialog::CoreMessage(LONG id,const BaseContainer &msg)  
{  
  return GeDialog::CoreMessage(id,msg);  
}  
  
LONG ColorPickerDialog::Message(const BaseContainer& msg, BaseContainer& result)  
{  
  switch (msg.GetId())  
  {  
  case BFM_COLORCHOOSER_PARENTMESSAGE:  
  {  
      m_Settings.SetContainer(BFM_COLORCHOOSER_PARENTMESSAGE,msg);  
      break;  
  }  
  }  
  
  return GeDialog::Message(msg,result);  
}  
  
//////////////////////////////////////////////////////////////////////////  
  
Bool IsKeyDown(LONG key)  
{  
  BaseContainer res;  
  return GetInputState(BFM_INPUT_KEYBOARD,key,res) && res.GetLong(BFM_INPUT_VALUE);  
}  
  
//////////////////////////////////////////////////////////////////////////  
  
typedef Bool CChooser(Vector *color);  
CChooser *g_ColorPicker=NULL;  
  
LONG g_InUse=0;  
  
Bool ColorPicker(Vector *color)  
{  
  if (IsKeyDown(KEY_SHIFT))  
  {  
      if (g_InUse==0 && g_ColorPicker)  
      {  
          g_InUse=2;  
  
          Bool bRet=g_ColorPicker(color);  
  
          g_InUse=0;  
  
          return bRet;  
      }  
  }  
  else if (g_InUse==0)  
  {  
      g_InUse=1;  
  
      ColorPickerDialog dlg(color);  
      dlg.Open(FALSE,0);  
  
      g_InUse=0;  
  
      return TRUE;  
  }  
  else if (g_InUse==1 && g_ColorPicker)  
  {  
      g_InUse=2;  
  
      Bool bRet=g_ColorPicker(color);  
  
      g_InUse=1;  
  
      return bRet;  
  }  
  
  return FALSE;  
}  
  
//////////////////////////////////////////////////////////////////////////  
  
Bool PluginStart(void)  
{  
  
  return TRUE;  
}  
  
void PluginEnd(void)  
{  
}  
  
Bool PluginMessage(LONG id, void *data)  
{  
  switch (id)  
  {  
  case C4DPL_INIT_SYS:  
      {  
          if(!resource.Init()) return FALSE;  
  
          OperatingSystem *os=(OperatingSystem* )data;  
  
          g_ColorPicker=os->Ge->ChooseColor;  
          os->Ge->ChooseColor=ColorPicker;  
      }  
      return TRUE;  
  
  case C4DMSG_PRIORITY:   
      return TRUE;  
  }  
  
  return FALSE;  
}  

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 10/12/2009 at 13:34, xxxxxxxx wrote:

Thanks much for this, it really helps me out.