Hi,

After review of the proposed on-screen help display window for the Wacom plug-in in GNOME settings daemon (aka OSD), the GNOME design team came back with some requirements that need an enhancement in the layouts definitions.

Basically, what's required is a caption indicator, i.e. a line that goes from the button itself to its label so that there is a visual link between the two.

As I reckon all placing/drawing/rendering should come from the layout, that means we need to amend the proposed definition to add those captions to the layout data (given that the layouts can be fairly complex, this needs to be done in the SVG rather than computed).

The following patch does this:

  - Adds the caption indicator definition
- Adds the caption indicators to the two existing layouts (namely Cintiq 12WX and Intuos5 M)
  - Modifies the check to very the presence of the caption indicators
- Improves the renderer example to show the trip/ring actions and all the captions (Screenshots [1] and [2])

Cheers,
Olivier.

[1] http://people.redhat.com/ofourdan/libwacom/misc/Cintiq-12WX-layout-viewer.png [2] http://people.redhat.com/ofourdan/libwacom/misc/Intuos5-M-layout-viewer.png


>From 920b8cdeaf6c7db904a5ba689f11fef431f155b9 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <ofour...@redhat.com>
Date: Tue, 27 Nov 2012 09:52:42 +0100
Subject: [PATCH] data: Add caption indicators to layouts

To match the buttons with their corresponding labels, the
layout SVG must also provide a caption indicator for each
label in the form of a line that links each button and its
label.

Improves the layout SVG for the Cintiq 12WX and Intuos 5 M
by adding details and rounded buttons to match the look of
the real device.

Buttons, labels and indicators are now grouped in the SVG
layout for better clarity of the SVG.

Adds indicators to the SVG check test so that incomplete
layouts would be detected.

Improves the SVG layout display sample program to show
touch ring/touch strips labels and label indocators.

Signed-off-by: Olivier Fourdan <ofour...@redhat.com>
---
 data/layouts/README          |  55 ++++++++++++++
 data/layouts/cintiq-12wx.svg | 116 ++++++++++++++++++++++-------
 data/layouts/intuos5-m.svg   |  81 ++++++++++++++------
 test/tablet-svg-validity.c   |  19 +++++
 tools/show-svg-image.c       | 174 +++++++++++++++++++++++++------------------
 5 files changed, 323 insertions(+), 122 deletions(-)

diff --git a/data/layouts/README b/data/layouts/README
index 37b644d..570de38 100644
--- a/data/layouts/README
+++ b/data/layouts/README
@@ -71,6 +71,7 @@ Each button's label ID in the SVG is made of the string "Label" with ID of the
 button to which it applies, between 'A' and 'Z'.
 
 Class includes both the button ID and the string "Label".
+
     id="LabelA"
     class="A Label"
 
@@ -122,3 +123,57 @@ Second touch-strip:
 
     id="LabelRingDown"
     class="Strip2Down Strip2 Label"
+
+ - Caption indicators
+
+To match the buttons with their corresponding labels, the SVG must also provide
+a caption indicator for each label in the form of a line that links each button
+and its label.
+
+Each caption indicator follows the same naming convention as the labels, using
+the special name "Indicator" in place of "Label", ie:
+
+    id="IndicatorA"
+    class="A Indicator"
+
+Touch-rings and touch-strips have 2 different labels and therefore 2 indicators.
+
+    id="IndicatorRingUp"
+    class="RingUp Ring Indicator"
+
+  and
+
+    id="IndicatorRingDown"
+    class="RingDown Ring Indicator"
+
+The second touch-ring button is identified by "Ring2" in place of "Ring":
+
+    id="IndicatorRing2Up"
+    class="Ring2Up Ring2 Indicator"
+
+  and
+
+    id="IndicatorRingDown"
+    class="Ring2Down Ring2 Indicator"
+
+Touchstrips button follow the same naming scheme, using "Strip" and "Strip2"
+to name the first and second touch-strip.
+
+    id="IndicatorStripUp"
+    class="StripUp Strip Indicator"
+
+  and
+
+    id="IndicatorStripDown"
+    class="StripDown Strip Indicator"
+
+Second touch-strip:
+
+    id="IndicatorStrip2Up"
+    class="Strip2Up Strip2 Indicator"
+
+  and
+
+    id="IndicatorRingDown"
+    class="Strip2Down Strip2 Indicator"
+
diff --git a/data/layouts/cintiq-12wx.svg b/data/layouts/cintiq-12wx.svg
index 370283d..ef23c63 100644
--- a/data/layouts/cintiq-12wx.svg
+++ b/data/layouts/cintiq-12wx.svg
@@ -3,32 +3,92 @@
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>
 <svg xmlns="http://www.w3.org/2000/svg"; version="1.1"
      style="color:#000000;stroke:#bebebe;fill:#000000;stroke-linejoin:round;stroke-width:1;font-size:8"
