Improve rendering of overlapping blocks, add click regions [#21]
This commit is contained in:
parent
82a2c1a219
commit
05d5f56db1
|
@ -3263,7 +3263,6 @@ define('sequence/components/BaseComponent',[],() => {
|
||||||
topY,
|
topY,
|
||||||
primaryY,
|
primaryY,
|
||||||
blockLayer,
|
blockLayer,
|
||||||
sectionLayer,
|
|
||||||
shapeLayer,
|
shapeLayer,
|
||||||
labelLayer,
|
labelLayer,
|
||||||
theme,
|
theme,
|
||||||
|
@ -3341,12 +3340,13 @@ define('sequence/components/Block',[
|
||||||
const config = env.theme.block;
|
const config = env.theme.block;
|
||||||
const agentInfoL = env.agentInfos.get(left);
|
const agentInfoL = env.agentInfos.get(left);
|
||||||
const agentInfoR = env.agentInfos.get(right);
|
const agentInfoR = env.agentInfos.get(right);
|
||||||
|
const {hold} = env.state.blocks.get(left);
|
||||||
|
|
||||||
let y = env.primaryY;
|
let y = env.primaryY;
|
||||||
|
|
||||||
if(!first) {
|
if(!first) {
|
||||||
y += config.section.padding.bottom;
|
y += config.section.padding.bottom;
|
||||||
env.sectionLayer.appendChild(svg.make('line', Object.assign({
|
hold.appendChild(svg.make('line', Object.assign({
|
||||||
'x1': agentInfoL.x,
|
'x1': agentInfoL.x,
|
||||||
'y1': y,
|
'y1': y,
|
||||||
'x2': agentInfoR.x,
|
'x2': agentInfoR.x,
|
||||||
|
@ -3354,14 +3354,16 @@ define('sequence/components/Block',[
|
||||||
}, config.separator.attrs)));
|
}, config.separator.attrs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clickable = env.makeRegion();
|
||||||
|
|
||||||
const modeRender = SVGShapes.renderBoxedText(mode, {
|
const modeRender = SVGShapes.renderBoxedText(mode, {
|
||||||
x: agentInfoL.x,
|
x: agentInfoL.x,
|
||||||
y,
|
y,
|
||||||
padding: config.section.mode.padding,
|
padding: config.section.mode.padding,
|
||||||
boxAttrs: config.section.mode.boxAttrs,
|
boxAttrs: config.section.mode.boxAttrs,
|
||||||
labelAttrs: config.section.mode.labelAttrs,
|
labelAttrs: config.section.mode.labelAttrs,
|
||||||
boxLayer: env.blockLayer,
|
boxLayer: hold,
|
||||||
labelLayer: env.labelLayer,
|
labelLayer: clickable,
|
||||||
SVGTextBlockClass: env.SVGTextBlockClass,
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3372,14 +3374,21 @@ define('sequence/components/Block',[
|
||||||
boxAttrs: {'fill': '#000000'},
|
boxAttrs: {'fill': '#000000'},
|
||||||
labelAttrs: config.section.label.labelAttrs,
|
labelAttrs: config.section.label.labelAttrs,
|
||||||
boxLayer: env.maskLayer,
|
boxLayer: env.maskLayer,
|
||||||
labelLayer: env.labelLayer,
|
labelLayer: clickable,
|
||||||
SVGTextBlockClass: env.SVGTextBlockClass,
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
||||||
});
|
});
|
||||||
|
|
||||||
return y + (
|
const labelHeight = Math.max(modeRender.height, labelRender.height);
|
||||||
Math.max(modeRender.height, labelRender.height) +
|
|
||||||
config.section.padding.top
|
clickable.insertBefore(svg.make('rect', {
|
||||||
);
|
'x': agentInfoL.x,
|
||||||
|
'y': y,
|
||||||
|
'width': agentInfoR.x - agentInfoL.x,
|
||||||
|
'height': labelHeight,
|
||||||
|
'fill': 'transparent',
|
||||||
|
}), clickable.firstChild);
|
||||||
|
|
||||||
|
return y + labelHeight + config.section.padding.top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3405,10 +3414,15 @@ define('sequence/components/Block',[
|
||||||
}
|
}
|
||||||
|
|
||||||
render(stage, env) {
|
render(stage, env) {
|
||||||
|
const hold = svg.make('g');
|
||||||
|
env.blockLayer.appendChild(hold);
|
||||||
|
|
||||||
env.state.blocks.set(stage.left, {
|
env.state.blocks.set(stage.left, {
|
||||||
|
hold,
|
||||||
mode: stage.mode,
|
mode: stage.mode,
|
||||||
startY: env.primaryY,
|
startY: env.primaryY,
|
||||||
});
|
});
|
||||||
|
|
||||||
return super.render(stage, env, true);
|
return super.render(stage, env, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3428,12 +3442,11 @@ define('sequence/components/Block',[
|
||||||
render({left, right}, env) {
|
render({left, right}, env) {
|
||||||
const config = env.theme.block;
|
const config = env.theme.block;
|
||||||
|
|
||||||
const {startY, mode} = env.state.blocks.get(left);
|
|
||||||
|
|
||||||
const agentInfoL = env.agentInfos.get(left);
|
const agentInfoL = env.agentInfos.get(left);
|
||||||
const agentInfoR = env.agentInfos.get(right);
|
const agentInfoR = env.agentInfos.get(right);
|
||||||
|
const {hold, startY, mode} = env.state.blocks.get(left);
|
||||||
const configMode = config.modes[mode] || config.modes[''];
|
const configMode = config.modes[mode] || config.modes[''];
|
||||||
env.blockLayer.appendChild(svg.make('rect', Object.assign({
|
hold.appendChild(svg.make('rect', Object.assign({
|
||||||
'x': agentInfoL.x,
|
'x': agentInfoL.x,
|
||||||
'y': startY,
|
'y': startY,
|
||||||
'width': agentInfoR.x - agentInfoL.x,
|
'width': agentInfoR.x - agentInfoL.x,
|
||||||
|
@ -4741,13 +4754,11 @@ define('sequence/Renderer',[
|
||||||
'mask': 'url(#' + this.namespace + 'LineMask)',
|
'mask': 'url(#' + this.namespace + 'LineMask)',
|
||||||
});
|
});
|
||||||
this.blocks = svg.make('g');
|
this.blocks = svg.make('g');
|
||||||
this.sections = svg.make('g');
|
|
||||||
this.actionShapes = svg.make('g');
|
this.actionShapes = svg.make('g');
|
||||||
this.actionLabels = svg.make('g');
|
this.actionLabels = svg.make('g');
|
||||||
this.base.appendChild(this.defs);
|
this.base.appendChild(this.defs);
|
||||||
this.base.appendChild(this.agentLines);
|
this.base.appendChild(this.agentLines);
|
||||||
this.base.appendChild(this.blocks);
|
this.base.appendChild(this.blocks);
|
||||||
this.base.appendChild(this.sections);
|
|
||||||
this.base.appendChild(this.actionShapes);
|
this.base.appendChild(this.actionShapes);
|
||||||
this.base.appendChild(this.actionLabels);
|
this.base.appendChild(this.actionLabels);
|
||||||
this.title = new this.SVGTextBlockClass(this.base);
|
this.title = new this.SVGTextBlockClass(this.base);
|
||||||
|
@ -4944,7 +4955,6 @@ define('sequence/Renderer',[
|
||||||
topY,
|
topY,
|
||||||
primaryY: topY + topShift,
|
primaryY: topY + topShift,
|
||||||
blockLayer: this.blocks,
|
blockLayer: this.blocks,
|
||||||
sectionLayer: this.sections,
|
|
||||||
shapeLayer: this.actionShapes,
|
shapeLayer: this.actionShapes,
|
||||||
labelLayer: this.actionLabels,
|
labelLayer: this.actionLabels,
|
||||||
maskLayer: this.mask,
|
maskLayer: this.mask,
|
||||||
|
@ -5065,7 +5075,6 @@ define('sequence/Renderer',[
|
||||||
svg.empty(this.mask);
|
svg.empty(this.mask);
|
||||||
svg.empty(this.agentLines);
|
svg.empty(this.agentLines);
|
||||||
svg.empty(this.blocks);
|
svg.empty(this.blocks);
|
||||||
svg.empty(this.sections);
|
|
||||||
svg.empty(this.actionShapes);
|
svg.empty(this.actionShapes);
|
||||||
svg.empty(this.actionLabels);
|
svg.empty(this.actionLabels);
|
||||||
this.mask.appendChild(this.maskReveal);
|
this.mask.appendChild(this.maskReveal);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -115,13 +115,11 @@ define([
|
||||||
'mask': 'url(#' + this.namespace + 'LineMask)',
|
'mask': 'url(#' + this.namespace + 'LineMask)',
|
||||||
});
|
});
|
||||||
this.blocks = svg.make('g');
|
this.blocks = svg.make('g');
|
||||||
this.sections = svg.make('g');
|
|
||||||
this.actionShapes = svg.make('g');
|
this.actionShapes = svg.make('g');
|
||||||
this.actionLabels = svg.make('g');
|
this.actionLabels = svg.make('g');
|
||||||
this.base.appendChild(this.defs);
|
this.base.appendChild(this.defs);
|
||||||
this.base.appendChild(this.agentLines);
|
this.base.appendChild(this.agentLines);
|
||||||
this.base.appendChild(this.blocks);
|
this.base.appendChild(this.blocks);
|
||||||
this.base.appendChild(this.sections);
|
|
||||||
this.base.appendChild(this.actionShapes);
|
this.base.appendChild(this.actionShapes);
|
||||||
this.base.appendChild(this.actionLabels);
|
this.base.appendChild(this.actionLabels);
|
||||||
this.title = new this.SVGTextBlockClass(this.base);
|
this.title = new this.SVGTextBlockClass(this.base);
|
||||||
|
@ -318,7 +316,6 @@ define([
|
||||||
topY,
|
topY,
|
||||||
primaryY: topY + topShift,
|
primaryY: topY + topShift,
|
||||||
blockLayer: this.blocks,
|
blockLayer: this.blocks,
|
||||||
sectionLayer: this.sections,
|
|
||||||
shapeLayer: this.actionShapes,
|
shapeLayer: this.actionShapes,
|
||||||
labelLayer: this.actionLabels,
|
labelLayer: this.actionLabels,
|
||||||
maskLayer: this.mask,
|
maskLayer: this.mask,
|
||||||
|
@ -439,7 +436,6 @@ define([
|
||||||
svg.empty(this.mask);
|
svg.empty(this.mask);
|
||||||
svg.empty(this.agentLines);
|
svg.empty(this.agentLines);
|
||||||
svg.empty(this.blocks);
|
svg.empty(this.blocks);
|
||||||
svg.empty(this.sections);
|
|
||||||
svg.empty(this.actionShapes);
|
svg.empty(this.actionShapes);
|
||||||
svg.empty(this.actionLabels);
|
svg.empty(this.actionLabels);
|
||||||
this.mask.appendChild(this.maskReveal);
|
this.mask.appendChild(this.maskReveal);
|
||||||
|
|
|
@ -45,7 +45,6 @@ define(() => {
|
||||||
topY,
|
topY,
|
||||||
primaryY,
|
primaryY,
|
||||||
blockLayer,
|
blockLayer,
|
||||||
sectionLayer,
|
|
||||||
shapeLayer,
|
shapeLayer,
|
||||||
labelLayer,
|
labelLayer,
|
||||||
theme,
|
theme,
|
||||||
|
|
|
@ -35,12 +35,13 @@ define([
|
||||||
const config = env.theme.block;
|
const config = env.theme.block;
|
||||||
const agentInfoL = env.agentInfos.get(left);
|
const agentInfoL = env.agentInfos.get(left);
|
||||||
const agentInfoR = env.agentInfos.get(right);
|
const agentInfoR = env.agentInfos.get(right);
|
||||||
|
const {hold} = env.state.blocks.get(left);
|
||||||
|
|
||||||
let y = env.primaryY;
|
let y = env.primaryY;
|
||||||
|
|
||||||
if(!first) {
|
if(!first) {
|
||||||
y += config.section.padding.bottom;
|
y += config.section.padding.bottom;
|
||||||
env.sectionLayer.appendChild(svg.make('line', Object.assign({
|
hold.appendChild(svg.make('line', Object.assign({
|
||||||
'x1': agentInfoL.x,
|
'x1': agentInfoL.x,
|
||||||
'y1': y,
|
'y1': y,
|
||||||
'x2': agentInfoR.x,
|
'x2': agentInfoR.x,
|
||||||
|
@ -48,14 +49,16 @@ define([
|
||||||
}, config.separator.attrs)));
|
}, config.separator.attrs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clickable = env.makeRegion();
|
||||||
|
|
||||||
const modeRender = SVGShapes.renderBoxedText(mode, {
|
const modeRender = SVGShapes.renderBoxedText(mode, {
|
||||||
x: agentInfoL.x,
|
x: agentInfoL.x,
|
||||||
y,
|
y,
|
||||||
padding: config.section.mode.padding,
|
padding: config.section.mode.padding,
|
||||||
boxAttrs: config.section.mode.boxAttrs,
|
boxAttrs: config.section.mode.boxAttrs,
|
||||||
labelAttrs: config.section.mode.labelAttrs,
|
labelAttrs: config.section.mode.labelAttrs,
|
||||||
boxLayer: env.blockLayer,
|
boxLayer: hold,
|
||||||
labelLayer: env.labelLayer,
|
labelLayer: clickable,
|
||||||
SVGTextBlockClass: env.SVGTextBlockClass,
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -66,14 +69,21 @@ define([
|
||||||
boxAttrs: {'fill': '#000000'},
|
boxAttrs: {'fill': '#000000'},
|
||||||
labelAttrs: config.section.label.labelAttrs,
|
labelAttrs: config.section.label.labelAttrs,
|
||||||
boxLayer: env.maskLayer,
|
boxLayer: env.maskLayer,
|
||||||
labelLayer: env.labelLayer,
|
labelLayer: clickable,
|
||||||
SVGTextBlockClass: env.SVGTextBlockClass,
|
SVGTextBlockClass: env.SVGTextBlockClass,
|
||||||
});
|
});
|
||||||
|
|
||||||
return y + (
|
const labelHeight = Math.max(modeRender.height, labelRender.height);
|
||||||
Math.max(modeRender.height, labelRender.height) +
|
|
||||||
config.section.padding.top
|
clickable.insertBefore(svg.make('rect', {
|
||||||
);
|
'x': agentInfoL.x,
|
||||||
|
'y': y,
|
||||||
|
'width': agentInfoR.x - agentInfoL.x,
|
||||||
|
'height': labelHeight,
|
||||||
|
'fill': 'transparent',
|
||||||
|
}), clickable.firstChild);
|
||||||
|
|
||||||
|
return y + labelHeight + config.section.padding.top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +109,15 @@ define([
|
||||||
}
|
}
|
||||||
|
|
||||||
render(stage, env) {
|
render(stage, env) {
|
||||||
|
const hold = svg.make('g');
|
||||||
|
env.blockLayer.appendChild(hold);
|
||||||
|
|
||||||
env.state.blocks.set(stage.left, {
|
env.state.blocks.set(stage.left, {
|
||||||
|
hold,
|
||||||
mode: stage.mode,
|
mode: stage.mode,
|
||||||
startY: env.primaryY,
|
startY: env.primaryY,
|
||||||
});
|
});
|
||||||
|
|
||||||
return super.render(stage, env, true);
|
return super.render(stage, env, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,12 +137,11 @@ define([
|
||||||
render({left, right}, env) {
|
render({left, right}, env) {
|
||||||
const config = env.theme.block;
|
const config = env.theme.block;
|
||||||
|
|
||||||
const {startY, mode} = env.state.blocks.get(left);
|
|
||||||
|
|
||||||
const agentInfoL = env.agentInfos.get(left);
|
const agentInfoL = env.agentInfos.get(left);
|
||||||
const agentInfoR = env.agentInfos.get(right);
|
const agentInfoR = env.agentInfos.get(right);
|
||||||
|
const {hold, startY, mode} = env.state.blocks.get(left);
|
||||||
const configMode = config.modes[mode] || config.modes[''];
|
const configMode = config.modes[mode] || config.modes[''];
|
||||||
env.blockLayer.appendChild(svg.make('rect', Object.assign({
|
hold.appendChild(svg.make('rect', Object.assign({
|
||||||
'x': agentInfoL.x,
|
'x': agentInfoL.x,
|
||||||
'y': startY,
|
'y': startY,
|
||||||
'width': agentInfoR.x - agentInfoL.x,
|
'width': agentInfoR.x - agentInfoL.x,
|
||||||
|
|
Loading…
Reference in New Issue