mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 00:05:22 +03:00
Change font presets to new dropdown UI.
This commit is contained in:
parent
4d582f45c8
commit
40cf566771
3 changed files with 29 additions and 17 deletions
|
@ -402,13 +402,17 @@ button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fontbuttons {
|
.fontpresets_wrapper {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 1.2em;
|
right: 1.2em;
|
||||||
top: .8em;
|
top: .8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fontpresets {
|
||||||
|
border: 1px solid #cccccc;
|
||||||
|
}
|
||||||
|
|
||||||
.tab-osd .switchable-field {
|
.tab-osd .switchable-field {
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
|
|
|
@ -910,7 +910,7 @@ OSD.constants = {
|
||||||
{ file: "default", name: "Default" },
|
{ file: "default", name: "Default" },
|
||||||
{ file: "bold", name: "Bold" },
|
{ file: "bold", name: "Bold" },
|
||||||
{ file: "large", name: "Large" },
|
{ file: "large", name: "Large" },
|
||||||
{ file: "extra_large", name: "X-Large" },
|
{ file: "extra_large", name: "Extra Large" },
|
||||||
{ file: "betaflight", name: "Betaflight" },
|
{ file: "betaflight", name: "Betaflight" },
|
||||||
{ file: "digital", name: "Digital" },
|
{ file: "digital", name: "Digital" },
|
||||||
{ file: "clarity", name: "Clarity" },
|
{ file: "clarity", name: "Clarity" },
|
||||||
|
@ -1471,17 +1471,18 @@ TABS.osd.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#content').load("./tabs/osd.html", function () {
|
$('#content').load("./tabs/osd.html", function () {
|
||||||
|
// Generate font type select element
|
||||||
// Generate font type buttons
|
var fontselect = $('.fontpresets');
|
||||||
var fontbuttons = $('.fontbuttons');
|
|
||||||
OSD.constants.FONT_TYPES.forEach(function(e, i) {
|
OSD.constants.FONT_TYPES.forEach(function(e, i) {
|
||||||
var button = $('<button>', {
|
var option = $('<option>', {
|
||||||
"data-font-file": e.file,
|
"data-font-file": e.file,
|
||||||
|
value: e.file,
|
||||||
text: e.name
|
text: e.name
|
||||||
});
|
});
|
||||||
fontbuttons.append($(button));
|
fontselect.append($(option));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var fontbuttons = $('.fontpresets_wrapper');
|
||||||
fontbuttons.append($('<button>', { class: "load_font_file", i18n: "osdSetupOpenFont" }));
|
fontbuttons.append($('<button>', { class: "load_font_file", i18n: "osdSetupOpenFont" }));
|
||||||
|
|
||||||
// must invoke before i18n.localizePage() since it adds translation keys for expected logo size
|
// must invoke before i18n.localizePage() since it adds translation keys for expected logo size
|
||||||
|
@ -1975,24 +1976,27 @@ TABS.osd.initialize = function (callback) {
|
||||||
// init structs once, also clears current font
|
// init structs once, also clears current font
|
||||||
FONT.initData();
|
FONT.initData();
|
||||||
|
|
||||||
var $fontPicker = $('.fontbuttons button');
|
var $fontpresets = $('.fontpresets')
|
||||||
$fontPicker.click(function(e) {
|
$fontpresets.change(function(e) {
|
||||||
if (!$(this).data('font-file')) { return; }
|
var $font = $('.fontpresets option:selected');
|
||||||
$fontPicker.removeClass('active');
|
$.get('./resources/osd/' + $font.data('font-file') + '.mcm', function(data) {
|
||||||
$(this).addClass('active');
|
|
||||||
$.get('./resources/osd/' + $(this).data('font-file') + '.mcm', function(data) {
|
|
||||||
FONT.parseMCMFontFile(data);
|
FONT.parseMCMFontFile(data);
|
||||||
FONT.preview($preview);
|
FONT.preview($preview);
|
||||||
LogoManager.drawPreview();
|
LogoManager.drawPreview();
|
||||||
updateOsdView();
|
updateOsdView();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// load the first font when we change tabs
|
// load the first font when we change tabs
|
||||||
$fontPicker.first().click();
|
var $font = $('.fontpresets option:selected');
|
||||||
|
$.get('./resources/osd/' + $font.data('font-file') + '.mcm', function(data) {
|
||||||
|
FONT.parseMCMFontFile(data);
|
||||||
|
FONT.preview($preview);
|
||||||
|
LogoManager.drawPreview();
|
||||||
|
updateOsdView();
|
||||||
|
});
|
||||||
|
|
||||||
$('button.load_font_file').click(function() {
|
$('button.load_font_file').click(function() {
|
||||||
$fontPicker.removeClass('active');
|
|
||||||
FONT.openFontFile().then(function() {
|
FONT.openFontFile().then(function() {
|
||||||
FONT.preview($preview);
|
FONT.preview($preview);
|
||||||
LogoManager.drawPreview();
|
LogoManager.drawPreview();
|
||||||
|
|
|
@ -124,7 +124,11 @@
|
||||||
<h1 class="tab_title" i18n="osdSetupFontPresets" />
|
<h1 class="tab_title" i18n="osdSetupFontPresets" />
|
||||||
<!-- Font preview and list -->
|
<!-- Font preview and list -->
|
||||||
<div class="content_wrapper font-preview"></div>
|
<div class="content_wrapper font-preview"></div>
|
||||||
<div class="fontbuttons"></div>
|
<div class="fontpresets_wrapper">
|
||||||
|
<label>Select Font Preset</label>
|
||||||
|
<select class="fontpresets"></select>
|
||||||
|
<span> Or </span>
|
||||||
|
</div>
|
||||||
<!-- Boot logo setup -->
|
<!-- Boot logo setup -->
|
||||||
<h1 class="tab_title" i18n="osdSetupCustomLogoTitle" />
|
<h1 class="tab_title" i18n="osdSetupCustomLogoTitle" />
|
||||||
<div id="font-logo-preview-container" class="content_wrapper">
|
<div id="font-logo-preview-container" class="content_wrapper">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue