Skip to content

Commit

Permalink
Refacto UI/App/Qt WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Jun 18, 2024
1 parent 1ba040d commit 55de9df
Show file tree
Hide file tree
Showing 297 changed files with 1,234 additions and 997 deletions.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions .github/workflows/todo/cmake_ui_qt_to_do.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CMake UI

on:
push:
branches: [ "master", "dev", "dev-ndy", "dev-sge", "dev-vge" ]
paths: ['lib/ui/**', '.github/workflows/cmake_ui.yml']

env:
CMAKELISTS_DIR: ${{github.workspace}}/lib/ui

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019, ubuntu-22.04, macos-12]
fail-fast: false

steps:
- name: Set git to use CRLF
run: |
git config --global core.autocrlf true
git config --global core.eol crlf
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Get Conan
uses: turtlebrowser/[email protected]

- name: Create default profile
run: conan profile detect

- name: Add custom remote
run: |
conan remote add --insecure cano7782 ${{ secrets.CONAN_SERVER_HOST }}
conan remote login -p ${{ secrets.CONAN_SERVER_PASSWORD }} cano7782 ${{ secrets.CONAN_SERVER_USER }}
- name: Create package
working-directory: ${{env.CMAKELISTS_DIR}}
run: |
conan export ../util
conan export ../core
conan export ../io
conan export ../renderer
conan export ../app
conan export ../python_binding
conan create . --build=missing --settings=compiler.cppstd=20 -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=True
# TODO: tests without gui?

- name: Upload dependencies
working-directory: ${{env.CMAKELISTS_DIR}}
run: |
conan upload qt -r=cano7782
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ cmake_minimum_required(VERSION 3.23)

project(vtx)

find_package(vtx_util CONFIG REQUIRED)
find_package(vtx_app CONFIG REQUIRED)
find_package(vtx_core CONFIG REQUIRED)
find_package(vtx_io CONFIG REQUIRED)
find_package(vtx_python_binding CONFIG REQUIRED)
find_package(vtx_renderer CONFIG REQUIRED)
find_package(vtx_tool CONFIG REQUIRED)
find_package(vtx_ui CONFIG REQUIRED)
find_package(vtx_util CONFIG REQUIRED)
find_package(vtx_ui_qt CONFIG REQUIRED)

set(_VTX_CONAN " ")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/library.cmake")
Expand Down
6 changes: 4 additions & 2 deletions cmake/library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ if (NOT DEFINED _VTX_CONAN)
target_link_libraries(vtx PUBLIC vtx_app)
target_link_libraries(vtx PUBLIC vtx_python_binding)
target_link_libraries(vtx PUBLIC vtx_ui)
#target_link_libraries(vtx PUBLIC vtx_tool)
target_link_libraries(vtx PUBLIC vtx_ui_qt)
target_link_libraries(vtx PUBLIC vtx_tool)
else()
target_link_libraries(vtx PRIVATE vtx_util::vtx_util)
target_link_libraries(vtx PRIVATE vtx_core::vtx_core)
Expand All @@ -23,7 +24,8 @@ else()
target_link_libraries(vtx PRIVATE vtx_app::vtx_app)
target_link_libraries(vtx PRIVATE vtx_python_binding::vtx_python_binding)
target_link_libraries(vtx PRIVATE vtx_ui::vtx_ui)
#target_link_libraries(vtx PRIVATE vtx_tool::vtx_tool)
target_link_libraries(vtx PRIVATE vtx_ui_qt::vtx_ui_qt)
target_link_libraries(vtx PRIVATE vtx_tool::vtx_tool)
endif()

vtx_register_build_directory_copy("${CMAKE_CURRENT_LIST_DIR}/../data" "./data")
Expand Down
3 changes: 2 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ class VTXRecipe(ConanFile):
exports_sources = "CMakeLists.txt", "include/*", "src/*", "asset/*", "data/*", "internal_data/*", "libraries/*", "CHANGELOG.md", "README.md", "license.txt"

