From 8ea01b45ae7b78cd5527f34b8cd01b5e14553035 Mon Sep 17 00:00:00 2001 From: Niraj Venkat Date: Thu, 25 Jun 2015 15:46:43 -0700 Subject: [PATCH] Word wrap implementation --- interface/resources/qml/Tooltip.qml | 105 +++++++++++++++------------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/interface/resources/qml/Tooltip.qml b/interface/resources/qml/Tooltip.qml index 43d4628063..f212bc11ea 100644 --- a/interface/resources/qml/Tooltip.qml +++ b/interface/resources/qml/Tooltip.qml @@ -1,5 +1,5 @@ import Hifi 1.0 as Hifi -import QtQuick 2.3 as Original +import QtQuick 2.4 import QtQuick.Layouts 1.1 import "controls" import "styles" @@ -7,59 +7,68 @@ import "styles" Hifi.Tooltip { id: root HifiConstants { id: hifi } - x: (lastMousePosition.x > surfaceSize.width/2) ? lastMousePosition.x - root.width : lastMousePosition.x - y: (lastMousePosition.y > surfaceSize.height/2) ? lastMousePosition.y - root.height : lastMousePosition.y - implicitWidth: border.implicitWidth - implicitHeight: border.implicitHeight + x: lastMousePosition.x + offsetX + y: lastMousePosition.y + offsetY + property int offsetX: 0 + property int offsetY: 0 + width: border.width + height: border.height - /* - Border { + Component.onCompleted: { + offsetX = (lastMousePosition.x > surfaceSize.width/2) ? -root.width : 0 + offsetY = (lastMousePosition.y > surfaceSize.height/2) ? -root.height : 0 + } + + Rectangle { id: border - anchors.fill: parent - implicitWidth: tooltipBackground.implicitWidth - //implicitHeight: Math.max(text.implicitHeight, 64) - implicitHeight: tooltipBackground.implicitHeight*/ + color: "#7f000000" + width: 322 + height: col.height + hifi.layout.spacing * 2 - Original.Rectangle { - id: border - color: "#7f000000" - implicitWidth: 322 - implicitHeight: col.height + hifi.layout.spacing * 2 - - ColumnLayout { - id: col - spacing: 5 - - Text { - id: textPlace - color: "#ffffff" - implicitWidth: 322 - //anchors.fill: parent - anchors.margins: 5 - font.pixelSize: hifi.fonts.pixelSize * 1.5 - text: root.text - wrapMode: Original.Text.WrapAnywhere + Column { + id: col + x: hifi.layout.spacing + y: hifi.layout.spacing + anchors.left: parent.left + anchors.leftMargin: hifi.layout.spacing + anchors.right: parent.right + anchors.rightMargin: hifi.layout.spacing + spacing: 5 + Text { + id: textPlace + color: "white" + anchors.left: parent.left + anchors.right: parent.right + font.pixelSize: hifi.fonts.pixelSize / 2 + text: root.text + wrapMode: Text.WrapAnywhere + + /* Uncomment for debugging to see the extent of the + Rectangle { + anchors.fill: parent + color: "#7fff00ff" } + */ + } - Original.Image { - id: tooltipPic - source: "../images/NoPictureProvided.svg" - //anchors.fill: parent - anchors.margins: 5 - } - - Text { - id: textDescription - color: "#ffffff" - implicitWidth: 322 - //anchors.fill: parent - anchors.margins: 5 - font.pixelSize: hifi.fonts.pixelSize - text: root.text - wrapMode: Original.Text.WrapAnywhere - } + Image { + id: tooltipPic + source: "../images/NoPictureProvided.svg" + anchors.left: parent.left + anchors.right: parent.right + verticalAlignment: Image.AlignVCenter + } + Text { + id: textDescription + color: "white" + width: border.implicitWidth + anchors.left: parent.left + anchors.right: parent.right + font.pixelSize: hifi.fonts.pixelSize / 2 + text: root.text + wrapMode: Text.WrapAnywhere } } - //} + } } \ No newline at end of file