Skip to content

Commit

Permalink
Fixed macOS: resizing windows is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
eranif committed Jul 9, 2024
1 parent 387f921 commit ea503d6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 39 deletions.
18 changes: 4 additions & 14 deletions LiteEditor/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include "BreakpointsView.hpp"
#include "ColoursAndFontsManager.h"
#include "CompilersDetectorManager.h"
#include "Cxx/cpptoken.h"
#include "CompilersFoundDlg.h"
#include "Cxx/cpptoken.h"
#include "DebuggerToolBar.h"
#include "GCCMetadata.hpp"
#include "Notebook.h"
Expand Down Expand Up @@ -1243,14 +1243,7 @@ void clMainFrame::CreateGUIControls()

m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE, 0);
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_PANE_BUTTON_SIZE, GetBestXButtonSize(this));

#if defined(__WXMSW__)
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_SASH_SIZE, 4);
#elif defined(__WXMAC__)
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_SASH_SIZE, 1);
#else
m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_SASH_SIZE, 4);
#endif

// add menu bar
m_mainMenuBar = wxXmlResource::Get()->LoadMenuBar("main_menu");
Expand Down Expand Up @@ -1328,7 +1321,7 @@ void clMainFrame::CreateGUIControls()

// Wrap the mainbook with a wxPanel
// We do this so we can place the find bar under the main book
long container_style = get_border_simple_theme_aware_bit() | wxTAB_TRAVERSAL;
long container_style = wxBORDER_NONE | wxTAB_TRAVERSAL;
wxPanel* container = new wxPanel(m_mainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, container_style);

EventNotifier::Get()->Bind(wxEVT_SYS_COLOURS_CHANGED, [container](clCommandEvent& e) {
Expand Down Expand Up @@ -5043,8 +5036,7 @@ void clMainFrame::OnRestoreDefaultLayout(wxCommandEvent& e)
void clMainFrame::SetAUIManagerFlags()
{
// Set the manager flags
unsigned int auiMgrFlags = wxAUI_MGR_TRANSPARENT_HINT | wxAUI_MGR_HINT_FADE | wxAUI_MGR_ALLOW_FLOATING;
auiMgrFlags |= wxAUI_MGR_LIVE_RESIZE;
unsigned int auiMgrFlags = wxAUI_MGR_TRANSPARENT_HINT | wxAUI_MGR_HINT_FADE;
m_mgr.SetFlags(auiMgrFlags);
}

Expand Down Expand Up @@ -5462,9 +5454,7 @@ void clMainFrame::OnSettingsChanged(wxCommandEvent& e)
m_mainFrameTitleTemplate = clConfig::Get().Read(kConfigFrameTitlePattern, wxString("$workspace $fullpath"));
}

void clMainFrame::OnDetachEditor(wxCommandEvent& e)
{ /*GetMainBook()->DetachActiveEditor();*/
}
void clMainFrame::OnDetachEditor(wxCommandEvent& e) { /*GetMainBook()->DetachActiveEditor();*/ }

void clMainFrame::OnDetachEditorUI(wxUpdateUIEvent& e) { e.Enable(GetMainBook()->GetActiveEditor() != NULL); }

Expand Down
2 changes: 1 addition & 1 deletion LiteEditor/mainbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ wxString create_platform_filepath(const wxString& fullpath)
} // namespace

MainBook::MainBook(wxWindow* parent)
: wxPanel(parent)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxTAB_TRAVERSAL)
, m_navBar(NULL)
, m_book(NULL)
, m_useBuffereLimit(true)
Expand Down
47 changes: 23 additions & 24 deletions Plugin/cl_aui_dock_art.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ bool IsRectOK(wxDC& dc, const wxRect& rect)
{
const wxSize dc_size = dc.GetSize();

if(0 > rect.x || 0 > rect.y || 0 >= rect.width || 0 >= rect.height || dc_size.GetWidth() < (rect.x + rect.width) ||
dc_size.GetHeight() < (rect.y + rect.height))
if (0 > rect.x || 0 > rect.y || 0 >= rect.width || 0 >= rect.height || dc_size.GetWidth() < (rect.x + rect.width) ||
dc_size.GetHeight() < (rect.y + rect.height))
return (false);
return (true);
}
Expand All @@ -61,17 +61,17 @@ wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size)

// first check if the text fits with no problems
dc.GetTextExtent(text, &x, &y);
if(x <= max_size)
if (x <= max_size)
return text;