-         id="cintiq-12wx"                                                     width="405" height="270" >
-  <title id="title"                                                                                    >Wacom Cintiq 12WX</title>
-  <rect  id="ButtonA"         class="A Button"                x="40"  y="54"  width="11"  height="17" />
-  <text  id="LabelA"          class="A Label"                 x="60"  y="63"                           >A</text>
-  <rect  id="ButtonB"         class="B Button"                x="40"  y="72"  width="11"  height="17" />
-  <text  id="LabelB"          class="B Label"                 x="60"  y="81"                           >B</text>
-  <rect  id="ButtonC"         class="C Button"                x="28"  y="54"  width="11"  height="35" />
-  <text  id="LabelC"          class="C Label"                 x="60"  y="72"                           >C</text>
-  <rect  id="ButtonD"         class="D Button"                x="28"  y="90"  width="23"  height="11" />
-  <text  id="LabelD"          class="D Label"                 x="60"  y="96"                           >D</text>
-  <rect  id="ButtonE"         class="E Button"                x="352" y="54"  width="11"  height="17" />
-  <text  id="LabelE"          class="E Label"                 x="342" y="63"                           >E</text>
-  <rect  id="ButtonF"         class="F Button"                x="352" y="72"  width="11"  height="17" />
-  <text  id="LabelF"          class="F Label"                 x="342" y="81"                           >F</text>
-  <rect  id="ButtonG"         class="G Button"                x="364" y="54"  width="11"  height="35" />
-  <text  id="LabelG"          class="G Label"                 x="342" y="72"                           >G</text>
-  <rect  id="ButtonH"         class="H Button"                x="352" y="90"  width="23"  height="11" />
-  <text  id="LabelH"          class="H Label"                 x="342" y="96"                           >H</text>
-  <rect  id="ButtonI"         class="I Button"                x="28"  y="42"  width="23"  height="11" />
-  <text  id="LabelI"          class="I Label"                 x="60"  y="51"                           >I</text>
-  <rect  id="ButtonJ"         class="J Button"                x="352" y="42"  width="23"  height="11" />
-  <text  id="LabelJ"          class="J Label"                 x="342" y="51"                           >J</text>
-  <rect  id="Strip"           class="Strip TouchStrip"        x="10"  y="41"  width="12"  height="60" />
-  <text  id="LabelStripUp"    class="StripUp Strip Label"     x="16"  y="30"                           >Up</text>
-  <text  id="LabelStripDown"  class="StripDown Strip Label"   x="16"  y="110"                          >Down</text>
-  <rect  id="Strip2"          class="Strip2 TouchStrip"       x="382" y="41"  width="12"  height="60" />
-  <text  id="LabelStrip2Up"   class="Strip2Up Strip2 Label"   x="388" y="30"                           >Up</text>
-  <text  id="LabelStrip2Down" class="Strip2Down Strip2 Label" x="388" y="110"                          >Down</text>
+         id="cintiq-12wx"                                                                   width="405" height="270"            >
+  <title id="title"                                                                                                             >Wacom Cintiq 12WX</title>
+  <g>
+    <rect  id="ButtonA"            class="A Button"     rx=".5" ry=".5" x="40"     y="54"   width="11"  height="17"            />
+    <path  id="IndicatorA"         class="A Indicator"                  d="M 53 63 L 65 63 L 65 72 L 78 72"                    />
+    <text  id="LabelA"             class="A Label"                      x="80"     y="72"                                       >A</text>
+  </g>
+  <g>
+    <rect   id="ButtonB"           class="B Button"     rx=".5" ry=".5" x="40"     y="72"   width="11"  height="17"             />
+    <circle id="DotB1"                                                 cx="45.5"  cy="77.5" r=".5"                              />
+    <circle id="DotB2"                                                 cx="45.5"  cy="80.5" r=".5"                              />
+    <circle id="DotB3"                                                 cx="45.5"  cy="83.5" r=".5"                              />
+    <path   id="IndicatorB"        class="B Indicator"                  d="M 53 81 L 65 81 L 65 87 L 78 87"                     />
+    <text   id="LabelB"            class="B Label"                      x="80"     y="87"                                        >B</text>
+  </g>
+  <g>
+    <rect   id="ButtonC"           class="C Button"                     x="28"     y="54"
+                                                                       rx=".5"    ry=".5"   width="11"  height="35"              />
+    <path   id="IndicatorC"        class="C Indicator"                  d="M 26 72 L 25 72 L 25 35 L 65 35 L 65 42 L 78 42     " />
+    <text   id="LabelC"            class="C Label"                      x="80"     y="42"                                         >C</text>
+  </g>
+  <g>
+    <rect   id="ButtonD"           class="D Button"                     x="28"     y="90"
+                                                                       rx=".5"    ry=".5"   width="23"  height="11"              />
+    <path   id="IndicatorD"        class="D Indicator"                  d="M 53 96 L 65 96 L 65 102 L 78 102"                    />
+    <text   id="LabelD"            class="D Label"                      x="80"     y="102"                                        >D</text>
+  </g>
+  <g>
+    <rect   id="ButtonE"           class="E Button"                     x="352"    y="54"
+                                                                       rx=".5"    ry=".5"   width="11"  height="17"              />
+    <path  id="IndicatorE"         class="E Indicator"                  d="M 350 63 L 338 63 L 338 72 L 324 72"                  />
+    <text   id="LabelE"            class="E Label"                      x="322"    y="72"                                         >E</text>
+  </g>
+  <g>
+    <rect   id="ButtonF"           class="F Button"                     x="352"    y="72"
+                                                                       rx=".5"    ry=".5"   width="11"  height="17"              />
+    <circle id="DotF1"                                                 cx="357.5" cy="77.5" r=".5"                               />
+    <circle id="DotF2"                                                 cx="357.5" cy="80.5" r=".5"                               />
+    <circle id="DotF3"                                                 cx="357.5" cy="83.5" r=".5"                               />
+    <path   id="IndicatorF"        class="F Indicator"                  d="M 350 81 L 338 81 L 338 87 L 324 87"                  />
+    <text   id="LabelF"            class="F Label"                      x="322"    y="87"                                         >F</text>
+  </g>
+  <g>
+    <rect   id="ButtonG"           class="G Button"                     x="364"    y="54"
+                                                                       rx=".5"    ry=".5"   width="11"  height="35"               />
+    <path   id="IndicatorG"        class="G Indicator"                  d="M 377 72 L 378 72 L 378 35 L 338 35 L 338 42 L 324 42" />
+    <text   id="LabelG"            class="G Label"                      x="322"    y="42"                                          >G</text>
+  </g>
+  <g>
+    <rect   id="ButtonH"            class="H Button"                    x="352"    y="90"
+                                                                       rx=".5"    ry=".5"   width="23"  height="11"               />
+    <path   id="IndicatorH"         class="H Indicator"                 d="M 350 96 L 338 96 L 338 102 L 324 102"                 />
+    <text   id="LabelH"             class="H Label"                     x="322"    y="102"                                         >H</text>
+  </g>
+  <g>
+    <rect   id="ButtonI"            class="I Button"                    x="28"     y="42"
+                                                                       rx=".5"    ry=".5"   width="23"  height="11"               />
+    <circle id="DotI1"                                                 cx="36.5"  cy="47.5" r=".5"                                />
+    <circle id="DotI2"                                                 cx="39.5"  cy="47.5" r=".5"                                />
+    <circle id="DotI3"                                                 cx="42.5"  cy="47.5" r=".5"                                />
+    <path   id="IndicatorI"         class="I Indicator"                 d="M 53 48 L 65 48 L 65 57 L 78 57"                       />
+    <text   id="LabelI"             class="I Label"                     x="80"     y="57"                                          >I</text>
+  </g>
+  <g>
+    <rect  id="ButtonJ"             class="J Button"                    x="352"    y="42"
+                                                                       rx=".5"    ry=".5"   width="23"  height="11"               />
+    <circle id="DotJ1"                                                 cx="360.5" cy="47.5" r=".5"                                />
+    <circle id="DotJ2"                                                 cx="363.5" cy="47.5" r=".5"                                />
+    <circle id="DotJ3"                                                 cx="366.5" cy="47.5" r=".5"                                />
+    <path   id="IndicatorJ"         class="J Indicator"                 d="M 350 48 L 338 48 L 338 57 L 324 57"                   />
+    <text   id="LabelJ"             class="J Label"                     x="322"    y="57"                                          >J</text>
+  </g>
+  <g>
+    <rect  id="Strip"               class="Strip TouchStrip"            x="10"     y="41"
+                                                                       rx="1"     ry="1"    width="12"  height="60"               />
+    <path  id="IndicatorStripUp"    class="StripUp Strip Indicator"     d="M 16 39 L 16 27 L 78 27"                               />
+    <text  id="LabelStripUp"        class="StripUp Strip Label"         x="80"     y="27"                                          >Up</text>
+    <path  id="IndicatorStripDown"  class="StripDown Strip Indicator"   d="M 16 103 L 16 117 L 78 117"                            />
+    <text  id="LabelStripDown"      class="StripDown Strip Label"       x="80"     y="117"                                         >Down</text>
+  </g>
+  <g>
+    <rect  id="Strip2"              class="Strip2 TouchStrip"           x="382"    y="41"
+                                                                       rx="1"     ry="1"    width="12"  height="60"               />
+    <path  id="IndicatorStrip2Up"   class="Strip2Up Strip2 Indicator"   d="M 388 39 L 388 27 L 325 27"                            />
+    <text  id="LabelStrip2Up"       class="Strip2Up Strip2 Label"       x="322"    y="27"                                          >Up</text>
+    <path  id="IndicatorStrip2Down" class="Strip2Down Strip2 Indicator" d="M 388 103 L 388 117 L 325 117"                         />
+    <text  id="LabelStrip2Down"     class="Strip2Down Strip2 Label"     x="322"    y="117"                                         >Down</text>
+  </g>
 </svg>
