Add option to auto hide tab bar

This commit is contained in:
JannisX11 2021-11-21 19:28:19 +01:00
parent ccc947b885
commit c76ed4ca3d
6 changed files with 44 additions and 8 deletions

View File

@ -6,6 +6,8 @@
border: 2px solid var(--color-frame);
border-top: none;
background-color: var(--color-dark);
display: flex;
flex-direction: column;
}
#page_wrapper.invisible {
visibility: hidden;
@ -36,7 +38,7 @@
"left_bar center right_bar"
"left_bar status_bar right_bar";
width: 100%;
height: calc(100% - 30px);
min-height: 300px;
}
#tab_bar {
@ -408,6 +410,12 @@
li.menu_bar_point.highlighted {
animation: menu_item_highlight 1s infinite ease-in-out;
}
#title_bar_home_button {
height: 100%;
}
#title_bar_home_button > i {
margin-top: 2px;
}
#mode_selector {
font-size: 1.1em;
@ -591,7 +599,7 @@
flex-grow: 1;
}
#start_screen {
height: calc(100% - 30px);
min-height: 300px;
width: 100%;
padding: 36px 0;
}

View File

@ -344,6 +344,7 @@
<img class="blockbench_logo" src="assets/logo_text_white.svg" alt="Blockbench" />
</div>
<ul id="menu_bar" class="scroll_horizontal"></ul>
<div id="title_bar_home_button" class="tool" onclick="Interface.tab_bar.openNewTab()"><i class="material-icons">home</i></div>
<div class="app-drag-region" id="header_free_bar"></div>
<div id="update_menu"></div>
<ul id="windows_window_menu" hidden>

View File

@ -241,7 +241,7 @@ function setupInterface() {
translateUI()
$('.edit_session_active').hide()
document.getElementById('title_bar_home_button').title = tl('projects.start_screen');
$('#center').toggleClass('checkerboard', settings.preview_checkerboard.value);
@ -443,6 +443,7 @@ function setProjectTitle(title) {
} else {
Prop.file_name = Prop.file_name_alt = ''
}
if (Project && !Project.saved) window_title = '● ' + window_title;
$('title').text(window_title);
$('#header_free_bar').text(window_title);
}

View File

@ -179,6 +179,9 @@ const Settings = {
currentwindow.webContents.setZoomFactor(factor)
resizeWindow()
}});
new Setting('hide_tab_bar', {category: 'interface', value: !isApp, onChange() {
updateTabBarVisibility();
}});
new Setting('origin_size', {category: 'interface', value: 10, type: 'number'});
new Setting('control_size', {category: 'interface', value: 10, type: 'number'});
new Setting('motion_trails', {category: 'interface', value: true, onChange() {

View File

@ -13,7 +13,8 @@ class ModelProject {
this._texture_height = 16;
this._name = '';
this.saved = true;
this._saved = true;
this.save_path = '';
this.export_path = '';
this.added_models = 0;
@ -86,7 +87,16 @@ class ModelProject {
set name(name) {
this._name = name;
if (Project == this) {
setProjectTitle(this._name);
setProjectTitle(name);
}
}
get saved() {
return this._saved;
}
set saved(saved) {
this._saved = saved;
if (Project == this) {
setProjectTitle(this.name);
}
}
get model_3d() {
@ -363,6 +373,11 @@ function newProject(format) {
Blockbench.dispatchEvent('new_project');
return true;
}
function updateTabBarVisibility() {
let hidden = Settings.get('hide_tab_bar') && Interface.tab_bar.tabs.length < 2;
document.getElementById('tab_bar').style.display = hidden ? 'none' : 'flex';
document.getElementById('title_bar_home_button').style.display = hidden ? 'block' : 'none';
}
// Resolution
function setProjectResolution(width, height, modify_uv) {
@ -463,7 +478,7 @@ onVueSetup(() => {
}
Project = 0;
Interface.tab_bar.new_tab.selected = true;
setProjectTitle(tl('projects.new_tab'));
setProjectTitle(ModelProject.all.length ? tl('projects.new_tab') : null);
},
openSettings() {}
}
@ -619,8 +634,15 @@ onVueSetup(() => {
}, 80)
}
}
},
watch: {
tabs() {
updateTabBarVisibility();
}
}
})
updateTabBarVisibility()
})

View File

@ -70,7 +70,6 @@
"dates.year": "%0 Year",
"dates.years": "%0 Years",
"mode.start": "Start",
"mode.edit": "Edit",
"mode.paint": "Paint",
"mode.display": "Display",
@ -577,6 +576,8 @@
"settings.interface_scale": "Interface Scale",
"settings.interface_scale.desc": "Scale of the entire Blockbench interface",
"settings.hide_tab_bar": "Auto-hide Tab Bar",
"settings.hide_tab_bar.desc": "Hide the tab bar when only one tab is open",
"settings.origin_size": "Pivot Marker",
"settings.origin_size.desc": "Size of the pivot point marker",
"settings.control_size": "Transform Gizmo Size",