Ember
Loading...
Searching...
No Matches
CustomTabArt.h
Go to the documentation of this file.
1#pragma once
2
3#include <wx/aui/auibook.h>
4#include <wx/aui/tabart.h>
5#include <wx/bitmap.h>
6#include <wx/event.h>
7
8namespace EmberForge {
9
10// Custom event types for tab bar buttons
11wxDECLARE_EVENT(EVT_TAB_ART_ADD_BUTTON, wxCommandEvent);
12wxDECLARE_EVENT(EVT_TAB_ART_MENU_BUTTON, wxCommandEvent);
13
14// Button identifiers for hit testing
15enum class TabBarButton { None = 0, AddTab = 1, Menu = 2 };
16
24class CustomTabArt : public wxAuiFlatTabArt {
25 public:
27 virtual ~CustomTabArt() = default;
28
29 wxAuiTabArt *Clone() override;
30
34 int GetIndentSize() override;
35
39 int GetBestTabCtrlSize(wxWindow *wnd, const wxAuiNotebookPageArray &pages, const wxSize &requiredBmpSize) override;
40
44 void UpdateAccentColor();
45
46 int DrawPageTab(wxDC &dc, wxWindow *wnd, wxAuiNotebookPage &page, const wxRect &rect) override;
47
52 void LoadButtonIcons();
53
60 void DrawTabBarButtons(wxDC &dc, wxWindow *wnd, const wxRect &rect);
61
68 TabBarButton ButtonHitTest(int x, int y) const;
69
74 int GetButtonAreaWidth() const;
75
80 void SetHoveredButton(TabBarButton button);
81
86 void SetPressedButton(TabBarButton button);
87
92 bool AreButtonsEnabled() const { return m_buttonsEnabled; }
93
98 void SetButtonsEnabled(bool enabled) { m_buttonsEnabled = enabled; }
99
100 private:
102
103 // Button icons (normal, hovered, pressed states)
106
107 // Button rectangles for hit testing (updated during drawing)
110
111 // Button states
114
115 // Whether buttons are enabled
118
119 // Button dimensions
120 static const int BUTTON_SIZE = 20;
121 static const int BUTTON_SPACING = 4;
122 static const int BUTTON_MARGIN = 8;
123};
124
125} // namespace EmberForge
void DrawTabBarButtons(wxDC &dc, wxWindow *wnd, const wxRect &rect)
Draw the tab bar buttons (+ and menu) at the right side of the tab area.
int GetBestTabCtrlSize(wxWindow *wnd, const wxAuiNotebookPageArray &pages, const wxSize &requiredBmpSize) override
Override to get a taller tab bar.
virtual ~CustomTabArt()=default
void LoadButtonIcons()
Load button icons from resources Must be called after construction when a window context is available...
void SetButtonsEnabled(bool enabled)
Enable or disable the integrated buttons.
static const int BUTTON_MARGIN
int GetButtonAreaWidth() const
Get the width reserved for buttons on the right side of the tab bar.
bool AreButtonsEnabled() const
Check if buttons are enabled/visible.
static const int BUTTON_SPACING
void SetHoveredButton(TabBarButton button)
Set the hovered button state (for visual feedback)
TabBarButton ButtonHitTest(int x, int y) const
Test if a point hits one of the tab bar buttons.
void UpdateAccentColor()
Update the highlight color to match the current accent color preference.
int GetIndentSize() override
Override to increase tab bar height for larger buttons.
static const int BUTTON_SIZE
int DrawPageTab(wxDC &dc, wxWindow *wnd, wxAuiNotebookPage &page, const wxRect &rect) override
wxAuiTabArt * Clone() override
void SetPressedButton(TabBarButton button)
Set the pressed button state (for visual feedback)
wxDECLARE_EVENT(EVT_TAB_ART_ADD_BUTTON, wxCommandEvent)