Solved HandleMouseDrag for ID_GRADIENTGUI_BROWSERPRESET and ColorSwatchData::browserPresetType

hi,

I would need to define how the preset encapsulate the data itself. And than expose how the data is stored.
(that took me some time to figure that out sorry about the delay)
I will ask if we can share this information.

I will have a look at why it's not working with a registered library.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

hi,
I was trying to reproduce the problem of loading a preset from a registered library but can't reproduce it.
I tested it with the last version maybe that's the problem.

Could you tell me witch version are you using ?
or, try this code, does it works ?

	Bool InputEvent(const BaseContainer& msg) override
	{

		// register my own lib 
		const SDKBrowserURL domain{ "preset://mycolors.lib4d"_s };
		const maxon::String libName{ "the library name"_s };
		const maxon::String presetName{ "mynewcolors"_s };
		const SDKBrowserURL presetUrl = domain + presetName;
		Filename presetLibFile{ "D:\\temp\\mycolors\\mycolors.lib4d"_s };

		const Int32 bd_index = SDKBrowser::RegisterPresetLibrary(domain, libName, presetLibFile);


		AutoAlloc<ColorSwatchData> newColorPreset;
		if (newColorPreset == nullptr)
			return false;

		ColorSwatchGroup* myGroup = newColorPreset->AddGroup();
		if (myGroup == nullptr)
			return false;
		const maxon::ColorA firstColor{ 1.0, 1.0, 1.0, 0 };
		const maxon::ColorA secondColor{ 0.4, 1.0, 1.0, 0 };
		const maxon::ColorA thirdColor{ 0.1, 0.5, 1.0, 0 };
		const maxon::ColorA fourthColor{ 0, 0, 0, 0 };

		myGroup->AddColor(firstColor);
		myGroup->AddColor(secondColor);
		myGroup->AddColor(thirdColor);
		myGroup->AddColor(fourthColor);

		if (!newColorPreset->SavePreset(presetUrl))
			return false;

		// normal way of doing it 
		AutoAlloc<ColorSwatchData> colorPreset;
		if (colorPreset == nullptr)
			return false;
		ColorAlphaArray colorArray;

		if (ColorSwatchData::ValidPreset(presetUrl))
		{
			if (colorPreset->LoadPreset(presetUrl))
			{
				ColorSwatchGroup* myColorPresetGroup = colorPreset->GetGroupAtIndex(0);
				myColorPresetGroup->GetColors(colorArray, false);
				for (auto value : colorArray)
					ApplicationOutput("color in the array @", value);

				return HandleMouseDrag(msg, DRAGTYPE_RGBA_ARRAY, &colorArray, 0);

			}
		}


		return true;
	}

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

Thanks Manuel. It looks like you are creating the preset and then using it directly all in the one go. I am loading an registering an existing library from disk and trying to access the presets within that. I will do some more investigation into it next week and let you know how I get on. Thanks again, Kent.

hi,

did you got time to look at it ?

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

Hi Manuel,

Sorry no I haven't yet. Been a busy couple of weeks. Hopefully I will have time next week to look into this again. Although due to the issues I had, and that there is still no information about how to work with gradients, I am still leaning towards ditching lib4d files and making my own custom format instead.

Will let you know next week when I have had another look into it. Thanks for following up with me.

Cheers,
Kent

Hello @kbar,

without any further questions or replies, we will consider this topic to be solved by Monday and flag it accordingly.

Thank you for your understanding,
Ferdinand

MAXON SDK Specialist
developers.maxon.net

Hi @ferdinand

This has not been solved. I could not get the data and there was no information for accessing gradient info.

I have abandoned this approach and am going to make a custom format of my own for storage.

Also in light of the depreciated Content Browser there is no point spending any more time on this issue.

Cheers,
Kent

Hello @kbar,

if you need further information, please feel free to unflag this topic. But as you know, we have a fourteen-days radio silence policy for closing topics. We understand that this can collide with workloads in a production environment, but we have to apply some form of control here. Which we feel is rather generous, since you can push back a topic almost indefinitely by simply posting in it.

Thank you for your understanding,
Ferdinand

MAXON SDK Specialist
developers.maxon.net

Hi,

my apology, i was waiting for feedback about the ColorSwatchData to dive into the gradient. I could not also talk about the Asset Browser in public.

MAXON SDK Specialist

MAXON Registered Developer

Hi,

Sorry about not having time to investigate the gradient part of your question. I was waiting for feedback about the color presets.
With the new asset browser out there's no point into investigate this question furthermore.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer