Jump to content

Spinner Widget


Josh
 Share

Recommended Posts

This will create a "spinner" widget like in 3ds max. You can use SetRange() to control the min and max values.

download.jpg.ee2f7dbfea3697e2319f0709b4a78c0d.jpg

Download:

Spinner.h

Example:

#include "UltraEngine.h"
#include "Spinner.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
	//Get displays
	auto displays = GetDisplays();

	//Create window
	auto mainwindow = CreateWindow("Spinner", 0, 0, 800, 600, displays[0]);
	
	//Create user interface
	auto ui = CreateInterface(mainwindow);
	iVec2 sz = ui->root->ClientSize();
	
	//Create spinners
	auto ispinner = CreateSpinner(20, 20, 100, 30, ui->root, SPINNER_INTEGER);
	auto fspinner = CreateSpinner(20, 60, 100, 30, ui->root, SPINNER_FLOAT);
	auto nspinner = CreateSpinner(20, 100, 100, 30, ui->root, SPINNER_FLOAT | SPINNER_NORMALIZE);

	//Show the window
	mainwindow->Show();
	mainwindow->Activate();

	//Easier to work with:
	ui->SetScale(2);

	while (true)
	{
		const Event event = WaitEvent();
		switch (event.id)
		{
		case EVENT_WIDGETACTION:
			if (event.source == ispinner) Print(event.data);
			if (event.source == fspinner or event.source == nspinner)
			{
				Print(event.source->As<Widget>()->GetProgress());
			}
			break;
		case EVENT_WINDOWCLOSE:
			if (event.source == mainwindow) return 0;
			break;
		}
	}
	return 0;
}

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

There are too many details to try to cram it in at the last minute.

I am going to change the slider value / range to use 64-bit integers, so that in the future a double float can fit into those bits.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...