Various gizmos refactoring

This commit is contained in:
Filip Sykala 2023-10-29 23:11:10 +08:00 committed by Noisyfox
parent 30af274d44
commit 9dbb2dfe0d
22 changed files with 292 additions and 451 deletions

View file

@ -29,7 +29,6 @@ class ImGuiWrapper;
class GLCanvas3D;
enum class CommonGizmosDataID;
class CommonGizmosDataPool;
class Selection;
class GLGizmoBase
{
@ -137,13 +136,9 @@ protected:
unsigned int m_sprite_id;
int m_hover_id{ -1 };
bool m_dragging{ false };
ColorRGBA m_base_color;
ColorRGBA m_drag_color;
ColorRGBA m_highlight_color;
mutable std::vector<Grabber> m_grabbers;
ImGuiWrapper* m_imgui;
bool m_first_input_window_render{ true };
mutable std::string m_tooltip;
CommonGizmosDataPool* m_c{ nullptr };
bool m_is_dark_mode = false;
@ -161,9 +156,6 @@ public:
std::string get_name(bool include_shortcut = true) const;
int get_group_id() const { return m_group_id; }
void set_group_id(int id) { m_group_id = id; }
EState get_state() const { return m_state; }
void set_state(EState state) { m_state = state; on_set_state(); }
@ -188,29 +180,30 @@ public:
int get_hover_id() const { return m_hover_id; }
void set_hover_id(int id);
void set_highlight_color(const ColorRGBA& color) { m_highlight_color = color; }
void enable_grabber(unsigned int id);
void disable_grabber(unsigned int id);
void start_dragging();
void stop_dragging();
bool is_dragging() const { return m_dragging; }
// returns True when Gizmo changed its state
bool update_items_state();
void render() { m_tooltip.clear(); on_render(); }
void render() { on_render(); }
void render_input_window(float x, float y, float bottom_limit);
virtual void on_change_color_mode(bool is_dark) { m_is_dark_mode = is_dark; }
/// <summary>
/// Mouse tooltip text
/// </summary>
/// <returns>Text to be visible in mouse tooltip</returns>
virtual std::string get_tooltip() const { return ""; }
int get_count() { return ++count; }
std::string get_gizmo_name() { return on_get_name(); }
/// <summary>
/// Is called when data (Selection) is changed
/// </summary>
virtual void data_changed(){};
/// <summary>
/// Implement when want to process mouse events in gizmo
/// Click, Right click, move, drag, ...
@ -265,10 +258,12 @@ protected:
void set_dirty();
/// <summary>
///
/// function which
/// Set up m_dragging and call functions
/// on_start_dragging / on_dragging / on_stop_dragging
/// </summary>
/// <param name="mouse_event"></param>
/// <returns></returns>
/// <param name="mouse_event">Keep information about mouse click</param>
/// <returns>same as on_mouse</returns>
bool use_grabbers(const wxMouseEvent &mouse_event);
private:
// Flag for dirty visible state of Gizmo