Skip to content

Commit

Permalink
Fix tree widget
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Oct 9, 2024
1 parent bd63dd1 commit a56b5f9
Show file tree
Hide file tree
Showing 24 changed files with 32 additions and 50 deletions.
2 changes: 1 addition & 1 deletion lib/app/include/app/application/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace VTX::App::Application
inline Component::Render::Camera & getCamera() { return *_camera; }

// Callbacks
Util::Callback<Component::Scene::SceneItemComponent> onSceneItemAdded;
Util::Callback<Component::Scene::SceneItemComponent &> onSceneItemAdded;

private:
int _persistentIDCounter = 0;
Expand Down
3 changes: 3 additions & 0 deletions lib/app/src/app/entity/scene/scene_item_entity.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "app/entity/scene/scene_item_entity.hpp"
#include "app/application/scene.hpp"
#include "app/component/chemistry/molecule.hpp"
#include "app/vtx_app.hpp"

namespace VTX::App::Entity::Scene
Expand All @@ -24,6 +25,8 @@ namespace VTX::App::Entity::Scene
Component::Scene::SceneItemComponent & sceneItemComponent
= MAIN_REGISTRY().getComponent<Component::Scene::SceneItemComponent>( p_entity );

assert( MAIN_REGISTRY().hasComponent<Component::Chemistry::Molecule>( sceneItemComponent ) );

scene->referenceItem( sceneItemComponent );
}
} // namespace VTX::App::Entity::Scene
7 changes: 1 addition & 6 deletions lib/ui/qt/include/ui/qt/dock_widget/colors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ namespace VTX::UI::QT::DockWidget
class Colors : public BaseWidget<Colors, QDockWidget>
{
public:
Colors( QWidget * p_parent ) : BaseWidget<Colors, QDockWidget>( "Colors", p_parent )
{
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
}

virtual ~Colors() {}
Colors( QWidget * p_parent );
};

} // namespace VTX::UI::QT::DockWidget
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/dock_widget/inspector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace VTX::UI::QT::DockWidget
{
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
}

virtual ~Inspector() {}
};

} // namespace VTX::UI::QT::DockWidget
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/dock_widget/render_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ namespace VTX::UI::QT::DockWidget
layout->setSizeConstraint( QLayout::SetNoConstraint );
setWidget( widget );
}

virtual ~RenderSettings() {}
};

} // namespace VTX::UI::QT::DockWidget
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/dock_widget/representations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace VTX::UI::QT::DockWidget
{
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
}

virtual ~Representations() {}
};

} // namespace VTX::UI::QT::DockWidget
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/qt/include/ui/qt/dock_widget/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ namespace VTX::UI::QT::DockWidget
using namespace App::Component::Scene;
App::SCENE().onSceneItemAdded += [ this ]( const SceneItemComponent & p_item )
{
using namespace App;
assert( MAIN_REGISTRY().hasComponent<Component::Chemistry::Molecule>( p_item ) );
if ( App::MAIN_REGISTRY().hasComponent<App::Component::Chemistry::Molecule>( p_item ) )
{
auto & molecule = App::MAIN_REGISTRY().getComponent<App::Component::Chemistry::Molecule>( p_item );
Expand Down Expand Up @@ -258,8 +260,6 @@ namespace VTX::UI::QT::DockWidget
layout->addWidget( _tree.get() );
}

virtual ~Scene() {}

void addTopLevelData( const TreeItemData & p_data, const LoadFunc & p_loadFunc )
{
QTreeWidgetItem * item = new QTreeWidgetItem();
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/dock_widget/sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ namespace VTX::UI::QT::DockWidget
{
setAllowedAreas( Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea );
}

virtual ~Sequence() {}
};

} // namespace VTX::UI::QT::DockWidget
Expand Down
1 change: 0 additions & 1 deletion lib/ui/qt/include/ui/qt/line_edit/command_launcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace VTX::UI::QT::LineEdit
{
public:
CommandLauncher( QWidget * p_parent );
virtual ~CommandLauncher() {}

private:
void _setupCompleter();
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/menu/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ namespace VTX::UI::QT::Menu
addAction<Action::Camera::Reset>();
}

virtual ~Camera() {}

private:
};

Expand Down
1 change: 0 additions & 1 deletion lib/ui/qt/include/ui/qt/menu/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace VTX::UI::QT::Menu
addSeparator();
addAction<Action::System::Quit>();
}
virtual ~File() {}

private:
};
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/menu/help.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ namespace VTX::UI::QT::Menu
addAction<Action::Help::About>();
}

virtual ~Help() {}

private:
};

Expand Down
1 change: 0 additions & 1 deletion lib/ui/qt/include/ui/qt/menu/theme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace VTX::UI::QT::Menu
auto * aReset = addAction<Action::Theme::ResetLayout>();
connect( aReset, &QAction::triggered, this, &Theme::_resetLayout );
}
virtual ~Theme() {}