diff --git a/data/layouts/intuos5-m.svg b/data/layouts/intuos5-m.svg
index 748959f..5783eb3 100644
--- a/data/layouts/intuos5-m.svg
+++ b/data/layouts/intuos5-m.svg
@@ -3,27 +3,62 @@
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>
 <svg xmlns="http://www.w3.org/2000/svg"; version="1.1"
      style="color:#000000;stroke:#bebebe;fill:#f0f0f0;stroke-linejoin:round;stroke-width:1;font-size:8"
-          id="intuos5-m"                                                  width="380" height="250">
-  <title  id="title"                                                                              >Wacom Intuos5 M Touch</title>
-  <rect   id="ButtonB"       class="B Button"             x="24"  y="40"  width="20" height="12" />
-  <text   id="LabelB"        class="B Label"              x="50"  y="46"                          >A</text>
-  <rect   id="ButtonC"       class="C Button"             x="24"  y="54"  width="20" height="12" />
-  <text   id="LabelC"        class="C Label"              x="50"  y="60"                          >B</text>
-  <rect   id="ButtonD"       class="D Button"             x="24"  y="68"  width="20" height="12" />
-  <text   id="LabelD"        class="D Label"              x="50"  y="74"                          >C</text>
-  <rect   id="ButtonE"       class="E Button"             x="24"  y="82"  width="20" height="12" />
-  <text   id="LabelE"        class="E Label"              x="50"  y="88"                          >D</text>
-  <rect   id="ButtonF"       class="F Button"             x="24"  y="156" width="20" height="12" />
-  <text   id="LabelF"        class="F Label"              x="50"  y="162"                         >E</text>
-  <rect   id="ButtonG"       class="G Button"             x="24"  y="170" width="20" height="12" />
-  <text   id="LabelG"        class="G Label"              x="50"  y="176"                         >F</text>
-  <rect   id="ButtonH"       class="H Button"             x="24"  y="184" width="20" height="12" />
-  <text   id="LabelH"        class="H Label"              x="50"  y="190"                         >G</text>
-  <rect   id="ButtonI"       class="I Button"             x="24"  y="198" width="20" height="12" />
-  <text   id="LabelI"        class="I Label"              x="50"  y="206"                         >H</text>
-  <circle id="Ring"          class="Ring TouchRing"      cx="34" cy="125" r="19.5"               />
-  <text   id="LabelRingUp"   class="RingUp Ring Label"    x="60"  y="105"                         >Up</text>
-  <text   id="LabelRingDown" class="RingDown Ring Label"  x="60"  y="145"                         >Down</text>
-  <circle id="ButtonA"       class="A ModeSwitch Button" cx="34" cy="125" r="9.5"                />
-  <text   id="LabelA"        class="A ModeSwitch Label"   x="60"  y="125"                         >I</text>
+          id="intuos5-m"                                                                       width="380" height="250" >
+  <title  id="title"                                                                                                    >Wacom Intuos5 M Touch</title>
+  <g>
+    <rect   id="ButtonB"           class="B Button"            rx="2" ry="2"     x="24"  y="40"    width="20"  height="12" />
+    <path   id="IndicatorB"        class="B Indicator"                           d="M 46 46 L 50 46"                       />
+    <text   id="LabelB"            class="B Label"                               x="52"  y="46"                             >A</text>
+  </g>
+  <g>
+    <rect   id="ButtonC"           class="C Button"            rx="2"  ry="2"    x="24"  y="54"    width="20"  height="12" />
+    <rect   id="DotC1"                                         rx="1"  ry="1"    x="30"  y="59.5"  width="8"   height="1"  />
+    <path   id="IndicatorC"        class="C Indicator"                           d="M 46 60 L 50 60"                       />
+    <text   id="LabelC"            class="C Label"                               x="52"  y="60"                             >B</text>
+  </g>
+  <g>
+    <rect   id="ButtonD"           class="D Button"            rx="2"  ry="2"    x="24"  y="68"    width="20"  height="12" />
+    <circle id="DotD1"                                                          cx="34" cy="74"    r=".75"                 />
+    <path   id="IndicatorD"        class="D Indicator"                           d="M 46 74 L 50 74"                       />
+    <text   id="LabelD"            class="D Label"                               x="52"  y="74"                             >C</text>
+  </g>
+  <g>
+    <rect   id="ButtonE"           class="E Button"            rx="2"  ry="2"    x="24"  y="82"    width="20"  height="12" />
+    <path   id="IndicatorE"        class="E Indicator"                           d="M 46 88 L 50 88"                       />
+    <text   id="LabelE"            class="E Label"                               x="52"  y="88"                             >D</text>
+  </g>
+  <g>
+    <rect   id="ButtonF"           class="F Button"            rx="2"  ry="2"    x="24"  y="156"   width="20"  height="12" />
+    <path   id="IndicatorF"        class="F Indicator"                           d="M 46 162 L 50 162"                       />
+    <text   id="LabelF"            class="F Label"                               x="52"  y="162"                            >E</text>
+  </g>
+  <g>
+    <rect   id="ButtonG"           class="G Button"            rx="2"  ry="2"    x="24"  y="170"   width="20"  height="12" />
+    <circle id="DotG1"                                                          cx="34" cy="176"   r=".75"                 />
+    <path   id="IndicatorG"        class="G Indicator"                           d="M 46 176 L 50 176"                     />
+    <text   id="LabelG"            class="G Label"                               x="52"  y="176"                            >F</text>
+  </g>
+  <g>
+    <rect   id="ButtonH"           class="H Button"            rx="2"  ry="2"    x="24"  y="184"   width="20"  height="12" />
+    <rect   id="DotH1"                                         rx="1"  ry="1"    x="30"  y="189.5" width="8"   height="1"  />
+    <path   id="IndicatorH"        class="H Indicator"                           d="M 46 190 L 50 190"                     />
+    <text   id="LabelH"            class="H Label"                               x="52"  y="190"                            >G</text>
+  </g>
+  <g>
+    <rect   id="ButtonI"           class="I Button"            rx="2"  ry="2"    x="24"  y="198"   width="20"  height="12" />
+    <path   id="IndicatorI"        class="I Indicator"                           d="M 46 206 L 50 206"                     />
+    <text   id="LabelI"            class="I Label"                               x="52"  y="206"                            >H</text>
+  </g>
+  <g>
+    <circle id="Ring"              class="Ring TouchRing"                       cx="34" cy="125"   r="19.5"                />
+    <path   id="IndicatorRingUp"   class="RingUp Ring Indicator"                 d="M 34 105 L 34 103 L 60 103"            />
+    <text   id="LabelRingUp"       class="RingUp Ring Label"                     x="62"  y="103"                            >Up</text>
+    <path   id="IndicatorRingDown" class="RingDown Ring Indicator"               d="M 34 145 L 34 147 L 60 147"            />
+    <text   id="LabelRingDown"     class="RingDown Ring Label"                   x="62"  y="147"                            >Down</text>
+  </g>
+  <g>
+    <circle id="ButtonA"           class="A ModeSwitch Button"                  cx="34" cy="125" r="9.5"                   />
+    <path   id="IndicatorA"        class="A ModeSwitch Indicator"                d="M 56 125 L 60 125"                     />
+    <text   id="LabelA"            class="A ModeSwitch Label"                    x="62"  y="125"                            >I</text>
+  </g>
 </svg>