def requirements(self):
self.requires("vtx_util/1.0")
self.requires("vtx_app/1.0")
self.requires("vtx_core/1.0")
self.requires("vtx_io/1.0")
self.requires("vtx_python_binding/1.0")
self.requires("vtx_renderer/1.0")
self.requires("vtx_tool/1.0")
self.requires("vtx_ui/1.0")
self.requires("vtx_util/1.0")
self.requires("vtx_ui_qt/1.0")

def layout(self):
cmake_layout(self)
Expand Down
5 changes: 5 additions & 0 deletions dev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ include("${DIR_LIBS}/ui/test/cmake/library.cmake")

vtx_clear_registered_copies()

# UI Qt.
include("${DIR_LIBS}/ui/qt/cmake/library.cmake")

vtx_clear_registered_copies()

# Tool.
include("${DIR_LIBS}/tool/cmake/library.cmake")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef __VTX_UI_ACTION_ANIMATION__
#define __VTX_UI_ACTION_ANIMATION__

#include "ui/internal/animation/orient.hpp"
#include "ui/internal/animation/reset_camera.hpp"
#include "app/core/animation/orient.hpp"
#include "app/core/animation/reset_camera.hpp"
#include <app/core/action/base_action.hpp>
#include <util/math/aabb.hpp>
#include <util/types.hpp>

namespace VTX::UI::Action::Animation
namespace VTX::App::Action::Animation
{
class Orient final : public App::Core::Action::BaseAction
{
Expand All @@ -21,7 +21,7 @@ namespace VTX::UI::Action::Animation
void execute() override;

private:
const UI::Internal::Animation::OrientInfo _orientInfo;
const Core::Animation::OrientInfo _orientInfo;
};
class ResetCamera final : public App::Core::Action::BaseAction
{
Expand All @@ -30,7 +30,7 @@ namespace VTX::UI::Action::Animation
void execute() override;

private:
const UI::Internal::Animation::ResetInfo _resetInfo;
const Core::Animation::ResetInfo _resetInfo;
};
} // namespace VTX::UI::Action::Animation
} // namespace VTX::App::Action::Animation
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <util/types.hpp>
#include <vector>

namespace VTX::UI::Action::Visualization
namespace VTX::App::Action::Visualization
{
class ToggleCameraController final : public App::Core::Action::BaseAction
{
Expand All @@ -30,5 +30,5 @@ namespace VTX::UI::Action::Visualization
ApplyNextCameraController() {}
void execute() override;
};
} // namespace VTX::UI::Action::Visualization
} // namespace VTX::App::Action::Visualization
#endif
59 changes: 59 additions & 0 deletions lib/app/include/app/controller/camera/freefly.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef __VTX_UI_INTERNAL_CONTROLLER_CAMERA_FREEFLY__
#define __VTX_UI_INTERNAL_CONTROLLER_CAMERA_FREEFLY__

#include "app/core/controller/base_camera_controller.hpp"
#include "app/core/controller/controller_manager.hpp"
#include "app/core/input/key_mapping.hpp"
#include "app/settings.hpp"
#include <util/hashing.hpp>

namespace VTX::App::Controller::Camera
{

class Freefly : public Core::Controller::BaseCameraController
{
public:
inline static const Core::CollectionKey COLLECTION_ID = "CONTROLLER_FREEFLY";
inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID );

private:
inline static const Core::Controller::ControllerCollection::Registration<Freefly> _reg { COLLECTION_ID };

public:
enum class Keys : int
{
MOVE_LEFT,
MOVE_RIGHT,
MOVE_FRONT,
MOVE_BACK,
MOVE_UP,
MOVE_DOWN,
};

public:
Freefly() = default;
Freefly( const Freefly & p_source ) = default;
~Freefly() = default;

void init() override;
void setActive( const bool p_active ) override;

inline VTX::Util::Hashing::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; };
std::unique_ptr<BaseController> clone() const { return std::make_unique<Freefly>( *this ); };

