 Hello everyone if you follow my channel you know that I'm working on the feature of floating panels in KD Plasma and I've worked on this for like months at this point it took me way more than expected I remember asking for donations about this very thing months and months ago but now finally it's almost done and with a bit of luck it will be in the next release of Plasma 5 as I said however it was hard it was super hard and I want to explain why doing that feature was that hard so let's get into it. So how would you think of approaching this is okay you have like the monitor this is the border of the monitor and usually you have the panel but we want to make this floating okay so we could just put a margin to the left and to the bottom of the panel and it would become like this and here you get the icons and that's actually not enough at all it would be super simple to do this but it's not like that. First of all if you look closely to the panel you can see that the borders are not rounded which makes sense if you like shorten the panel they become rounded but not on the bottom if a panel is floating it should be rounded so what you have to say is okay if it's attached to the border then it shouldn't be rounded if it's floating it should be rounded and of course I do animate between the two if you click on the please float button or if you minimize a window the panel stops floating and there's an animation between not floating and floating so you do actually have to animate between the two like this what's the issue if you animate between these two you also have to animate the corners otherwise it would look weird that it goes from being not rounded to immediately rounded how can you animate between rounded corners and not rounded corners you can't you just can't I've looked everywhere and it's not possible to animate within the two which is an issue there's also another issue now what you see as the panel looks like just a panel and you think okay that's the panel that's easy however it's actually made from two different components a panel and the effects applied behind the panel as an example example blur so how this works is that you have the panel and then underneath the panel in the same exact position you have a mask for the blur and so that behind the panel you actually blur all the stuff and you don't just have that you also have the contrast effect which I've talked about in the past which is changing the colors of the background to make sure that it's prettier so if I just move the panel and that's it what's going to happen is that the mask for the blur is going to remain in the same place so the panel moves but the blur doesn't and that could look horribly wrong and that means that when the panel is floating I just have to move the mask accordingly issue the position of the mask and the position of the panel are actually managed by two different files and so I have to communicate within those files but okay I can do that that's not hard however however I also have to animate both at the same time I cannot like animate the panel that moves and then moving the mask at the same time that's just that would look weird like the panel moves and then the blur does weird I have to animate them at the same time and that's already slightly more difficult but it's not just that so when the panel is rounded the blur effect also needs to be rounded otherwise we have the corner spot so what we need to do is when the panel is attached to the border we have a blur effect that's like no square corners when it's floating it has to have rounded corners and you have to animate the mask between rounded corners and square corners when you switch between the two and as I said that's actually impossible that you can't do that and that means that is a mess so how did I actually approach this seemingly seemingly unfixable issue so what I did is I actually go to plasma and say you know what can you actually draw two panels from me so we've got the floating panel and you also have the normal panel okay so you've got both of them at this point when you switch between the two you don't actually move the panel in one and the other position because that's impossible you have to animate a lot of things that you cannot animate but you just change the opacity of the two and then you also animate the position of the floating one to make it appear as if you're actually morphing the panel when you're not you're just switching between two panels that are already there still you do have to sync the position of the mask underneath the floating panel and the mask of the panel that's stuck to the border and also you need to change the masks of the two panels because you have two panels you're going to have two masks one that's not rounded and one that is rounded so you also need to switch between the masks however whereas with panels I can actually do like opacity changes of the two panels to make it seems like you're switching from one to another the mask is just that one if you cannot give opacity to the mask blur is going to be blur regardless of where it is so you just need to switch from one to another without any animation and that would sound easy if it was however it isn't and to be completely honest with you I still haven't understood why when you change the mask it doesn't actually change so what's happening right now is that you switch to a floating panel and you still preserve the same mask of the panel that's not floating and that means that you get the corners back so currently I'm trying to implement floating panels I'm almost there but I still get corners back which is annoying now before I wrap up and explain how I actually the last issues that I'm trying to solve let me just say that if I'm able to do this because it's my free time it's only thanks to the people who actually donate to my patreon and people and everything so I really really have to say thank you for all of them because otherwise without them I wouldn't be able to have this much time to dedicate to kd so if you have some mind to spare even a couple of bucks every month that would help but anyway let me get back to my sweet panels and let me actually get in slightly more detail so let's open up the panels that sorry defies that I'm working on so I was almost done almost done until I sent the merge request and I was please asked to add an option to switch between a panel that's floating and a panel that's not floating and I thought okay that's not too hard I just have to add an option to actually check if a panel is floating or not so what I do is I've got panel code and this is like the panel we could and in here I just check if the panel configuration file as it's floating or it's not floating in it and if it's floating it sets a variable that can then be read by here which is just the appearance of the panel and the appearance of the panel actually changes the margin only if it's floating and by changing the margin it has an animation on a variable that is then read by the panel code which then takes that variable and updates it during the update mask the update mask function what is the update mask function is the function that actually draws the mask and then does the blur and the contrast effect and you do have hit here what it does it frees the property panel mask from the root object of this file and then it just draws it for the blur and the background contrast effect what I added here is also reading the properties of the margin and moving this mask depending on the margin and as the variable changes in the file with appearance it also changes here to actually move the mask that's underneath the panel that kind of works kind of the issue is of course this panel mask variable because the panel mask should be the rounded mask when it's floating and the non rounded mask when it's not floating which means that in here the panel mask should switch between non-floating and floating masks depending on whether we are floating however it is already switching between something and that something is the opaque or the translucent items because we also have adaptive transparency and what that means is that I have to switch between a translucent floating mask if it's translucent and floating a opaque floating mask if it's opaque and floating a opaque non-floating mask and a translucent non-floating depending on the floating floating as a value and the adaptive transparency value it's a mess it's a mess right so what I did is say okay if your panel is floating it has to be transparent like sorry that's how it is so if you do that it's slightly easier because now we've just got three opaque non-floating transparent non-floating and transparent floating and the floating one is the messy one so we just have that one of that so what we would do here is add a new check and say that if it's floating then always return a translucent translucent floating mask does this work kind of kind of so to summarize I'm almost done this is the issues that I've had this is why it's been so hard to make this and if you're wondering why do we even have that complexity under the hood well complex things are complex and plasma is a desktop and a desktop is not easy as an example blur and contrast effect underneath the panel being managed by a different file that's because of a variety of reasons first of all blur and contrast effect are actually completely independent on when they're used you can use blur and the contrast effect the very same ones pretty much everywhere and third party might want to use it to some plasma themes don't use it some plasma themes too so you have to be super customizable in that regard and also at the very beginning okd plasma everything was in the c++ file then qml came and it was later so everything had to be ported to a qml and it's not so easy to make sure that over time all of the code base is still makes sense complete sense so you do have to deal with a bit of weirdness in the code sometimes and for the floating panels that's what killing me right me right now sorry