Skip to content

Commit

Permalink
changes for Orca
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftFever committed Apr 28, 2024
1 parent 9c0a8be commit 440b863
Show file tree
Hide file tree
Showing 22 changed files with 199 additions and 59 deletions.
4 changes: 4 additions & 0 deletions build/cmake/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,11 @@ if(wxUSE_GUI)
else()
find_package(OpenGL)
if(WXGTK3 AND OpenGL_EGL_FOUND AND wxUSE_GLCANVAS_EGL)
if(UNIX AND NOT APPLE)
set(OPENGL_LIBRARIES OpenGL EGL)
else()
set(OPENGL_LIBRARIES OpenGL::OpenGL OpenGL::EGL)
endif()
find_package(WAYLANDEGL)
if(WAYLANDEGL_FOUND AND wxHAVE_GDK_WAYLAND)
list(APPEND OPENGL_LIBRARIES ${WAYLANDEGL_LIBRARIES})
Expand Down
4 changes: 2 additions & 2 deletions build/cmake/lib/webview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ if(APPLE)
elseif(WXMSW)
if(wxUSE_WEBVIEW_EDGE)
# Update the following variables if updating WebView2 SDK
set(WEBVIEW2_VERSION "1.0.705.50")
set(WEBVIEW2_VERSION "1.0.1418.22")
set(WEBVIEW2_URL "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/${WEBVIEW2_VERSION}")
set(WEBVIEW2_SHA256 "6a34bb553e18cfac7297b4031f3eac2558e439f8d16a45945c22945ac404105d")
set(WEBVIEW2_SHA256 "51d2ef56196e2a9d768a6843385bcb9c6baf9ed34b2603ddb074fb4995543a99")

set(WEBVIEW2_DEFAULT_PACKAGE_DIR "${CMAKE_BINARY_DIR}/packages/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}")

Expand Down
15 changes: 13 additions & 2 deletions include/wx/fontutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ public :
wxFontEncoding GetEncoding() const;

void SetPointSize(int pointsize);
void SetFractionalPointSize(double pointsize);
void SetFractionalPointSize(double pointsize
#if defined(__WXMSW__)
, const wxWindow *window = nullptr
#endif
);
void SetPixelSize(const wxSize& pixelSize);
void SetStyle(wxFontStyle style);
void SetNumericWeight(int weight);
Expand All @@ -307,12 +311,19 @@ public :

// Helper used in many ports: use the normal font size if the input is
// negative, as we handle -1 as meaning this for compatibility.
void SetSizeOrDefault(double size)
void SetSizeOrDefault(double size
#if defined(__WXMSW__)
, const wxWindow *window = nullptr
#endif
)
{
SetFractionalPointSize
(
size < 0 ? wxNORMAL_FONT->GetFractionalPointSize()
: size
#if defined(__WXMSW__)
,window
#endif
);
}

Expand Down
3 changes: 3 additions & 0 deletions include/wx/gdicmn.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class WXDLLIMPEXP_FWD_CORE wxRegion;
class WXDLLIMPEXP_FWD_BASE wxString;
class WXDLLIMPEXP_FWD_CORE wxIconBundle;
class WXDLLIMPEXP_FWD_CORE wxPoint;
class WXDLLIMPEXP_FWD_CORE wxWindow;

// ---------------------------------------------------------------------------
// constants
Expand Down Expand Up @@ -1092,7 +1093,9 @@ extern int WXDLLIMPEXP_CORE wxDisplayDepth();

// get the display size
extern void WXDLLIMPEXP_CORE wxDisplaySize(int *width, int *height);
extern void WXDLLIMPEXP_CORE wxDisplaySize(const wxWindow *window, int *width, int *height);
extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySize();
extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySize(const wxWindow *window);
extern void WXDLLIMPEXP_CORE wxDisplaySizeMM(int *width, int *height);
extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySizeMM();
extern wxSize WXDLLIMPEXP_CORE wxGetDisplayPPI();
Expand Down
4 changes: 3 additions & 1 deletion include/wx/generic/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -2951,9 +2951,11 @@ class WXDLLIMPEXP_CORE wxGrid : public wxScrolledCanvas
wxGridWindow* gridWindow);

// Update the width/height of the column/row being drag-resized.
//Orca: add cursor mode for DoGridDragResize's paremeters
void DoGridDragResize(const wxPoint& position,
const wxGridOperations& oper,
wxGridWindow* gridWindow);
wxGridWindow* gridWindow,
CursorMode mode);

// process different clicks on grid cells
void DoGridCellLeftDown(wxMouseEvent& event,
Expand Down
2 changes: 1 addition & 1 deletion include/wx/msw/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WXDLLIMPEXP_CORE wxFont : public wxFontBase
// ctors and such
wxFont() { }

wxFont(const wxFontInfo& info);
wxFont(const wxFontInfo& info, const wxWindow *window = nullptr);

wxFont(int size,
wxFontFamily family,
Expand Down
4 changes: 2 additions & 2 deletions include/wx/msw/tooltip.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ class WXDLLIMPEXP_CORE wxToolTip : public wxObject
// the one and only one tooltip control we use - never access it directly
// but use GetToolTipCtrl() which will create it when needed
static WXHWND ms_hwndTT;

public:
// create the tooltip ctrl if it doesn't exist yet and return its HWND
static WXHWND GetToolTipCtrl();

private:
// to be used in wxModule for deleting tooltip ctrl window when exiting mainloop
static void DeleteToolTipCtrl();

Expand Down
2 changes: 1 addition & 1 deletion include/wx/osx/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class WXDLLIMPEXP_CORE wxApp: public wxAppBase

public:
bool OSXInitWasCalled() { return m_inited; }
void OSXStoreOpenFiles(const wxArrayString &files ) { m_openFiles = files ; }
virtual void OSXStoreOpenFiles(const wxArrayString &files ) { m_openFiles = files ; }
void OSXStorePrintFiles(const wxArrayString &files ) { m_printFiles = files ; }
void OSXStoreOpenURL(const wxString &url ) { m_getURL = url ; }
#endif
Expand Down
13 changes: 10 additions & 3 deletions src/common/combocmn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,7 @@ void wxComboCtrlBase::CreatePopup()
#if !USES_GENERICTLW
m_winPopup = new wxComboPopupWindowBase2( this, wxNO_BORDER );
#else
int tlwFlags = wxNO_BORDER;
int tlwFlags = wxNO_BORDER | wxSTAY_ON_TOP;
#ifdef wxCC_GENERIC_TLW_IS_FRAME
tlwFlags |= wxFRAME_NO_TASKBAR;
#endif
Expand Down Expand Up @@ -2285,6 +2285,9 @@ void wxComboCtrlBase::ShowPopup()

SetFocus();

//int displayIdx = wxDisplay::GetFromWindow(this);
//wxRect displayRect = wxDisplay(displayIdx != wxNOT_FOUND ? displayIdx : 0u).GetGeometry();

// Space above and below
int screenHeight;
wxPoint scrPos;
Expand Down Expand Up @@ -2407,9 +2410,13 @@ void wxComboCtrlBase::ShowPopup()

int showFlags = CanDeferShow;

if ( spaceBelow < szp.y )
int anchorSideVertical = m_anchorSide & (wxUP | wxDOWN);
if (// Pop up as asked for by the library user.
(anchorSideVertical & wxUP) ||
// Automatic: Pop up if it does not fit down.
(anchorSideVertical == 0 && spaceBelow < szp.y ))
{
popupY = scrPos.y - szp.y;
popupY = scrPos.y - szp.y + displayRect.GetTop();
showFlags |= ShowAbove;
}

Expand Down
6 changes: 5 additions & 1 deletion src/common/datavcmn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,11 @@ wxDataViewItem wxDataViewCtrlBase::GetSelection() const

wxDataViewItemArray selections;
GetSelections(selections);
return selections[0];
// Orca
if (!selections.empty())
return selections[0];
else
return wxDataViewItem(0);
}

namespace
Expand Down
8 changes: 7 additions & 1 deletion src/common/dcbufcmn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,15 @@ class wxSharedDCBufferManager : public wxModule
const double scale = dc ? dc->GetContentScaleFactor() : 1.0;
wxBitmap* const buffer = new wxBitmap;

#if __WXMSW__
// we must always return a valid bitmap but creating a bitmap of
// size 0 would fail, so create a 1*1 bitmap in this case
buffer->CreateScaled(wxMax(w, 1), wxMax(h, 1), -1, scale);
buffer->Create(wxMax(w, 1), wxMax(h, 1), 24);
#else
// we must always return a valid bitmap but creating a bitmap of
// size 0 would fail, so create a 1*1 bitmap in this case
buffer->CreateScaled(wxMax(w, 1), wxMax(h, 1), -1, scale);
#endif

return buffer;
}
Expand Down
14 changes: 14 additions & 0 deletions src/common/gdicmn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,25 @@ void wxDisplaySize(int *width, int *height)
*height = size.y;
}

