Difference between revisions of "LatteDock"

Jump to: navigation, search
(Version 0.1 of thepage)
(Version 0.2 of the page. Included information up to the Indicators Section.)
Line 1: Line 1:
 
== Purpose of this page ==
 
== Purpose of this page ==
  
<p><strong>Technical Details</strong><br>
+
=== Technical Details ===
  
</p>This is an effort to expose some of the Latte Tricks and APIs that developers can use in order to leverage Latte Dock capabilities. Two major sections are currently provided, Applets and Indicators. In the <strong>Applets</strong> section you will understand how a Plasma QML applet can obtain information from Latte and how it can be implemented properly in order to work just fine with parabolic effect. In Indicators section you will learn how you can create your own Latte Indicators.
+
<p>This is an effort to expose some of the Latte Tricks and APIs that developers can use in order to leverage Latte Dock capabilities. Two major sections are currently provided, Applets and Indicators. In the <strong>Applets</strong> section you will understand how a Plasma QML applet can obtain information from Latte and how it can be implemented properly in order to work just fine with parabolic effect. In Indicators section you will learn how you can create your own Latte Indicators.
  
<strong>NOTE:</strong> All APIs are provided since Latte [v0.9.0] and if a new property or function is added then in that case there will be a tag mentioning when it was introduced for example [v0.9.4]
+
<strong>NOTE:</strong> All APIs are provided since Latte [v0.9.0] and if a new property or function is added then in that case there will be a tag mentioning when it was introduced for example [v0.9.4] </p>
  
 
== Applets ==  
 
== Applets ==  
Line 44: Line 44:
 
<code>readonly property bool inLatte: latteBridge !== null</code>
 
<code>readonly property bool inLatte: latteBridge !== null</code>
 
</p>
 
</p>
 +
 +
----
  
 
=== Can a plasma applet behave properly with parabolic effect? ===
 
=== Can a plasma applet behave properly with parabolic effect? ===
Line 78: Line 80:
  
 
</p>
 
</p>
 +
 +
----
  
 
=== latteBridge ===
 
=== latteBridge ===
Line 85: Line 89:
 
After the latteBridge Object has been set from Latte you can access the following.
 
After the latteBridge Object has been set from Latte you can access the following.
  
<pre>latteBrige <properties></pre>
+
<code>latteBrige <properties></code>
  
 
<code><strong>version</strong>[int] (readonly)</code>: latteBridge Version whhich is based on Latte Version.
 
<code><strong>version</strong>[int] (readonly)</code>: latteBridge Version whhich is based on Latte Version.
Line 108: Line 112:
 
</pre>
 
</pre>
  
<strong>actions</strong> [QtObject] (readonly): you can use it to pass information to Latte concerning your applet requirements. <em>This is explained in detail in the <strong>latteBridge.actions</strong> section</em>
+
<code><strong>actions</strong> [QtObject] (readonly)</code>: you can use it to pass information to Latte concerning your applet requirements. <em>This is explained in detail in the <strong>latteBridge.actions</strong> section</em>
 +
 
 +
<code><strong>pallete </strong>[SchemeColors *QtObject] (readonly)</code>: the current Latte color scheme palette used. Properties available for color scheme object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h</a>
  
<strong>pallete </strong>[SchemeColors *QtObject] (readonly): the current Latte color scheme palette used. Properties available for color scheme object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h</a>
+
<code><strong>windowsTracker</strong> [QtObject] (readonly)</code>: all windows tracking information that can be used from applets to update their contents. It is explained in detail in the <strong>latteBridge.windowsTracker section.</strong>
 +
<strong>Important:</strong>You need to enable <code>windowsTrackingEnabled</code> first though <strong>latteBridge.actions</strong> object.
  
<strong>windowsTracker</strong> [QtObject] (readonly): all windows tracking information that can be used from applets to update their contents. It is explained in detail in the <strong>latteBridge.windowsTracker section.</strong>
+
----
<strong>Important:</strong> You need to enable <code>windowsTrackingEnabled</code> first though <strong>latteBridge.actions</strong> object.
 
  
 
==== LatteBridge <signals> ====
 
==== LatteBridge <signals> ====
Line 145: Line 151:
 
}
 
}
 
</syntaxhighlight>}}
 
</syntaxhighlight>}}
 +
 +
----
  
 
==== LatteBridge <actions> ====
 
==== LatteBridge <actions> ====
Line 150: Line 158:
 
Through actions an applet can send information to Latte and other neighbour applets. The following functions can be used to accomplish this:
 
