Commit 72aea819 authored by Marco Martin's avatar Marco Martin

Merge branch 'tab-visuals' into 'master'

Improved padding anotation.

See merge request websites/hig-kde-org!2
parents f3eccfef 2c93d102
......@@ -49,7 +49,6 @@ Item {
font.pointSize: 8
lineHeight: 8
height: 8
}
}
......@@ -100,8 +99,8 @@ Item {
}
dim.text = aspect
prot.visible = true;
prot.x = cItem.x + item.width / 2 - prot.width / 2
prot.y = cItem.y + item.height / 2 - prot.height / 2
prot.x = Math.round(cItem.x + item.width / 2 - prot.width / 2)
prot.y = Math.round(cItem.y + item.height / 2 - prot.height / 2)
}
else {
......@@ -109,8 +108,8 @@ Item {
if (container.label) {
dim.text = Math.round(item.width * 100) / 100 + " x " + Math.round(item.height * 100) / 100;
prot.visible = true;
prot.x = cItem.x + item.width / 2 - prot.width / 2
prot.y = cItem.y + item.height / 2 - prot.height / 2
prot.x = Math.round(cItem.x + item.width / 2 - prot.width / 2)
prot.y = Math.round(cItem.y + item.height / 2 - prot.height / 2)
}
}
......
......@@ -28,7 +28,7 @@ Item {
property bool label: false
property Item item
property Item root : container.parent
property string padding: ""
property var padding: []
z: 10
id: container
......@@ -71,13 +71,31 @@ Item {
onPaint: {
// Determen padding
var padding = {
"top": item.topPadding,
"right": item.rightPadding,
"bottom": item.bottomPadding,
"left": item.leftPadding
var padding;
if (typeof container.padding === "number") {
padding = {
"top": container.padding,
"right": container.padding,
"bottom": container.padding,
"left": container.padding
}
}
else if (Array.isArray(container.padding) && container.padding.length == 4) {
padding = {
"top": container.padding[0],
"right": container.padding[1],
"bottom": container.padding[2],
"left": container.padding[3]
}
}
else {
padding = {
"top": item.topPadding,
"right": item.rightPadding,
"bottom": item.bottomPadding,
"left": item.leftPadding
}
}
// setup drawing context
var offset;
var cItem = item.mapToItem(container.root, 0, 0);
......@@ -111,19 +129,19 @@ Item {
// Write labels
top.text = padding.top;
top.x = cItem.x + item.width / 2;
top.y = cItem.y - 4;
top.y = cItem.y - 4 - padding.top / 2;
right.text = padding.right;
right.x = cItem.x + item.width - right.width;
right.y = cItem.y + item.height / 2;
right.x = cItem.x + item.width - right.width + padding.right / 2;
right.y = cItem.y + item.height / 2 - right.height;
bottom.text = padding.bottom;
bottom.x = cItem.x + item.width / 2;
bottom.y = cItem.y + item.height - bottom.height - 4;
bottom.y = cItem.y + item.height - bottom.height - 4 + padding.bottom / 2;
left.text = padding.left;
left.x = cItem.x;
left.y = cItem.x + item.height / 2;
left.x = cItem.x - padding.left / 2;
left.y = cItem.x + item.height / 2 - left.height;
}
}
......
......@@ -94,7 +94,6 @@ Item {
anchors.rightMargin: base
color: "#da4453"
font.pixelSize: 10
renderType: Text.QtRendering
}
Row {
......
......@@ -268,7 +268,10 @@ An.prototype._draw = function(node, type, opt) {
ruler.createObject(root, options);
break
case "padding":
padding.createObject(root, {item: node});
var options = getOpts({
padding: opt.padding
}, opt);
padding.createObject(root, {item: node, padding: options.padding});
break
case "brace":
brace.createObject(root, {"from": node, "to": opt.to.nodes[0], "text": opt.text, "center": opt.center, "horizontal": opt.horizontal});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment