Skip to content

Commit

Permalink
wxGTK fixes
Browse files Browse the repository at this point in the history
The GLCanvas for the check needs to be properly shown to create the context on wxGTK, so pop it up momentarily in a wxMiniFrame

Also fixed a PaletteCanvas issue
  • Loading branch information
sirjuddington committed Apr 20, 2024
1 parent ea8bdbb commit da376fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Application/SLADEWxApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ class SLADELog : public wxLog
void DoLogText(const wxString& msg) override
{
if (msg.Lower().Contains("error"))
log::error(msg.Right(msg.size() - 10));
log::error("wxWidgets: " + msg.Right(msg.size() - 10));
else if (msg.Lower().Contains("warning"))
log::warning(msg.Right(msg.size() - 10));
log::warning("wxWidgets: " + msg.Right(msg.size() - 10));
else
log::info(msg.Right(msg.size() - 10));
log::info("wxWidgets: " + msg.Right(msg.size() - 10));
}

public:
Expand Down
12 changes: 9 additions & 3 deletions src/MainEditor/UI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,16 @@ void MainWindow::onSize(wxSizeEvent& e)
// Test creation of OpenGL context
if (!opengl_test_done && e.GetSize().x > 20 && e.GetSize().y > 20)
{
auto test_canvas = new GLCanvas(this);
test_canvas->Show();
auto mf = new wxMiniFrame(this, -1, "OpenGL Test", wxDefaultPosition, { 32, 32 });
mf->SetSizer(new wxBoxSizer(wxVERTICAL));

auto test_canvas = new GLCanvas(mf);
mf->GetSizer()->Add(test_canvas, wxSizerFlags(1).Expand());

mf->Show();
test_canvas->activateContext();
delete test_canvas;
mf->Close(true);

opengl_test_done = true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/UI/Canvas/PaletteCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ void PaletteCanvas::updateBuffer(bool force)
int y_size = height / rows;
auto square_size = std::min<int>(x_size, y_size);

// Check canvas is large enough to display the palette
if (square_size < 3)
return;

// If the size hasn't changed we don't need to update the buffer
if (!force && rows == rows_ && cols == cols_ && square_size == square_size_)
return;
Expand Down

0 comments on commit da376fc

Please sign in to comment.