Skip to content

Commit

Permalink
UI|libgui: Working on BrowserWidget; handling native UI mode
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 76369d5 commit e1083dc
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 25 deletions.
4 changes: 0 additions & 4 deletions doomsday/apps/client/src/ui/home/nogamescolumnwidget.cpp
Expand Up @@ -63,8 +63,6 @@ void NoGamesColumnWidget::browseForDataFiles()
{
bool reload = false;

// Use a native dialog to select the IWAD folder.
ClientApp::app().beginNativeUIMode();
auto &cfg = Config::get();

FileDialog dlg;
Expand Down Expand Up @@ -96,8 +94,6 @@ void NoGamesColumnWidget::browseForDataFiles()
reload = true;
}

ClientApp::app().endNativeUIMode();

// Reload packages and recheck for game availability.
if (reload)
{
Expand Down
4 changes: 0 additions & 4 deletions doomsday/apps/client/src/ui/widgets/nativepathwidget.cpp
Expand Up @@ -109,8 +109,6 @@ void NativePathWidget::setPath(const NativePath &path)

void NativePathWidget::chooseUsingNativeFileDialog()
{
ClientApp::app().beginNativeUIMode();

// Use a native dialog to pick the path.
NativePath dir = d->path;
if (d->path.isEmpty()) dir = NativePath::homePath();
Expand All @@ -125,8 +123,6 @@ void NativePathWidget::chooseUsingNativeFileDialog()
setText(d->labelText());
DE_FOR_AUDIENCE2(UserChange, i) i->pathChangedByUser(*this);
}

ClientApp::app().endNativeUIMode();
}

void NativePathWidget::clearPath()
Expand Down
Expand Up @@ -25,7 +25,7 @@ namespace de {
class DirectoryBrowserWidget : public BrowserWidget
{
public:
DirectoryBrowserWidget(const String &name = {});
DirectoryBrowserWidget(const String &name = "dir-browser");

private:
DE_PRIVATE(d)
Expand Down
7 changes: 6 additions & 1 deletion doomsday/libs/gui/src/dialogs/filedialog_windows.cpp
Expand Up @@ -17,6 +17,7 @@
*/

#include "de/FileDialog"
#include "de/BaseGuiApp"

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
Expand Down Expand Up @@ -89,7 +90,7 @@ List<NativePath> FileDialog::selectedPaths() const

bool FileDialog::exec(GuiRootWidget &)
{
d->selection.clear();
d->selection.clear();

IFileOpenDialog *dlg = nullptr;
if (FAILED(CoCreateInstance(
Expand All @@ -98,6 +99,8 @@ bool FileDialog::exec(GuiRootWidget &)
return false;
}

DE_BASE_GUI_APP->beginNativeUIMode();

// Configure the dialog according to user-specified options.
DWORD options;
dlg->GetOptions(&options);
Expand Down Expand Up @@ -170,6 +173,8 @@ bool FileDialog::exec(GuiRootWidget &)
// Cleanup.
dlg->Release();

DE_BASE_GUI_APP->endNativeUIMode();

return !d->selection.empty();
}

Expand Down
18 changes: 15 additions & 3 deletions doomsday/libs/gui/src/dialogs/filedialog_x11.cpp
Expand Up @@ -18,7 +18,7 @@

#include "de/FileDialog"
#include "de/DirectoryBrowserWidget"
#include "de/DialogWidget"
#include "de/MessageDialog"

namespace de {

Expand Down Expand Up @@ -47,12 +47,24 @@ DE_PIMPL_NOREF(FileDialog)
// return list;
// }

DialogWidget *makeDialog()
MessageDialog *makeDialog()
{
auto *dlg = new DialogWidget;
auto *dlg = new MessageDialog;
dlg->setDeleteAfterDismissed(true);
dlg->title().setText(title);
dlg->message().setText("Here's what you can do.");
dlg->buttons() << new DialogButtonItem(DialogWidget::Default | DialogWidget::Accept, prompt)
<< new DialogButtonItem(DialogWidget::Reject);

dlg->area().enableScrolling(false);
dlg->area().enableIndicatorDraw(false);
dlg->area().enablePageKeys(false);

browser = new DirectoryBrowserWidget;
browser->setCurrentPath(initialLocation);
browser->rule().setInput(Rule::Height, browser->rule().width());
dlg->area().add(browser);
dlg->updateLayout();

return dlg;
}
Expand Down
29 changes: 21 additions & 8 deletions doomsday/libs/gui/src/widgets/browserwidget.cpp
Expand Up @@ -20,6 +20,7 @@
#include "de/ButtonWidget"
#include "de/MenuWidget"
#include "de/ProgressWidget"
#include "de/ScrollAreaWidget"

namespace de {

Expand All @@ -28,28 +29,40 @@ DE_PIMPL(BrowserWidget)
const ui::TreeData *data = nullptr;
Path path;
LabelWidget *currentPath;
ScrollAreaWidget *scroller;
MenuWidget *menu;

Impl(Public *i)
: Base(i)
{
RuleRectangle &rule = self().rule();

currentPath = new LabelWidget;
currentPath->rule()
.setInput(Rule::Width, rule.width())
.setLeftTop(rule.left(), rule.top());
currentPath = new LabelWidget("cwd");
currentPath->setSizePolicy(ui::Fixed, ui::Expand);
currentPath->rule()
.setLeftTop(rule.left(), rule.top())
.setInput(Rule::Width, rule.width());

menu = new MenuWidget;
// menu->enableIndicatorDraw(true);
menu->rule()
scroller = new ScrollAreaWidget("scroller");
scroller->rule()
.setLeftTop(rule.left(), currentPath->rule().bottom())
.setInput(Rule::Width, rule.width())
.setInput(Rule::Bottom, rule.bottom());

menu = new MenuWidget("items");
menu->setGridSize(1, ui::Filled, 0, ui::Expand);
menu->rule()
.setLeftTop(scroller->contentRule().left(), scroller->contentRule().top())
.setInput(Rule::Width, rule.width());

scroller->setContentSize(menu->rule());
scroller->enablePageKeys(true);
scroller->enableScrolling(true);
scroller->enableIndicatorDraw(true);

i->add(currentPath);
i->add(menu);
scroller->add(menu);
i->add(scroller);
}

void changeTo(const Path &newPath)
Expand Down
4 changes: 0 additions & 4 deletions doomsday/libs/gui/src/widgets/directoryarraywidget.cpp
Expand Up @@ -41,8 +41,6 @@ DirectoryArrayWidget::DirectoryArrayWidget(Variable &variable, String const &nam
addButton().setText("Add Folder...");
addButton().setActionFn([this] ()
{
DE_BASE_GUI_APP->beginNativeUIMode();

auto &cfg = Config::get();
FileDialog dlg;
dlg.setTitle("Select Folder");
Expand All @@ -57,8 +55,6 @@ DirectoryArrayWidget::DirectoryArrayWidget(Variable &variable, String const &nam
elementsMenu().items() << makeItem(TextValue(dir));
setVariableFromWidget();
}

DE_BASE_GUI_APP->endNativeUIMode();
});

updateFromVariable();
Expand Down

0 comments on commit e1083dc

Please sign in to comment.