Header of Layers Panel
This commit is contained in:
1 parent
2ea7dfeecd
commit
155e35b2a8
3 files changed
+80
-50
No files matched your search
+9
-46
@@ -452,57 +452,20 @@ function newLayer () {
|
||||
roundedCornersBackground(params)
|
||||
|
||||
if (label2 !== undefined) {
|
||||
drawLabel(label1, 1 / 2, 2 / 8, 16)
|
||||
drawLabel(label2, 1 / 2, 4 / 8, 16)
|
||||
drawLabel(label1, 1 / 2, 2 / 8, 16, thisObject.container)
|
||||
drawLabel(label2, 1 / 2, 4 / 8, 16, thisObject.container)
|
||||
} else {
|
||||
drawLabel(label1, 1 / 2, 3 / 8, 20)
|
||||
drawLabel(label1, 1 / 2, 3 / 8, 20, thisObject.container)
|
||||
}
|
||||
|
||||
drawLabel(label3, 1 / 2, 6 / 8, 10)
|
||||
drawLabel(label4, 1 / 2, 7 / 8, 10)
|
||||
|
||||
function drawLabel (label, xFactor, yFactor, fontSize) {
|
||||
if (label === undefined) { return }
|
||||
let xOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10
|
||||
|
||||
let labelPoint = {
|
||||
x: thisObject.container.frame.width * xFactor - xOffset / 2,
|
||||
y: thisObject.container.frame.height * yFactor
|
||||
}
|
||||
|
||||
labelPoint = thisObject.container.frame.frameThisPoint(labelPoint)
|
||||
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||
|
||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||
}
|
||||
drawLabel(label3, 1 / 2, 6 / 8, 10, thisObject.container)
|
||||
drawLabel(label4, 1 / 2, 7 / 8, 10, thisObject.container)
|
||||
|
||||
/* Images */
|
||||
|
||||
drawIcon(icon1, 1 / 8, 1 / 4)
|
||||
drawIcon(icon2, 7 / 8, 1 / 4)
|
||||
drawIcon(icon3, 1 / 8, 3 / 4)
|
||||
drawIcon(icon4, 7 / 8, 3 / 4)
|
||||
|
||||
function drawIcon (icon, xFactor, yFactor) {
|
||||
if (icon !== undefined) {
|
||||
if (icon.canDrawIcon === true) {
|
||||
let imageSize = 20
|
||||
let imagePosition = {
|
||||
x: thisObject.container.frame.width * xFactor - imageSize / 2,
|
||||
y: thisObject.container.frame.height * yFactor - imageSize / 2
|
||||
}
|
||||
|
||||
imagePosition = thisObject.container.frame.frameThisPoint(imagePosition)
|
||||
browserCanvasContext.drawImage(
|
||||
icon, imagePosition.x,
|
||||
imagePosition.y,
|
||||
imageSize,
|
||||
imageSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
drawIcon(icon1, 1 / 8, 1 / 4, 20, thisObject.container)
|
||||
drawIcon(icon2, 7 / 8, 1 / 4, 20, thisObject.container)
|
||||
drawIcon(icon3, 1 / 8, 3 / 4, 20, thisObject.container)
|
||||
drawIcon(icon4, 7 / 8, 3 / 4, 20, thisObject.container)
|
||||
}
|
||||
}
|
||||
|
||||
+36
-4
@@ -49,7 +49,7 @@ function newProductsPanel () {
|
||||
thisObject.container.name = thisObject.payload.node.name
|
||||
thisObject.container.frame.containerName = thisObject.container.name
|
||||
thisObject.container.frame.width = UI_PANEL.WIDTH.MEDIUM
|
||||
thisObject.container.frame.height = UI_PANEL.HEIGHT.LARGE // viewPort.visibleArea.bottomLeft.y - viewPort.visibleArea.topLeft.y // UI_PANEL.HEIGHT.LARGE;
|
||||
thisObject.container.frame.height = 95 * 5 + 60
|
||||
|
||||
let position = {
|
||||
x: viewPort.visibleArea.topLeft.x,
|
||||
@@ -97,7 +97,7 @@ function newProductsPanel () {
|
||||
/* Positioning within thisObject Panel */
|
||||
let position = {
|
||||
x: 0,
|
||||
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
|
||||
y: 60
|
||||
}
|
||||
|
||||
layer.container.frame.position.x = position.x
|
||||
@@ -148,7 +148,7 @@ function newProductsPanel () {
|
||||
/* Positioning within thisObject Panel */
|
||||
let position = {
|
||||
x: 0,
|
||||
y: thisObject.container.frame.height - thisObject.container.frame.getBodyHeight()
|
||||
y: 60
|
||||
}
|
||||
layer.container.frame.position.x = position.x
|
||||
layer.container.frame.position.y = position.y + layer.container.frame.height * visibleLayers.length + LAYER_SEPARATION
|
||||
@@ -292,12 +292,44 @@ function newProductsPanel () {
|
||||
function draw () {
|
||||
if (isInitialized === false) { return }
|
||||
|
||||
thisObject.container.frame.draw(false, false, false, thisObject.fitFunction)
|
||||
// thisObject.container.frame.draw(false, false, false, thisObject.fitFunction)
|
||||
|
||||
drawHeader()
|
||||
for (let i = 0; i < visibleLayers.length; i++) {
|
||||
visibleLayers[i].draw()
|
||||
}
|
||||
|
||||
panelTabButton.draw()
|
||||
}
|
||||
|
||||
function drawHeader () {
|
||||
let label1 = thisObject.payload.node.name.substring(0, 15)
|
||||
let label2 = thisObject.payload.node.payload.parentNode.name.substring(0, 15)
|
||||
let label3 = ''
|
||||
|
||||
let icon1 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.payload.parentNode.type)
|
||||
let icon2 = canvas.designerSpace.iconByUiObjectType.get(thisObject.payload.node.type)
|
||||
|
||||
let backgroundColor = UI_COLOR.BLACK
|
||||
|
||||
let params = {
|
||||
cornerRadius: 15,
|
||||
lineWidth: 2,
|
||||
container: thisObject.container,
|
||||
borderColor: UI_COLOR.RUSTED_RED,
|
||||
castShadow: false,
|
||||
backgroundColor: backgroundColor,
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
roundedCornersBackground(params)
|
||||
|
||||
drawLabel(label1, 1 / 2, 6 / 100, 10, thisObject.container)
|
||||
drawLabel(label2, 1 / 2, 9 / 100, 10, thisObject.container)
|
||||
|
||||
/* Images */
|
||||
drawIcon(icon1, 1 / 8, 6 / 100, 40, thisObject.container)
|
||||
drawIcon(icon2, 7 / 8, 6 / 100, 40, thisObject.container)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,3 +104,38 @@ function roundedCornersBackground (params) {
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + params.borderColor + ', ' + params.opacity + ')'
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
|
||||
function drawLabel (label, xFactor, yFactor, fontSize, container) {
|
||||
if (label === undefined) { return }
|
||||
let xOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10
|
||||
|
||||
let labelPoint = {
|
||||
x: container.frame.width * xFactor - xOffset / 2,
|
||||
y: container.frame.height * yFactor
|
||||
}
|
||||
|
||||
labelPoint = container.frame.frameThisPoint(labelPoint)
|
||||
|
||||
browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)'
|
||||
|
||||
browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y)
|
||||
}
|
||||
|
||||
function drawIcon (icon, xFactor, yFactor, imageSize, container) {
|
||||
if (icon !== undefined) {
|
||||
if (icon.canDrawIcon === true) {
|
||||
let imagePosition = {
|
||||
x: container.frame.width * xFactor - imageSize / 2,
|
||||
y: container.frame.height * yFactor - imageSize / 2
|
||||
}
|
||||
|
||||
imagePosition = container.frame.frameThisPoint(imagePosition)
|
||||
browserCanvasContext.drawImage(
|
||||
icon, imagePosition.x,
|
||||
imagePosition.y,
|
||||
imageSize,
|
||||
imageSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user