diff --git a/test/tablet-svg-validity.c b/test/tablet-svg-validity.c
index 0dca5a4..3987772 100644
--- a/test/tablet-svg-validity.c
+++ b/test/tablet-svg-validity.c
@@ -157,6 +157,24 @@ check_touch (xmlNodePtr cur, gchar *id, gchar *type)
 	class = g_strdup_printf ("%sDown %s Label", id, id);
 	verify_has_class (node, class);
 	g_free (class);
+
+	sub = g_strdup_printf ("Indicator%sUp", id);
+	node = verify_has_sub (cur, sub);
+	g_assert (node != NULL);
+	g_free (sub);
+
+	class = g_strdup_printf ("%sUp %s Indicator", id, id);
+	verify_has_class (node, class);
+	g_free (class);
+
+	sub = g_strdup_printf ("Indicator%sDown", id);
+	node = verify_has_sub (cur, sub);
+	g_assert (node != NULL);
+	g_free (sub);
+
+	class = g_strdup_printf ("%sDown %s Indicator", id, id);
+	verify_has_class (node, class);
+	g_free (class);
 }
 
 static void
@@ -203,6 +221,7 @@ verify_tablet_layout (WacomDeviceDatabase *db, WacomDevice *device)
 	for (button = 'A'; button < 'A' + num_buttons; button++) {
 		check_button (cur, device, button, "Button");
 		check_button (cur, device, button, "Label");
+		check_button (cur, device, button, "Indicator");
 	}
 
 	/* Touch rings */