void wxDisplaySize(const wxWindow *window, int *width, int *height)
{
const wxSize size = wxGetDisplaySize(window);
if ( width )
*width = size.x;
if ( height )
*height = size.y;
}

wxSize wxGetDisplaySize()
{
return wxDisplay().GetGeometry().GetSize();
}

wxSize wxGetDisplaySize(const wxWindow *window)
{
return window ? wxDisplay(window).GetGeometry().GetSize() : wxDisplay().GetGeometry().GetSize();
}

void wxClientDisplayRect(int *x, int *y, int *width, int *height)
{
const wxRect rect = wxGetClientDisplayRect();
Expand Down
6 changes: 3 additions & 3 deletions src/common/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ wxImage wxImage::ShrinkBy( int xFactor , int yFactor ) const
unsigned char red = pixel[0] ;
unsigned char green = pixel[1] ;
unsigned char blue = pixel[2] ;
unsigned char alpha = 255 ;
if ( source_alpha )
alpha = *(source_alpha + y_offset + x * xFactor + x1) ;
if ( !hasMask || red != maskRed || green != maskGreen || blue != maskBlue )
{
unsigned char alpha = 255 ;
if ( source_alpha )
alpha = *(source_alpha + y_offset + x * xFactor + x1) ;
if ( alpha > 0 )
{
avgRed += red ;
Expand Down
7 changes: 7 additions & 0 deletions src/common/intl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,12 @@ GetInfoFromLCID(LCID lcid,
{
str = buf;

//FIXME Vojtech: We forcefully set the locales for a decimal point to "C", but this
// is not possible for the Win32 locales, therefore there is a discrepancy.
// It looks like we live with the discrepancy for at least half a year, so we will
// suppress the assert until we fix Slic3r to properly switch to "C" locales just
// for file import / export.
#if 0
// As we get our decimal point separator from Win32 and not the
// CRT there is a possibility of mismatch between them and this
// can easily happen if the user code called setlocale()
Expand All @@ -1641,6 +1647,7 @@ GetInfoFromLCID(LCID lcid,
"Decimal separator mismatch -- did you use setlocale()?"
"If so, use wxLocale to change the locale instead."
);
#endif
}
break;

Expand Down
53 changes: 43 additions & 10 deletions src/generic/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3824,7 +3824,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
{
case WXGRID_CURSOR_RESIZE_ROW:
{
DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
//Orca: add cursor mode for DoGridDragResize's paremeters
DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow, WXGRID_CURSOR_RESIZE_ROW);
}
break;

Expand Down Expand Up @@ -4166,7 +4167,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
switch ( m_cursorMode )
{
case WXGRID_CURSOR_RESIZE_COL:
DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow);
//Orca: add cursor mode for DoGridDragResize's paremeters
DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow, WXGRID_CURSOR_RESIZE_COL);
break;

case WXGRID_CURSOR_SELECT_COL:
Expand Down Expand Up @@ -4708,11 +4710,13 @@ bool wxGrid::DoGridDragEvent(wxMouseEvent& event,
return DoGridCellDrag(event, coords, isFirstDrag);

case WXGRID_CURSOR_RESIZE_ROW:
DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
//Orca: add cursor mode for DoGridDragResize's paremeters
DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow, WXGRID_CURSOR_RESIZE_ROW);
break;

case WXGRID_CURSOR_RESIZE_COL:
DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow);
//Orca: add cursor mode for DoGridDragResize's paremeters
DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow, WXGRID_CURSOR_RESIZE_COL);
break;

default:
Expand Down Expand Up @@ -4803,6 +4807,8 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
case wxGridSelectCells:
case wxGridSelectRowsOrColumns:
// nothing to do in these cases
//Orca: select this cell when first click
m_selection->SelectBlock(coords.GetRow(), coords.GetCol(), coords.GetRow(), coords.GetCol(), event);
break;

case wxGridSelectRows:
Expand Down Expand Up @@ -5044,9 +5050,11 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event, wxGridWindow *eventG
}
}

