Hi guys
Inspired by @scottyp scripting school, I’ve decided to finally dive into Qt documentation and @Kapyia and @slightlyangrydodo’s plugin (which is a treasure full of complex scripting tricks - thank you guys).
For those who don’t like to read long texts, here is a short feature showcase video:
Add-on can be downloaded from Github. And for those who like to read, here is a full description I wrote on github:
kritaSubwindowOrganizer
Krita plugin that helps keep order of subwindows.
Requirement:
‘subwindow’ mode is enabled, instead of the default ‘tabs’.
Can be configured in Settings > Configure Krita... > General > Window > Multiple Document Mode.
Installation:
Get the krita resources folder location: “Settings > Manage Resources > Open Resource Folder”.
in ‘pykrita’ folder, put downloaded ‘pykrita’ contents.
in ‘actions’ folder, put downloaded ‘actions’ contents.
New actions are on the bottom of “View” menu. Keyboard shortcuts can be changed in settings.
Features:
responsive subwindows: never get larger than workspace. Adjusts to krita window resize, dockers resize, toggle fullscreen and canvas-only modes.
automatic maximize: always toggled when amount of subwindows changes to one.
open as floating windows: all newly created subwindows open as ‘always on top’ and hover over the canvas.
“split screen” mode (default): second subwindow (main reference image) adjusts its size to fit in the space remained by the first one (painting canvas).
“one window” mode: all views are floaters but the canvas
snap floaters to borders: floaters can’t go out of the workspace borders, which would cause it to create sliders.
maximize: can maximize one window, without “always on top” windows appearing.
User actions:
Toggle split screen: View > Split screen(ctrl+alt+n)
Switches between two modes.
turn ON: the active subwindow is being taken as a reference image (random when main canvas selected).
turn OFF: reference image becomes a floating window
-Organizing action: View > Pick subwindow(ctrl+alt+m)
Gives the ability to switch subwindows with each other. Uses active subwindow.
“split screen” mode:
-when the ‘floater’ is activated, make it a ‘main reference’. (switching between multiple reference images)
-when the ‘canvas’ or the ‘main reference’ is activated, they take each others place. (gives the ability to change the main drawing canvas)
“one window” mode:
-when the ‘floater’ is activated, open it in main canvas (which becomes a floater)
-when the ‘canvas’ is activated, the tool is idle
maximize (override): when one window is maximized by the user, all the rest are not visible, even when the “always on top” is toggled
minimize (override): only floating windows can get minimized
Known issues:
pressing minimize on maximized window makes it impossible to demaximize (such document have to be saved and closed)
after going from maximize to normal, split screen looses minimal width for both windows (one can take whole space if krita window is shrinked a lot)
not working in “tabs” mode - currently won’t install in this case and will put a message box, but still this mode can be turned on during add-on work.
minimized window won’t be automatically put in the background, if the background one gets closed.
To be done:
remove title bar for the background windows and replacing them with a custom widget (maximize and close) as the minimize is idle, and they can’t be moved apart from resizing width
ability to toggle the whole add-on without closing krita - will solve the tabs mode issue.
Main task: integrate my “reference tracking canvas” script. When this mode is enabled, panning, rotating and mirroring the canvas, would cause the reference image to do the same. Current script don’t apply pan and runs on keyboard action, but the canvas could be continuously tracked.
I never leave subwindows mode, and dreamt of fixing those small issues for a while.
Yeah, I already promised to add some add-ons, and never did - but this one is definately the most advanced and I’ll really want it to be there. I’ll just have to work on it for a while to make sure I already fixed all those ‘crushing’ bugs
And by the way, how adding the brush presets to resource page looks like? I’ve seen that apart from the links, some kind of header image is needed there - do one need to clone and push those changes into the repository, or it’s not that different, than adding the plugins there?
You need to fork it first, and then if you’re not easily scared by elaborate GUI, just add a new branch in your fork, add the picture, change the page to show your picture and link to your bundle, and then submit a MR.
Thank you - the UI redesign code helped me a lot, showing how to get deeper into krita objects: mainly intercept events.
The code is a mess right now :D, and I’ll probably have to organize it before I start working on it again. I really hope I’ll be able to get into canvas variables in those views: pan, scale, rotation and mirror…
You’re welcome! I hope you’ll find it useful (I must admit that after a week of development, it’s the first day for me that I can actually use it, and I was just adjusting the views a lot just for the pleasure of it Well spend time).
Funny how I was inspired by blender behavior, and thought about the exact thing. Technically there shouldn’t be that hard to get all those features - opening another view of the same document if the moved edge was on the border of workspace, closing views when width or height gets to 0 (but this can cause problems with accidentally closing artwork - in blender you have only one document so it’s ok).
But I’ve come to conclusion that I just don’t want to write that It feels like a over complicating the problem - when drawing you usually just use one canvas, may want to open some additional reference images or canvas overview, but having so many views don’t feel that necessary for me - what works for blender doesn’t have to work here - then there will be problems with opening new images, as you would have to create a view and then assign it to the view, while now you just open it.
But if somebody wants to do that, feel free to experiment with this code. I think it’s possible to do, and I can help with explaining how to do it.
I would rather expand it to allow move reference/overview subwindows in the column on left. Currently there is zero (one window mode) or one (split screen), but it would make sense to be allowed to customize it to be a different number, dividing this column into two or three views (of course as new views are opened - it just makes the floaters start to appear with more views). This is much easier to get with what I have, but once again I’m not sure it’s that needed in 2D painting (I’m personally ok with just two of those in split screen).
But I would like to know how much needed is ability to have this column on the right, for left handed people (don’t matter so much now, but in the future I want the canvas and reference have a bit different behavior) and customizing the split to be vertical instead of horizontal.
I used it when I was finishing a comic page. It works like a charm so far. to start, it makes closing multiple windows easier after exiting Full Canvas mode because the subwindows are now positioned in a way that’s not beyond Krita’s boundary.
I know - it was way more advanced than any krita script I wrote so far. But just in case anyone would like to try to understand it, here is the main idea:
using qwin = window.qwindow() in createActions I can get the access to the krita window. Then qwin.mdiArea() gives the workspace where all the subwindows are stored, and qwin.mdiArea().subwindowList() stores all the actual subwindows. Whenever any of these gets changed (closed, moved or resized) they send an event.
But I create something called eventFilter, which would intercept those events before they reach their destination. It just have to be installed to the object (subwindow or mdiArea) with object.installEventFilter(filter).
In the event filter I can write any code (like moving the subwindow to other position that the user dragged it into), or even prevent the object from doing this action (return true would hold the event, not allowing it to reach its destination)
1.1.0 feature update is here!
From now I will only distribute the addon via Github, so that the link stays the same, and I can easily modify the code.
You probably missed two recent bugfix releases so here is a whole changelog from 1.0.0:
Features:
drag and drop backgrounder into floater or another backgrounder to swap them
go into split-mode by dragging a floater to left or right border of the screen
go into one-window mode by dragging reference window download
reference can now be displayed on the left or right part of the screen
floaters stick to the borders if the krita window gets bigger
Bugfixes:
crash on using multiple krita windows
pressing minimize on maximized window makes it impossible to demaximize (such document have to be saved and closed)
minimized window won’t be automatically put in the background, if the background one gets closed.
opening new window don’t work when background window is maximized (split mode)
I still need to make it all switchable, so that you can easily switch between tabs and subwindows mode. It would be awesome if the add-on could be shipped with krita someday (great responsibility, but I want to make it once the add-on really gets userproof). I would also have to prevent the user from using “always on top”, “tile” and “cascade”, and fix the remaining bugs before that. (there is a one crash on going out the split mode with ‘drag and drop’ that is very hard to reproduce, if someone manages to get the step by step instructions for making it happen, I would be grateful)
By the way link to the addon, as well as my brushes got merged into official krita resources page a week ago, though the site haven’t updated since then But I hope that it will be available there soon.
Awesome Plugin
Great main task, would be awesome if you achieve this.
Main task: integrate my “reference tracking canvas” script. When this mode is enabled, panning, rotating and mirroring the canvas, would cause the reference image to do the same. Current script don’t apply pan and runs on keyboard action, but the canvas could be continuously tracked.
On iOS I’m using iArtbookPro wich does exactly this and it’s a great way learn drawing/painting.
Ow, it seems there is always someone who had the same idea before
Currently I haven’t tried to get to those values in qt, but as I did this drag and drop operations, I believe I should start working on that somewhere soon wish me luck
Ok, so I sit down to it, and now I can be quite sure we’re not getting this feature
It found the objects that seems to be responsible for those kind of manipulations (KisCanvasController and KoCanvasControllerWidget). The first one is directly available in python under name canvas, but the latter is not, even with those new ways I learned about. There is no way I can do it with scripting until I get the access to those functions and events.
All I can possibly get with what I have is just applying rotation, scale and mirror (no pan) to the reference on a keyboard action. Could even do it automatically well, so I guess it won’t be included in the final version at all.