diff --git a/tools/show-svg-image.c b/tools/show-svg-image.c
index 01a7b13..d1efe33 100644
--- a/tools/show-svg-image.c
+++ b/tools/show-svg-image.c
@@ -37,10 +37,10 @@
 #include "libwacom.h"
 
 
-#define INACTIVE_COLOR		"#2d2d2d"
-#define ACTIVE_COLOR		"#ffffff"
-#define STROKE_COLOR		"#b4b4b4"
-#define DARK_COLOR		"#141414"
+#define INACTIVE_COLOR		"#ededed"
+#define ACTIVE_COLOR		"#729fcf"
+#define STROKE_COLOR		"#000000"
+#define DARK_COLOR		"#535353"
 #define BACK_COLOR		"#000000"
 
 /* Convenient struct to store our stuff around */
@@ -100,76 +100,96 @@ get_sub_location (cairo_t *cairo_context, RsvgHandle *handle, const char *sub, d
 }
 
 static void
-print_button_labels (cairo_t *cairo_context, Tablet *tablet)
+print_label (cairo_t *cairo_context, Tablet *tablet, const char *sub, const char *markup, WacomButtonFlags flags)
 {
-	char button;
-	GtkWidget *widget;
-	GtkAllocation allocation;
+	GtkWidget        *widget;
+	GtkAllocation     allocation;
+	GtkStyle         *style;
+	PangoContext     *pango_context;
+	PangoLayout      *pango_layout;
+	PangoRectangle    pango_rect;
+	double            label_x, label_y;
+	int               x, y;
+
+	if (!get_sub_location (cairo_context, tablet->handle, sub, &label_x, &label_y, NULL, NULL))
+		return;
 
 	widget = GTK_WIDGET(tablet->widget);
 	gtk_widget_get_allocation(widget, &allocation);
+	style = gtk_widget_get_style (widget);
+	pango_context = gtk_widget_get_pango_context (widget);
+	pango_layout  = pango_layout_new (pango_context);
+
+	pango_layout_set_markup (pango_layout, markup, -1);
+	pango_layout_get_pixel_extents (pango_layout, NULL, &pango_rect);
+
+	if (flags & WACOM_BUTTON_POSITION_LEFT) {
+		pango_layout_set_alignment (pango_layout, PANGO_ALIGN_LEFT);
+		x = (int) label_x + pango_rect.x;
+		y = (int) label_y + pango_rect.y - pango_rect.height / 2;
+	} else if (flags & WACOM_BUTTON_POSITION_RIGHT) {
+		pango_layout_set_alignment (pango_layout, PANGO_ALIGN_RIGHT);
+		x = (int) label_x + pango_rect.x - pango_rect.width;
+		y = (int) label_y + pango_rect.y - pango_rect.height / 2;
+	} else {
+		pango_layout_set_alignment (pango_layout, PANGO_ALIGN_CENTER);
+		x = (int) label_x + pango_rect.x - pango_rect.width / 2;
+		y = (int) label_y + pango_rect.y;
+	}
+
+	gtk_paint_layout (style,
+		          gtk_widget_get_window (widget),
+		          0,
+		          TRUE,
+			  &allocation,
+		          widget,
+		          NULL,
+		          x,
+		          y,
+		          pango_layout);
+
+	g_object_unref (pango_layout);
+}
+
+static void
+print_button_labels (cairo_t *cairo_context, Tablet *tablet)
+{
+	char button;
 
 	for (button = 'A'; button < 'A' + tablet->num_buttons; button++) {
 		WacomButtonFlags  flags;
-		GtkStyle        *style;
-		PangoContext     *pango_context;
-		PangoLayout      *pango_layout;
-		PangoRectangle    pango_rect;
-		double            label_x, label_y;
-		int               x, y;
 		gchar            *sub;
-		gchar            *markup;
+		gchar            *label;
 
 		flags = libwacom_get_button_flag(tablet->device, button);
 		sub = g_strdup_printf ("#Label%c", button);
-		if (!get_sub_location (cairo_context, tablet->handle, sub, &label_x, &label_y, NULL, NULL)) {
-			g_warning ("Failed to retrieve %s position", sub);
-			goto next;
-		}
-
-		/* Write the label */
-		style = gtk_widget_get_style (widget);
-		pango_context = gtk_widget_get_pango_context (widget);
-		pango_layout  = pango_layout_new (pango_context);
 		if (button == tablet->active_button)
-			markup = g_strdup_printf ("<span foreground=\"" ACTIVE_COLOR "\" weight=\"bold\">Button %c</span>", button);
+			label = g_strdup_printf ("<span foreground=\"" ACTIVE_COLOR "\" >Button %c</span>", button);
 		else
-			markup = g_strdup_printf ("<span foreground=\"" INACTIVE_COLOR "\" weight=\"bold\">Button %c</span>", button);
-		pango_layout_set_markup (pango_layout, markup, -1);
-		g_free (markup);
-
-		pango_layout_get_pixel_extents (pango_layout, NULL, &pango_rect);
-
-		if (flags & WACOM_BUTTON_POSITION_LEFT) {
-			pango_layout_set_alignment (pango_layout, PANGO_ALIGN_LEFT);
-			x = (int) label_x;
-			y = (int) label_y + pango_rect.height / 2;
-		} else if (flags & WACOM_BUTTON_POSITION_RIGHT) {
-			pango_layout_set_alignment (pango_layout, PANGO_ALIGN_RIGHT);
-			x = (int) label_x - pango_rect.width;
-			y = (int) label_y + pango_rect.height / 2;
-
-		} else {
-			pango_layout_set_alignment (pango_layout, PANGO_ALIGN_CENTER);
-			x = (int) label_x - pango_rect.width / 2;
-			y = (int) label_y;
-		}
-
-		gtk_paint_layout (style,
-			          gtk_widget_get_window (widget),
-			          0,
-			          TRUE,
-				  &allocation,
-			          widget,
-			          NULL,
-			          x,
-			          y,
-			          pango_layout);
-
-		g_object_unref (pango_layout);
-next:
+			label = g_strdup_printf ("<span foreground=\"" INACTIVE_COLOR "\" >Button %c</span>", button);
+		print_label (cairo_context, tablet, sub, label, flags);
+		g_free (label);
 		g_free (sub);
 	}
+
+	/* Touch rings */
+	if (libwacom_has_ring(tablet->device)) {
+		print_label (cairo_context, tablet, "#LabelRingUp", "<span foreground=\"" INACTIVE_COLOR "\" >Ring Up</span>", WACOM_BUTTON_POSITION_LEFT);
+		print_label (cairo_context, tablet, "#LabelRingDown", "<span foreground=\"" INACTIVE_COLOR "\" >Ring Down</span>", WACOM_BUTTON_POSITION_LEFT);
+	}
+	if (libwacom_has_ring2(tablet->device)) {
+		print_label (cairo_context, tablet, "#LabelRing2Up", "<span foreground=\"" INACTIVE_COLOR "\" >2nd Ring Up</span>", WACOM_BUTTON_POSITION_RIGHT);
+		print_label (cairo_context, tablet, "#LabelRing2Down", "<span foreground=\"" INACTIVE_COLOR "\" >2nd Ring Down</span>", WACOM_BUTTON_POSITION_RIGHT);
+	}
+	/* Touch strips */
+	if (libwacom_get_num_strips(tablet->device) > 0) {
+		print_label (cairo_context, tablet, "#LabelStripUp", "<span foreground=\"" INACTIVE_COLOR "\" >Strip Up</span>", WACOM_BUTTON_POSITION_LEFT);
+		print_label (cairo_context, tablet, "#LabelStripDown", "<span foreground=\"" INACTIVE_COLOR "\" >Strip Down</span>", WACOM_BUTTON_POSITION_LEFT);
+	}
+	if (libwacom_get_num_strips(tablet->device) > 1) {
+		print_label (cairo_context, tablet, "#LabelStrip2Up", "<span foreground=\"" INACTIVE_COLOR "\" >2nd Strip Up</span>", WACOM_BUTTON_POSITION_RIGHT);
+		print_label (cairo_context, tablet, "#LabelStrip2Down", "<span foreground=\"" INACTIVE_COLOR "\" >2nd Strip Down</span>", WACOM_BUTTON_POSITION_RIGHT);
+	}
 }
 
 static void