private:
void _resetLayout();
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/menu/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ namespace VTX::UI::QT::Menu
*/
}

virtual ~View() {}

private:
};

Expand Down
1 change: 0 additions & 1 deletion lib/ui/qt/include/ui/qt/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace VTX::UI::QT
{
public:
Settings();
virtual ~Settings() {}

inline void add( Savable * const p_savable ) { _savables.push_back( p_savable ); }
inline void remove( Savable * const p_savable ) { std::erase( _savables, p_savable ); }
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/tool_bar/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace VTX::UI::QT::ToolBar
addAction<Action::Camera::Reset>();
}

virtual ~Camera() {}

private:
};

Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/tool_bar/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace VTX::UI::QT::ToolBar
addAction<Action::System::Save>();
}

virtual ~File() {}

private:
};

Expand Down
2 changes: 0 additions & 2 deletions lib/ui/qt/include/ui/qt/tool_bar/snapshot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace VTX::UI::QT::ToolBar
addAction<Action::Snapshot::Export>();
}

virtual ~Snapshot() {}

private:
};

Expand Down
1 change: 0 additions & 1 deletion lib/ui/qt/include/ui/qt/widget/main_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace VTX::UI::QT::Widget
{
public:
MainWindow();
virtual ~MainWindow() {}

void prepare();
void build();
Expand Down
5 changes: 2 additions & 3 deletions lib/ui/qt/include/ui/qt/widget/opengl_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace VTX::UI::QT::Widget
{
public:
OpenGLWidget( QWidget * );
virtual ~OpenGLWidget();
~OpenGLWidget();

void render();
void resizeEvent( QResizeEvent * ) override;
Expand All @@ -29,8 +29,7 @@ namespace VTX::UI::QT::Widget

private:
QPointer<QOpenGLContext> _context;
QPointer<Window::EventCatchWindow> _surface;
QOpenGLPaintDevice * _device;
QPointer<Window::EventCatchWindow> _window;
QPointer<QWidget> _container;
};
} // namespace VTX::UI::QT::Widget
Expand Down
1 change: 0 additions & 1 deletion lib/ui/qt/include/ui/qt/widget/status_bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace VTX::UI::QT::Widget
{
public:
StatusBar( QWidget * p_parent );
virtual ~StatusBar() {}
};

} // namespace VTX::UI::QT::Widget
Expand Down
11 changes: 11 additions & 0 deletions lib/ui/qt/src/ui/qt/dock_widget/colors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "ui/qt/dock_widget/colors.hpp"

namespace VTX::UI::QT::DockWidget
{

Colors::Colors( QWidget * p_parent ) : BaseWidget<Colors, QDockWidget>( "Colors", p_parent )
{
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
}

} // namespace VTX::UI::QT::DockWidget
22 changes: 11 additions & 11 deletions lib/ui/qt/src/ui/qt/widget/opengl_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ namespace VTX::UI::QT::Widget
}

// Create window.
_surface = new Window::EventCatchWindow();
_surface->setFormat( format );
_surface->setSurfaceType( QSurface::OpenGLSurface );
_surface->setFlags( Qt::FramelessWindowHint );
_surface->create();
_window = new Window::EventCatchWindow();
_window->setFormat( format );
_window->setSurfaceType( QSurface::OpenGLSurface );
_window->setFlags( Qt::FramelessWindowHint );
_window->create();

// Use a widget container to embed the window.
_container = createWindowContainer( _surface, this );
_container = createWindowContainer( _window, this );

// Set context.
_context->makeCurrent( _surface );
_context->makeCurrent( _window );

// Connect signals.
APP::onPostRender += [ this ]( const float ) { render(); };
Expand All @@ -46,18 +46,18 @@ namespace VTX::UI::QT::Widget

void OpenGLWidget::render()
{
_context->swapBuffers( _surface );
_context->makeCurrent( _surface );
_context->swapBuffers( _window );
_context->makeCurrent( _window );
}

void OpenGLWidget::resizeEvent( QResizeEvent * p_event )
{
assert( _surface );
assert( _window );
assert( _container );

QWidget::resizeEvent( p_event );

_surface->resize( p_event->size() );
_window->resize( p_event->size() );
_container->resize( p_event->size() );

App::ACTION_SYSTEM().execute<App::Action::Application::Resize>(
Expand Down
2 changes: 1 addition & 1 deletion lib/util/include/util/callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace VTX::Util
{
for ( const auto & callback : _callbacks )
{
callback.second( p_args... );
callback.second( std::forward<Args>( p_args )... );
}
}

Expand Down

0 comments on commit a56b5f9

Please sign in to comment.