Skip to content

Commit

Permalink
Fix owner usage bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Feb 14, 2025
1 parent ed4938c commit 08bd55d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 8 deletions.
3 changes: 2 additions & 1 deletion libopensimcreator/UI/FrameDefinition/FrameDefinitionTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,9 +960,10 @@ class osc::FrameDefinitionTab::Impl final : public TabPrivate {
{
m_PanelManager->register_toggleable_panel(
"Navigator",
[this](Widget*, std::string_view panelName)
[this](Widget* parent, std::string_view panelName)
{
return std::make_shared<NavigatorPanel>(
parent,
panelName,
m_Model,
[this](const OpenSim::ComponentPath& rightClickedPath)
Expand Down
3 changes: 2 additions & 1 deletion libopensimcreator/UI/ModelEditor/ModelEditorTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ class osc::ModelEditorTab::Impl final : public TabPrivate {

m_PanelManager->register_toggleable_panel(
"Navigator",
[this](Widget*, std::string_view panelName)
[this](Widget* parent, std::string_view panelName)
{
return std::make_shared<NavigatorPanel>(
parent,
panelName,
m_Model,
[this](const OpenSim::ComponentPath& p)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ class osc::PreviewExperimentalDataTab::Impl final : public TabPrivate {
[this](Widget* parent, std::string_view panelName)
{
return std::make_shared<NavigatorPanel>(
parent,
panelName,
m_UiState->updSharedModelPtr(),
[this, parent](const OpenSim::ComponentPath& p)
Expand Down
2 changes: 1 addition & 1 deletion libopensimcreator/UI/Shared/ComponentContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class osc::ComponentContextMenu::Impl final : public PopupPrivate {
m_Path{std::move(path_)},
m_Flags{flags_}
{
owner.set_modal(false);
set_modal(false);
OSC_ASSERT(m_Model != nullptr);
}

Expand Down
2 changes: 1 addition & 1 deletion libopensimcreator/UI/Shared/ImportStationsFromCSVPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class osc::ImportStationsFromCSVPopup::Impl final : public PopupPrivate {
PopupPrivate{owner, parent, popupName_},
m_OnImportCallback{std::move(onImport_)}
{
owner.set_modal(true);
set_modal(true);
}

void draw_content()
Expand Down
6 changes: 4 additions & 2 deletions libopensimcreator/UI/Shared/NavigatorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ class osc::NavigatorPanel::Impl final : public PanelPrivate {
public:
Impl(
NavigatorPanel& owner,
Widget* parent,
std::string_view panelName,
std::shared_ptr<IModelStatePair> model,
std::function<void(const OpenSim::ComponentPath&)> onRightClick) :

PanelPrivate{owner, nullptr, panelName},
PanelPrivate{owner, parent, panelName},
m_Model{std::move(model)},
m_OnRightClick{std::move(onRightClick)}
{}
Expand Down Expand Up @@ -329,10 +330,11 @@ class osc::NavigatorPanel::Impl final : public PanelPrivate {
};

osc::NavigatorPanel::NavigatorPanel(
Widget* parent,
std::string_view panelName,
std::shared_ptr<IModelStatePair> model,
std::function<void(const OpenSim::ComponentPath&)> onRightClick) :

Panel{std::make_unique<Impl>(*this, panelName, std::move(model), std::move(onRightClick))}
Panel{std::make_unique<Impl>(*this, parent, panelName, std::move(model), std::move(onRightClick))}
{}
void osc::NavigatorPanel::impl_draw_content() { private_data().draw_content(); }
1 change: 1 addition & 0 deletions libopensimcreator/UI/Shared/NavigatorPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace osc
class NavigatorPanel final : public Panel {
public:
explicit NavigatorPanel(
Widget* parent,
std::string_view panelName,
std::shared_ptr<IModelStatePair>,
std::function<void(const OpenSim::ComponentPath&)> onRightClick = [](const auto&){}
Expand Down
1 change: 1 addition & 0 deletions libopensimcreator/UI/Simulation/SimulationTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class osc::SimulationTab::Impl final :
[this](Widget* parent, std::string_view panelName)
{
return std::make_shared<NavigatorPanel>(
parent,
panelName,
m_ShownModelState,
[this, parent](const OpenSim::ComponentPath& p)
Expand Down
8 changes: 6 additions & 2 deletions liboscar/UI/Popups/Popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ void osc::PopupPrivate::request_close()
should_open_ = false;
}

void osc::PopupPrivate::set_modal(bool v)
{
is_modal_ = v;
}

osc::Popup::Popup(
Widget* parent,
std::string_view name,
Expand Down Expand Up @@ -183,8 +188,7 @@ bool osc::Popup::is_modal() const
}
void osc::Popup::set_modal(bool v)
{
PopupPrivate& pimpl = private_data();
pimpl.is_modal_ = v;
private_data().set_modal(v);
}
void osc::Popup::set_rect(const Rect& rect)
{
Expand Down
1 change: 1 addition & 0 deletions liboscar/UI/Popups/PopupPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace osc
protected:
bool is_popup_opened_this_frame() const;
void request_close();
void set_modal(bool);

OSC_OWNER_GETTERS(Popup);
private:
Expand Down

0 comments on commit 08bd55d

Please sign in to comment.