//Orca: add cursor mode for DoGridDragResize's paremeters
void wxGrid::DoGridDragResize(const wxPoint& position,
const wxGridOperations& oper,
wxGridWindow* gridWindow)
wxGridWindow* gridWindow,
CursorMode mode)
{
// Get the logical position from the physical one we're passed.
const wxPoint
Expand All @@ -5056,10 +5064,28 @@ void wxGrid::DoGridDragResize(const wxPoint& position,
// orthogonal direction.
const int linePos = oper.Dual().Select(logicalPos);

const int lineStart = oper.GetLineStartPos(this, m_dragRowOrCol);
oper.SetLineSize(this, m_dragRowOrCol,
//Orca: add logic for resize multiplexed cols
if (mode == WXGRID_CURSOR_RESIZE_COL) {
int col_to_resize = m_dragRowOrCol;
int num_rows, num_cols;
this->GetCellSize(0, m_dragRowOrCol, &num_rows, &num_cols);
if (num_cols < 1)
col_to_resize = m_dragRowOrCol - 1;

const int lineEnd = oper.GetLineEndPos(this, m_dragRowOrCol);
const int lineSize = oper.GetLineSize(this, col_to_resize);
int size = linePos - lineEnd + lineSize;
oper.SetLineSize(this, col_to_resize,
wxMax(size,
oper.GetMinimalLineSize(this, col_to_resize)));
}
else {
const int lineStart = oper.GetLineStartPos(this, m_dragRowOrCol);

oper.SetLineSize(this, m_dragRowOrCol,
wxMax(linePos - lineStart,
oper.GetMinimalLineSize(this, m_dragRowOrCol)));
}

// TODO: generate RESIZING event, see #10754, if the size has changed.
}
Expand All @@ -5082,7 +5108,8 @@ wxPoint wxGrid::GetPositionForResizeEvent(int width) const

void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow* gridWindow)
{
DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
//Orca: add cursor mode for DoGridDragResize's paremeters
DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow, WXGRID_CURSOR_RESIZE_ROW);

SendGridSizeEvent(wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event);

Expand All @@ -5091,7 +5118,8 @@ void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow* gridWin

void wxGrid::DoEndDragResizeCol(const wxMouseEvent& event, wxGridWindow* gridWindow)
{
DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow);
//Orca: add cursor mode for DoGridDragResize's paremeters
DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow, WXGRID_CURSOR_RESIZE_COL);

SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event);

Expand All @@ -5105,9 +5133,10 @@ void wxGrid::DoHeaderStartDragResizeCol(int col)

void wxGrid::DoHeaderDragResizeCol(int width)
{
//Orca: add cursor mode for DoGridDragResize's paremeters
DoGridDragResize(GetPositionForResizeEvent(width),
wxGridColumnOperations(),
m_gridWin);
m_gridWin, WXGRID_CURSOR_RESIZE_COL);
}

void wxGrid::DoHeaderEndDragResizeCol(int width)
Expand Down Expand Up @@ -5891,6 +5920,10 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
DisableCellEditControl();

MoveCursorDown( event.ShiftDown() );
//Orca: select this cell when first click
m_selection->SelectBlock(m_currentCellCoords.GetRow(), m_currentCellCoords.GetCol(),
m_currentCellCoords.GetRow(), m_currentCellCoords.GetCol(),
event);
}
break;

Expand Down
Loading

0 comments on commit 440b863

Please sign in to comment.