Through actions an applet can send information to Latte and other neighbour applets. The following functions can be used to accomplish this:
  
<code>setProperty(appletId, parameter, value)</code>
+
<code><strong>setProperty(appletId, parameter, value)</strong></code>
  
 
Applets can set their characteristics and demands through this function. For example when an applet wants to disable the Active Indicator in Latte Side can use:
 
Applets can set their characteristics and demands through this function. For example when an applet wants to disable the Active Indicator in Latte Side can use:
Line 158: Line 166:
 
OR when wants to disable the Latte Side Coloring that overlays the applets monochromatic in Smart Coloring mode then it can use:
 
OR when wants to disable the Latte Side Coloring that overlays the applets monochromatic in Smart Coloring mode then it can use:
  
latteBridge.actions.setProperty(plasmoid.id, “latteSideColoringEnabled”, false);
+
<code>latteBridge.actions.setProperty(plasmoid.id, “latteSideColoringEnabled”, false);</code>
 +
 
 +
<code><strong>getProperty(appletId, parameter)</strong></code>
 +
 
 +
Applets can read the current assigned characteristics through this function:
 +
 
 +
<code>var indicatorEnabled = latteBridge.actions.readProperty(plasmoid.id, “activeIndicatorEnabled”);</code>
 +
 
 +
<code><strong>broadcastToApplet(receiverPluginId, action, value)</strong></code>
 +
 
 +
Applets can communicate with other neighbour applets. For example when Window Title is informing AppMenu that needs to hide itself it sends:
 +
 
 +
<code>latteBridge.actions.broadcastToApplet(“ord.kde.windowappmenu”,”setVisible”, false);</code>
 +
 
 +
<code><strong>version(major, minor, patch)</strong></code>
 +
 
 +
It is used to produce a unique integer based on major, minor and patch versions in order to compare different versions, for example:
 +
 
 +
<code>latteBridge.version >= latteBridge.actions.makeVersion(0,9,2)</code>
 +
 
 +
----
 +
 
 +
=== latteBridge.actions <applet characteristics> ===
 +
 
 +
Applets can have different demands and characteristics that can be set and accessed through <strong>setProperty</strong> and <strong>getProperty</strong> functions.
 +
 
 +
<code><strong>activeIndicatorEnabled</strong>[bool]: false </code> means Latte will not draw any indicator for this applet, a good example being the Global Menu plasmoid.
 +
 
 +
<code><strong>latteIconOverlayEnabled</strong>[bool]: false </code> means Latte will never try to identify the central icon used in order to make this applet draw itself correctly with parabolic effect. Most applets are using PlasmaCore.IconItem in order to draw the CompactRepresentation icon when they are in a panel, but plasma iconitem does not play nice with parabolic effect. This is why Latte is trying to handle the case and take resposibility by hiding the <strong>PlasmaCore.IconItem</strong> and draw a <strong>LatteComponents.IconItem</strong> instead. If you dont want this to happen then you must this property to <code>false</code>.
 +
 
 +
<code><strong>latteSideColoringEnabled</strong> [bool]: false</code> means Latte will never overlay any color over this applet because applet takes resposibility for painting itself at all cases.
 +
 
 +
<code><strong>lengthMarginsEnabled</strong> [bool]: false</code> means means Latte will not draw any margins around this applet comparing to its neighbours. Good example is the spacer plasmoid that in panel mode does not need any extra margins around it.
 +
 
 +
means Latte will not draw any margins around this applet comparing to its neighbours. Good example is the spacer plasmoid that in panel mode does not need any extra margins around it.
 +
 
 +
<code><strong>parabolicEffectLocked</strong>[bool]: true </code> means Latte must disable parabolic effect for that specific applet.
 +
 
 +
<code><strong>windowsTrackingEnabled</strong>[bool]: true</code> means Latte must provide a, <strong>latteBridge.windowsTracker</strong> object through <strong>latteBridge</strong>
 +
 
 +
----
 +
 
 +
===latteBridge.windowsTracker===
 +
 
 +
WindowTracker provides two major objects <strong>currentScreen</strong> and <strong>allScreens</strong> in order for applets to identify correctly which windows tracking states are useful for them.
 +
 
 +
<code>latteBridge.windowsTracker.currentScreen <properties></code>
 +
 
 +
<code><strong>activeWindowMaximized</strong>[bool] (readonly): true</code> when there is an active and maximized windows in current session.
 +
 
 +
<code><strong>activeWindowTouching</strong>[bool] (readonly) : true</code> when there is an active window in current screen and that window is also touching the Latte dock/panel.
 +
 
 +
