Cleaned up ServerOverlay UI to use new TextInput::StyleLine mode, and

also include additional transcoder settings.
This commit is contained in:
casey langen 2017-05-29 14:32:36 -07:00
parent dfe8dc9693
commit 92d605e933
4 changed files with 61 additions and 36 deletions

View File

@ -5,12 +5,18 @@ user-facing:
* added `minimize to tray` and `start minimized` options to the windows build * added `minimize to tray` and `start minimized` options to the windows build
* a handful of small `musikdroid` bug fixes, mostly related to audio focus * a handful of small `musikdroid` bug fixes, mostly related to audio focus
and ducking. and ducking.
* documented the `websocket_remote` api on the wiki
low-level: low-level:
* added authentication support to the the `websocket_remote` audio server * added authentication support to the the `websocket_remote` audio server
* found and fixed a handful of missing `websocket_remote` metadata responses * found and fixed a handful of missing `websocket_remote` metadata responses
* added the ability to hot-reload plugins * added the ability to hot-reload plugins
* modified `IPlugin` -- every plugin must now supply a unique `guid` * modified `IPlugin` -- every plugin must now supply a unique `guid`
* fixed a bug in Transcoder if the number of cache files was set to 0
* fixed a number of bugs that could result in undefined behavior or crashes if
views are drawn outside of their parents (or screen) bounds
* fixed a bug where input fields may stop drawing properly if the value entered
by the user exceeds the window bounds
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -61,10 +61,8 @@ static const char* KEY_TRANSCODER_SYNCHRONOUS = "transcoder_synchronous";
static const char* KEY_PASSWORD = "password"; static const char* KEY_PASSWORD = "password";
#define VERTICAL_PADDING 1 #define VERTICAL_PADDING 1
#define DEFAULT_HEIGHT 18 #define DEFAULT_HEIGHT 17
#define DEFAULT_WIDTH 45 #define DEFAULT_WIDTH 45
#define PORT_INPUT_WIDTH 10
#define PORT_INPUT_HEIGHT 3
#define STYLE_OVERLAY_LABEL(x) \ #define STYLE_OVERLAY_LABEL(x) \
x->SetContentColor(CURSESPP_OVERLAY_CONTENT); x->SetContentColor(CURSESPP_OVERLAY_CONTENT);
@ -74,10 +72,16 @@ static const char* KEY_PASSWORD = "password";
x->SetFocusedContentColor(CURSESPP_OVERLAY_TEXT_FOCUSED); x->SetFocusedContentColor(CURSESPP_OVERLAY_TEXT_FOCUSED);
#define STYLE_OVERLAY_INPUT(x) \ #define STYLE_OVERLAY_INPUT(x) \
if (x->GetStyle() == TextInput::StyleBox) { \
x->SetFrameColor(CURSESPP_OVERLAY_FRAME); \ x->SetFrameColor(CURSESPP_OVERLAY_FRAME); \
x->SetContentColor(CURSESPP_OVERLAY_CONTENT); \ x->SetContentColor(CURSESPP_OVERLAY_CONTENT); \
x->SetFocusedFrameColor(CURSESPP_OVERLAY_INPUT_FRAME); \ x->SetFocusedFrameColor(CURSESPP_OVERLAY_INPUT_FRAME); \
x->SetFocusedContentColor(CURSESPP_OVERLAY_CONTENT); x->SetFocusedContentColor(CURSESPP_OVERLAY_CONTENT); \
} \
else { \
x->SetContentColor(CURSESPP_OVERLAY_CONTENT); \
x->SetFocusedContentColor(CURSESPP_OVERLAY_TEXT_FOCUSED); \
}
#define RIGHT(x) (x->GetX() + x->GetWidth()) #define RIGHT(x) (x->GetX() + x->GetWidth())
#define TEXT_WIDTH(x) ((int) u8cols(x->GetText())) #define TEXT_WIDTH(x) ((int) u8cols(x->GetText()))
@ -154,24 +158,29 @@ void ServerOverlay::InitViews() {
this->enableWssCb->SetText(_TSTR("settings_server_enable_websockets")); this->enableWssCb->SetText(_TSTR("settings_server_enable_websockets"));
this->wssPortLabel.reset(new TextLabel()); this->wssPortLabel.reset(new TextLabel());
this->wssPortLabel->SetText(_TSTR("settings_server_metadata_port"), text::AlignRight); this->wssPortLabel->SetText(_TSTR("settings_server_port"), text::AlignRight);
this->wssPortInput.reset(new TextInput()); this->wssPortInput.reset(new TextInput(TextInput::StyleLine));
/* http server */ /* http server */
this->enableHttpCb.reset(new Checkbox()); this->enableHttpCb.reset(new Checkbox());
this->enableHttpCb->SetText(_TSTR("settings_server_enable_http")); this->enableHttpCb->SetText(_TSTR("settings_server_enable_http"));
this->httpPortLabel.reset(new TextLabel()); this->httpPortLabel.reset(new TextLabel());
this->httpPortLabel->SetText(_TSTR("settings_server_audio_port"), text::AlignRight); this->httpPortLabel->SetText(_TSTR("settings_server_port"), text::AlignRight);
this->httpPortInput.reset(new TextInput()); this->httpPortInput.reset(new TextInput(TextInput::StyleLine));
/* transcoder */ /* transcoder */
this->enableSyncTransCb.reset(new Checkbox()); this->enableSyncTransCb.reset(new Checkbox());
this->enableSyncTransCb->SetText(_TSTR("settings_server_transcoder_synchronous")); this->enableSyncTransCb->SetText(_TSTR("settings_server_transcoder_synchronous"));
this->transCacheLabel.reset(new TextLabel());
this->transCacheLabel->SetText(_TSTR("settings_server_transcoder_cache_count"));
this->transCacheInput.reset(new TextInput(TextInput::StyleLine));
/* password */ /* password */
this->pwLabel.reset(new TextLabel()); this->pwLabel.reset(new TextLabel());
this->pwLabel->SetText(_TSTR("settings_server_password"), text::AlignRight); this->pwLabel->SetText(_TSTR("settings_server_password"), text::AlignRight);
this->pwInput.reset(new TextInput(IInput::InputPassword)); this->pwInput.reset(new TextInput(TextInput::StyleLine, IInput::InputPassword));
/* style 'em */ /* style 'em */
STYLE_OVERLAY_LABEL(this->titleLabel); STYLE_OVERLAY_LABEL(this->titleLabel);
@ -182,18 +191,22 @@ void ServerOverlay::InitViews() {
STYLE_OVERLAY_LABEL(this->httpPortLabel); STYLE_OVERLAY_LABEL(this->httpPortLabel);
STYLE_OVERLAY_INPUT(this->httpPortInput); STYLE_OVERLAY_INPUT(this->httpPortInput);
STYLE_OVERLAY_CHECKBOX(this->enableSyncTransCb); STYLE_OVERLAY_CHECKBOX(this->enableSyncTransCb);
STYLE_OVERLAY_LABEL(this->transCacheLabel);
STYLE_OVERLAY_INPUT(this->transCacheInput);
STYLE_OVERLAY_LABEL(this->pwLabel); STYLE_OVERLAY_LABEL(this->pwLabel);
STYLE_OVERLAY_INPUT(this->pwInput); STYLE_OVERLAY_INPUT(this->pwInput);
/* add 'em */ /* add 'em */
this->AddWindow(this->titleLabel); this->AddWindow(this->titleLabel);
this->AddWindow(this->enableWssCb); this->AddWindow(this->enableWssCb);
this->AddWindow(this->enableHttpCb);
this->AddWindow(this->enableSyncTransCb);
this->AddWindow(this->wssPortLabel); this->AddWindow(this->wssPortLabel);
this->AddWindow(this->wssPortInput); this->AddWindow(this->wssPortInput);
this->AddWindow(this->enableHttpCb);
this->AddWindow(this->httpPortLabel); this->AddWindow(this->httpPortLabel);
this->AddWindow(this->httpPortInput); this->AddWindow(this->httpPortInput);
this->AddWindow(this->enableSyncTransCb);
this->AddWindow(this->transCacheLabel);
this->AddWindow(this->transCacheInput);
this->AddWindow(this->pwLabel); this->AddWindow(this->pwLabel);
this->AddWindow(this->pwInput); this->AddWindow(this->pwInput);
this->AddWindow(this->shortcuts); this->AddWindow(this->shortcuts);
@ -201,10 +214,11 @@ void ServerOverlay::InitViews() {
/* focus order */ /* focus order */
int order = 0; int order = 0;
this->enableWssCb->SetFocusOrder(order++); this->enableWssCb->SetFocusOrder(order++);
this->enableHttpCb->SetFocusOrder(order++);
this->enableSyncTransCb->SetFocusOrder(order++);
this->wssPortInput->SetFocusOrder(order++); this->wssPortInput->SetFocusOrder(order++);
this->enableHttpCb->SetFocusOrder(order++);
this->httpPortInput->SetFocusOrder(order++); this->httpPortInput->SetFocusOrder(order++);
this->enableSyncTransCb->SetFocusOrder(order++);
this->transCacheInput->SetFocusOrder(order++);
this->pwInput->SetFocusOrder(order++); this->pwInput->SetFocusOrder(order++);
} }
@ -222,24 +236,27 @@ void ServerOverlay::Layout() {
int y = 2; int y = 2;
clientWidth -= 2; clientWidth -= 2;
int labelWidth = std::max(TEXT_WIDTH(this->wssPortLabel), TEXT_WIDTH(this->httpPortLabel)); const int wssPortLabelWidth = TEXT_WIDTH(wssPortLabel);
labelWidth = std::max(labelWidth, TEXT_WIDTH(this->pwLabel));
int inputWidth = clientWidth - labelWidth - 1;
this->enableWssCb->MoveAndResize(x, y++, clientWidth, 1); this->enableWssCb->MoveAndResize(x, y++, clientWidth, 1);
this->wssPortLabel->MoveAndResize(x + 4, y, wssPortLabelWidth, 1);
this->wssPortInput->MoveAndResize(x + 4 + wssPortLabelWidth + 1, y, 8, 1);
y += 2;
const int httpPortLabelWidth = TEXT_WIDTH(httpPortLabel);
this->enableHttpCb->MoveAndResize(x, y++, clientWidth, 1); this->enableHttpCb->MoveAndResize(x, y++, clientWidth, 1);
this->httpPortLabel->MoveAndResize(x + 4, y, httpPortLabelWidth, 1);
this->httpPortInput->MoveAndResize(x + 4 + httpPortLabelWidth + 1, y, 8, 1);
y += 2;
const int transCcacheLabelWidth = TEXT_WIDTH(transCacheLabel);
this->enableSyncTransCb->MoveAndResize(x, y++, clientWidth, 1); this->enableSyncTransCb->MoveAndResize(x, y++, clientWidth, 1);
this->transCacheLabel->MoveAndResize(x, y, transCcacheLabelWidth, 1);
this->transCacheInput->MoveAndResize(x + transCcacheLabelWidth + 1, y, 5, 1);
y += 2;
this->wssPortLabel->MoveAndResize(x, y + 1, labelWidth, 1); const int pwLabelWidth = TEXT_WIDTH(pwLabel);
this->wssPortInput->MoveAndResize(labelWidth + 2, y, inputWidth, PORT_INPUT_HEIGHT); this->pwLabel->MoveAndResize(x, y, pwLabelWidth, 1);
y += 3; this->pwInput->MoveAndResize(pwLabelWidth + 2, y, clientWidth - pwLabelWidth - 1, 1);
this->httpPortLabel->MoveAndResize(x, y + 1, labelWidth, 1);
this->httpPortInput->MoveAndResize(labelWidth + 2, y, inputWidth, PORT_INPUT_HEIGHT);
y += 3;
this->pwLabel->MoveAndResize(x, y + 1, labelWidth, 1);
this->pwInput->MoveAndResize(labelWidth + 2, y, inputWidth, PORT_INPUT_HEIGHT);
} }
void ServerOverlay::Show(Callback callback) { void ServerOverlay::Show(Callback callback) {
@ -268,14 +285,16 @@ void ServerOverlay::Load() {
this->wssPortInput->SetText(settingIntToString(prefs, KEY_METADATA_SERVER_PORT, 7905)); this->wssPortInput->SetText(settingIntToString(prefs, KEY_METADATA_SERVER_PORT, 7905));
this->httpPortInput->SetText(settingIntToString(prefs, KEY_AUDIO_SERVER_PORT, 7906)); this->httpPortInput->SetText(settingIntToString(prefs, KEY_AUDIO_SERVER_PORT, 7906));
this->transCacheInput->SetText(settingIntToString(prefs, KEY_TRANSCODER_CACHE_COUNT, 50));
this->pwInput->SetText(prefs->GetString(KEY_PASSWORD, "")); this->pwInput->SetText(prefs->GetString(KEY_PASSWORD, ""));
} }
bool ServerOverlay::Save() { bool ServerOverlay::Save() {
int wssPort = getIntFromTextInput(this->wssPortInput.get()); int wssPort = getIntFromTextInput(this->wssPortInput.get());
int httpPort = getIntFromTextInput(this->httpPortInput.get()); int httpPort = getIntFromTextInput(this->httpPortInput.get());
int cacheCount = getIntFromTextInput(this->transCacheInput.get());
if (wssPort <= 0 || httpPort <= 0) { if (wssPort <= 0 || httpPort <= 0 || cacheCount < 0) {
return false; return false;
} }
@ -284,6 +303,7 @@ bool ServerOverlay::Save() {
this->prefs->SetBool(KEY_TRANSCODER_SYNCHRONOUS, this->enableSyncTransCb->IsChecked()); this->prefs->SetBool(KEY_TRANSCODER_SYNCHRONOUS, this->enableSyncTransCb->IsChecked());
this->prefs->SetInt(KEY_METADATA_SERVER_PORT, wssPort); this->prefs->SetInt(KEY_METADATA_SERVER_PORT, wssPort);
this->prefs->SetInt(KEY_AUDIO_SERVER_PORT, httpPort); this->prefs->SetInt(KEY_AUDIO_SERVER_PORT, httpPort);
this->prefs->SetInt(KEY_TRANSCODER_CACHE_COUNT, cacheCount);
this->prefs->SetString(KEY_PASSWORD, this->pwInput->GetText().c_str()); this->prefs->SetString(KEY_PASSWORD, this->pwInput->GetText().c_str());
this->prefs->Save(); this->prefs->Save();

View File

@ -78,8 +78,8 @@ namespace musik {
std::shared_ptr<cursespp::TextLabel> titleLabel; std::shared_ptr<cursespp::TextLabel> titleLabel;
std::shared_ptr<cursespp::Checkbox> enableWssCb, enableHttpCb, enableSyncTransCb; std::shared_ptr<cursespp::Checkbox> enableWssCb, enableHttpCb, enableSyncTransCb;
std::shared_ptr<cursespp::TextLabel> wssPortLabel, httpPortLabel, pwLabel; std::shared_ptr<cursespp::TextLabel> wssPortLabel, httpPortLabel, pwLabel, transCacheLabel;
std::shared_ptr<cursespp::TextInput> wssPortInput, httpPortInput, pwInput; std::shared_ptr<cursespp::TextInput> wssPortInput, httpPortInput, pwInput, transCacheInput;
std::shared_ptr<cursespp::ShortcutsWindow> shortcuts; std::shared_ptr<cursespp::ShortcutsWindow> shortcuts;
}; };
} }

View File

@ -41,11 +41,10 @@
"settings_server_setup": "server setup", "settings_server_setup": "server setup",
"settings_server_enable_websockets": "metadata server enabled", "settings_server_enable_websockets": "metadata server enabled",
"settings_server_metadata_port": "metadata port:",
"settings_server_enable_http": "audio streaming enabled", "settings_server_enable_http": "audio streaming enabled",
"settings_server_audio_port": "audio port:", "settings_server_port": "port:",
"settings_server_transcoder_synchronous": "synchronous transcoding", "settings_server_transcoder_synchronous": "synchronous transcoding",
"settings_server_transcoder_cache_size": "transcoder file cache count", "settings_server_transcoder_cache_count": "transcoder file cache count:",
"settings_server_password": "password:", "settings_server_password": "password:",
"settings_server_invalid_settings_title": "invalid settings", "settings_server_invalid_settings_title": "invalid settings",
"settings_server_invalid_settings_message": "invalid or missing settings. please check the values and try again.", "settings_server_invalid_settings_message": "invalid or missing settings. please check the values and try again.",