Commit 48a99a11 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

Added more fine-grained adjustments to activated msg text position

* Currently only font sizes 12 and 16 are fully tuned

* Still need to do 8, 10, 24, 36

* Note that at zoom levels -5 and lower there is something funny happening with the font widths. Then again, who will want to edit stuff at that zoom level when nothing is even legible, is beyond me.
parent 3cacb1f3
......@@ -2626,7 +2626,7 @@ function gui_message_update_textarea_border(elem, init_width) {
elem.getAttribute("cid"),
elem.getAttribute("tag"),
parseInt(elem.offsetWidth / elem.getAttribute("font_width")) * elem.getAttribute("font_width") + 4,
elem.offsetHeight-1
parseInt(elem.offsetHeight / elem.getAttribute("font_height")) * elem.getAttribute("font_height") + 4
);
}
}
......@@ -6281,26 +6281,58 @@ function get_style_by_selector(w, selector) {
// for debugging purposes
exports.get_style_by_selector = get_style_by_selector;
function textarea_line_height_kludge(font_size) {
function textarea_line_height_kludge(font_size, zoom) {
var height_array;
switch(font_size) {
case 8: return "133%";
case 10: return "133%";
case 12: return "140%";
case 16: return "120%";
case 24: return "128%";
case 36: return "122%";
// zoom levels -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7
case 8:
height_array = [133,133,133,133,133,133,133,133,133,133,133,133,133,133,133];
break;
case 10:
height_array = [133,133,133,133,133,133,133,133,133,133,133,133,133,133,133];
break;
case 12:
height_array = [ 80, 90,100,134,148,140,140,140,144,140,140,140,140,140,140];
break;
case 16:
height_array = [ 90,100,120,120,120,120,120,120,120,115,115,115,115,115,115];
break;
case 24:
height_array = [128,128,128,128,128,128,128,128,128,128,128,128,128,128,128];
break;
case 36:
height_array = [122,122,122,122,122,122,122,122,122,122,122,122,122,122,122];
break;
}
post("textarea_line_height_kludge " + font_size + " " + zoom + " " + height_array[zoom+7]);
return height_array[zoom+7]+"%";
}
function textarea_y_offset_kludge(font_size) {
function textarea_y_offset_kludge(font_size, zoom) {
var offset_array;
switch(font_size) {
case 8: return 1.5;
case 10: return 0.5;
case 12: return 1.5;
case 16: return 1.5;
case 24: return 1.5;
case 36: return 1.5;
// zoom levels -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7
case 8:
offset_array = [1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5];
break;
case 10:
offset_array = [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5];
break;
case 12:
offset_array = [1.5,1.5,1.5,2.0,1.5,1.5,1.5,1.5,1.5,1.5,1.5,2.0,1.5,1.5,1.5];
break;
case 16:
offset_array = [1.5,1.5,-1.,1.5,1.0,1.5,0.0,1.5,1.5,1.5,1.2,1.5,1.0,0.7,1.2];
break;
case 24:
offset_array = [1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5];
break;
case 36:
offset_array = [1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5];
break;
}
post("textarea_y_offset_kludge " + font_size + " " + zoom + " " + offset_array[zoom+7]);
return offset_array[zoom+7];
}
function textarea_msg_kludge(zoom) {
......@@ -6313,11 +6345,12 @@ function textarea_msg_kludge(zoom) {
case 5: return -0.5;
case 6: return -0.5;
case 7: return -0.5;
default: return 0;
}
}
function gui_textarea(cid, tag, type, x, y, width_spec, height_spec, text,
font_size, font_width, is_gop, state, sel_start, sel_end) {
font_size, font_width, font_height, is_gop, state, sel_start, sel_end) {
var range, svg_view, p,
gobj = get_gobj(cid, tag), zoom;
gui(cid).get_nw_window(function(nw_win) {
......@@ -6362,7 +6395,8 @@ function gui_textarea(cid, tag, type, x, y, width_spec, height_spec, text,
id: "new_object_textentry",
cid: cid,
tag: tag,
font_width: font_width
font_width: font_width,
font_height: font_height
});
svg_view = patchwin[cid].window.document.getElementById("patchsvg")
.viewBox.baseVal;
......@@ -6388,11 +6422,11 @@ function gui_textarea(cid, tag, type, x, y, width_spec, height_spec, text,
}
p.style.setProperty("left", (x - svg_view.x - 0.5) + "px");
p.style.setProperty("top", (y - svg_view.y + textarea_y_offset_kludge(font_size)) + "px");
p.style.setProperty("top", (y - svg_view.y + textarea_y_offset_kludge(font_size, zoom)) + "px");
p.style.setProperty("font-size",
pd_fontsize_to_gui_fontsize(font_size) + "px");
p.style.setProperty("line-height",
textarea_line_height_kludge(font_size));
textarea_line_height_kludge(font_size, zoom));
//pd_fontsize_to_gui_fontsize(font_size) + 1 + "px");
p.style.setProperty("transform", "translate(0px, " +
(zoom > 0 ? 0.5 : 0) + "px)");
......
......@@ -642,7 +642,7 @@ void rtext_activate(t_rtext *x, int state)
sprintf(tmpbuf, "%.*s", (int)x->x_bufsize, x->x_buf);
/* in case x_bufsize is 0... */
tmpbuf[x->x_bufsize] = '\0';
gui_vmess("gui_textarea", "xssiiiisiiiiii",
gui_vmess("gui_textarea", "xssiiiisiiiiiii",
canvas,
x->x_tag,
(pd_class((t_pd *)x->x_text) == message_class ? "msg" : "obj"),
......@@ -653,6 +653,7 @@ void rtext_activate(t_rtext *x, int state)
tmpbuf,
sys_hostfontsize(glist_getfont(glist)),
sys_fontwidth(glist_getfont(glist)),
sys_fontheight(glist_getfont(glist)),
isgop,
state,
selstart,
......
Supports Markdown
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