Added the splitratio dispatcher

This commit is contained in:
vaxerski 2022-04-20 16:53:41 +02:00
parent 418e2d96ae
commit 87b8491294
7 changed files with 95 additions and 26 deletions

View file

@ -778,4 +778,17 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
// recalc the workspace
getMasterNodeOnWorkspace(PNODE->workspaceID)->recalcSizePosRecursive();
}
void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
// window should be valid, insallah
const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE || !PNODE->pParent)
return;
PNODE->pParent->splitRatio = std::clamp(PNODE->pParent->splitRatio + ratio, 0.1f, 1.9f);
PNODE->pParent->recalcSizePosRecursive();
}

View file

@ -51,7 +51,8 @@ public:
virtual void toggleWindowGroup(CWindow*);
virtual void switchGroupWindow(CWindow*);
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
virtual void switchWindows(CWindow*, CWindow*);
virtual void switchWindows(CWindow*, CWindow*);
virtual void alterSplitRatioBy(CWindow*, float);
private:

View file

@ -90,4 +90,10 @@ public:
The layout is free to ignore.
*/
virtual void switchWindows(CWindow*, CWindow*) = 0;
/*
Called when the user requests to change the splitratio by X
on a window
*/
virtual void alterSplitRatioBy(CWindow*, float) = 0;
};