@@ -192,10 +212,16 @@ update_tablet (Tablet *tablet)
 	                    "     xmlns:xi=\"http://www.w3.org/2001/XInclude\"\n";
 	                    "     width=\"", width, "\"\n"
 	                    "     height=\"", height, "\">\n"
-	                    "  <style type=\"text/css\">\n"
-	                    "    * {\n"
-	                    "      stroke: ", STROKE_COLOR," !important;\n"
-	                    "      fill:   ", INACTIVE_COLOR," !important;\n"
+	                    "  <style type=\"text/css\">\n",
+	                    "    .Indicator {\n"
+	                    "      stroke-width: .5 !important;\n"
+	                    "      stroke: ", INACTIVE_COLOR, ";\n"
+	                    "      fill:    none !important;\n"
+	                    "    }\n",
+	                    "    .Button {\n"
+	                    "      stroke-width: 0.25;\n"
+	                    "      stroke: ", INACTIVE_COLOR, ";\n"
+	                    "      fill:   ", INACTIVE_COLOR, ";\n"
 	                    "    }\n",
 	                    NULL);
 	g_free (width);
@@ -206,25 +232,31 @@ update_tablet (Tablet *tablet)
 		if (button == tablet->active_button) {
 			data = g_strconcat (data,
 			                    "    .", class, " {\n"
-			                    "      stroke: ", STROKE_COLOR," !important;\n"
-			                    "      fill:   ", button == tablet->active_button ? ACTIVE_COLOR : INACTIVE_COLOR, " !important;\n"
+			                    "      stroke: ", ACTIVE_COLOR, " !important;\n"
+			                    "      fill:   ", ACTIVE_COLOR, " !important;\n"
 			                    "    }\n",
 			                    NULL);
 	    }
 	}
 