float translationSpeed = Setting::Controller::TRANSLATION_SPEED_DEFAULT;
float accelerationFactor = Setting::Controller::ACCELERATION_FACTOR_DEFAULT;
float decelerationFactor = Setting::Controller::DECELERATION_FACTOR_DEFAULT;
float rotationSpeed = Setting::Controller::ROTATION_SPEED_DEFAULT;
bool invertY = Setting::Controller::INVERT_Y_DEFAULT;
bool elasticityActive = Setting::Controller::ELASTICITY_ACTIVE_DEFAULT;
float elasticityFactor = Setting::Controller::ELASTICITY_FACTOR_DEFAULT;

protected:
void _updateInputs( const float & p_deltaTime ) override;

private:
Core::Input::KeyMapping _mapping;
};
} // namespace VTX::App::Controller::Camera
#endif
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#ifndef __VTX_UI_INTERNAL_CONTROLLER_CAMERA_TRACKBALL__
#define __VTX_UI_INTERNAL_CONTROLLER_CAMERA_TRACKBALL__

#include "ui/core/input/key_mapping.hpp"
#include "ui/internal/all_settings.hpp"
#include "ui/qt/controller/base_camera_controller.hpp"
#include "ui/qt/controller/controller_manager.hpp"
#include "app/core/controller/base_camera_controller.hpp"
#include "app/core/controller/controller_manager.hpp"
#include "app/core/input/key_mapping.hpp"
#include "app/settings.hpp"
#include <app/component/render/camera.hpp>
#include <util/hashing.hpp>
#include <util/types.hpp>

namespace VTX::UI::Internal::Controller::Camera
namespace VTX::App::Controller::Camera
{
using namespace VTX::UI::QT;
using namespace VTX::UI::QT::Controller;

class Trackball : public BaseCameraController
class Trackball : public Core::Controller::BaseCameraController
{
public:
inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_TRACKBALL";
inline static const Core::CollectionKey COLLECTION_ID = "CONTROLLER_TRACKBALL";
inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID );

private:
inline static const ControllerCollection::Registration<Trackball> _reg { COLLECTION_ID };
inline static const float _CONTROLLER_ELASTICITY_THRESHOLD = 1e-4f;
inline static const Core::Controller::ControllerCollection::Registration<Trackball> _reg { COLLECTION_ID };
inline static const float _CONTROLLER_ELASTICITY_THRESHOLD = 1e-4f;

public:
enum class Keys : int
Expand Down Expand Up @@ -52,13 +50,13 @@ namespace VTX::UI::Internal::Controller::Camera

Vec3f targetSimulationFromCamera( const App::Component::Render::Camera & p_camera ) const;

float translationSpeed = Internal::Controller::TRANSLATION_SPEED_DEFAULT;
float accelerationFactor = Internal::Controller::ACCELERATION_FACTOR_DEFAULT;
float decelerationFactor = Internal::Controller::DECELERATION_FACTOR_DEFAULT;
float rotationSpeed = Internal::Controller::ROTATION_SPEED_DEFAULT;
bool invertY = Internal::Controller::INVERT_Y_DEFAULT;
bool elasticityActive = Internal::Controller::ELASTICITY_ACTIVE_DEFAULT;
float elasticityFactor = Internal::Controller::ELASTICITY_FACTOR_DEFAULT;
float translationSpeed = Setting::Controller::TRANSLATION_SPEED_DEFAULT;
float accelerationFactor = Setting::Controller::ACCELERATION_FACTOR_DEFAULT;
float decelerationFactor = Setting::Controller::DECELERATION_FACTOR_DEFAULT;
float rotationSpeed = Setting::Controller::ROTATION_SPEED_DEFAULT;
bool invertY = Setting::Controller::INVERT_Y_DEFAULT;
bool elasticityActive = Setting::Controller::ELASTICITY_ACTIVE_DEFAULT;
float elasticityFactor = Setting::Controller::ELASTICITY_FACTOR_DEFAULT;

protected:
void _updateInputs( const float & ) override;
Expand All @@ -71,5 +69,5 @@ namespace VTX::UI::Internal::Controller::Camera

bool _needUpdate = false;
};
} // namespace VTX::UI::Internal::Controller::Camera
} // namespace VTX::App::Controller::Camera
#endif
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#ifndef __VTX_UI_INTERNAL_CONTROLLER_PICKER_SELECTION_PICKER__
#define __VTX_UI_INTERNAL_CONTROLLER_PICKER_SELECTION_PICKER__

