Skip to content

Commit

Permalink
Shell: Improved UI style and behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 12, 2019
1 parent d8f32ee commit 41f77a8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 25 deletions.
10 changes: 10 additions & 0 deletions doomsday/libs/gui/src/widgets/tabwidget.cpp
Expand Up @@ -233,6 +233,16 @@ void TabWidget::update()
{
GuiWidget::update();

// Show or hide the selection highlight when enabled/disabled.
if (isEnabled() && fequal(d->selected->opacity().target(), 0.0f))
{
d->selected->setOpacity(1.0f, 300_ms);
}
else if (isDisabled() && !fequal(d->selected->opacity().target(), 0.0f))
{
d->selected->setOpacity(0.0f, 300_ms);
}

if (d->needUpdate)
{
d->updateSelected();
Expand Down
36 changes: 26 additions & 10 deletions doomsday/tools/shell/src/linkwindow.cpp
Expand Up @@ -144,6 +144,10 @@ DE_PIMPL(LinkWindow)
{
auto &style = Style::get();

LabelWidget *background = &root.addNew<LabelWidget>();
background->set(GuiWidget::Background(Vec4f(0.15f, 0.15f, 0.15f, 1.0f)));
background->rule().setRect(root.viewRule());

// Toolbar + menu bar.
{
tools = new GuiWidget;
Expand Down Expand Up @@ -230,6 +234,8 @@ DE_PIMPL(LinkWindow)
serverLogBuffer.addSink(logWidget->logSink());
}

root.moveToTop(*pageTabs);

// Page for quickly starting a new local server.
{
newLocalServerPage = new GuiWidget;
Expand All @@ -246,6 +252,7 @@ DE_PIMPL(LinkWindow)
}

auto *statusBar = new GuiWidget;
statusBar->set(GuiWidget::Background(Style::get().colors().colorf("background")));

// Status bar.
{
Expand All @@ -263,6 +270,7 @@ DE_PIMPL(LinkWindow)
menuButton->setSizePolicy(ui::Expand, ui::Expand);
menuButton->setText("Menu");
menuButton->setPopup(*menu, ui::Up);
menuButton->setFont("small");
// menuButton->setStyleImage("", menuButton->fontId());

root.add(statusBar);
Expand All @@ -272,32 +280,37 @@ DE_PIMPL(LinkWindow)
timeCounter = new LabelWidget;
currentHost = new LabelWidget;

AutoRef<Rule> statusHeight{style.fonts().font("default").height() +
statusMessage->setText(Stringf("Doomsday Shell %s", SHELL_VERSION));

AutoRef<Rule> statusHeight{style.fonts().font("small").height() +
statusMessage->margins().height()};

timeCounter->setFont("monospace");
timeCounter->setText("0:00:00");
timeCounter->margins().setTop(style.rules().rule("gap") +
style.fonts().font("default").ascent() -
style.fonts().font("small").ascent() -
style.fonts().font("monospace").ascent());
timeCounter->set(GuiWidget::Background(Vec4f(1, 0, 0, 1)));
// timeCounter->set(GuiWidget::Background(Vec4f(1, 0, 0, 1)));

//statusMessage->setText("Status message");
statusMessage->set(GuiWidget::Background(Vec4f(0, 0, 1, 1)));
statusMessage->setAlignment(ui::AlignLeft);
// statusMessage->set(GuiWidget::Background(Vec4f(0, 0, 1, 1)));
//gameStatus->setText("");
gameStatus->setOpacity(0.6f);
//currentHost->setText("localhost");

SequentialLayout layout(menuButton->rule().left(), statusBar->rule().top(), ui::Left);

for (auto *label : {timeCounter, currentHost, gameStatus, statusMessage})
{
label->setSizePolicy(ui::Expand, ui::Fixed);
if (label != statusMessage) label->setSizePolicy(ui::Expand, ui::Fixed);
if (label != timeCounter) label->setFont("small");
label->rule().setInput(Rule::Height, statusHeight);
statusBar->add(label);
layout << *label;
}
statusMessage->setSizePolicy(ui::Fixed, ui::Fixed);
statusMessage->rule().setInput(Rule::Left, statusBar->rule().left());
statusMessage->rule()
.setInput(Rule::Left, statusBar->rule().left());

statusBar->rule()
.setInput(Rule::Left, root.viewLeft())
Expand Down Expand Up @@ -481,9 +494,12 @@ DE_PIMPL(LinkWindow)
String mapId = rec["mapId"].value().asText();
String rules = rec["rules"].value().asText();

String msg = gameMode;
if (!mapId.isEmpty()) msg += " " + mapId;
if (!rules.isEmpty()) msg += " (" + rules + ")";
String msg; // = gameMode;
//if (!mapId.isEmpty()) msg += " " + mapId;
//if (!rules.isEmpty()) msg += " (" + rules + ")";
msg = mapId;
msg += " ";
msg += rules;

gameStatus->setText(msg);
}
Expand Down
31 changes: 16 additions & 15 deletions doomsday/tools/shell/src/localserverdialog.cpp
Expand Up @@ -71,12 +71,15 @@ DE_GUI_PIMPL(LocalServerDialog)
{
games->items() << new ChoiceItem(mode.title, TextValue(mode.option));
}
/*auto sel = games->items().findData(TextValue(cfg.gets("LocalServer.gameMode", "doom1-share")));

// Restore previous selection.
auto sel = games->items().findData(TextValue(cfg.gets("LocalServer.gameMode", "doom1-share")));
if (sel == ui::Data::InvalidPos)
{
sel = games->items().findData(TextValue("doom1-share"));
}*/
games->setSelected(cfg.getui("LocalServer.gameMode", 0));
}
games->setSelected(sel);

layout << *LabelWidget::newWithText("Game Mode:", &area)
<< *games;

Expand Down Expand Up @@ -270,18 +273,16 @@ void LocalServerDialog::configureGameOptions()

void LocalServerDialog::saveState()
{
auto &cfg = Config::get();

cfg.set("LocalServer.name", d->name->text());
cfg.set("LocalServer.gameMode", int(d->games->selected())); //Item().data().asText());
if (d->portChanged)
{
cfg.set("LocalServer.port", d->port->text().toInt());
}
cfg.set("LocalServer.announce", d->announce->isActive());
cfg.set("LocalServer.password", d->password->text());
cfg.set("LocalServer.runtime", d->runtime->path().toString());
cfg.set("LocalServer.options", d->options->text());
// Replace previous state completely.
Record &vars = Config::get().objectNamespace().addSubrecord("LocalServer");

vars.set("name", d->name->text());
vars.set("gameMode", d->games->selectedItem().data().asText());
vars.set("port", d->port->text().toInt());
vars.set("announce", d->announce->isActive());
vars.set("password", d->password->text());
vars.set("runtime", d->runtime->path().toString());
vars.set("options", d->options->text());
}

void LocalServerDialog::validate()
Expand Down
1 change: 1 addition & 0 deletions doomsday/tools/shell/src/statuswidget.cpp
Expand Up @@ -52,6 +52,7 @@ DE_GUI_PIMPL(StatusWidget)
.setInput(Rule::Bottom, rect.bottom() - i.margins().bottom());

stateLabel = &i.addNew<LabelWidget>("gamestate");
stateLabel->setOpacity(0.6f);
stateLabel->setSizePolicy(ui::Expand, ui::Expand);
//stateLabel->setFont("heading");
stateLabel->margins().setTop(rule("gap") * 2).setBottom(Const(0));
Expand Down

0 comments on commit 41f77a8

Please sign in to comment.