-	/* Hide the existing labels */
 	data = g_strconcat (data,
+	                    "    .Indicator {\n"
+	                    "      fill:    none !important;\n"
+	                    "    }\n",
 	                    "    .Label {\n"
-	                    "      stroke: none !important;\n"
-	                    "      fill:   ", BACK_COLOR, "  !important;\n"
+	                    "      stroke: none      !important;\n"
+	                    "      stroke-width: 0.1 !important;\n"
+	                    "      opacity:   .0     !important;\n"
+	                    "      font-size: .1     !important;\n"
+	                    "      fill:   ", BACK_COLOR,    " !important;\n"
 	                    "    }\n",
 	                    "    .TouchStrip,.TouchRing {\n"
+	                    "      stroke-width: 0.1   !important;\n"
 	                    "      stroke: ", INACTIVE_COLOR," !important;\n"
-	                    "      fill:   ", DARK_COLOR, "  !important;\n"
+	                    "      fill:   ", DARK_COLOR,    " !important;\n"
 	                    "    }\n",
 	                    "  </style>\n"
-	                    "  <xi:include href=\"", libwacom_get_layout_filename (tablet->device), "\"/>\n"
+	                    "  <xi:include href=\"",  libwacom_get_layout_filename (tablet->device), "\"/>\n"
 	                    "</svg>",
 	                    NULL);
 
@@ -371,7 +403,7 @@ main (int argc, char **argv)
 
 	g_signal_connect (tablet->widget, "expose-event", G_CALLBACK(on_expose_cb), tablet);
 	g_signal_connect (tablet->widget, "delete-event", G_CALLBACK(on_delete_cb), tablet);
-	tablet->timeout = g_timeout_add(500 /* ms */, (GSourceFunc) on_timer_cb, tablet);
+	tablet->timeout = g_timeout_add(750 /* ms */, (GSourceFunc) on_timer_cb, tablet);
 
 	gtk_widget_show (tablet->widget);
 
-- 
1.8.0


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to