mirror of
https://github.com/viliusle/miniPaint.git
synced 2026-02-06 11:42:13 +00:00
information window update, fixed issues when formatting numbers
This commit is contained in:
parent
39f8d5ed52
commit
e5af391390
@ -11,9 +11,14 @@ import Helper_class from './../../libs/helpers.js';
|
||||
var template = `
|
||||
<span class="trn label">Size:</span>
|
||||
<span id="mouse_info_size">-</span>
|
||||
<span class="id-mouse_info_units"></span>
|
||||
<br />
|
||||
<span class="trn label">Mouse:</span>
|
||||
<span id="mouse_info_mouse">-</span>
|
||||
<span class="id-mouse_info_units"></span>
|
||||
<br />
|
||||
<span class="trn label">Resolution:</span>
|
||||
<span id="mouse_info_resolution">-</span>
|
||||
`;
|
||||
|
||||
/**
|
||||
@ -76,6 +81,17 @@ class GUI_information_class {
|
||||
var height = this.Helper.get_user_unit(config.HEIGHT, this.units, this.resolution);
|
||||
|
||||
document.getElementById('mouse_info_size').innerHTML = width + ' x ' + height;
|
||||
|
||||
var resolution = this.Tools_settings.get_setting('resolution');
|
||||
document.getElementById('mouse_info_resolution').innerHTML = resolution;
|
||||
|
||||
//show units
|
||||
var default_units = this.Tools_settings.get_setting('default_units_short');
|
||||
var targets = document.querySelectorAll('.id-mouse_info_units');
|
||||
for (var i = 0; i < targets.length; i++) {
|
||||
targets[i].innerHTML = default_units;
|
||||
}
|
||||
|
||||
this.last_width = config.WIDTH;
|
||||
this.last_height = config.HEIGHT;
|
||||
}
|
||||
|
||||
@ -422,20 +422,16 @@ class Helper_class {
|
||||
* JavaScript Number Formatter, author: KPL, KHL
|
||||
*
|
||||
* @param {int} n
|
||||
* @param {int} decPlaces
|
||||
* @param {string} thouSeparator
|
||||
* @param {string} decSeparator
|
||||
* @param {int} maximumFractionDigits
|
||||
* @returns {string}
|
||||
*/
|
||||
number_format(n, decPlaces, thouSeparator, decSeparator) {
|
||||
var decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces;
|
||||
var decSeparator = decSeparator == undefined ? "." : decSeparator;
|
||||
var thouSeparator = thouSeparator == undefined ? "," : thouSeparator;
|
||||
var sign = n < 0 ? "-" : "";
|
||||
var i = parseInt(n = Math.abs(+n || 0).toFixed(decPlaces)) + "";
|
||||
var j = (j = i.length) > 3 ? j % 3 : 0;
|
||||
var result = sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(n - i).toFixed(decPlaces).slice(2) : "");
|
||||
return parseFloat(result);
|
||||
number_format(n, maximumFractionDigits) {
|
||||
let x = parseFloat(n);
|
||||
var number = x.toLocaleString('us', {minimumFractionDigits: 0, maximumFractionDigits: maximumFractionDigits});
|
||||
number = number.replaceAll(',', '');
|
||||
number = parseFloat(number);
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
check_input_color_support() {
|
||||
|
||||
@ -53,10 +53,10 @@ class Image_size_class {
|
||||
var units = this.Tools_settings.get_setting('default_units');
|
||||
var resolution = this.Tools_settings.get_setting('resolution');
|
||||
|
||||
if (width < 1){
|
||||
if (width < 0){
|
||||
width = 1;
|
||||
}
|
||||
if (height < 1){
|
||||
if (height < 0){
|
||||
height = 1;
|
||||
}
|
||||
|
||||
|
||||
@ -9,14 +9,20 @@ class Tools_settings_class {
|
||||
this.Base_gui = new Base_gui_class();
|
||||
this.POP = new Dialog_class();
|
||||
this.Helper = new Helper_class();
|
||||
|
||||
this.default_units_config = {
|
||||
pixels: 'px',
|
||||
inches: '"',
|
||||
centimeters: 'cm',
|
||||
millimetres: 'mm',
|
||||
};
|
||||
}
|
||||
|
||||
settings() {
|
||||
var _this = this;
|
||||
var transparency_values = ['squares', 'green', 'grey'];
|
||||
var default_units_all = ['pixels', 'inches', 'centimeters', 'millimetres'];
|
||||
var resolutions_values = [72, 150, 300, 600];
|
||||
|
||||
var default_units_all = Object.keys(this.default_units_config);
|
||||
var transparency = this.get_setting('transparency');
|
||||
var theme = this.get_setting('theme');
|
||||
var snap = this.get_setting('snap');
|
||||
@ -67,6 +73,7 @@ class Tools_settings_class {
|
||||
this.save_setting('safe_search', params.safe_search);
|
||||
this.save_setting('exit_confirm', params.exit_confirm);
|
||||
this.save_setting('default_units', params.default_units);
|
||||
this.save_setting('default_units_short', this.default_units_config[params.default_units]);
|
||||
this.save_setting('resolution', params.resolution);
|
||||
this.save_setting('thick_guides', params.thick_guides);
|
||||
|
||||
@ -115,7 +122,8 @@ class Tools_settings_class {
|
||||
'guides': true,
|
||||
'safe_search': true,
|
||||
'exit_confirm': true,
|
||||
'default_units': 'pixels',
|
||||
'default_units': Object.keys(this.default_units_config)[0],
|
||||
'default_units_short': Object.values(this.default_units_config)[0],
|
||||
'resolution': 72,
|
||||
'thick_guides': false,
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user