Skip to content

Commit

Permalink
macOS: draw 3D sash for the docking windows
Browse files Browse the repository at this point in the history
Signed-off-by: Eran Ifrah <[email protected]>
  • Loading branch information
eranif committed Nov 16, 2024
1 parent a7dab79 commit 2ec6797
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
4 changes: 3 additions & 1 deletion LiteEditor/mainbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ int FrameTimerId = wxNewId();
// return the wxBORDER_SIMPLE that matches the current application theme
wxBorder get_border_simple_theme_aware_bit()
{
#if defined(__WXMAC__) || defined(__WXMSW__)
#if defined(__WXMSW__)
if (clSystemSettings::GetAppearance().IsDark()) {
return wxBORDER_SIMPLE;
} else {
return wxBORDER_THEME;
}
#elif defined(__WXMAC__)
return wxBORDER_NONE;
#else
return wxBORDER_DEFAULT;
#endif
Expand Down
43 changes: 41 additions & 2 deletions Plugin/cl_aui_dock_art.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size)
ret += wxT("...");
return ret;
}

void Draw3DSash(wxDC& dc, const wxRect& rect, int orientation, const wxColour& bg, const wxColour& light_colour,
const wxColour& dark_colour)
{
dc.SetPen(bg);
dc.SetBrush(bg);
dc.DrawRectangle(rect);

if (orientation == wxVERTICAL) {
dc.SetPen(light_colour);
dc.DrawLine(rect.GetTopRight(), rect.GetBottomRight());

dc.SetPen(dark_colour);
dc.DrawLine(rect.GetTopLeft(), rect.GetBottomLeft());
} else {
dc.SetPen(light_colour);
dc.DrawLine(rect.GetBottomLeft(), rect.GetBottomRight());

dc.SetPen(dark_colour);
dc.DrawLine(rect.GetTopLeft(), rect.GetTopRight());
}
}
} // namespace

// ------------------------------------------------------------
Expand Down Expand Up @@ -297,16 +319,33 @@ void clAuiDockArt::DrawSash(wxDC& dc, wxWindow* window, int orientation, const w
wxUnusedVar(window);

bool isDark = clSystemSettings::IsDark();
#ifdef __WXGTK__
#if defined(__WXGTK__)
auto colour = isDark ? clSystemSettings::GetDefaultPanelColour().ChangeLightness(120)
: clSystemSettings::GetColour(wxSYS_COLOUR_3DFACE).ChangeLightness(80);

dc.SetPen(colour);
dc.SetBrush(colour);
dc.DrawRectangle(rect);
#elif defined(__WXMAC__)
if (isDark) {
auto bg_colour = clSystemSettings::GetDefaultPanelColour().ChangeLightness(120);
auto light_col = bg_colour.ChangeLightness(50);
auto dark_col = bg_colour.ChangeLightness(50);
Draw3DSash(dc, rect, orientation, bg_colour, light_col, dark_col);

} else {
auto dark_col = wxColour("LIGHT GREY");
auto light_col = wxColour("WHITE");
auto bg_colour = clSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
Draw3DSash(dc, rect, orientation, bg_colour, light_col, dark_col);
}
#else
auto colour = isDark ? clSystemSettings::GetDefaultPanelColour().ChangeLightness(120)
: clSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
#endif
dc.SetPen(colour);
dc.SetBrush(colour);
dc.DrawRectangle(rect);
#endif
}

void clAuiDockArt::OnSettingsChanged(clCommandEvent& event)
Expand Down

0 comments on commit 2ec6797

Please sign in to comment.