<code><strong>existsWindowActive</strong>[bool] (readonly) : true</code> when there is an active window in current screen.
 +
 
 +
<code><strong>existsWindowMaximized</strong>[bool] (readonly): true</code> when there is a maximized window in current screen independent of if this window is active or not.
 +
 
 +
<code><strong>existsWindowTouching</strong>[bool] (readonly): true</code> where there is a window in current screen that is touching the Latte dock/panel independent of if this window is active or not
 +
 
 +
<code><strong>activeWindowScheme</strong>[SchemeColors *QtObject] (readonly):</code> color scheme object for window that is touching Latte dock/panel in current screen and <code>null</code> if there is not any. Properties availble for color scheme object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h</a>
 +
 
 +
<code><strong>lastActiveWindow</strong>[LastActiveWindow *QtObject] (readonly):</code> last active window that is still present and shown in the current screen. Propertyies available for lastActiveWindow object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/tracker/lastactivewindow.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/tracker/lastactivewindow.h</a>
 +
 
 +
----
 +
 
 +
====latteBridge.windowTracker.allScreens <properties>====
 +
 
 +
<code><strong>activeWindowMaximized</strong>[bool] (readonly) : true</code> when there is an active maximized window in any screen.
 +
 
 +
<code><strong>existsWindowActive</strong>[bool] (readonly) : true</code> when there is an active window in any screen.
 +
 
 +
<code><strong>existsWindowMaximized</strong>[bool] (readonly) : true</code> when there is a maximized window in any screen independent of if this window is active or not.
 +
 
 +
<code><strong>activeWindowScheme</strong>[SchemeColors *QtObject] (readonly):</code> color scheme object for active window in any screen, and <code>null</code> if there isn't any. Properties available for color scheme object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h</a>
 +
 
 +
<code><strong>lastActiveWindow</strong></code> last active window that is still present and shown in any screen. Properties available for LastActiveWindow object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/tracker/lastactivewindow.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/tracker/lastactivewindow.h</a>
 +
 
 +
=== Applet Examples ===
 +
 
 +
<a href="https://github.com/psifidotos/applet-latte-separator">Latte Separator</a>
 +
<a href="https://github.com/psifidotos/applet-latte-spacer">Latte Spacer</a>
 +
<a href="https://github.com/psifidotos/applet-window-title">Window Title Applet</a>
 +
<a href="https://github.com/psifidotos/applet-window-buttons)">Window Buttons Applet</a>
 +
<a href="https://github.com/psifidotos/applet-window-appmenu">Window AppMenu Applet</a>
 +
 
 +
----
 +
 
 +
== Indicators ==
 +
 
 +
==== Introduction ===

Revision as of 10:06, 13 July 2019

Purpose of this page

Technical Details

This is an effort to expose some of the Latte Tricks and APIs that developers can use in order to leverage Latte Dock capabilities. Two major sections are currently provided, Applets and Indicators. In the Applets section you will understand how a Plasma QML applet can obtain information from Latte and how it can be implemented properly in order to work just fine with parabolic effect. In Indicators section you will learn how you can create your own Latte Indicators. NOTE: All APIs are provided since Latte [v0.9.0] and if a new property or function is added then in that case there will be a tag mentioning when it was introduced for example [v0.9.4]

Applets

Can a Plasma Applet access Latte Information?

Most definitely! This is very simple. The only thing you need to add in your applet main QML file is:

1 import QtQuick 2.0
2 
3 Item {
4     id: root
5 
6     //! Latte Connection
7     property QtObject latteBridge: null
8     //!
9 }

The latteBridge object is assigned from Latte when applet is loaded and it is the “ONE to rule them ALL” way to communicate with Latte. Important thing to mention is that if your applet is using both Compact and FullRepresentation(s) then the relevant code should be placed in CompactRepresentation.

 1 import QtQuick 2.0
 2 
 3 Item {
 4     id: root
 5 
 6     Plasmoid.compactRepresentation: Item {
 7         //! Latte Connection
 8         property QtObject latteBridge: null
 9         //!
10     }
11 }


After adding latteBridge property it is straightforward to identify when your applet is inside a Latte panel/dock OR in a Plasma panel with:

readonly property bool inLatte: latteBridge !== null


Can a plasma applet behave properly with parabolic effect?

