Make TabContainer use TabBar internally
This commit is contained in:
parent
cfd4433bbc
commit
a811ebf699
19 changed files with 617 additions and 966 deletions
|
|
@ -33,46 +33,32 @@
|
|||
|
||||
#include "scene/gui/container.h"
|
||||
#include "scene/gui/popup.h"
|
||||
#include "scene/resources/text_line.h"
|
||||
#include "scene/gui/tab_bar.h"
|
||||
|
||||
class TabContainer : public Container {
|
||||
GDCLASS(TabContainer, Container);
|
||||
|
||||
public:
|
||||
enum AlignmentMode {
|
||||
ALIGNMENT_LEFT,
|
||||
ALIGNMENT_CENTER,
|
||||
ALIGNMENT_RIGHT,
|
||||
};
|
||||
|
||||
private:
|
||||
int first_tab_cache = 0;
|
||||
int tabs_ofs_cache = 0;
|
||||
int last_tab_cache = 0;
|
||||
int current = 0;
|
||||
int previous = 0;
|
||||
TabBar *tab_bar;
|
||||
bool tabs_visible = true;
|
||||
bool all_tabs_in_front = false;
|
||||
bool buttons_visible_cache = false;
|
||||
bool menu_hovered = false;
|
||||
int highlight_arrow = -1;
|
||||
AlignmentMode alignment = ALIGNMENT_CENTER;
|
||||
int _get_top_margin() const;
|
||||
mutable ObjectID popup_obj_id;
|
||||
bool drag_to_rearrange_enabled = false;
|
||||
bool use_hidden_tabs_for_min_size = false;
|
||||
int tabs_rearrange_group = -1;
|
||||
bool theme_changing = false;
|
||||
|
||||
Vector<Ref<TextLine>> text_buf;
|
||||
Vector<Control *> _get_tabs() const;
|
||||
int _get_tab_width(int p_index) const;
|
||||
bool _theme_changing = false;
|
||||
int _get_top_margin() const;
|
||||
Vector<Control *> _get_tab_controls() const;
|
||||
void _on_theme_changed();
|
||||
void _repaint();
|
||||
void _update_margins();
|
||||
void _on_mouse_exited();
|
||||
void _update_current_tab();
|
||||
void _draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_index, float p_x);
|
||||
void _refresh_texts();
|
||||
void _on_tab_changed(int p_tab);
|
||||
void _on_tab_selected(int p_tab);
|
||||
|
||||
Variant _get_drag_data_fw(const Point2 &p_point, Control *p_from_control);
|
||||
bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) const;
|
||||
void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control);
|
||||
|
||||
protected:
|
||||
void _child_renamed_callback();
|
||||
|
|
@ -81,17 +67,17 @@ protected:
|
|||
virtual void add_child_notify(Node *p_child) override;
|
||||
virtual void move_child_notify(Node *p_child) override;
|
||||
virtual void remove_child_notify(Node *p_child) override;
|
||||
|
||||
Variant get_drag_data(const Point2 &p_point) override;
|
||||
bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
|
||||
void drop_data(const Point2 &p_point, const Variant &p_data) override;
|
||||
int get_tab_idx_at_point(const Point2 &p_point) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_tab_alignment(AlignmentMode p_alignment);
|
||||
AlignmentMode get_tab_alignment() const;
|
||||
int get_tab_idx_at_point(const Point2 &p_point) const;
|
||||
int get_tab_idx_from_control(Control *p_child) const;
|
||||
|
||||
void set_tab_alignment(TabBar::AlignmentMode p_alignment);
|
||||
TabBar::AlignmentMode get_tab_alignment() const;
|
||||
|
||||
void set_clip_tabs(bool p_clip_tabs);
|
||||
bool get_clip_tabs() const;
|
||||
|
||||
void set_tabs_visible(bool p_visible);
|
||||
bool are_tabs_visible() const;
|
||||
|
|
@ -106,10 +92,10 @@ public:
|
|||
Ref<Texture2D> get_tab_icon(int p_tab) const;
|
||||
|
||||
void set_tab_disabled(int p_tab, bool p_disabled);
|
||||
bool get_tab_disabled(int p_tab) const;
|
||||
bool is_tab_disabled(int p_tab) const;
|
||||
|
||||
void set_tab_hidden(int p_tab, bool p_hidden);
|
||||
bool get_tab_hidden(int p_tab) const;
|
||||
bool is_tab_hidden(int p_tab) const;
|
||||
|
||||
int get_tab_count() const;
|
||||
void set_current_tab(int p_current);
|
||||
|
|
@ -139,6 +125,4 @@ public:
|
|||
TabContainer();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(TabContainer::AlignmentMode);
|
||||
|
||||
#endif // TAB_CONTAINER_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue