Dynamic MessageWindow height

This commit is contained in:
Jack Andersen 2016-01-02 16:42:52 -10:00
parent 8dfafc81c2
commit 04a182d5bb
4 changed files with 10 additions and 4 deletions

View File

@ -57,6 +57,7 @@ class ModalWindow : public View
protected: protected:
virtual void updateContentOpacity(float opacity) {} virtual void updateContentOpacity(float opacity) {}
RectangleConstraint& constraint() {return m_constraint;}
public: public:
ModalWindow(ViewResources& res, View& parentView, const RectangleConstraint& constraint, const Zeus::CColor& bgColor); ModalWindow(ViewResources& res, View& parentView, const RectangleConstraint& constraint, const Zeus::CColor& bgColor);

View File

@ -117,7 +117,7 @@ void FileBrowser::navigateToPath(const HECL::SystemString& path)
return; return;
m_path = path; m_path = path;
m_comps = PathComponents(path); m_comps = PathComponents(m_path);
if (S_ISREG(theStat.st_mode)) if (S_ISREG(theStat.st_mode))
{ {
HECL::SystemUTF8View utf8(m_comps.back()); HECL::SystemUTF8View utf8(m_comps.back());

View File

@ -8,7 +8,7 @@ namespace Specter
MessageWindow::MessageWindow(ViewResources& res, View& parentView, MessageWindow::MessageWindow(ViewResources& res, View& parentView,
Type type, const std::string& message, Type type, const std::string& message,
std::function<void (bool)> func) std::function<void (bool)> func)
: ModalWindow(res, parentView, RectangleConstraint(400 * res.pixelFactor(), 150 * res.pixelFactor()), : ModalWindow(res, parentView, RectangleConstraint(),
type==Type::ErrorOk ? res.themeData().splashErrorBackground() : res.themeData().splashBackground()), type==Type::ErrorOk ? res.themeData().splashErrorBackground() : res.themeData().splashBackground()),
m_type(type), m_func(func), m_type(type), m_func(func),
m_okBind(*this, rootView().viewManager().translateOr("ok", "OK")), m_okBind(*this, rootView().viewManager().translateOr("ok", "OK")),
@ -18,6 +18,7 @@ MessageWindow::MessageWindow(ViewResources& res, View& parentView,
m_text.reset(new MultiLineTextView(res, *this, res.m_mainFont, TextView::Alignment::Center)); m_text.reset(new MultiLineTextView(res, *this, res.m_mainFont, TextView::Alignment::Center));
m_text->typesetGlyphs(message, res.themeData().uiText(), 380 * res.pixelFactor()); m_text->typesetGlyphs(message, res.themeData().uiText(), 380 * res.pixelFactor());
constraint() = RectangleConstraint(400 * res.pixelFactor(), 80 * res.pixelFactor() + m_text->nominalHeight());
m_ok.m_view.reset(new Button(res, *this, &m_okBind, m_okBind.m_name, m_ok.m_view.reset(new Button(res, *this, &m_okBind, m_okBind.m_name,
Button::Style::Block, RectangleConstraint(150 * res.pixelFactor()))); Button::Style::Block, RectangleConstraint(150 * res.pixelFactor())));
@ -73,7 +74,7 @@ void MessageWindow::resized(const boo::SWindowRect& root, const boo::SWindowRect
ModalWindow::resized(root, sub); ModalWindow::resized(root, sub);
boo::SWindowRect buttonRect = subRect(); boo::SWindowRect buttonRect = subRect();
float pf = rootView().viewRes().pixelFactor(); float pf = rootView().viewRes().pixelFactor();
buttonRect.location[1] += 25 * pf; buttonRect.location[1] += 20 * pf;
buttonRect.size[0] = m_ok.m_view->nominalWidth(); buttonRect.size[0] = m_ok.m_view->nominalWidth();
buttonRect.size[1] = m_ok.m_view->nominalHeight(); buttonRect.size[1] = m_ok.m_view->nominalHeight();
if (m_type == Type::ConfirmOkCancel) if (m_type == Type::ConfirmOkCancel)
@ -91,7 +92,7 @@ void MessageWindow::resized(const boo::SWindowRect& root, const boo::SWindowRect
boo::SWindowRect textRect = subRect(); boo::SWindowRect textRect = subRect();
textRect.location[0] += 200 * pf; textRect.location[0] += 200 * pf;
textRect.location[1] += 120 * pf; textRect.location[1] += 65 * pf;
m_text->resized(root, textRect); m_text->resized(root, textRect);
} }

View File

@ -244,7 +244,11 @@ void Table::selectRow(size_t r)
Log.report(LogVisor::FatalError, "selectRow out of bounds (%" PRISize ", %" PRISize ")", Log.report(LogVisor::FatalError, "selectRow out of bounds (%" PRISize ", %" PRISize ")",
r, m_rows); r, m_rows);
if (r == m_selectedRow) if (r == m_selectedRow)
{
if (m_state)
m_state->setSelectedRow(r);
return; return;
}
if (m_selectedRow != -1) if (m_selectedRow != -1)
for (auto& col : m_cellViews) for (auto& col : m_cellViews)
{ {