BitmapButton image change works in R13 but not R14
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 01:14, xxxxxxxx wrote:
Hi Yannick,
is this bug only occuring when a res file is used? Or is the bug meant to be there when the layout is made with GetDDescription?
WP. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 01:42, xxxxxxxx wrote:
Originally posted by xxxxxxxx
is this bug only occuring when a res file is used? Or is the bug meant to be there when the layout is made with GetDDescription?
The issue is only occurring with descriptions and if we want to respond to MSG_DESCRIPTION_GETBITMAP.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 05:13, xxxxxxxx wrote:
Thanks, Yannick! I will use the workaround to get the bitmap buttons working in Cinema 4D again.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 10:49, xxxxxxxx wrote:
One thing that I realize is that I have to register the images as icons. There are ALOT of images involved here. And due to the dynamic nature of the plugin, some of the images might be 'created' by the user during the use of the plugin which makes use of RegisterIcon() impossible - right? Any alternative ideas on making these work again?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 16:53, xxxxxxxx wrote:
Hi Yannick and Rob,
by descriptions - do you mean the layout etc as shown in the AM?
I've got an object plugin I'm working on, and I have made my own image boolean for it. It's in a dynamic group where the user can add as many groups (and thus buttons) as they need. The toggle state seems to work on that - but I'm drawing the image through the message function itself, so no reference to a file as such. It's under the MSG_DESCRIPTION_GETBITMAP so that seems to be working at my end...? Using Get & SetDParameter, but no .res file (I try program everything into the one file, just habbit).
R14.034 - latest build.
WP. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 22:38, xxxxxxxx wrote:
WP,
Yes, these would be Descriptions associated with a plugin that displays its options in the Attributes Manager and not a GeDialog or derivative of one.
Could you show some code (an example would suffice)? My plugins are built for R13 but run in R14. It seems that all of them that use a BitmapButton (typically for a banner image clickable button in the AM for opening HTML help) are exhibiting this problem. I may need to break down and built for R14 explicitly with code changes specifically for it to resolve this issue.
Thanks,
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 02:08, xxxxxxxx wrote:
Hi Rob,
sure. This is pretty much what I have, and it seems to work. Just remember the bitmap button is being added inside of a dynamic group, and the image is drawn manually.***** In my GetDDescription function ***** *** note: this is just the bitmap element in a dynamic group virtual Bool GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC & flags) { cid_Bitmap = DescLevel(Bool_Active+i, DTYPE_BUTTON, 0); if (!id_Bitmap || cid_Bitmap.IsPartOf(*id_Bitmap,NULL)) { BaseContainer bc_leftgroupbool = GetCustomDataTypeDefault(CUSTOMGUI_BITMAPBUTTON); bc_leftgroupbool.GetCustomDataType( DTYPE_BUTTON, CUSTOMGUI_BITMAPBUTTON); bc_leftgroupbool.SetLong(DESC_CUSTOMGUI, CUSTOMGUI_BITMAPBUTTON); bc_leftgroupbool.SetLong(DESC_ANIMATE,DESC_ANIMATE_OFF); bc_leftgroupbool.SetLong(BITMAPBUTTON_BORDER, BORDER_NONE); bc_leftgroupbool.SetBool(BITMAPBUTTON_NOBORDERDRAW, TRUE); bc_leftgroupbool.SetBool(BITMAPBUTTON_TOGGLE, TRUE); bc_leftgroupbool.SetBool(BITMAPBUTTON_BUTTON, TRUE); bc_leftgroupbool.SetLong(BITMAPBUTTON_BACKCOLOR, COLOR_BGFOCUS); bc_leftgroupbool.SetString(DESC_NAME, ""); bc_leftgroupbool.SetString(DESC_SHORT_NAME, ""); if (!description->SetParameter(cid_Bitmap, bc_leftgroupbool, DescLevel(DYNAMIC_GROUP_LEFT+i))) { GePrint("Bitmap Boolean failed."); return TRUE; } } } ***** My GetDParameter function ***** ***note: Count is a LONG for each group number added to description virtual Bool GetDParameter(GeListNode *node, const DescID &id, GeData &t_data, DESCFLAGS_GET &flags) { if(!node){return FALSE;} LONG Button_Bitmap_Bool = id[0].id; if((Button_Bitmap_Bool >= BOOL_ACTIVE+1) && (Button_Bitmap_Bool <= BOOL_ACTIVE+Count)) { LONG dirty = 0; BitmapButtonStruct bbs(static_cast<BaseObject*>(node), id, dirty); t_data = GeData(CUSTOMDATATYPE_BITMAPBUTTON, bbs); flags |= DESCFLAGS_GET_PARAM_GET; } return SUPER::GetDParameter(node,id,t_data,flags); } ***** My SetDParameter function ***** *** note: bitmap_bool virtual Bool SetDParameter(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_SET &flags) { if(!node){return FALSE;} LONG Bitmap_Button = id[0].id; if((Bitmap_Button >= BOOL_ACTIVE+1) && (Bitmap_Button <= BOOL_ACTIVE+Count)) { BaseContainer *Container = ((BaseList2D* )node)->GetDataInstance(); Bool Active_Temp = Container->GetBool(Bitmap_Button,NULL); if(Active_Temp == TRUE) { Container->SetBool(Bitmap_Button,FALSE); } if(Active_Temp == FALSE) { Container->SetBool(Bitmap_Button,TRUE); } flags |= DESCFLAGS_SET_PARAM_SET; } return SUPER::SetDParameter(node,id,t_data,flags); } ***** My Message function ***** virtual Bool Message(GeListNode *node, LONG type, void *data) { if(type == MSG_DESCRIPTION_GETBITMAP) { DescriptionCommand *dc_Bool = (DescriptionCommand* )data; LONG Button_Bool = dc_Bool->id[0].id; if ((Button_Bool >= 320001) && (Button_Bool <= 320000 + Count)) { BaseContainer *Container = ((BaseList2D* )node)->GetDataInstance(); Bool Active_Temp = Container->GetBool(Button_Bool,NULL); Bool Active = Active_Temp; if(Group_Bool_Active == TRUE) { DescriptionGetBitmap *DGB_Bool_Active = static_cast<DescriptionGetBitmap*>(data); AutoAlloc<BaseBitmap> Active; // Active bitmap bool drawn here... } if(Group_Bool_Active == FALSE) { DescriptionGetBitmap *DGB_Bool_InActive = static_cast<DescriptionGetBitmap*>(data); AutoAlloc<BaseBitmap> InActive; // Inactive bitmap bool drawn here... } } } }
I hope I've copied all that across correctly! I removed some of the laborious code like the drawn image to keep it as short as possible. I can sure sympathise with you for having troubles getting it to work. This took me weeks to figure out
Hope it helps.
WP. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 03:06, xxxxxxxx wrote:
Thanks for the code WP.
I got it working in a simple plugin. It wasn't working before because I had not implemented GetDParameter()/SetDParameter()...Robert, I'm sure something is broken in your code. Also I think you should try to pass 0 to the dirty parameter of BitmapButtonStruct constructor.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 04:08, xxxxxxxx wrote:
Remember that my code works all the way back to at least 10.1 and is based on the code given by Matthias to handle BitmapButtons as descriptions (and handle user interaction and image toggling).
Interestingly, my dynamically added BitmapButton descriptions are working (loaded a test scene that uses them). So that means that ones added statically via the .res file are no longer working. Could be a difference in default Container settings or something so I will try to description->SetParameter() for the static ones and see what happens.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 04:41, xxxxxxxx wrote:
Confirmed. If I set one of my static bitmapbuttons with description->SetParameter() using the BaseContainer settings used by dynamically added bitmapbuttons, it works. But...
This means doing my entire description resource programmatically so as to keep them organized properly. My resources for the Greebler Object and Tag are massive to be nice about it. The one tab section just for stock greebles is three groups with three subgroups below two of them and hundreds of descriptions (about 1000 lines for the .res file). Is there anyway to control the insertion of the bitmapbuttons with respect to the static elements?
Maybe I can use the Browse feature of Description to update the BaseContainer for BitmapButton types?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 05:53, xxxxxxxx wrote:
Alright. Here is my solution that makes statically defined BITMAPBUTTON descriptions work in R14! It is a bit non-standard but at least my static bitmapbuttons work again! I call one of these methods in GetDDescription() for each static BitmapButton depending on whether it is a clickable button or a toggle button:
// GreeblerObj.FixBitmapButton // - Fix static BitmapButtons for Cinema 4D R14 //*---------------------------------------------------------------------------* Bool GreeblerObj::FixBitmapButton(Description* description, const DescID& descID) //*---------------------------------------------------------------------------* { BaseContainer bmbcdt; BaseContainer* param = description->GetParameterI(descID, NULL); if (!param) return FALSE; bmbcdt = GetCustomDataTypeDefault(DTYPE_BUTTON); bmbcdt.CopyTo(param, COPYFLAGS_0, NULL); param->GetCustomDataType(DTYPE_BUTTON, CUSTOMGUI_BITMAPBUTTON); param->SetLong(DESC_CUSTOMGUI, CUSTOMGUI_BITMAPBUTTON); param->SetLong(BITMAPBUTTON_BORDER, BORDER_NONE); param->SetBool(BITMAPBUTTON_BUTTON, TRUE); param->SetBool(BITMAPBUTTON_TOGGLE, FALSE); return TRUE; } // GreeblerObj.FixBitmapButtonToggle // - Fix static Toggle BitmapButtons for Cinema 4D R14 //*---------------------------------------------------------------------------* Bool GreeblerObj::FixBitmapButtonToggle(Description* description, const DescID& descID) //*---------------------------------------------------------------------------* { BaseContainer bmbcdt; BaseContainer* param = description->GetParameterI(descID, NULL); if (!param) return FALSE; bmbcdt = GetCustomDataTypeDefault(DTYPE_BUTTON); bmbcdt.CopyTo(param, COPYFLAGS_0, NULL); param->GetCustomDataType(DTYPE_BUTTON, CUSTOMGUI_BITMAPBUTTON); param->SetLong(DESC_CUSTOMGUI, CUSTOMGUI_BITMAPBUTTON); param->SetLong(BITMAPBUTTON_BORDER, BORDER_NONE); param->SetBool(BITMAPBUTTON_BUTTON, TRUE); param->SetBool(BITMAPBUTTON_TOGGLE, TRUE); return TRUE; }
A final thought:
As the revered Dr. McCoy said on Star Trek: "I know engineers , they love to change things!"
Or, in more mundane terms: if it ain't broke, don't fix it!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 08:19, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Confirmed. If I set one of my static bitmapbuttons with description->SetParameter() using the BaseContainer settings used by dynamically added bitmapbuttons, it works. But...
I can't confirm that. In my test I declare a BITMAPBUTTON in the resource description and it works in R14.
Do you really set the BitmapButton container after you initialize it in GetDDescription()? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 08:24, xxxxxxxx wrote:
This is an R13 build working in R14. There could be differences if I built explicitly R14 but I am not ready to make such builds yet. All that I know is that updating the BaseContainer for the static BitmapButton elements allows them to work in both R13 and R14.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 09:46, xxxxxxxx wrote:
For what it's worth, I also found that bitmap button behavior changed in R14 (in an ObjectData with BITMAPBUTTONs defined in RES, in my case). I don't precisely recall debugging the issue, and it would take awhile to go back through the changes to remind myself, but according to my notes, it appears to come down to this: in R14, Message is called for button clicks, rather than SetDParameter. Here are those notes in context (please excuse my version-independence macros, you can easily infer what they do) :
viIMPL_NODEDATA_MESSAGE(mxSceneObject)
{
viGET_NODEDATA_MESSAGE_OBJECTS;switch (type)
{
case MSG_DESCRIPTION_COMMAND :
{
LONG param = ((DescriptionCommand* )data)->id[0].id;if (param > MX_BITMAP_BUTTONS_FIRST && param < MX_BITMAP_BUTTONS_LAST)
{
// This is what gets called when you click a bitmap button in
// version R14. In R96 through R13, SetDParameter is called.OnButtonEvent(param, doc, bc);
viIMPL_NODEDATA_SETDPARAMETER(mxSceneObject)
{
viGET_NODEDATA_SETDPARAMETER_OBJECTS;if (param > MX_BITMAP_BUTTONS_FIRST && param < MX_BITMAP_BUTTONS_LAST)
{
// This is what gets called when you click a bitmap button
// in versions R96 through R13. in R14, Message is called.if (flags & viDESCFLAGS_SET_USERINTERACTION)
{
OnButtonEvent(param, doc, bc);I am not sure if this is exactly related to the current discussion but anyway, I thought it might be worth mentioning.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 12:24, xxxxxxxx wrote:
This is also what I found in X-Particles in R14, my BitmapButtons would no longer respond when using the SetDParameter method given by Matthias in this forum. In R14, Message() is used instead, which I think it should have been all along. My guess is that using SetDParameter() was a bit of a hack to get round a bug and that in R14 this has now been fixed. Annoying that the hack no longer works though since it was a critical function in my plugin and required a specific R14 build to get round it.
Steve
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/12/2012 at 01:09, xxxxxxxx wrote:
I will remember that when R14 builds become necessary.
Thanks!