It is currently April 19th, 2024, 12:22 pm

Upgrade DragGroup functionality

Report bugs with the Rainmeter application and suggest features.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Upgrade DragGroup functionality

Post by death.crafter »

So, there is this DragGroup functionality, which I found out recently, from sl23's question about relative positioning skins.

So, the question is, when I define DragGroup under the Rainmeter section of some skins, they get selected only if I first ctrl+alt click them and then drag them.

Well, I don't contest the implementation, but it would feel more natural if it we could just drag one skin and the skins in the same drag group get dragged by default, without the need of Ctrl+Alt+Primary Click and then drag.

Some of may disagree, but if I read DragGroup this is what comes to my mind.

Given not an widely used option from what my experience is, you can either change it directly, or may be add an suitable option that enables this option by default.

Or may be give an insight on how I might do this on my own, through custom plugins or something.

Thank you,
death.crafter
from the Realm of Death
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Upgrade DragGroup functionality

Post by Brian »

death.crafter wrote: October 6th, 2021, 11:55 am Well, I don't contest the implementation, but it would feel more natural if it we could just drag one skin and the skins in the same drag group get dragged by default, without the need of Ctrl+Alt+Primary Click and then drag.
But then there would no way to move/drag 1 specific skin within the drag group.

Yes, we could have made the CTRL+ALT+CLICK function move a specific skin independent of the drag group...but I think it would be more confusing that non-drag grouped skins only need a single click to drag the skin, and skins in a drag group need the CTRL+ALT+CLICK to move it.

IMO, it is simplier to have left click and drag always move the skin (if it is draggable). And CTRL+ALT+CLICK always move the drag group.

-Brian
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Upgrade DragGroup functionality

Post by death.crafter »

Brian wrote: October 7th, 2021, 5:33 am Yes, we could have made the CTRL+ALT+CLICK function move a specific skin independent of the drag group...but I think it would be more confusing that non-drag grouped skins only need a single click to drag the skin, and skins in a drag group need the CTRL+ALT+CLICK to move it.
Exactly. Btw, only ctrl + drag would work, like it does for non-draggable skins.

I had to make a plugin to get this functionality working. And even the plugin is unreliable when simply dragging the a skin (the skin to which other skins are anchored), it just flickers the current skin and anchored skin. I have to use Mouse plugin to move the skin.



The source of the plugin is here btw, but I can't see why wouldn't it work when simply dragged:

Code: Select all

#include <Windows.h>
#include "../../API/RainmeterAPI.h"
#include <string>

struct Measure
{
	Measure() {}
	HWND currentSkin = NULL;
	HWND otherSkin = NULL;
	int xoff = 0;
	int yoff = 0;
	void* pointer = NULL;
	std::wstring skinName = L"";
};

HWND GetSkinWindow(const WCHAR* configName)
{
	HWND trayWnd = FindWindow(L"RainmeterTrayClass", NULL);
	if (trayWnd)
	{
		COPYDATASTRUCT cds;
		cds.dwData = 5101;
		cds.cbData = (DWORD)(wcslen(configName) + 1) * sizeof(WCHAR);
		cds.lpData = (void*)configName;
		return (HWND)SendMessage(trayWnd, WM_COPYDATA, 0, (LPARAM)&cds);
	}

	return NULL;
}

PLUGIN_EXPORT void Initialize(void** data, void* rm)
{
	Measure* measure = new Measure;
	*data = measure;

	measure->pointer = RmGetSkin(rm);
	measure->currentSkin = RmGetSkinWindow(rm);
	measure->skinName = RmReadString(rm, L"ConfigName", NULL, 1);
	measure->xoff = RmReadInt(rm, L"XOffset", 0);
	measure->yoff = RmReadInt(rm, L"YOffset", 0);
}

PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
	Measure* measure = (Measure*)data;
	measure->otherSkin = GetSkinWindow(measure->skinName.c_str());
}

PLUGIN_EXPORT double Update(void* data)
{
	Measure* measure = (Measure*)data;

	if (measure->otherSkin == NULL)
	{
		return 0.0;
	}

	RECT currSkinPos;
	bool success = GetWindowRect(measure->currentSkin, &currSkinPos);
	if (!success)
	{
		return 0.0;
	}

	RECT otherSkinPos{};
	success = GetWindowRect(measure->otherSkin, &otherSkinPos);
	if (!success)
	{
		return 0.0;
	}

	if ((otherSkinPos.left != currSkinPos.left + measure->xoff) || (otherSkinPos.top != currSkinPos.top + measure->yoff))
	{
		RmExecute(measure->pointer, (L"[!Move \"" + std::to_wstring(currSkinPos.left + measure->xoff) + L"\" \"" + std::to_wstring(currSkinPos.top + measure->yoff) + L"\" \"" + measure->skinName + L"\"]").c_str());
	}
	return 0.0;
}

PLUGIN_EXPORT void Finalize(void* data)
{
	Measure* measure = (Measure*)data;
	delete measure;
}
from the Realm of Death