size_t i, len = text.Length();
size_t last_good_length = 0;
for(i = 0; i < len; ++i) {
for (i = 0; i < len; ++i) {
wxString s = text.Left(i);
s += wxT("...");

dc.GetTextExtent(s, &x, &y);
if(x > max_size)
if (x > max_size)
break;

last_good_length = i;
Expand Down Expand Up @@ -105,22 +105,22 @@ void clAuiDockArt::DrawPaneButton(wxDC& dc, wxWindow* window, int button, int bu
{
wxRect buttonRect = _rect;

if(!IsRectOK(dc, _rect))
if (!IsRectOK(dc, _rect))
return;
// Make sure that the height and width of the button are equals
if(buttonRect.GetWidth() != buttonRect.GetHeight()) {
if (buttonRect.GetWidth() != buttonRect.GetHeight()) {
buttonRect.SetHeight(wxMin(buttonRect.GetHeight(), buttonRect.GetWidth()));
buttonRect.SetWidth(wxMin(buttonRect.GetHeight(), buttonRect.GetWidth()));
} else {
buttonRect.Deflate(1);
}
if(buttonRect.GetHeight() < 2) {
if (buttonRect.GetHeight() < 2) {
// A wx3.0.x build may arrive here with a 1*1 rect -> a sigabort in libcairo
return;
}
buttonRect = buttonRect.CenterIn(_rect);
eButtonState buttonState = eButtonState::kNormal;
switch(button_state) {
switch (button_state) {
case wxAUI_BUTTON_STATE_HOVER:
buttonState = eButtonState::kHover;
break;
Expand All @@ -142,7 +142,7 @@ void clAuiDockArt::DrawPaneButton(wxDC& dc, wxWindow* window, int button, int bu
#endif

// Prepare the colours
switch(button) {
switch (button) {
case wxAUI_BUTTON_CLOSE:
DrawingUtils::DrawButtonX(dc, window, buttonRect, pen_colour, bg_colour, buttonState);
break;
Expand All @@ -160,7 +160,7 @@ void clAuiDockArt::DrawPaneButton(wxDC& dc, wxWindow* window, int button, int bu
void clAuiDockArt::DrawCaption(wxDC& dc, wxWindow* window, const wxString& text, const wxRect& rect,
wxAuiPaneInfo& pane)
{
if(!IsRectOK(dc, rect))
if (!IsRectOK(dc, rect))
return;

wxRect tmpRect;
Expand Down Expand Up @@ -199,13 +199,13 @@ void clAuiDockArt::DrawCaption(wxDC& dc, wxWindow* window, const wxString& text,
wxRect clip_rect = tmpRect;
clip_rect.width -= 3; // text offset
clip_rect.width -= 2; // button padding
if(pane.HasCloseButton()) {
if (pane.HasCloseButton()) {
clip_rect.width -= m_buttonSize;
}
if(pane.HasPinButton()) {
if (pane.HasPinButton()) {
clip_rect.width -= m_buttonSize;
}
if(pane.HasMaximizeButton()) {
if (pane.HasMaximizeButton()) {
clip_rect.width -= m_buttonSize;
}

Expand Down Expand Up @@ -237,11 +237,11 @@ void clAuiDockArt::DrawCaption(wxDC& dc, wxWindow* window, const wxString& text,
wxRect clip_rect = tmpRect;
clip_rect.width -= caption_offset; // text offset
clip_rect.width -= 2; // button padding
if(pane.HasCloseButton())
if (pane.HasCloseButton())
clip_rect.width -= m_buttonSize;
if(pane.HasPinButton())
if (pane.HasPinButton())
clip_rect.width -= m_buttonSize;
if(pane.HasMaximizeButton())
if (pane.HasMaximizeButton())
clip_rect.width -= m_buttonSize;

// Truncate the text if needed
Expand Down Expand Up @@ -295,20 +295,19 @@ void clAuiDockArt::DrawSash(wxDC& dc, wxWindow* window, int orientation, const w
{
wxUnusedVar(orientation);
wxUnusedVar(window);
#ifdef __WXMSW__
DrawingUtils::DrawStippleBackground(rect, dc);
#else
dc.SetPen(m_bgColour);
dc.SetBrush(m_bgColour);

auto colour = clSystemSettings::GetDefaultPanelColour().ChangeLightness(
clSystemSettings::GetAppearance().IsDark() ? 120 : 80);
dc.SetPen(colour);
dc.SetBrush(colour);
dc.DrawRectangle(rect);
#endif
}

void clAuiDockArt::OnSettingsChanged(clCommandEvent& event)
{
event.Skip();
m_bgColour = clSystemSettings::GetDefaultPanelColour();
if(DrawingUtils::IsDark(m_bgColour)) {
if (DrawingUtils::IsDark(m_bgColour)) {
m_captionTextColour = wxColour(*wxWHITE).ChangeLightness(80);
} else {
m_captionTextColour = wxColour(*wxBLACK).ChangeLightness(120);
Expand Down

0 comments on commit ea503d6

Please sign in to comment.