Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(render bug fix): new render method
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer committed Sep 14, 2020
1 parent 8c99536 commit a1bcf81
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 132 deletions.
4 changes: 2 additions & 2 deletions src/controllers/menuButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2948,10 +2948,10 @@ const menuButton = {
}

if(attr == "tb" || attr == "tr" || attr == "fs"){
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, null, true);
jfrefreshgrid(d, Store.luckysheet_select_save, cfg, null, true, false);
}
else{
jfrefreshgrid(d, Store.luckysheet_select_save);
jfrefreshgrid(d, Store.luckysheet_select_save, undefined, undefined,undefined,false);
}
},
updateFormat_mc: function(d, foucsStatus){
Expand Down
48 changes: 39 additions & 9 deletions src/global/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,17 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee

let value = textInfo.values[0]
let horizonAlignPos = pos_x + value.left;
let verticalAlignPos = pos_y + value.top;
let verticalAlignPos = pos_y + value.top- textInfo.textHeightAll;

if(verticalAlign == "0"){ //居中对齐
verticalAlignPos = pos_y + cellHeight/2 - textInfo.textHeightAll/2;
}
else if(verticalAlign == "1"){ //上对齐
verticalAlignPos = pos_y;
}
else if(verticalAlign == "2"){ //下对齐
verticalAlignPos =verticalAlignPos - textInfo.desc;
}

verticalAlignPos = verticalAlignPos/Store.zoomRatio;
horizonAlignPos = horizonAlignPos/Store.zoomRatio;
Expand All @@ -1530,12 +1540,12 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee
32,
pos_x/Store.zoomRatio ,
verticalAlignPos,
textContent.textHeightAll/Store.zoomRatio,
textContent.textHeightAll/Store.zoomRatio
textInfo.textHeightAll/Store.zoomRatio,
textInfo.textHeightAll/Store.zoomRatio
);

if(horizonAlign != "0" && horizonAlign != "2"){ //左对齐时 文本渲染空出一个图标的距离
horizonAlignPos = horizonAlignPos + textContent.textHeightAll/Store.zoomRatio;
horizonAlignPos = horizonAlignPos + textInfo.textHeightAll/Store.zoomRatio;
}
}

Expand Down Expand Up @@ -1805,10 +1815,15 @@ function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end){
// value = getcellvalue(r, c);
// }

let textMetrics = getCellTextInfo(cell, canvas,{
let textMetricsObj = getCellTextInfo(cell, canvas,{
r:r,
c:c,
}).textWidthAll;
});
let textMetrics = 0;
if(textMetricsObj!=null){
textMetrics = textMetricsObj.textWidthAll;
}

//canvas.measureText(value).width;

let start_c = c - 1 < 0 ? 0 : Store.visibledatacolumn[c - 1];
Expand Down Expand Up @@ -2008,12 +2023,24 @@ function cellOverflow_colIn(map, r, c, col_st, col_ed){
}

function cellTextRender(textInfo, ctx, option){
if(textInfo==null){
return
}
let values = textInfo.values;
let pos_x = option.pos_x, pos_y = option.pos_y;
if(values==null){
return;
}
console.log(textInfo, pos_x, pos_y, values[0].width, values[0].left, ctx);
// console.log(textInfo, pos_x, pos_y, values[0].width, values[0].left, ctx);

// for(let i=0;i<values.length;i++){
// let word = values[i];
// ctx.font = word.style;
// ctx.fillText(word.content, (pos_x + word.left)/Store.zoomRatio, (pos_y+word.top)/Store.zoomRatio);
// }

// ctx.fillStyle = "rgba(255,255,0,0.2)";
// ctx.fillRect((pos_x + values[0].left)/Store.zoomRatio, (pos_y+values[0].top-values[0].asc)/Store.zoomRatio, textInfo.textWidthAll, textInfo.textHeightAll)

if(textInfo.rotate!=0 && textInfo.type!="verticalWrap"){
ctx.save();
Expand All @@ -2022,13 +2049,16 @@ function cellTextRender(textInfo, ctx, option){
ctx.translate(-(textInfo.textLeftAll+pos_x), -(pos_y+textInfo.textTopAll));
}


// ctx.fillStyle = "rgb(0,0,0)";
for(let i=0;i<values.length;i++){
let word = values[i];
ctx.font = word.style;
ctx.fillText(word.content, (pos_x + word.left)/Store.zoomRatio, (pos_y+word.top)/Store.zoomRatio);
}

// ctx.fillStyle = "rgba(0,0,0,0.2)";
// ctx.fillRect((pos_x + values[0].left)/Store.zoomRatio, (pos_y+values[0].top-values[0].asc)/Store.zoomRatio, textInfo.textWidthAll, textInfo.textHeightAll)
// ctx.fillStyle = "rgba(255,0,0,1)";
// ctx.fillRect(pos_x+textInfo.textLeftAll-2, pos_y+textInfo.textTopAll-2, 4,4);
if(textInfo.rotate!=0 && textInfo.type!="verticalWrap"){
ctx.restore();
}
Expand Down
Loading

0 comments on commit a1bcf81

Please sign in to comment.