Commit 30695d84 authored by Albert Gräf's avatar Albert Gräf
Browse files

Merge branch 'iemgui-numbox-autoheight-from-font' into release_2.15.0

parents 4b0e7e91 89d8eda5
......@@ -291,6 +291,27 @@
<fieldset>
<legend data-i18n="iem.prop.heading.colors"></legend>
<table class="draw_style prop hidden" style="margin-bottom: 7px;">
<tr>
<td>
<label data-i18n="[title]iem.prop.drawstyle_tt">
<span data-i18n="iem.prop.drawstyle"
style="margin-right: 6px;"></span>
</label>
</td>
<td data-i18n="[title]iem.prop.drawstyle_tt">
<select name="draw_style"
onchange="update_attr(this, true);"
style="width: 14em;">
<option value="0">draw everything (default)</option>
<option value="1">draw frame only</option>
<option value="2">draw triangle only</option>
<option value="3">draw number only</option>
</select>
</td>
<td>
</table>
<div class="background_color prop hidden">
<label data-i18n="[title]iem.prop.bgcolor_tt">
<input type="color" name="background_color"
......@@ -512,6 +533,8 @@ function send_params(attrs, create_undo_point) {
var slot18 = attrs.steady_on_click ? +attrs.steady_on_click : 0;
var draw_style = attrs.draw_style ? +attrs.draw_style : 0;
pdgui.pdsend(pd_object_callback, "dialog",
width, height,
slot3, // bng: flash_interrupt
......@@ -532,7 +555,7 @@ function send_params(attrs, create_undo_point) {
background_color, foreground_color,
label_color,
slot18, // steady on click
0, // not sure what this is doing here
draw_style, // numbox draw style
create_undo_point ? 1 : 0 // whether we set an undo point
);
}
......
......@@ -5,7 +5,7 @@
"size": "Größe und Verhalten",
"messages": "Nachrichten",
"label": "Etikett",
"colors": "Farben"
"colors": "Erscheinungsbild"
},
"size_tt": "Größe des iemgui-Elements",
"size": "Größe",
......@@ -41,6 +41,8 @@
"log_height_tt": "the framus intersects with the ramistan approximately at the podernoster",
"steady": "stabil beim Klicken",
"steady_tt": "verschiebe den Schieberegler nicht beim Klicken. Verschiebe ihn nur beim Ziehen der Maus",
"drawstyle": "Rahmen-Stil",
"drawstyle_tt": "Rahmen-Stil durch Auswahl der Elemente anpassen",
"send": "Sende-Symbol",
"send_tt": "Symbol zum Senden drahtloser Nachrichten an andere iemgui-Elemente oder Objekte",
"receive": "Empfangs-Symbol",
......
......@@ -5,7 +5,7 @@
"size": "size and behavior",
"messages": "messaging",
"label": "label",
"colors": "colors"
"colors": "appearance"
},
"size_tt": "size of the iemgui",
"size": "size",
......@@ -41,6 +41,8 @@
"log_height_tt": "the framus intersects with the ramistan approximately at the podernoster",
"steady": "steady on click",
"steady_tt": "don't move the slider when clicked. Only move it when dragging the mouse",
"drawstyle": "frame style",
"drawstyle_tt": "adjust number frame style by toggling its elements",
"send": "send symbol",
"send_tt": "symbol to send wireless messages to other iemguis or objects",
"receive": "receive symbol",
......
......@@ -5,7 +5,7 @@
"size": "Taille et comportement",
"messages": "Messages",
"label": "Label",
"colors": "Couleurs"
"colors": "Apparence"
},
"size": "Taille",
"size_tt": "Taille de l'objet IemGui",
......@@ -41,6 +41,8 @@
"log_height_tt": "Le framus se croise avec le ramistan approximativement au paternoster !",
"steady": "Fixe au clic",
"steady_tt": "Ne bouge pas le curseur quand cliqué. Bouge seulement quand on le fait glisser avec la souris",
"drawstyle": "Style du cadre",
"drawstyle_tt": "Ajuster le style du cadre en choisissant ses éléments",
"send": "Envoyer au symbole",
"send_tt": "Messages sans-fil à envoyer à travers le Symbole vers d'autres IemGui ou Objets",
"receive": "Recevoir du symbole",
......
......@@ -2964,7 +2964,7 @@ function gui_text_set (cid, tag, text) {
function gui_text_set_mynumbox (cid, tag, text, active) {
gui(cid).get_elem(tag + "text", function(e) {
//post("guit_text_set_activate " + tag + " " + text + " " + active);
//post("gui_text_set_mynumbox " + tag + " " + text + " " + active);
text = text.trim();
e.textContent = "";
text_to_tspans(cid, e, text);
......@@ -3272,13 +3272,18 @@ function gui_toggle_update(cid, tag, state, color) {
})
}
function numbox_data_string(w, h) {
function numbox_data_string_frame(w, h) {
return ["M", 0, 0,
"L", w - 4, 0,
w, 4,
w, h,
0, h,
"z",
"z"]
.join(" ");
}
function numbox_data_string_triangle(w, h) {
return ["M", 0, 0,
"L", 0, 0,
(h / 2)|0, (h / 2)|0, // |0 to force int
0, h]
......@@ -3286,27 +3291,38 @@ function numbox_data_string(w, h) {
}
// Todo: send fewer parameters from c
function gui_numbox_new(cid, tag, color, x, y, w, h, is_toplevel) {
function gui_numbox_new(cid, tag, color, x, y, w, h, drawstyle, is_toplevel) {
// numbox doesn't have a standard iemgui border,
// so we must create its gobj manually
gui(cid).get_elem("patchsvg", function() {
var g = gui_gobj_new(cid, tag, "iemgui", x, y, is_toplevel);
var data = numbox_data_string(w, h);
var border = create_item(cid, "path", {
d: data,
d: numbox_data_string_frame(w, h),
fill: color,
stroke: "black",
"stroke-width": 1,
"stroke-width": (drawstyle < 2 ? 1 : 0),
id: (tag + "border"),
"class": "border"
});
g.appendChild(border);
var triangle = create_item(cid, "path", {
d: numbox_data_string_triangle(w, h),
fill: color,
stroke: "black",
"stroke-width": (drawstyle == 0 || drawstyle == 2 ? 1 : 0),
id: (tag + "triangle"),
"class": "border"
});
g.appendChild(triangle);
});
}
function gui_numbox_coords(cid, tag, w, h) {
gui(cid).get_elem(tag + "border", {
d: numbox_data_string(w, h)
d: numbox_data_string_frame(w, h)
});
gui(cid).get_elem(tag + "triangle", {
d: numbox_data_string_triangle(w, h)
});
}
......@@ -3332,14 +3348,14 @@ function gui_numbox_draw_text(cid,tag,text,font_size,color,xpos,ypos,basex,basey
});
}
function gui_numbox_update(cid, tag, fcolor, bgcolor, font_name, font_size, font_weight) {
function gui_numbox_update(cid, tag, fcolor, bgcolor, num_font_size, font_name, font_size, font_weight) {
gui(cid)
.get_elem(tag + "border", {
fill: bgcolor
})
.get_elem(tag + "text", {
fill: fcolor,
"font-size": font_size
"font-size": num_font_size
})
// label may or may not exist, but that's covered by the API
.get_elem(tag + "label", function() {
......@@ -5847,12 +5863,7 @@ function gui_iemgui_dialog(did, attr_array) {
// We are subtracting 25 for the menu
// ico@vt.edu: since adding frameless window, we use top 20px for draggable titlebar,
// so now we subtract only 5 (25-20)
//post("attr_array=" + attr_array);
var height = 409;
if (attr_array[1] === "vu") {
height = 360;
}
create_window(did, "iemgui", 298, height,
create_window(did, "iemgui", 298, 414-5,
popup_coords[2] + 10, popup_coords[3] + 60,
attr_array_to_object(attr_array));
}
......
......@@ -1268,7 +1268,7 @@ void iemgui_draw_io(t_iemgui *x, int old_sr_flags)
t_canvas *canvas=glist_getcanvas(x->x_glist);
if (x->x_glist != canvas) return; // is gop
t_class *c = pd_class((t_pd *)x);
if (c == my_numbox_class && ((t_my_numbox *)x)->x_hide_frame > 1)
if (c == my_numbox_class && ((t_my_numbox *)x)->x_drawstyle > 1)
return; //sigh
if (!(old_sr_flags&4) && !glist_isvisible(canvas))
{
......
......@@ -190,9 +190,14 @@ typedef struct _my_numbox
int x_numwidth; // unsigned (width in pixels)
int x_scalewidth; /* temporary value for scalehandle */
int x_scaleheight; /* temporary value for scalehandle */
int x_yresize_x; /* value of x when y resize started */
int x_tmpfontsize; /* temporary value for scalehandle */
int x_num_fontsize;/* font size for the number only that should
automatically adjust to the box size */
int x_focused; /* helps us determine when and how we are editing value
0 no focus, 1 keyboard focus, 2 mouse focus */
int x_log_height;
int x_hide_frame; /* 0 default, 1 just arrow, 2, just frame, 3 both */
int x_drawstyle; /* 0 default, 1 just frame, 2, just arrow, 3 number only */
} t_my_numbox;
extern int sys_noloadbang;
......
This diff is collapsed.
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