How about to add this type of button?


So strange values… Just 2 images or even one line also is waste time, understand?
You never feel wasting time, perhaps time is worth nothing for you and demand of your users, hehe~

Certainly, ROLI and JUCE team love these answers of yours. Hope they will send you a big red-envelope at the end of the year :smiley:



I don’t know if there’s a tidier solution? But this looks pretty sexy to me. It might want a disabled state and a mouse over effect depending on how it’s going to be used.

class AnimatedToggleSlider : public Button, Timer
	AnimatedToggleSlider () : Button({}) { setClickingTogglesState(true); }

	void buttonStateChanged () override { startTimer(30); }

	void timerCallback() override
		auto rate = 0.1f;
		rate *= getToggleState() ? 1.0f : -1.0f;

		position = jlimit(0.0f, 1.0f, position + rate);

		if (position == 0.0f || position == 1.0f)


	void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) override
		auto h = float(getHeight());
		auto area = getLocalBounds().toFloat();

		Path p;  // leaving as a path so an optional outline can be added
		p.addRoundedRectangle(area, h / 2.0f);
		g.setColour(Colours::darkgrey.interpolatedWith(Colours::green, position * position));

		auto circleBounds = area.withWidth(h).translated((area.getWidth() - h) * position, 0.0f);

	float position{ 0.0f };


Thanks, jimc. You’re a great pioneer :slight_smile:

Still hope the superior JUCE team will add this common button to the library…



I’ve become obsessed … better go for some lunch instead of making widgets :slight_smile:


Sincerely invite you to come to my country when you have free time, jimc. I will entertain you with the best delicacy in the world :smiley:


No, I don’t understand. As a software engineer of 30 years I find your attitude a bit whiny. You ARE requesting an ImageButton with baked in images, do you understand?




      ...20 words...


Now you’re just being rude and immature. Best of luck.


拉倒吧, cpr。看你也一把年纪的人了,实在不想打击你。



Dude, chill out. Your behavior continues to be inappropriate for the JUCE message board. Feel free to continue to insult me with private messages, but respect the other users of this message board and stop posting this stuff in the thread.


@loopfine: this is not KVR. Please stop it.


you should give this words to cpr, not me. understand?


@loopfine: You are the problem here, not @cpr. You are rude and insulting. I wish this forum had a mute button…


yes, if it has, I’ll mute you first in my thread, will you feel happy?

It’s not insulting at all, at least in the first and second reply for cpr. I invited my colleagues to see this thread, all of them happy to laugh. Seems you guys should learn some language skills of Chinese rather than C++ only…

Never mind. I think you guys just jealous with jimc.

OK, anybody here come to my home when you have free time, I’ll certainly entertain you all with the best delicacy in the world too :smiley:

OK, I stop. Thanks.


Last words in this thread:

I’m not for myself. If only me need this, I won’t waste any time to post these crap here.


LOL. Wow, what a guy…

That button IS in the JUCE library… Even if they implemented that specific look for the toggle button, everyone would still need to override it for their specific application, thus making your request worthless.


Guys can we delete this whole thread now. Enough weirdness.


@loopfine - The messages you have posted in this thread are not acceptable on the JUCE forum.

We regularly receive feedback from JUCE users (usually beginners) telling us that the forum can feel intimidating, which, in turn, stops them contributing to the wider JUCE community. It should come as no surprise that the JUCE team is 100% committed to creating an environment which is as inclusive as possible and encourages everyone to become a part of it. If there is a repeat of the hostile attitude in this thread the creators of any offending messages will have their accounts removed. Please consider this a warning.

You can find the JUCE forum code of conduct here:

We are not going to add such a specific bit of functionality to the JUCE API. As a few people have indicated, creating your own button is relatively straighforward and the JUCE API is already pretty big - the more features we add the harder it is to navigate and maintain. GUI elements in particular get outdated relatively quickly. However, there is clearly value in making the code required to create a button like this easily discoverable. We’re currently in the process of improving our documentation and I think including something like @jimc’s button implementation as a code sample or snippet would be useful to a lot of people. Another thing we’re considering is something along the lines of a JUCE module marketplace where JUCE users could contribute their own modules containing things like ready-styled buttons and sliders.

I don’t think there is much to add to this topic. Please start a new thread if you wish to discuss anything related.