#include "ui/qt/controller/base_picker_controller.hpp"
#include "ui/qt/controller/controller_manager.hpp"
#include "app/core/controller/base_picker_controller.hpp"
#include "app/core/controller/controller_manager.hpp"
#include <app/application/selection/picking_info.hpp>
#include <util/hashing.hpp>
#include <util/types.hpp>

namespace VTX::UI::Internal::Controller::Picker
namespace VTX::App::Controller::Picker
{
using namespace VTX::UI::QT;
using namespace VTX::UI::QT::Controller;

class Selection : public BasePickerController
class Selection : public Core::Controller::BasePickerController
{
public:
using PickingInfo = App::Application::Selection::PickingInfo;
Expand All @@ -21,7 +19,7 @@ namespace VTX::UI::Internal::Controller::Picker
inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID );

private:
inline static const ControllerCollection::Registration<Selection> _reg { COLLECTION_ID };
inline static const Core::Controller::ControllerCollection::Registration<Selection> _reg { COLLECTION_ID };

public:
Selection() = default;
Expand All @@ -44,6 +42,6 @@ namespace VTX::UI::Internal::Controller::Picker
private:
PickingInfo _lastPickingInfo = PickingInfo();
};
} // namespace VTX::UI::Internal::Controller::Picker
} // namespace VTX::App::Controller::Picker

#endif
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
#ifndef __VTX_UI_INTERNAL_CONTROLLER_DEBUG_SHORTCUT__
#define __VTX_UI_INTERNAL_CONTROLLER_DEBUG_SHORTCUT__

#include "ui/core/input/keys.hpp"
#include "ui/qt/controller/base_shortcut_controller.hpp"
#include "ui/qt/controller/controller_manager.hpp"
#include "app/core/controller/base_shortcut_controller.hpp"
#include "app/core/controller/controller_manager.hpp"
#include <memory>
#include <util/hashing.hpp>

namespace VTX::UI::Internal::Controller::Shortcut
namespace VTX::App::Controller::Shortcut
{
using namespace VTX::UI::QT;
using namespace VTX::UI::QT::Controller;

class Debug final : public BaseShortcutController
class Debug final : public Core::Controller::BaseShortcutController
{
public:
inline static const App::Core::CollectionKey COLLECTION_ID = "CONTROLLER_SHORTCUT_DEBUG";
inline static const VTX::Util::Hashing::Hash HASHED_COLLECTION_ID = VTX::Util::Hashing::hash( COLLECTION_ID );

private:
inline static const ControllerCollection::Registration<Debug> _reg { COLLECTION_ID };
inline static const Core::Controller::ControllerCollection::Registration<Debug> _reg { COLLECTION_ID };

public:
Debug() = default;
Expand All @@ -31,5 +27,5 @@ namespace VTX::UI::Internal::Controller::Shortcut
inline VTX::Util::Hashing::Hash getHashedCollectionID() const override { return HASHED_COLLECTION_ID; };
std::unique_ptr<BaseController> clone() const { return std::make_unique<Debug>( *this ); };
};
} // namespace VTX::UI::Internal::Controller::Shortcut
} // namespace VTX::App::Controller::Shortcut
#endif
Loading

0 comments on commit 55de9df

Please sign in to comment.