Skip to content

Commit

Permalink
add option to hide the title bar
Browse files Browse the repository at this point in the history
Closes #139
  • Loading branch information
MaxKellermann committed Sep 11, 2024
1 parent 4ffd1d0 commit 1108dc0
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ncmpc 0.50 - not yet released
* build: require Meson 0.60
* require libfmt 9
* draw progress bar as Unicode double line
* add option to hide the title bar
* add color style "text" for input text controls
* remove option "text-editor-ask"
* fix lyrics editor crash
Expand Down
3 changes: 3 additions & 0 deletions doc/config.sample
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
#lyrics-timeout = 60

############## Display ######################
## Show a title bar at the top of the screen
#show-title-bar = yes

## Show a list of the screens in the top line.
#welcome-screen-list = yes

Expand Down
2 changes: 2 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ is 5 seconds.
Interface
^^^^^^^^^

:command:`show-title-bar = yes|no` - "no" allows hiding the title bar.

:command:`enable-mouse = yes|no` - Enable mouse support (if enabled at compile time).

:command:`screen-list = SCREEN1 SCREEN2...` - A list of screens to
Expand Down
2 changes: 2 additions & 0 deletions src/ConfigParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ parse_line(char *line)
/* key definition */
if (StringIsEqualIgnoreCase(CONF_KEY_DEFINITION, name))
parse_key_definition(value);
else if (StringIsEqualIgnoreCase("show-title-bar", name))
options.show_title_bar = str2bool(value);
/* enable colors */
else if(StringIsEqualIgnoreCase(CONF_ENABLE_COLORS, name))
#ifdef ENABLE_COLORS
Expand Down
2 changes: 2 additions & 0 deletions src/Options.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ struct Options {
bool lyrics_show_plugin = false;
#endif

bool show_title_bar = true;

bool auto_center = false;

#ifndef NCMPC_MINI
Expand Down
3 changes: 2 additions & 1 deletion src/screen.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ ScreenManager::Update(struct mpdclient &c, const DelayedSeek &seek) noexcept
was_connected = now_connected;
#endif

title_bar.Update(c.status);
if (options.show_title_bar)
title_bar.Update(c.status);

unsigned elapsed;
if (c.status == nullptr)
Expand Down
14 changes: 10 additions & 4 deletions src/screen_init.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "QueuePage.hxx"
#include "config.h"
#include "Styles.hxx"
#include "Options.hxx"
#include "page/Page.hxx"
#include "dialogs/ModalDialog.hxx"
#include "ui/Options.hxx"
Expand All @@ -25,14 +26,18 @@ GetCorrectedScreenSize() noexcept

struct ScreenManager::Layout {
Size size;
Point main{0, 0};

static constexpr Point title{0, 0};
static constexpr Point main{0, (int)TitleBar::GetHeight()};
static constexpr int progress_x = 0;
static constexpr int status_x = 0;

constexpr explicit Layout(Size _size) noexcept
:size(_size) {}
explicit Layout(Size _size) noexcept
:size(_size)
{
if (options.show_title_bar)
main.y = TitleBar::GetHeight();
}

constexpr unsigned GetMainRows() const noexcept {
return GetProgress().y - main.y;
Expand Down Expand Up @@ -108,7 +113,8 @@ ScreenManager::OnResize() noexcept
resizeterm(layout.size.height, layout.size.width);
#endif

title_bar.OnResize(layout.size.width);
if (options.show_title_bar)
title_bar.OnResize(layout.size.width);

/* main window */
main_window.Resize(layout.GetMainSize());
Expand Down
8 changes: 6 additions & 2 deletions src/screen_paint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
// Copyright The Music Player Daemon Project

#include "screen.hxx"
#include "Options.hxx"
#include "page/Page.hxx"
#include "dialogs/ModalDialog.hxx"
#include "ui/Options.hxx"

void
inline void
ScreenManager::PaintTopWindow() noexcept
{
assert(options.show_title_bar);

const auto title = GetCurrentPage().GetTitle({buf, buf_size});
title_bar.Paint(GetCurrentPageMeta(), title);
}
Expand All @@ -17,7 +20,8 @@ void
ScreenManager::Paint() noexcept
{
/* update title/header window */
PaintTopWindow();
if (options.show_title_bar)
PaintTopWindow();

/* paint the bottom window */

Expand Down

0 comments on commit 1108dc0

Please sign in to comment.