Parabolic effect is not working at present when applets provide different lengths. Applets with large lengths decrease the animations speed and the applets with small lengths increase it. The best way for parabolic effect to work is for all applets to provide a squared layout that does not update its content positioning when zoomed. In order to make things easy for developers Latte can provide you with the best layout to achieve this without needing from you to make any calculations. To do this, you need to set it up as such:

 1 import QtQuick 2.0
 2 
 3 import org.kde.plasma.plasmoid 2.0
 4 
 5 Item {
 6     id: root
 7 
 8     Layout.minimumWidth: inLatte && isHorizontal  ? -1 : [plasma case]
 9     Layout.preferredWidth: inLatte && isHorizontal  ? -1 : [plasma case]
10     Layout.maximumWidth: inLatte && isHorizontal  ? -1 : [plasma case]
11 
12     Layout.minimumHeight: inLatte && !isHorizontal  ? -1 : [plasma case]
13     Layout.preferredHeight: inLatte && !isHorizontal  ? -1 : [plasma case]
14     Layout.maximumHeight: inLatte && !isHorizontal  ? -1 : [plasma case]
15 
16     readonly property bool isHorizontal: plasmoid.formFactor === PlasmaCore.Types.Horizontal
17 
18     //! Latte Connection
19     property QtObject latteBridge: null
20     readonly property bool inLatte: latteBridge !== null
21     //!
22 }

In the above example you can see that when the applet is not providing any information for its Layout [-1 case] then Latte has the freedom to set it in the best appropriate


latteBridge

latteBridge <properties>

After the latteBridge Object has been set from Latte you can access the following.

latteBrige <properties>

version[int] (readonly): latteBridge Version whhich is based on Latte Version. For example, Latte 0.9.0 produces a unique integer that can be used for numeric comparisons for greater than, lower than etc. If you want to make a version comparison, you can try the following in your code. latteBridge.version >= latteBridge.actions.makeVersion(0,9,2)

applyPalette [bool] (readonly) : true when latte is advising the applet to use the Latte colors palette in order to draw its contents with proper contrast

inEditMode[bool] (readonly): true when Latte behaves as a Plasma Panel concerning external shadow rendering, transparency levels, etc.

parabolicEffectEnabled[bool] (readonly): true when Latte Parabolid Effect is enabled.

iconSize[int] (readonly): the current icon size used for all appletsin the containment this applet is present

maxZoomFactor[real] (readonly): the current zoom factor with values from 1.0 to 2.0

1 – no zoom
1.2 – zoom for 20%
2 – zoom for 100%

actions [QtObject] (readonly): you can use it to pass information to Latte concerning your applet requirements. This is explained in detail in the latteBridge.actions section

pallete [SchemeColors *QtObject] (readonly): the current Latte color scheme palette used. Properties available for color scheme object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h</a>

windowsTracker [QtObject] (readonly): all windows tracking information that can be used from applets to update their contents. It is explained in detail in the latteBridge.windowsTracker section. Important:You need to enable windowsTrackingEnabled first though latteBridge.actions object.


LatteBridge <signals>

broadcasted(string action, variant value)

Applets in Latte can create their own protocols in order to communicate with other applets. When such signal is received it means that some applet is requesting from you to make “action” with parameter “value” . A good example for this are the Window Title and Window AppMenu applets. These applets need to communicate with each other in order to hide or show themselves in Unity Mode. Window Title is shown when there is no mouse hovering and Window AppMenu when there is one. All this is orchestrated through applets without Latte taking any responsibility except broadcasting the requested actions only to the correct receivers. How applets are sending such actions through latteBridge.actions is explained better at the relevant section. If you want to track this signal you can use:

 1 import QtQuick 2.0
 2 
 3 Item {
 4     id: root
 5 
 6     //! Latte Connection
 7     property QtObject latteBridge: null
 8     readonly property bool inLatte: latteBridge !== null
 9     //!
10 
11     Connections {
12         target: latteBridge
13         onBroadcasted: {
14             if (action === "actionname1") {
15                 //! your code here
16             } else if (action === "actionname2") {
17                 //! your code here
18             }
19         }
20     }
21 
22 }

LatteBridge <actions>

Through actions an applet can send information to Latte and other neighbour applets. The following functions can be used to accomplish this:

setProperty(appletId, parameter, value)

Applets can set their characteristics and demands through this function. For example when an applet wants to disable the Active Indicator in Latte Side can use:

latteBridge.actions.setProperty(plasmoid.id, “activeIndicatorEnabled”, false);

OR when wants to disable the Latte Side Coloring that overlays the applets monochromatic in Smart Coloring mode then it can use:

latteBridge.actions.setProperty(plasmoid.id, “latteSideColoringEnabled”, false);

getProperty(appletId, parameter)

