[Icon Plasmoid] Provide a generic plasmoid class for icon based plasmoid

Loïc Marteau loic.marteau at gmail.com
Sun Jun 1 00:57:55 CEST 2008


Sorry i forgot the attached files....


Aaron J. Seigo wrote:
> On Saturday 31 May 2008, Loïc Marteau wrote:
>  
>> I would like to have icon plasmoid with the same default size (the same
>> as the screenshot) perhaps 75 %
>> but size should be configurable (by setting an other percentage in the
>> class ?) .
>> In the screenshot the K button is bigger than others and i think it's
>> great to can do this.
>>     
>
> i think this is really up to the Containment, in this case the Panel, 
> to provide some mechanism for varying the size of select applets. 
> perhaps something like zones of differing height.
>
> sebas and alexis have both working on graphics items groupers that 
> might be applicable in such situations.
>
>   
good :)
>> What do you think about proposing a recommended way to implement an icon
>> plasmoid ?
>>     
>
> that's probably a good idea.
>
>  
>> In fact there is still a space (too big imho) between each plasmoid. Is
>> it possible to reduce it ?
>>     
>
> the best way would be to ensure that each applet accurately reports 
> the size it needs. this can be tricky with icons because they often 
> have an unspecified amount of whitespace on their edges.
>
> having them square ensures there is a consistent spacing of them, 
> though due to the whitespace issue the apparent visual spacing may 
> vary slightly. in the end it is up to the artists to ensure a 
> reasonable centering of the image(s) that make up an icon.
>
>   
In fact there is two points
1- the most important : due to plasmoid itself :
                    - not correct size setting in the code -> i confirm 
that plasma::square is a good solution and for the moment a lot of icon  
based plasmoid  doesnt seems to use it
                    - or like you said here too because of icon with 
"portrait" format -> art issue

2- a less minor one : the constant size between each plasmoid in a 
panel. I tink that even between 2 square icon plasmoids (implemented 
with plasma:square sizeconstraint methode) the space between them is too 
high. But this is certainly subject to discussion. This don't depend 
direclty of plasmoids but certainly on the panel and probably rejoin 
what you are talking with zone containments (space on each plasmoid 
should depends on which zone we are ?!). What do you think reduce (a 
litlle) the distance between two plasmoids in the default panel settings ?
>>> in the case of the icons, we probably don't actually want to be using
>>> Plasma::Square, but just set the size policy to be minimum for the 
>>> growth
>>> direction (horizontally on horizontal panels, vertically on vertical
>>> panels)
>>>       
>> so isn't the idea to provide a generic class for them not good ?     
>
> i'm just not sure how much code would end up being saved by this, 
> since making an icon applet takes 6 lines of code: set the form factor 
> to Square, create the Plasma::Icon, create a layout, set the margins 
> and spacing to 0, add the icon to the layout.
>
> if there was a generic applet, you'd still need to define which  icon 
> by name to load, so we save 5 lines per applet. those 5 lines are not 
> exactly tricky, and i don't think they justify having another library 
> class.
>
> what we *could* do, perhaps, it add another special constructor or 
> method to Plasma::Icon that would put the icon inside a layout in the 
> applet and make applets that are a simple icon based thing use that. 
> even that's a bit drastic, but is a nicer solution imho than a whole 
> new class.
>
> also remember that some of these applets will expand to be more than 
> just an icon when moved out of a Vertical or Horizontal Containment, 
Yes i am aware of the problem and i was thinking that the majority (not 
all) of plasmoid want in final the same comportment about the adjustment 
needed with vertical or horizontal containment.

By looking the code of some of icon based plasmoid I was thinking that 
the implementation of this constraint stuff was not trivial. I attach a 
basic (trivial) iconplasmoid code based on your recommendations. Could 
you check if this is ok for you.

Perhaps the problem with this is that we dont put max size constraint 
when panel is big. I dont know if it is important. If it is, the 
solution have to be directly in plasma::square related code or can your 
proposed solution deal with this  ?

When we will found a proper solution perhaps i can start to propose 
patch to existing plasmoid ?!
showdesktop (petri already use a layout), showdashboard, trashcan, 
.desktop shortcut plasmoid, notify, new device notifier...
> and others, such as the battery which is essentially just an icon, 
> need to do extra painting themselves anyways (such as on mouse hover 
> in the case of the battery)... so the actual code savings would be 
> pretty low and getting them all consistent isn't very hard ... =)
>   
is it not possible to let the class share the icon and the child class 
add slot/signal for him, and provide setter to change the icon when he 
want ? However it's true that (for the moment) the skelet code for icon 
plasmoid with layout and plasma:square is very simple.

I'm not an expert of c++ and dont know plasma, sorry if some of my 
questions/remarks are stupid :o).

Hope this can help.

Cheers,

Loic



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CMakeLists.txt
Url: http://mail.kde.org/pipermail/panel-devel/attachments/20080601/ad78108a/attachment-0001.txt 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iconplasmoid.cpp
Type: text/x-c++src
Size: 1480 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080601/ad78108a/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iconplasmoid.h
Type: text/x-chdr
Size: 1034 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080601/ad78108a/attachment-0003.bin 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: plasma-applet-iconplasmoid.desktop
Url: http://mail.kde.org/pipermail/panel-devel/attachments/20080601/ad78108a/attachment-0001.ksh 


More information about the Panel-devel mailing list