CustomGui in Resource Based Dialogs?



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

    On 15/03/2012 at 13:55, xxxxxxxx wrote:

    Is it possible to include CustomGui bitmaps in a resource based dialog? I am trying to restructure my plugin to fit the recommendation that dialogs be created through the res/dialogs/MyDialog.res. Currently everything in withing the main dialog class.

    Here is an example of how I am getting my custom buttons(thanks to Niklas, Scott and Yannick for the help on this bit!) :

    bc = c4d.BaseContainer()                     ######Create a new container to store the button image 
    bc.SetLong(c4d.BITMAPBUTTON_ICONID1, c4d.OBJECT_BULGE) #####Sets Button Icon
    bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True)
    bc.SetString(c4d.BITMAPBUTTON_TOOLTIP, "Bulge")
    self.myBitButton=self.AddCustomGui(BUTTON_SELECT_BULGE, c4d.CUSTOMGUI_BITMAPBUTTON, "Bulge", c4d.BFH_CENTER | c4d.BFV_CENTER, 32, 32, bc)

    Now, I know that this can be condensed down into some sort of function in itself, so that I wouldnt have to repeat this code for every button...but that may be another discussion altogether :)

    For now, how do I get this into a dialog res structure?

    If this is an obvious question...my apologies...newbie here :)

    Thanks in advance!
    Marc



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

    On 15/03/2012 at 15:42, xxxxxxxx wrote:

    There's an example of that in my Res based dialog example that you downloaded.

    There's a Bitmap Button example in there that uses the .res file to load an image onto the button. Instead of using the self.AddCustomGui() method.
    Look at the bottm of the plugin code where things get registered for these lines of code:

      
    - BITMAP_ID = 100000                              #Be sure to get a unique ID from PluginCafe.com!  
    - buttonimage = bitmaps.BaseBitmap()    #We need an instance of BaseBitmap class to use an image  
    - buttonimage.InitWith(os.path.join(path, "res/icons/", "buttonimage.jpg"))#The location where the button image exists  
    - gui.RegisterIcon(BITMAP_ID, buttonimage)  #We need to register custom images & icons  
    

    These lines of code register the custom image. And also tells the plugin where to find it. Edit those lines of code to point at whatever image you need on your gizmo.
    If you look at the CreateLayout() method in that example. You'll see that there's no mention of this Bitmap button in that method. Because it's being created in the .res file instead.
    If you open the .res file you'll see it there.

    -ScottA

    *Edit- One other thing I just thought of. If you want to use one of the registered icons. Then you don't need all of that registration code. You should be able to use them in your .res file like this:

      BITMAPBUTTON MYBITMAPBUTTON { BORDER; ICONID1 5102; } //The spotlight icon
    

    The ID numbers for the icons can be found in the "interface_icons.txt" file in your Maxon\resource\icons folder.



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

    On 15/03/2012 at 19:33, xxxxxxxx wrote:

    Thanks Scott!

    The last bit about the C4D icons is what I was trying to sort out. For some reason though I was getting errors...if I was a betting man I would bet that it is a typo on my part ;)

    Thanks again!!!

    PS I have a buddy trying to sort out all of this structure and dialog stuff....would you mind if I passed your code on to him?



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

    On 15/03/2012 at 21:09, xxxxxxxx wrote:

    Sure. Pass it along to whoever needs it.
    I was going to eventually post it with some other Python and C++ plugins on my website anyway.

    -ScottA



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

    On 16/03/2012 at 07:16, xxxxxxxx wrote:

    Thanks Scott! I worked on it for a while last night with no luck at all :( Never could get it to load the bitmap. Turns out I needed to reconstruct my c4d_symbols.h file. I had the enum automatically incrementing and after I changed it to mirror what you sent...it worked!

    Thanks again!



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

    On 16/03/2012 at 07:55, xxxxxxxx wrote:

    Trying now to get the tooltip function added into:

     BITMAPBUTTON BUTTON_SELECT_BEND {ICONID1 5128;}
    

    I tried:

    BITMAPBUTTON BUTTON_SELECT_BEND { TOOLTIP "Bend" ; ICONID1 5128;}
    


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

    On 16/03/2012 at 09:16, xxxxxxxx wrote:

    AFAIK. You can't use that in a resource file. It has to go in the main .pyp file.

    Be careful about what you read here concerning the resource method.
    Everyone will tell you that you should always use a resource file in your plugins. But that's not true.
    There will be certain cases when making dialog plugins where the resource file method is not possible.
    Take a look at this thread: https://plugincafe.maxon.net/topic/6257/6624_descriptions-vs-additem-getting-mixed-messages

    Here's another plugin example.
    The one you have already is for R12+ users. This one is for R13+ users only. And has the new AddCustomGui() method with the TOOLTIP option in it.:https://sites.google.com/site/scottayersmedia/myPythonDialog_R13.zip

    -ScottA



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

    On 16/03/2012 at 12:36, xxxxxxxx wrote:

    Scott,

    Thanks for the example! I already had the tooltips working before I decided to try to get a dynamic dialog layout through the use of res files, but its a bummer that you just cant make a call to a different res file and have it know whats happening.

    So, if I am understanding correctly, if I want the layout of my dialog to COMPLETELY change dynamically based on what the user tells it to do, then I would set up the "default" layout as a res file and then use LayoutFlushGroup to "refresh" the layout? The code for the new layout would then be hardcoded into my main pyp file?

    Is that correct? I currently have three layout res files that build the layout for each case, but just couldnt figure out how to get it to react to the request for a change...now I know why.

    Thanks for the info! A huge help as always! Now to figure out how to code the flush group :)

    last note: If you cant make calls to multiple layout files then why bother with them at all? I know it helps for multi-language support and all, but wouldnt it be just as cool to dynamically change your dialog haha



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

    On 16/03/2012 at 13:02, xxxxxxxx wrote:

    Based on what I've learned so far. It appears that most of the dynamic behaviors for diaolg gizmos are done via the AddItem() method in the .pyp file.
    There's possibly some dynamic things that are possible to do in Dialogs using resouces. But I'm not aware of them.
    This is one area where the Maxon team has to step up to the plate. Only the devs know for sure what is, and what isn't possible. And it should be documented better.

    The thing that might be confusing you(as it did me) is that although resource files have a fairly limited use when used with dialogs. They have much stronger abilites when used with Tag, tool, and object plugins.
    If you want to do dynamic GUI stuff with those type of plugins. They are done via the .res file.
    Resource files are only "whimpy" when it comes to dialogs.

    As the guys in the C++ told me.
    It's probably best to think of dialogs as a special case. Requiring a lot more .cpp(.pyp in python) code to be used.
    All the other plugin types rely much more heavily on the resource files to set up their GUI's.

    -ScottA



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

    On 16/03/2012 at 13:11, xxxxxxxx wrote:

    gotcha.

    Looks like I may end up abandoning the res altogether for this one and going with the dynamic groups. I REALLY want my users to be able to click a button and have the layout change to horizontal or vertical. The nature of my plugin almost requires that it be "dockable", and I would like to have the flexibility to choose a layout to suit those needs.

    haha well at least I am learning new stuff as I go :)

    -Marc


Log in to reply