Git Product home page Git Product logo

c4d_bitmapbutton's Introduction

c4d_bitmapbutton

This is an example of adding a bitmap button to a GeDialog in Cinema 4D R13+

This small helper I came up with when I tried to add a BitmapButtonCustomGui to a GeDialog. It was quite a pain to find a way of having it as a clickable button but eventually I found a way. As others struggled before with this I thought sharing this might save some others from the trouble.

It's quite useful as it allows to easily add:

  • buttons (pressed border effect and/or stylish C4D like hover buttons)
  • image checkboxes (toggable)
  • splash screens and generally image display in a dialog

The code is released under the BSD-3 license.

Requirements

  • Cinema 4D R13 (or higher) SDK.
  • C++03/C++11 compliant compiler

By default it compiles for R15 SDK and a C++11 compiler (VS2013+/XCode 5+) To support previous versions/compilers outcomment the preprocessor directives in DialogBitmapButton.h.

How to use

Simply include the files in your project.

There is only one class: DialogBitmapButton

Basically all you need to do is construct it with an element ID and call the 4 public functions:

  • DialogBitmapButton::AddToLayout
  • DialogBitmapButton::HandleInitValues
  • DialogBitmapButton::HandleMessage
  • DialogBitmapButton::HandleCommand

Furthermore AddToLayout also allows to pass a popup callback. An example of how such a callback function might look like can be found in the DialogBitmapButton header file (at the very bottom).

Example

const int bitmapbutton_id = 2000; //Element ID of the bitmap button

class TestDialog : public GeDialog
{
 private:
    NAVIE_MAXON::DialogBitmapButton m_bmpbutton;
    [...]
 public:
    TestDialog() : m_bmpbutton(bitmapbutton_id) {}
}

Bool TestDialog::CreateLayout(void)
{
	[...]
	//Adds a clickable button (switches from sphere to cube icon). 
	m_bmpbutton.AddToLayout(this,NAVIE_MAXON::BBMode::Clickable, Osphere, Ocube, true, BORDER_OUT, BFH_CENTER|BFH_CENTER, "Tooltip Info");
	[...]
}

Bool TestDialog::InitValues(void)
{
	if (!Base::InitValues()) return false;
	m_bmpbutton.HandleInitValues();
	return true;
}

Bool TestDialog::Command(Int32 id, const BaseContainer& msg)
{	
	m_bmpbutton.HandleCommand(id);
}

Int32_C4D TestDialog::Message(const BaseContainer &msg, BaseContainer &result)
{
	m_bmpbutton.HandleMessage(msg);
	return Base::Message(msg,result);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.