Zren / material-decoration

Material-ish window decoration theme for KWin, with LIM, based on zzag's original design.
GNU General Public License v2.0
197 stars 17 forks source link

[applet window buttons] - support kdecoration2 standalone button creation #7

Closed psifidotos closed 4 years ago

psifidotos commented 4 years ago

Currently that theme does not support independent buttons drawing through KDecoration2 so Window Buttons Applet is not drawing anything. This is achieved through: https://github.com/KDE/breeze/blob/master/kdecoration/breezebutton.h#L48

Zren commented 4 years ago

Ah, looks like I gotta move this function to be a static function. this can be replaced by casting the unused decoration.

Zren commented 4 years ago

How does it know to use namespace Breeze { static Button::create }?

I tried moving buttonCreator to a static function (static Decoration::createButton), but it doesn't seem to work.

psifidotos commented 4 years ago

I suppose from: https://github.com/KDE/breeze/blob/master/kdecoration/breezedecoration.cpp#L60

Zren commented 4 years ago

Thanks, I'm on the right track.

Had to also create an explicit CommonButton(QObject *parent, const QVariantList &args) contructor.

Breeze doesn't use m_flag = FlagStandalone, but it does use m_iconSize = QSize(-1, -1) to set the iconSize to m_iconSize = geometry().size().toSize() when painting.

I've managed to get buttons in applet-window-buttons, and the hover effect is visible. I just need to correctly paint the icons.

2020-04-20___17-44-03

psifidotos commented 4 years ago

nice!! ;) window buttons everywhere!!! :) I liked your decoration a lot! Only issue is that in my computer with very high resolution 2560x1440 the window titlebar is really really thin and I can not grow it a bit.

Zren commented 4 years ago

Uhg... the reason why there's no icon, is because it's a CommonButton instance. It doesn't use CommonButton::create(), that's for ButtonGroup. registerPlugin only uses CommonButton(QObject parent, QVariantList args) to create instances.

So Close/Maximize/Minimize need to have their logic moved out of the descendent classes into CommonButton like Breeze. No wonder Breeze only has 1 button class.

registerPlugin has a CreateInstanceFunction argument, but I've seen no examples I could use.

https://api.kde.org/frameworks/kcoreaddons/html/classKPluginFactory.html#ac6e27887213999995c98716f530f5fcd

Zren commented 4 years ago

I've managed to get it working. I'll be moving the fg+bg color logic into CommonButton, then using a switch to call static functions for init and paintIcon so that buttons are still broken up into different files.

2020-04-21___16-26-51

Zren commented 4 years ago

Finished OnAllDesktop and KeepAbove, so the Window Buttons widget should work now.

psifidotos commented 4 years ago

Nice! Really nice to have new implementation for others to follow up. Do you have any idea how it would be the best way for buttons to provide width/height ratio? I can add it as a user setting in the applet but I would prefer a more automatic way.