Applets can read the current assigned characteristics through this function:

var indicatorEnabled = latteBridge.actions.readProperty(plasmoid.id, “activeIndicatorEnabled”);

broadcastToApplet(receiverPluginId, action, value)

Applets can communicate with other neighbour applets. For example when Window Title is informing AppMenu that needs to hide itself it sends:

latteBridge.actions.broadcastToApplet(“ord.kde.windowappmenu”,”setVisible”, false);

version(major, minor, patch)

It is used to produce a unique integer based on major, minor and patch versions in order to compare different versions, for example:

latteBridge.version >= latteBridge.actions.makeVersion(0,9,2)


latteBridge.actions <applet characteristics>

Applets can have different demands and characteristics that can be set and accessed through setProperty and getProperty functions.

activeIndicatorEnabled[bool]: false means Latte will not draw any indicator for this applet, a good example being the Global Menu plasmoid.

latteIconOverlayEnabled[bool]: false means Latte will never try to identify the central icon used in order to make this applet draw itself correctly with parabolic effect. Most applets are using PlasmaCore.IconItem in order to draw the CompactRepresentation icon when they are in a panel, but plasma iconitem does not play nice with parabolic effect. This is why Latte is trying to handle the case and take resposibility by hiding the PlasmaCore.IconItem and draw a LatteComponents.IconItem instead. If you dont want this to happen then you must this property to false.

latteSideColoringEnabled [bool]: false means Latte will never overlay any color over this applet because applet takes resposibility for painting itself at all cases.

lengthMarginsEnabled [bool]: false means means Latte will not draw any margins around this applet comparing to its neighbours. Good example is the spacer plasmoid that in panel mode does not need any extra margins around it.

means Latte will not draw any margins around this applet comparing to its neighbours. Good example is the spacer plasmoid that in panel mode does not need any extra margins around it.

parabolicEffectLocked[bool]: true means Latte must disable parabolic effect for that specific applet.

windowsTrackingEnabled[bool]: true means Latte must provide a, latteBridge.windowsTracker object through latteBridge


latteBridge.windowsTracker

WindowTracker provides two major objects currentScreen and allScreens in order for applets to identify correctly which windows tracking states are useful for them.

latteBridge.windowsTracker.currentScreen <properties>

activeWindowMaximized[bool] (readonly): true when there is an active and maximized windows in current session.

activeWindowTouching[bool] (readonly) : true when there is an active window in current screen and that window is also touching the Latte dock/panel.

existsWindowActive[bool] (readonly) : true when there is an active window in current screen.

existsWindowMaximized[bool] (readonly): true when there is a maximized window in current screen independent of if this window is active or not.

existsWindowTouching[bool] (readonly): true where there is a window in current screen that is touching the Latte dock/panel independent of if this window is active or not

activeWindowScheme[SchemeColors *QtObject] (readonly): color scheme object for window that is touching Latte dock/panel in current screen and null if there is not any. Properties availble for color scheme object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h</a>

lastActiveWindow[LastActiveWindow *QtObject] (readonly): last active window that is still present and shown in the current screen. Propertyies available for lastActiveWindow object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/tracker/lastactivewindow.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/tracker/lastactivewindow.h</a>


latteBridge.windowTracker.allScreens <properties>

activeWindowMaximized[bool] (readonly) : true when there is an active maximized window in any screen.

existsWindowActive[bool] (readonly) : true when there is an active window in any screen.

existsWindowMaximized[bool] (readonly) : true when there is a maximized window in any screen independent of if this window is active or not.

activeWindowScheme[SchemeColors *QtObject] (readonly): color scheme object for active window in any screen, and null if there isn't any. Properties available for color scheme object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/schemecolors.h</a>

lastActiveWindow last active window that is still present and shown in any screen. Properties available for LastActiveWindow object are provided through <a href="https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/tracker/lastactivewindow.h">https://phabricator.kde.org/source/latte-dock/browse/master/app/wm/tracker/lastactivewindow.h</a>

Applet Examples

<a href="https://github.com/psifidotos/applet-latte-separator">Latte Separator</a> <a href="https://github.com/psifidotos/applet-latte-spacer">Latte Spacer</a> <a href="https://github.com/psifidotos/applet-window-title">Window Title Applet</a> <a href="https://github.com/psifidotos/applet-window-buttons)">Window Buttons Applet</a> <a href="https://github.com/psifidotos/applet-window-appmenu">Window AppMenu Applet</a>


Indicators

= Introduction


Content is available under Creative Commons License SA 4.0 unless otherwise noted.