Revert to WxWidgets 3.1.5 (#3249)

* revert to WxWidgets 3.1.5

* update nanosvg unicode path
This commit is contained in:
SoftFever 2023-12-23 17:44:09 +08:00 committed by GitHub
parent cc23ec6626
commit 374f78c768
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
95 changed files with 6841 additions and 1618 deletions

1
deps/CMakeLists.txt vendored
View file

@ -236,7 +236,6 @@ endif ()
include(JPEG/JPEG.cmake)
include(TIFF/TIFF.cmake)
include(NanoSVG/NanoSVG.cmake)
include(wxWidgets/wxWidgets.cmake)
include(OCCT/OCCT.cmake)
include(FREETYPE/FREETYPE.cmake)

667
deps/wxWidgets/0001-wxWidget-fix.patch vendored Normal file
View file

@ -0,0 +1,667 @@
diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake
index 0bc4f934b9..479431a69c 100644
--- a/build/cmake/init.cmake
+++ b/build/cmake/init.cmake
@@ -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})
diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt
index cc3298ff33..8adbeaea4f 100644
--- a/build/cmake/lib/webview/CMakeLists.txt
+++ b/build/cmake/lib/webview/CMakeLists.txt
@@ -56,7 +56,7 @@ 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")
diff --git a/include/wx/fontutil.h b/include/wx/fontutil.h
index 09ad8c8ef3..3c0c2d8f7e 100644
--- a/include/wx/fontutil.h
+++ b/include/wx/fontutil.h
@@ -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);
@@ -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
);
}
diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h
index e29a77627c..dc48cf9451 100644
--- a/include/wx/gdicmn.h
+++ b/include/wx/gdicmn.h
@@ -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
@@ -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();
diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h
index d7a3890764..e4dee51d5a 100644
--- a/include/wx/generic/grid.h
+++ b/include/wx/generic/grid.h
@@ -2951,9 +2951,11 @@ private:
wxGridWindow* gridWindow);
// Update the width/height of the column/row being drag-resized.
+ //BBS: 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,
diff --git a/include/wx/msw/font.h b/include/wx/msw/font.h
index 0f9768b44e..094d774918 100644
--- a/include/wx/msw/font.h
+++ b/include/wx/msw/font.h
@@ -23,7 +23,7 @@ public:
// ctors and such
wxFont() { }
- wxFont(const wxFontInfo& info);
+ wxFont(const wxFontInfo& info, const wxWindow *window = nullptr);
wxFont(int size,
wxFontFamily family,
diff --git a/include/wx/msw/tooltip.h b/include/wx/msw/tooltip.h
index 4c3be08cec..96fb378d01 100644
--- a/include/wx/msw/tooltip.h
+++ b/include/wx/msw/tooltip.h
@@ -91,10 +91,10 @@ private:
// 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();
diff --git a/include/wx/osx/app.h b/include/wx/osx/app.h
index 317a0ca96f..58014ec1d4 100644
--- a/include/wx/osx/app.h
+++ b/include/wx/osx/app.h
@@ -161,7 +161,7 @@ private:
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
diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp
index b61aac35bf..d12b745e8c 100644
--- a/src/common/combocmn.cpp
+++ b/src/common/combocmn.cpp
@@ -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
@@ -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;
@@ -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;
}
diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp
index 1f5fd4d66b..14ea2f8ef1 100644
--- a/src/common/datavcmn.cpp
+++ b/src/common/datavcmn.cpp
@@ -1322,7 +1322,11 @@ wxDataViewItem wxDataViewCtrlBase::GetSelection() const
wxDataViewItemArray selections;
GetSelections(selections);
- return selections[0];
+ // BBS
+ if (!selections.empty())
+ return selections[0];
+ else
+ return wxDataViewItem(0);
}
namespace
diff --git a/src/common/dcbufcmn.cpp b/src/common/dcbufcmn.cpp
index 74958fce10..59844f4526 100644
--- a/src/common/dcbufcmn.cpp
+++ b/src/common/dcbufcmn.cpp
@@ -82,9 +82,15 @@ private:
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;
}
diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp
index 20442bbc73..9a24951ec7 100644
--- a/src/common/gdicmn.cpp
+++ b/src/common/gdicmn.cpp
@@ -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();
diff --git a/src/common/intl.cpp b/src/common/intl.cpp
index 0b0d8798f4..7072fab18a 100644
--- a/src/common/intl.cpp
+++ b/src/common/intl.cpp
@@ -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()
@@ -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;
diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp
index 41fd4524cf..f4a15cb839 100644
--- a/src/generic/grid.cpp
+++ b/src/generic/grid.cpp
@@ -3824,7 +3824,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
{
case WXGRID_CURSOR_RESIZE_ROW:
{
- DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
+ //BBS: add cursor mode for DoGridDragResize's paremeters
+ DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow, WXGRID_CURSOR_RESIZE_ROW);
}
break;
@@ -4166,7 +4167,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
switch ( m_cursorMode )
{
case WXGRID_CURSOR_RESIZE_COL:
- DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow);
+ //BBS: add cursor mode for DoGridDragResize's paremeters
+ DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow, WXGRID_CURSOR_RESIZE_COL);
break;
case WXGRID_CURSOR_SELECT_COL:
@@ -4708,11 +4710,13 @@ bool wxGrid::DoGridDragEvent(wxMouseEvent& event,
return DoGridCellDrag(event, coords, isFirstDrag);
case WXGRID_CURSOR_RESIZE_ROW:
- DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
+ //BBS: 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);
+ //BBS: add cursor mode for DoGridDragResize's paremeters
+ DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow, WXGRID_CURSOR_RESIZE_COL);
break;
default:
@@ -4803,6 +4807,8 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
case wxGridSelectCells:
case wxGridSelectRowsOrColumns:
// nothing to do in these cases
+ //BBS: select this cell when first click
+ m_selection->SelectBlock(coords.GetRow(), coords.GetCol(), coords.GetRow(), coords.GetCol(), event);
break;
case wxGridSelectRows:
@@ -5044,9 +5050,11 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event, wxGridWindow *eventG
}
}
+//BBS: 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
@@ -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,
+ //BBS: 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.
}
@@ -5082,7 +5108,8 @@ wxPoint wxGrid::GetPositionForResizeEvent(int width) const
void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow* gridWindow)
{
- DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
+ //BBS: 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);
@@ -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);
+ //BBS: 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);
@@ -5105,9 +5133,10 @@ void wxGrid::DoHeaderStartDragResizeCol(int col)
void wxGrid::DoHeaderDragResizeCol(int width)
{
+ //BBS: add cursor mode for DoGridDragResize's paremeters
DoGridDragResize(GetPositionForResizeEvent(width),
wxGridColumnOperations(),
- m_gridWin);
+ m_gridWin, WXGRID_CURSOR_RESIZE_COL);
}
void wxGrid::DoHeaderEndDragResizeCol(int width)
@@ -5891,6 +5920,10 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
DisableCellEditControl();
MoveCursorDown( event.ShiftDown() );
+ //BBS: select this cell when first click
+ m_selection->SelectBlock(m_currentCellCoords.GetRow(), m_currentCellCoords.GetCol(),
+ m_currentCellCoords.GetRow(), m_currentCellCoords.GetCol(),
+ event);
}
break;
diff --git a/src/msw/bmpcbox.cpp b/src/msw/bmpcbox.cpp
index 0a2d167ad7..0aeba45ea9 100644
--- a/src/msw/bmpcbox.cpp
+++ b/src/msw/bmpcbox.cpp
@@ -156,13 +156,20 @@ void wxBitmapComboBox::RecreateControl()
wxComboBox::DoClear();
- HWND hwnd = GetHwnd();
+ WNDPROC wndproc_edit = nullptr;
+ WinStruct<COMBOBOXINFO> combobox_info;
+ HWND hwnd = GetHwnd();
+if (::GetComboBoxInfo(hwnd, &combobox_info))
+ wndproc_edit = (WNDPROC)wxGetWindowProc(combobox_info.hwndItem);
DissociateHandle();
::DestroyWindow(hwnd);
if ( !MSWCreateControl(wxT("COMBOBOX"), wxEmptyString, pos, size) )
return;
+if (::GetComboBoxInfo(GetHwnd(), &combobox_info))
+ wxSetWindowProc(combobox_info.hwndItem, wndproc_edit);
+
// initialize the controls contents
for ( i = 0; i < numItems; i++ )
{
diff --git a/src/msw/font.cpp b/src/msw/font.cpp
index 0bd240d79f..d38b1b00f5 100644
--- a/src/msw/font.cpp
+++ b/src/msw/font.cpp
@@ -54,7 +54,7 @@ static const int PITCH_MASK = FIXED_PITCH | VARIABLE_PITCH;
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
{
public:
- wxFontRefData(const wxFontInfo& info = wxFontInfo());
+ wxFontRefData(const wxFontInfo& info = wxFontInfo(), const wxWindow* window = nullptr);
wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0)
{
@@ -324,7 +324,7 @@ protected:
// wxFontRefData
// ----------------------------------------------------------------------------
-wxFontRefData::wxFontRefData(const wxFontInfo& info)
+wxFontRefData::wxFontRefData(const wxFontInfo& info, const wxWindow *window)
{
m_hFont = NULL;
@@ -335,7 +335,7 @@ wxFontRefData::wxFontRefData(const wxFontInfo& info)
}
else
{
- m_nativeFontInfo.SetSizeOrDefault(info.GetFractionalPointSize());
+ m_nativeFontInfo.SetSizeOrDefault(info.GetFractionalPointSize(), window);
}
SetStyle(info.GetStyle());
@@ -518,12 +518,12 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
return wxGetFontEncFromCharSet(lf.lfCharSet);
}
-void wxNativeFontInfo::SetFractionalPointSize(double pointSizeNew)
+void wxNativeFontInfo::SetFractionalPointSize(double pointSizeNew, const wxWindow *window)
{
// We don't have the correct DPI to use here, so use that of the
// primary screen and rely on WXAdjustToPPI() changing it later if
// necessary.
- const int ppi = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
+ const int ppi = window ? window->GetDPI().GetY() : ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
lf.lfHeight = GetLogFontHeightAtPPI(pointSizeNew, ppi);
pointSize = pointSizeNew;
@@ -812,9 +812,9 @@ wxFont::wxFont(const wxString& fontdesc)
(void)Create(info);
}
-wxFont::wxFont(const wxFontInfo& info)
+wxFont::wxFont(const wxFontInfo& info, const wxWindow *window)
{
- m_refData = new wxFontRefData(info);
+ m_refData = new wxFontRefData(info, window);
}
bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp
index 9bb397d472..30af7154a7 100644
--- a/src/msw/menuitem.cpp
+++ b/src/msw/menuitem.cpp
@@ -368,6 +368,8 @@ void MenuDrawData::Init(wxWindow const* window)
// native menu uses small top margin for separator
if ( SeparatorMargin.cyTopHeight >= 2 )
SeparatorMargin.cyTopHeight -= 2;
+
+ SeparatorSize.cy = 0;
}
else
#endif // wxUSE_UXTHEME
diff --git a/src/msw/window.cpp b/src/msw/window.cpp
index eadc2f5700..f64fea4446 100644
--- a/src/msw/window.cpp
+++ b/src/msw/window.cpp
@@ -4773,33 +4773,49 @@ static wxSize GetWindowDPI(HWND hwnd)
}
/*extern*/
-int wxGetSystemMetrics(int nIndex, const wxWindow* window)
+int wxGetSystemMetrics(int nIndex, const wxWindow* win)
{
#if wxUSE_DYNLIB_CLASS
- if ( !window )
- window = wxApp::GetMainTopWindow();
+ const wxWindow* window = (!win && wxTheApp) ? wxTheApp->GetTopWindow() : win;
- if ( window )
+ if (window)
{
- typedef int (WINAPI * GetSystemMetricsForDpi_t)(int nIndex, UINT dpi);
- static GetSystemMetricsForDpi_t s_pfnGetSystemMetricsForDpi = NULL;
- static bool s_initDone = false;
-
- if ( !s_initDone )
- {
- wxLoadedDLL dllUser32("user32.dll");
- wxDL_INIT_FUNC(s_pfn, GetSystemMetricsForDpi, dllUser32);
- s_initDone = true;
+#if 1
+ if (window->GetHWND() && (nIndex == SM_CXSCREEN || nIndex == SM_CYSCREEN)) {
+ HDC hdc = GetDC(window->GetHWND());
+#if 0
+ double dim = GetDeviceCaps(hdc, nIndex == SM_CXSCREEN ? HORZRES : VERTRES);
+ ReleaseDC(window->GetHWND(), hdc);
+ wxSize dpi = window->GetDPI();
+ dim *= 96.0 / (nIndex == SM_CXSCREEN ? dpi.x : dpi.y);
+ return int(dim + 0.5);
+#else
+ return int(GetDeviceCaps(hdc, nIndex == SM_CXSCREEN ? HORZRES : VERTRES));
+#endif
}
-
- if ( s_pfnGetSystemMetricsForDpi )
+ else
+#endif
{
- const int dpi = window->GetDPI().y;
- return s_pfnGetSystemMetricsForDpi(nIndex, (UINT)dpi);
+ typedef int (WINAPI * GetSystemMetricsForDpi_t)(int nIndex, UINT dpi);
+ static GetSystemMetricsForDpi_t s_pfnGetSystemMetricsForDpi = NULL;
+ static bool s_initDone = false;
+
+ if ( !s_initDone )
+ {
+ wxLoadedDLL dllUser32("user32.dll");
+ wxDL_INIT_FUNC(s_pfn, GetSystemMetricsForDpi, dllUser32);
+ s_initDone = true;
+ }
+
+ if ( s_pfnGetSystemMetricsForDpi )
+ {
+ const int dpi = window->GetDPI().y;
+ return s_pfnGetSystemMetricsForDpi(nIndex, (UINT)dpi);
+ }
}
}
#else
- wxUnusedVar(window);
+ wxUnusedVar(win);
#endif // wxUSE_DYNLIB_CLASS
return ::GetSystemMetrics(nIndex);
diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm
index 6ff0cc3088..4943f3ea38 100644
--- a/src/osx/cocoa/dataview.mm
+++ b/src/osx/cocoa/dataview.mm
@@ -1734,12 +1734,22 @@ outlineView:(NSOutlineView*)outlineView
if ( !dvc->GetEventHandler()->ProcessEvent(eventDV) )
[super keyDown:event];
}
- else
+ //FIXME Vojtech's hack to get the accelerators assigned to the wxDataViewControl working.
+ else if (! implementation->DoHandleKeyEvent(event))
{
[super keyDown:event]; // all other keys
}
}
+//FIXME Vojtech: This is a workaround to get at least the "mouse move" events at the wxDataViewControl,
+// so we can show the tooltips. The "mouse move" events are being send only if the wxDataViewControl
+// has focus, which is a limitation of wxWidgets. We may grab focus on "mouse entry" though.
+- (void)mouseMoved:(NSEvent *)event
+{
+if (! implementation->DoHandleMouseEvent(event))
+ [super mouseMoved:event];
+}
+
//
// contextual menus
//
@@ -2672,12 +2682,22 @@ void wxCocoaDataViewControl::DoSetIndent(int indent)
void wxCocoaDataViewControl::HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
{
- NSPoint const nativePoint = wxToNSPoint((NSScrollView*) GetWXWidget(),point);
+ NSTableHeaderView *headerView = [m_OutlineView headerView];
+ if (headerView && point.y < headerView.visibleRect.size.height) {
+ // The point is inside the header area.
+ columnPtr = NULL;
+ item = wxDataViewItem();
+ return;
+ }
+ // Convert from the window coordinates to the virtual scrolled view coordinates.
+ NSScrollView *scrollView = [m_OutlineView enclosingScrollView];
+ const NSRect &visibleRect = scrollView.contentView.visibleRect;
+ NSPoint const nativePoint = wxToNSPoint((NSScrollView*) GetWXWidget(),
+ wxPoint(point.x + visibleRect.origin.x, point.y + visibleRect.origin.y));
int indexColumn;
int indexRow;
-
indexColumn = [m_OutlineView columnAtPoint:nativePoint];
indexRow = [m_OutlineView rowAtPoint: nativePoint];
if ((indexColumn >= 0) && (indexRow >= 0))
diff --git a/src/osx/cocoa/settings.mm b/src/osx/cocoa/settings.mm
index de5f52860c..a9581174a4 100644
--- a/src/osx/cocoa/settings.mm
+++ b/src/osx/cocoa/settings.mm
@@ -224,7 +224,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
// ----------------------------------------------------------------------------
// Get a system metric, e.g. scrollbar size
-int wxSystemSettingsNative::GetMetric(wxSystemMetric index, const wxWindow* WXUNUSED(win))
+int wxSystemSettingsNative::GetMetric(wxSystemMetric index, const wxWindow* win)
{
int value;
@@ -259,11 +259,11 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, const wxWindow* WXUN
// TODO case wxSYS_WINDOWMIN_Y:
case wxSYS_SCREEN_X:
- wxDisplaySize(&value, NULL);
+ wxDisplaySize(win, &value, NULL);
return value;
case wxSYS_SCREEN_Y:
- wxDisplaySize(NULL, &value);
+ wxDisplaySize(win, NULL, &value);
return value;
// TODO case wxSYS_FRAMESIZE_X:

View file

@ -1,5 +1,4 @@
set(_wx_git_tag v3.2.1)
set(_wx_patch_name 0001-patch-v3.2.1-for-OrcaSlicer.patch)
set(_wx_git_tag v3.1.5)
set(_wx_toolkit "")
set(_wx_private_font "-DwxUSE_PRIVATE_FONTS=1")
@ -18,13 +17,13 @@ else ()
endif ()
if (MSVC)
set(_patch_cmd if not exist WXWIDGETS_PATCHED ( "${GIT_EXECUTABLE}" apply --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/${_wx_patch_name} && type nul > WXWIDGETS_PATCHED ) )
set(_patch_cmd if not exist WXWIDGETS_PATCHED ( "${GIT_EXECUTABLE}" apply --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch && type nul > WXWIDGETS_PATCHED ) )
else ()
set(_patch_cmd test -f WXWIDGETS_PATCHED || ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/${_wx_patch_name} && touch WXWIDGETS_PATCHED)
set(_patch_cmd test -f WXWIDGETS_PATCHED || ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch && touch WXWIDGETS_PATCHED)
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(_patch_cmd ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/${_wx_patch_name})
set(_patch_cmd ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch)
endif ()
orcaslicer_add_cmake_project(
@ -32,7 +31,7 @@ orcaslicer_add_cmake_project(
GIT_REPOSITORY "https://github.com/wxWidgets/wxWidgets"
GIT_TAG ${_wx_git_tag}
PATCH_COMMAND ${_patch_cmd}
DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} dep_TIFF dep_JPEG dep_NanoSVG
DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} dep_TIFF dep_JPEG
CMAKE_ARGS
-DwxBUILD_PRECOMP=ON
${_wx_toolkit}
@ -48,9 +47,7 @@ orcaslicer_add_cmake_project(
-DwxUSE_WEBVIEW=ON
${_wx_edge}
-DwxUSE_WEBVIEW_IE=OFF
-DwxUSE_NANOSVG=sys
-DwxUSE_NANOSVG_EXTERNAL=ON
-DwxUSE_REGEX=OFF
-DwxUSE_REGEX=builtin
-DwxUSE_LIBXPM=builtin
-DwxUSE_LIBSDL=OFF
-DwxUSE_XTEST=OFF

View file

@ -95,9 +95,6 @@ if (SLIC3R_GUI)
# libslic3r_gui will link to opengl anyway, so lets override wx
list(FILTER wxWidgets_LIBRARIES EXCLUDE REGEX OpenGL)
if (UNIX AND NOT APPLE)
list(APPEND wxWidgets_LIBRARIES X11 wayland-client wayland-egl EGL)
endif ()
# list(REMOVE_ITEM wxWidgets_LIBRARIES oleacc)
message(STATUS "wx libs: ${wxWidgets_LIBRARIES}")

1
src/nanosvg/README.txt Normal file
View file

@ -0,0 +1 @@
Upstream source: https://github.com/SoftFever/nanosvg

3120
src/nanosvg/nanosvg.h Normal file

File diff suppressed because it is too large Load diff

1483
src/nanosvg/nanosvgrast.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -524,8 +524,6 @@ set(SLIC3R_GUI_SOURCES
Utils/CalibUtils.hpp
)
find_package(NanoSVG REQUIRED)
if (WIN32)
list(APPEND SLIC3R_GUI_SOURCES
GUI/dark_mode/dark_mode.hpp
@ -573,7 +571,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SLIC3R_GUI_SOURCES})
encoding_check(libslic3r_gui)
target_link_libraries(libslic3r_gui libslic3r cereal::cereal imgui minilzo GLEW::GLEW OpenGL::GL hidapi ${wxWidgets_LIBRARIES} glfw libcurl OpenSSL::SSL OpenSSL::Crypto NanoSVG::nanosvg NanoSVG::nanosvgrast)
target_link_libraries(libslic3r_gui libslic3r cereal::cereal imgui minilzo GLEW::GLEW OpenGL::GL hidapi ${wxWidgets_LIBRARIES} glfw libcurl OpenSSL::SSL OpenSSL::Crypto)
#target_link_libraries(libslic3r_gui libslic3r cereal imgui minilzo GLEW::GLEW OpenGL::GL hidapi libcurl OpenSSL::SSL OpenSSL::Crypto ${wxWidgets_LIBRARIES} glfw)
if (MSVC)

View file

@ -1084,7 +1084,7 @@ void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
m_input_nozzle_min->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
//m_clr_picker->msw_rescale();
degree->sys_color_changed();
degree->msw_rescale();
bitmap_max_degree->SetBitmap(degree->bmp());
bitmap_min_degree->SetBitmap(degree->bmp());
m_button_reset->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);

View file

@ -19,7 +19,7 @@ AboutDialogLogo::AboutDialogLogo(wxWindow* parent)
{
this->SetBackgroundColour(*wxWHITE);
this->logo = ScalableBitmap(this, Slic3r::var("OrcaSlicer_192px.png"), wxBITMAP_TYPE_PNG);
this->SetMinSize(this->logo.GetSize());
this->SetMinSize(this->logo.GetBmpSize());
this->Bind(wxEVT_PAINT, &AboutDialogLogo::onRepaint, this);
}
@ -30,9 +30,9 @@ void AboutDialogLogo::onRepaint(wxEvent &event)
dc.SetBackgroundMode(wxTRANSPARENT);
wxSize size = this->GetSize();
int logo_w = this->logo.GetWidth();
int logo_h = this->logo.GetHeight();
dc.DrawBitmap(this->logo.get_bitmap(), (size.GetWidth() - logo_w)/2, (size.GetHeight() - logo_h)/2, true);
int logo_w = this->logo.GetBmpWidth();
int logo_h = this->logo.GetBmpHeight();
dc.DrawBitmap(this->logo.bmp(), (size.GetWidth() - logo_w)/2, (size.GetHeight() - logo_h)/2, true);
event.Skip();
}
@ -232,7 +232,7 @@ AboutDialog::AboutDialog()
main_sizer->Add(ver_sizer, 0, wxEXPAND | wxALL, 0);
// logo
m_logo_bitmap = ScalableBitmap(this, "OrcaSlicer_about", {562,250});
m_logo_bitmap = ScalableBitmap(this, "OrcaSlicer_about", 250);
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp(), wxDefaultPosition,wxDefaultSize, 0);
m_logo->SetSizer(vesizer);
@ -380,7 +380,7 @@ AboutDialog::AboutDialog()
void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bitmap.sys_color_changed();
m_logo_bitmap.msw_rescale();
m_logo->SetBitmap(m_logo_bitmap.bmp());
const wxFont& font = GetFont();

View file

@ -187,7 +187,7 @@ void MaterialItem::doRender(wxDC &dc)
auto acolor = m_ams_coloul;
if (mcolor.Alpha() == 0 || acolor.Alpha() == 0) {
dc.DrawBitmap(m_transparent_mitem.get_bitmap(), FromDIP(1), FromDIP(1));
dc.DrawBitmap(m_transparent_mitem.bmp(), FromDIP(1), FromDIP(1));
}
if (!IsEnabled()) {
@ -247,10 +247,10 @@ void MaterialItem::doRender(wxDC &dc)
//arrow
if ( (acolor.Red() > 160 && acolor.Green() > 160 && acolor.Blue() > 160) &&
(acolor.Red() < 180 && acolor.Green() < 180 && acolor.Blue() < 180)) {
dc.DrawBitmap(m_arraw_bitmap_white.get_bitmap(), GetSize().x - m_arraw_bitmap_white.GetSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_white.GetSize().y);
dc.DrawBitmap(m_arraw_bitmap_white.bmp(), GetSize().x - m_arraw_bitmap_white.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_white.GetBmpSize().y);
}
else {
dc.DrawBitmap(m_arraw_bitmap_gray.get_bitmap(), GetSize().x - m_arraw_bitmap_gray.GetSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_gray.GetSize().y);
dc.DrawBitmap(m_arraw_bitmap_gray.bmp(), GetSize().x - m_arraw_bitmap_gray.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_gray.GetBmpSize().y);
}
@ -677,7 +677,7 @@ void MappingItem::doRender(wxDC &dc)
dc.SetBrush(wxBrush(m_coloul));
if (m_coloul.Alpha() == 0) {
dc.DrawBitmap( m_transparent_mapping_item.get_bitmap(), 0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
dc.DrawBitmap( m_transparent_mapping_item.bmp(), 0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
}
else {
dc.DrawRectangle(0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2, MAPPING_ITEM_REAL_SIZE.x, MAPPING_ITEM_REAL_SIZE.y);
@ -1494,7 +1494,7 @@ void AmsRMGroup::doRender(wxDC& dc)
float startAngle = 0.0;
float endAngle = 0.0;
dc.DrawBitmap(bitmap_bg.get_bitmap(), wxPoint((size.x - bitmap_bg.GetSize().x) / 2, (size.y - bitmap_bg.GetSize().y) / 2));
dc.DrawBitmap(bitmap_bg.bmp(), wxPoint((size.x - bitmap_bg.GetBmpSize().x) / 2, (size.y - bitmap_bg.GetBmpSize().y) / 2));
for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) {
std::string tray_name = iter->first;
@ -1575,7 +1575,7 @@ void AmsRMGroup::doRender(wxDC& dc)
dc.DrawEllipticArc(x - center_mask_radius, y - center_mask_radius, center_mask_radius * 2, center_mask_radius * 2, 0, 360);
//draw center icon
dc.DrawBitmap(bitmap_backup_tips_0.get_bitmap(), wxPoint((size.x - bitmap_backup_tips_0.GetSize().x) / 2, (size.y - bitmap_backup_tips_0.GetSize().y) / 2));
dc.DrawBitmap(bitmap_backup_tips_0.bmp(), wxPoint((size.x - bitmap_backup_tips_0.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_0.GetBmpSize().y) / 2));
//dc.DrawBitmap(bitmap_backup_tips_1.bmp(), wxPoint((size.x - bitmap_backup_tips_1.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_1.GetBmpSize().y) / 2));
//draw material

View file

@ -226,7 +226,7 @@ void AuFile::PaintBackground(wxDC &dc)
dc.SetPen(AUFILE_GREY200);
dc.SetBrush(AUFILE_GREY200);
dc.DrawRoundedRectangle(0, 0, size.x, size.y, AUFILE_ROUNDING);
dc.DrawBitmap(m_file_bitmap.get_bitmap(), (size.x - m_file_bitmap.GetWidth()) / 2, (size.y - m_file_bitmap.GetHeight()) / 2);
dc.DrawBitmap(m_file_bitmap.bmp(), (size.x - m_file_bitmap.GetBmpWidth()) / 2, (size.y - m_file_bitmap.GetBmpHeight()) / 2);
}
}
@ -257,7 +257,7 @@ void AuFile::PaintForeground(wxDC &dc)
}
if (m_type == MODEL_PICTURE) {
dc.DrawBitmap(m_file_edit_mask.get_bitmap(), 0, size.y - m_file_edit_mask.GetSize().y);
dc.DrawBitmap(m_file_edit_mask.bmp(), 0, size.y - m_file_edit_mask.GetBmpSize().y);
}
@ -268,14 +268,14 @@ void AuFile::PaintForeground(wxDC &dc)
auto sizet = dc.GetTextExtent(cover_text_left);
auto pos = wxPoint(0, 0);
pos.x = (size.x / 2 - sizet.x) / 2;
pos.y = (size.y - (m_file_edit_mask.GetSize().y + sizet.y) / 2);
pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
dc.DrawText(cover_text_left, pos);
// right text
sizet = dc.GetTextExtent(cover_text_right);
pos = wxPoint(0, 0);
pos.x = size.x / 2 + (size.x / 2 - sizet.x) / 2;
pos.y = (size.y - (m_file_edit_mask.GetSize().y + sizet.y) / 2);
pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
dc.DrawText(cover_text_right, pos);
// Split
@ -283,7 +283,7 @@ void AuFile::PaintForeground(wxDC &dc)
dc.SetBrush(*wxWHITE);
pos = wxPoint(0, 0);
pos.x = size.x / 2 - 1;
pos.y = size.y - FromDIP(24) - (m_file_edit_mask.GetSize().y - FromDIP(24)) / 2;
pos.y = size.y - FromDIP(24) - (m_file_edit_mask.GetBmpSize().y - FromDIP(24)) / 2;
dc.DrawRectangle(pos.x, pos.y, 2, FromDIP(24));
} else {
// right text
@ -297,7 +297,7 @@ void AuFile::PaintForeground(wxDC &dc)
if (m_cover) {
dc.SetTextForeground(*wxWHITE);
dc.DrawBitmap(m_file_cover.get_bitmap(), size.x - m_file_cover.GetSize().x, 0);
dc.DrawBitmap(m_file_cover.bmp(), size.x - m_file_cover.GetBmpSize().x, 0);
dc.SetFont(Label::Body_12);
auto sizet = dc.GetTextExtent(cover_text_cover);
auto pos = wxPoint(0, 0);
@ -306,7 +306,7 @@ void AuFile::PaintForeground(wxDC &dc)
dc.DrawText(cover_text_cover, pos);
}
if (m_hover) { dc.DrawBitmap(m_file_delete.get_bitmap(), size.x - m_file_delete.GetSize().x - FromDIP(10), FromDIP(10)); }
if (m_hover) { dc.DrawBitmap(m_file_delete.bmp(), size.x - m_file_delete.GetBmpSize().x - FromDIP(10), FromDIP(10)); }
}
void AuFile::on_mouse_enter(wxMouseEvent &evt)
@ -421,7 +421,7 @@ void AuFile::on_mouse_left_up(wxMouseEvent &evt)
auto pos = evt.GetPosition();
// set cover
auto mask_size = wxSize(GetSize().x, m_file_edit_mask.GetSize().y);
auto mask_size = wxSize(GetSize().x, m_file_edit_mask.GetBmpSize().y);
auto cover_left = 0;
auto cover_top = size.y - mask_size.y;
auto cover_right = mask_size.x / 2;
@ -443,10 +443,10 @@ void AuFile::on_mouse_left_up(wxMouseEvent &evt)
if (pos.x > rename_left && pos.x < rename_right && pos.y > rename_top && pos.y < rename_bottom) { on_set_rename(); return; }
// close
auto close_left = size.x - m_file_delete.GetSize().x - FromDIP(10);
auto close_left = size.x - m_file_delete.GetBmpSize().x - FromDIP(10);
auto close_top = FromDIP(10);
auto close_right = size.x - FromDIP(10);
auto close_bottom = m_file_delete.GetSize().y + FromDIP(10);
auto close_bottom = m_file_delete.GetBmpSize().y + FromDIP(10);
if (pos.x > close_left && pos.x < close_right && pos.y > close_top && pos.y < close_bottom) { on_set_delete(); return; }
exit_rename_mode();

View file

@ -29,11 +29,6 @@ enum CUSTOM_ID
ID_AMS_NOTEBOOK,
};
static bool IsThemeDark()
{
return wxSystemSettings::GetAppearance().IsDark();
}
class BBLTopbarArt : public wxAuiDefaultToolBarArt
{
public:
@ -98,7 +93,9 @@ void BBLTopbarArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& i
int bmpX = 0, bmpY = 0;
int textX = 0, textY = 0;
const wxBitmap &bmp = item.GetCurrentBitmapFor(wnd);
const wxBitmap& bmp = item.GetState() & wxAUI_BUTTON_STATE_DISABLED
? item.GetDisabledBitmap()
: item.GetBitmap();
const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);
@ -135,18 +132,18 @@ void BBLTopbarArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& i
if (item.GetState() & wxAUI_BUTTON_STATE_PRESSED)
{
dc.SetPen(wxPen(m_highlightColour));
dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(IsThemeDark() ? 20 : 150)));
dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(20)));
dc.DrawRectangle(rect);
}
else if ((item.GetState() & wxAUI_BUTTON_STATE_HOVER) || item.IsSticky())
{
dc.SetPen(wxPen(m_highlightColour));
dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(IsThemeDark() ? 40 : 170)));
dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(40)));
// draw an even lighter background for checked item hovers (since
// the hover background is the same color as the check background)
if (item.GetState() & wxAUI_BUTTON_STATE_CHECKED)
dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(IsThemeDark() ? 50 : 180)));
dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(50)));
dc.DrawRectangle(rect);
}
@ -155,7 +152,7 @@ void BBLTopbarArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& i
// it's important to put this code in an else statement after the
// hover, otherwise hovers won't draw properly for checked items
dc.SetPen(wxPen(m_highlightColour));
dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(IsThemeDark() ? 40 : 170)));
dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(40)));
dc.DrawRectangle(rect);
}
}
@ -200,25 +197,23 @@ void BBLTopbar::Init(wxFrame* parent)
m_skip_popup_dropdown_menu = false;
m_skip_popup_calib_menu = false;
m_font.Scale(parent->GetDPIScaleFactor());
wxInitAllImageHandlers();
this->AddSpacer(5);
/*wxBitmap logo_bitmap = *get_bmp_bundle("topbar_logo", TOPBAR_ICON_SIZE);
/*wxBitmap logo_bitmap = create_scaled_bitmap("topbar_logo", nullptr, TOPBAR_ICON_SIZE);
wxAuiToolBarItem* logo_item = this->AddTool(ID_LOGO, "", logo_bitmap);
logo_item->SetHoverBitmap(logo_bitmap);
logo_item->SetActive(false);*/
wxBitmapBundle file_bitmap = *get_bmp_bundle("topbar_file", TOPBAR_ICON_SIZE);
wxBitmap file_bitmap = create_scaled_bitmap("topbar_file", nullptr, TOPBAR_ICON_SIZE);
m_file_menu_item = this->AddTool(ID_TOP_FILE_MENU, _L("File"), file_bitmap, wxEmptyString, wxITEM_NORMAL);
this->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
this->AddSpacer(FromDIP(5));
wxBitmapBundle dropdown_bitmap = *get_bmp_bundle("topbar_dropdown", TOPBAR_ICON_SIZE);
wxBitmap dropdown_bitmap = create_scaled_bitmap("topbar_dropdown", nullptr, TOPBAR_ICON_SIZE);
m_dropdown_menu_item = this->AddTool(ID_TOP_DROPDOWN_MENU, "",
dropdown_bitmap, wxEmptyString);
@ -226,32 +221,32 @@ void BBLTopbar::Init(wxFrame* parent)
this->AddSeparator();
this->AddSpacer(FromDIP(5));
//wxBitmap open_bitmap = *get_bmp_bundle("topbar_open", TOPBAR_ICON_SIZE);
//wxBitmap open_bitmap = create_scaled_bitmap("topbar_open", nullptr, TOPBAR_ICON_SIZE);
//wxAuiToolBarItem* tool_item = this->AddTool(wxID_OPEN, "", open_bitmap);
this->AddSpacer(FromDIP(10));
wxBitmapBundle save_bitmap = *get_bmp_bundle("topbar_save", TOPBAR_ICON_SIZE);
wxBitmap save_bitmap = create_scaled_bitmap("topbar_save", nullptr, TOPBAR_ICON_SIZE);
wxAuiToolBarItem* save_btn = this->AddTool(wxID_SAVE, "", save_bitmap);
this->AddSpacer(FromDIP(10));
wxBitmapBundle undo_bitmap = *get_bmp_bundle("topbar_undo", TOPBAR_ICON_SIZE);
wxBitmap undo_bitmap = create_scaled_bitmap("topbar_undo", nullptr, TOPBAR_ICON_SIZE);
m_undo_item = this->AddTool(wxID_UNDO, "", undo_bitmap);
wxBitmapBundle undo_inactive_bitmap = *get_bmp_bundle("topbar_undo_inactive", TOPBAR_ICON_SIZE);
wxBitmap undo_inactive_bitmap = create_scaled_bitmap("topbar_undo_inactive", nullptr, TOPBAR_ICON_SIZE);
m_undo_item->SetDisabledBitmap(undo_inactive_bitmap);
this->AddSpacer(FromDIP(10));
wxBitmapBundle redo_bitmap = *get_bmp_bundle("topbar_redo", TOPBAR_ICON_SIZE);
wxBitmap redo_bitmap = create_scaled_bitmap("topbar_redo", nullptr, TOPBAR_ICON_SIZE);
m_redo_item = this->AddTool(wxID_REDO, "", redo_bitmap);
wxBitmapBundle redo_inactive_bitmap = *get_bmp_bundle("topbar_redo_inactive", TOPBAR_ICON_SIZE);
wxBitmap redo_inactive_bitmap = create_scaled_bitmap("topbar_redo_inactive", nullptr, TOPBAR_ICON_SIZE);
m_redo_item->SetDisabledBitmap(redo_inactive_bitmap);
this->AddSpacer(FromDIP(10));
wxBitmapBundle calib_bitmap = *get_bmp_bundle("calib_sf", TOPBAR_ICON_SIZE);
wxBitmapBundle calib_bitmap_inactive = *get_bmp_bundle("calib_sf_inactive", TOPBAR_ICON_SIZE);
wxBitmap calib_bitmap = create_scaled_bitmap("calib_sf", nullptr, TOPBAR_ICON_SIZE);
wxBitmap calib_bitmap_inactive = create_scaled_bitmap("calib_sf_inactive", nullptr, TOPBAR_ICON_SIZE);
m_calib_item = this->AddTool(ID_CALIB, _L("Calibration"), calib_bitmap);
m_calib_item->SetDisabledBitmap(calib_bitmap_inactive);
@ -264,14 +259,14 @@ void BBLTopbar::Init(wxFrame* parent)
this->AddSpacer(FromDIP(10));
this->AddStretchSpacer(1);
m_publish_bitmap = *get_bmp_bundle("topbar_publish", TOPBAR_ICON_SIZE);
m_publish_bitmap = create_scaled_bitmap("topbar_publish", nullptr, TOPBAR_ICON_SIZE);
m_publish_item = this->AddTool(ID_PUBLISH, "", m_publish_bitmap);
m_publish_disable_bitmap = *get_bmp_bundle("topbar_publish_disable", TOPBAR_ICON_SIZE);
m_publish_disable_bitmap = create_scaled_bitmap("topbar_publish_disable", nullptr, TOPBAR_ICON_SIZE);
m_publish_item->SetDisabledBitmap(m_publish_disable_bitmap);
this->EnableTool(m_publish_item->GetId(), false);
this->AddSpacer(FromDIP(4));
/*wxBitmap model_store_bitmap = *get_bmp_bundle("topbar_store", TOPBAR_ICON_SIZE);
/*wxBitmap model_store_bitmap = create_scaled_bitmap("topbar_store", nullptr, TOPBAR_ICON_SIZE);
m_model_store_item = this->AddTool(ID_MODEL_STORE, "", model_store_bitmap);
this->AddSpacer(12);
*/
@ -279,13 +274,13 @@ void BBLTopbar::Init(wxFrame* parent)
//this->AddSeparator();
this->AddSpacer(FromDIP(4));
wxBitmapBundle iconize_bitmap = *get_bmp_bundle("topbar_min", TOPBAR_ICON_SIZE);
wxBitmap iconize_bitmap = create_scaled_bitmap("topbar_min", nullptr, TOPBAR_ICON_SIZE);
wxAuiToolBarItem* iconize_btn = this->AddTool(wxID_ICONIZE_FRAME, "", iconize_bitmap);
this->AddSpacer(FromDIP(4));
maximize_bitmap = *get_bmp_bundle("topbar_max", TOPBAR_ICON_SIZE);
window_bitmap = *get_bmp_bundle("topbar_win", TOPBAR_ICON_SIZE);
maximize_bitmap = create_scaled_bitmap("topbar_max", nullptr, TOPBAR_ICON_SIZE);
window_bitmap = create_scaled_bitmap("topbar_win", nullptr, TOPBAR_ICON_SIZE);
if (m_frame->IsMaximized()) {
maximize_btn = this->AddTool(wxID_MAXIMIZE_FRAME, "", window_bitmap);
}
@ -295,7 +290,7 @@ void BBLTopbar::Init(wxFrame* parent)
this->AddSpacer(FromDIP(4));
wxBitmapBundle close_bitmap = *get_bmp_bundle("topbar_close", TOPBAR_ICON_SIZE);
wxBitmap close_bitmap = create_scaled_bitmap("topbar_close", nullptr, TOPBAR_ICON_SIZE);
wxAuiToolBarItem* close_btn = this->AddTool(wxID_CLOSE_FRAME, "", close_bitmap);
Realize();
@ -471,51 +466,49 @@ void BBLTopbar::Rescale() {
int em = em_unit(this);
wxAuiToolBarItem* item;
m_font.Scale(m_frame->GetDPIScaleFactor());
/*item = this->FindTool(ID_LOGO);
item->SetBitmap(*get_bmp_bundle("topbar_logo", TOPBAR_ICON_SIZE));*/
item->SetBitmap(create_scaled_bitmap("topbar_logo", nullptr, TOPBAR_ICON_SIZE));*/
item = this->FindTool(ID_TOP_FILE_MENU);
item->SetBitmap(*get_bmp_bundle("topbar_file", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("topbar_file", this, TOPBAR_ICON_SIZE));
item = this->FindTool(ID_TOP_DROPDOWN_MENU);
item->SetBitmap(*get_bmp_bundle("topbar_dropdown", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("topbar_dropdown", this, TOPBAR_ICON_SIZE));
//item = this->FindTool(wxID_OPEN);
//item->SetBitmap(*get_bmp_bundle("topbar_open", nullptr, TOPBAR_ICON_SIZE));
//item->SetBitmap(create_scaled_bitmap("topbar_open", nullptr, TOPBAR_ICON_SIZE));
item = this->FindTool(wxID_SAVE);
item->SetBitmap(*get_bmp_bundle("topbar_save", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("topbar_save", this, TOPBAR_ICON_SIZE));
item = this->FindTool(wxID_UNDO);
item->SetBitmap(*get_bmp_bundle("topbar_undo", TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(*get_bmp_bundle("topbar_undo_inactive", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("topbar_undo", this, TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(create_scaled_bitmap("topbar_undo_inactive", nullptr, TOPBAR_ICON_SIZE));
item = this->FindTool(wxID_REDO);
item->SetBitmap(*get_bmp_bundle("topbar_redo", TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(*get_bmp_bundle("topbar_redo_inactive", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("topbar_redo", this, TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(create_scaled_bitmap("topbar_redo_inactive", nullptr, TOPBAR_ICON_SIZE));
item = this->FindTool(ID_CALIB);
item->SetBitmap(*get_bmp_bundle("calib_sf", TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(*get_bmp_bundle("calib_sf_inactive", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("calib_sf", nullptr, TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(create_scaled_bitmap("calib_sf_inactive", nullptr, TOPBAR_ICON_SIZE));
item = this->FindTool(ID_TITLE);
/*item = this->FindTool(ID_PUBLISH);
item->SetBitmap(*get_bmp_bundle("topbar_publish", TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(*get_bmp_bundle("topbar_publish_disable", TOPBAR_ICON_SIZE));*/
item->SetBitmap(create_scaled_bitmap("topbar_publish", this, TOPBAR_ICON_SIZE));
item->SetDisabledBitmap(create_scaled_bitmap("topbar_publish_disable", nullptr, TOPBAR_ICON_SIZE));*/
/*item = this->FindTool(ID_MODEL_STORE);
item->SetBitmap(*get_bmp_bundle("topbar_store", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("topbar_store", this, TOPBAR_ICON_SIZE));
*/
item = this->FindTool(wxID_ICONIZE_FRAME);
item->SetBitmap(*get_bmp_bundle("topbar_min", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("topbar_min", this, TOPBAR_ICON_SIZE));
item = this->FindTool(wxID_MAXIMIZE_FRAME);
maximize_bitmap = *get_bmp_bundle("topbar_max", TOPBAR_ICON_SIZE);
window_bitmap = *get_bmp_bundle("topbar_win", TOPBAR_ICON_SIZE);
maximize_bitmap = create_scaled_bitmap("topbar_max", this, TOPBAR_ICON_SIZE);
window_bitmap = create_scaled_bitmap("topbar_win", this, TOPBAR_ICON_SIZE);
if (m_frame->IsMaximized()) {
item->SetBitmap(window_bitmap);
}
@ -524,7 +517,7 @@ void BBLTopbar::Rescale() {
}
item = this->FindTool(wxID_CLOSE_FRAME);
item->SetBitmap(*get_bmp_bundle("topbar_close", TOPBAR_ICON_SIZE));
item->SetBitmap(create_scaled_bitmap("topbar_close", this, TOPBAR_ICON_SIZE));
Realize();
}

View file

@ -75,11 +75,11 @@ private:
wxAuiToolBarItem* m_calib_item;
wxAuiToolBarItem* maximize_btn;
wxBitmapBundle m_publish_bitmap;
wxBitmapBundle m_publish_disable_bitmap;
wxBitmap m_publish_bitmap;
wxBitmap m_publish_disable_bitmap;
wxBitmapBundle maximize_bitmap;
wxBitmapBundle window_bitmap;
wxBitmap maximize_bitmap;
wxBitmap window_bitmap;
int m_toolbar_h;
bool m_skip_popup_file_menu;

View file

@ -13,8 +13,10 @@
#include <wx/rawbmp.h>
#endif /* __WXGTK2__ */
#include <nanosvg/nanosvg.h>
#include <nanosvg/nanosvgrast.h>
#define NANOSVG_IMPLEMENTATION
#include "nanosvg/nanosvg.h"
#define NANOSVGRAST_IMPLEMENTATION
#include "nanosvg/nanosvgrast.h"
namespace Slic3r { namespace GUI {
@ -58,168 +60,7 @@ static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image, float scale = 1.
#endif
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vector<wxBitmapBundle*>& bmps)
{
wxVector<wxBitmap> bitmaps;
std::set<double> scales = {1.0};
#ifndef __linux__
#ifdef __APPLE__
scales.emplace(m_scale);
#else
size_t disp_cnt = wxDisplay::GetCount();
for (size_t disp = 0; disp < disp_cnt; ++disp)
scales.emplace(wxDisplay(disp).GetScaleFactor());
#endif
#endif // !__linux__
for (double scale : scales) {
size_t width = 0;
size_t height = 0;
for (const wxBitmapBundle* bmp_bndl : bmps) {
#ifdef __APPLE__
wxSize size = bmp_bndl->GetDefaultSize();
#else
wxSize size = bmp_bndl->GetPreferredBitmapSizeAtScale(scale);
#endif
width += size.GetWidth();
height = std::max<size_t>(height, size.GetHeight());
}
std::string bitmap_key = name + "," +float_to_string_decimal_point(scale);
#ifdef __WXGTK2__
// Broken alpha workaround
wxImage image(width, height);
image.InitAlpha();
// Fill in with a white color.
memset(image.GetData(), 0x0ff, width * height * 3);
// Fill in with full transparency.
memset(image.GetAlpha(), 0, width * height);
size_t x = 0;
for (const wxBitmapBundle* bmp_bndl : bmps) {
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetDefaultSize());
if (bmp.GetWidth() > 0) {
if (bmp.GetDepth() == 32) {
wxAlphaPixelData data(bmp);
//FIXME The following method is missing from wxWidgets 3.1.1.
// It looks like the wxWidgets 3.0.3 called the wrapped bitmap's UseAlpha().
//data.UseAlpha();
if (data) {
for (int r = 0; r < bmp.GetHeight(); ++r) {
wxAlphaPixelData::Iterator src(data);
src.Offset(data, 0, r);
unsigned char* dst_pixels = image.GetData() + (x + r * width) * 3;
unsigned char* dst_alpha = image.GetAlpha() + x + r * width;
for (int c = 0; c < bmp.GetWidth(); ++c, ++src) {
*dst_pixels++ = src.Red();
*dst_pixels++ = src.Green();
*dst_pixels++ = src.Blue();
*dst_alpha++ = src.Alpha();
}
}
}
}
else if (bmp.GetDepth() == 24) {
wxNativePixelData data(bmp);
if (data) {
for (int r = 0; r < bmp.GetHeight(); ++r) {
wxNativePixelData::Iterator src(data);
src.Offset(data, 0, r);
unsigned char* dst_pixels = image.GetData() + (x + r * width) * 3;
unsigned char* dst_alpha = image.GetAlpha() + x + r * width;
for (int c = 0; c < bmp.GetWidth(); ++c, ++src) {
*dst_pixels++ = src.Red();
*dst_pixels++ = src.Green();
*dst_pixels++ = src.Blue();
*dst_alpha++ = wxALPHA_OPAQUE;
}
}
}
}
}
x += bmp.GetScaledWidth();
}
bitmaps.push_back(* this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image))));
#else
wxBitmap* bitmap = this->insert(bitmap_key, width, height, scale);
wxMemoryDC memDC;
memDC.SelectObject(*bitmap);
memDC.SetBackground(*wxTRANSPARENT_BRUSH);
memDC.Clear();
size_t x = 0;
for (const wxBitmapBundle* bmp_bndl : bmps) {
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetPreferredBitmapSizeAtScale(scale));
if (bmp.GetWidth() > 0)
memDC.DrawBitmap(bmp, x, 0, true);
// we should "move" with step equal to non-scaled width
#ifdef __APPLE__
x += bmp.GetScaledWidth();
#else
x += bmp.GetWidth();
#endif
}
memDC.SelectObject(wxNullBitmap);
bitmaps.push_back(*bitmap);
#endif
}
return insert_bndl(name, bitmaps);
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string &bitmap_key, const char* data, size_t width, size_t height)
{
wxBitmapBundle* bndl = nullptr;
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
bndl = new wxBitmapBundle(wxBitmapBundle::FromSVG(data, wxSize(width, height)));
m_bndl_map[bitmap_key] = bndl;
}
else {
bndl = it->second;
*bndl = wxBitmapBundle::FromSVG(data, wxSize(width, height));
}
return bndl;
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& bitmap_key, const wxBitmapBundle& bmp)
{
wxBitmapBundle* bndl = nullptr;
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
bndl = new wxBitmapBundle(bmp);
m_bndl_map[bitmap_key] = bndl;
}
else {
bndl = it->second;
*bndl = wxBitmapBundle(bmp);
}
return bndl;
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& bitmap_key, const wxVector<wxBitmap>& bmps)
{
wxBitmapBundle* bndl = nullptr;
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
bndl = new wxBitmapBundle(wxBitmapBundle::FromBitmaps(bmps));
m_bndl_map[bitmap_key] = bndl;
}
else {
bndl = it->second;
*bndl = wxBitmapBundle::FromBitmaps(bmps);
}
return bndl;
}
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height, double scale/* = -1.0*/)
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height)
{
wxBitmap *bitmap = nullptr;
auto it = m_map.find(bitmap_key);
@ -235,7 +76,7 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_
// So, We need to let the Mac OS wxBitmap implementation
// know that the image may already be scaled appropriately for Retina,
// and thereby that it's not supposed to upscale it.
bitmap->CreateScaled(width, height, -1, scale < 0.0 ? m_scale : scale);
bitmap->CreateScaled(width, height, -1, m_scale);
#endif
m_map[bitmap_key] = bitmap;
} else {
@ -264,6 +105,110 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp
return bitmap;
}
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2)
{
// Copying the wxBitmaps is cheap as the bitmap's content is reference counted.
const wxBitmap bmps[2] = { bmp, bmp2 };
return this->insert(bitmap_key, bmps, bmps + 2);
}
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3)
{
// Copying the wxBitmaps is cheap as the bitmap's content is reference counted.
const wxBitmap bmps[3] = { bmp, bmp2, bmp3 };
return this->insert(bitmap_key, bmps, bmps + 3);
}
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap *begin, const wxBitmap *end)
{
size_t width = 0;
size_t height = 0;
for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) {
#ifdef __APPLE__
width += bmp->GetScaledWidth();
height = std::max<size_t>(height, bmp->GetScaledHeight());
#else
width += bmp->GetWidth();
height = std::max<size_t>(height, bmp->GetHeight());
#endif
}
#ifdef __WXGTK2__
// Broken alpha workaround
wxImage image(width, height);
image.InitAlpha();
// Fill in with a white color.
memset(image.GetData(), 0x0ff, width * height * 3);
// Fill in with full transparency.
memset(image.GetAlpha(), 0, width * height);
size_t x = 0;
for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) {
if (bmp->GetWidth() > 0) {
if (bmp->GetDepth() == 32) {
wxAlphaPixelData data(*const_cast<wxBitmap*>(bmp));
//FIXME The following method is missing from wxWidgets 3.1.1.
// It looks like the wxWidgets 3.0.3 called the wrapped bitmap's UseAlpha().
//data.UseAlpha();
if (data) {
for (int r = 0; r < bmp->GetHeight(); ++ r) {
wxAlphaPixelData::Iterator src(data);
src.Offset(data, 0, r);
unsigned char *dst_pixels = image.GetData() + (x + r * width) * 3;
unsigned char *dst_alpha = image.GetAlpha() + x + r * width;
for (int c = 0; c < bmp->GetWidth(); ++ c, ++ src) {
*dst_pixels ++ = src.Red();
*dst_pixels ++ = src.Green();
*dst_pixels ++ = src.Blue();
*dst_alpha ++ = src.Alpha();
}
}
}
} else if (bmp->GetDepth() == 24) {
wxNativePixelData data(*const_cast<wxBitmap*>(bmp));
if (data) {
for (int r = 0; r < bmp->GetHeight(); ++ r) {
wxNativePixelData::Iterator src(data);
src.Offset(data, 0, r);
unsigned char *dst_pixels = image.GetData() + (x + r * width) * 3;
unsigned char *dst_alpha = image.GetAlpha() + x + r * width;
for (int c = 0; c < bmp->GetWidth(); ++ c, ++ src) {
*dst_pixels ++ = src.Red();
*dst_pixels ++ = src.Green();
*dst_pixels ++ = src.Blue();
*dst_alpha ++ = wxALPHA_OPAQUE;
}
}
}
}
}
x += bmp->GetWidth();
}
return this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image)));
#else
wxBitmap *bitmap = this->insert(bitmap_key, width, height);
wxMemoryDC memDC;
memDC.SelectObject(*bitmap);
memDC.SetBackground(*wxTRANSPARENT_BRUSH);
memDC.Clear();
size_t x = 0;
for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) {
if (bmp->GetWidth() > 0)
memDC.DrawBitmap(*bmp, x, 0, true);
#ifdef __APPLE__
// we should "move" with step equal to non-scaled width
x += bmp->GetScaledWidth();
#else
x += bmp->GetWidth();
#endif
}
memDC.SelectObject(wxNullBitmap);
return bitmap;
#endif
}
wxBitmap* BitmapCache::insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale/* = false*/)
{
wxImage image(width, height);
@ -360,101 +305,6 @@ error:
return NULL;
}
void BitmapCache::nsvgGetDataFromFileWithReplace(const char* filename, std::string& data_str, const std::map<std::string, std::string>& replaces)
{
FILE* fp = NULL;
size_t size;
char* data = NULL;
fp = boost::nowide::fopen(filename, "rb");
if (!fp) goto error;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
data = (char*)malloc(size + 1);
if (data == NULL) goto error;
if (fread(data, 1, size, fp) != size) goto error;
data[size] = '\0'; // Must be null terminated.
fclose(fp);
data_str.assign(data);
for (auto val : replaces)
boost::replace_all(data_str, val.first, val.second);
free(data);
return;
error:
if (fp) fclose(fp);
if (data) free(data);
return;
}
wxBitmapBundle* BitmapCache::from_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height,
const bool dark_mode, const std::string& new_color /*= ""*/)
{
if (target_width == 0)
target_width = target_height;
std::string bitmap_key = bitmap_name + (target_height != 0 ?
"-h" + std::to_string(target_height) :
"-w" + std::to_string(target_width))
+ (dark_mode ? "-dm" : "")
+ new_color;
auto it = m_bndl_map.find(bitmap_key);
if (it != m_bndl_map.end())
return it->second;
// map of color replaces
//Orca: use replaces from load_svg function
std::map<std::string, std::string> replaces;
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#00FF00\""] = "\"#52c7b8\"";
if (dark_mode) {
replaces["\"#262E30\""] = "\"#EFEFF0\"";
replaces["\"#323A3D\""] = "\"#B3B3B5\"";
replaces["\"#808080\""] = "\"#818183\"";
replaces["\"#CECECE\""] = "\"#54545B\"";
replaces["\"#6B6B6B\""] = "\"#818182\"";
replaces["\"#909090\""] = "\"#FFFFFF\"";
replaces["\"#00FF00\""] = "\"#FF0000\"";
replaces["\"#009688\""] = "\"#00675b\"";
}
std::string str;
nsvgGetDataFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), str, replaces);
if (str.empty())
return nullptr;
return insert_bndl(bitmap_key, str.data(), target_width, target_height);
}
wxBitmapBundle* BitmapCache::from_png(const std::string& bitmap_name, unsigned width, unsigned height)
{
std::string bitmap_key = bitmap_name + (height != 0 ?
"-h" + std::to_string(height) :
"-w" + std::to_string(width));
auto it = m_bndl_map.find(bitmap_key);
if (it != m_bndl_map.end())
return it->second;
wxImage image;
if (!image.LoadFile(Slic3r::GUI::from_u8(Slic3r::var(bitmap_name + ".png")), wxBITMAP_TYPE_PNG) ||
image.GetWidth() == 0 || image.GetHeight() == 0)
return nullptr;
if (height != 0 && unsigned(image.GetHeight()) != height)
width = unsigned(0.5f + float(image.GetWidth()) * height / image.GetHeight());
else if (width != 0 && unsigned(image.GetWidth()) != width)
height = unsigned(0.5f + float(image.GetHeight()) * width / image.GetWidth());
if (height != 0 && width != 0)
image.Rescale(width, height, wxIMAGE_QUALITY_BILINEAR);
return this->insert_bndl(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image)));
}
wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
const bool grayscale/* = false*/, const bool dark_mode/* = false*/, const std::string& new_color /*= ""*/, const float scale_in_center/* = 0*/)
{
@ -472,7 +322,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
// map of color replaces
std::map<std::string, std::string> replaces;
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#00FF00\""] = "\"#52c7b8\"";
if (dark_mode) {
replaces["\"#262E30\""] = "\"#EFEFF0\"";
@ -483,7 +333,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
replaces["\"#6B6B6B\""] = "\"#818182\"";
replaces["\"#909090\""] = "\"#FFFFFF\"";
replaces["\"#00FF00\""] = "\"#FF0000\"";
replaces["\"#009688\""] = "\"#00675b\"";
replaces["\"#009688\""] = "\"#00675b\"";
}
//if (!new_color.empty())
// replaces["\"#ED6B21\""] = "\"" + new_color + "\"";
@ -536,9 +386,9 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
return this->insert_raw_rgba(bitmap_key, width, height, data.data(), grayscale);
}
/*
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false* /, size_t border_width /*= 0* /, bool dark_mode/* = false* /)
wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false*/, size_t border_width /*= 0*/, bool dark_mode/* = false*/)
{
double scale = suppress_scaling ? 1.0f : m_scale;
width *= scale;
@ -580,89 +430,6 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
}
*/
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
wxBitmapBundle BitmapCache::mksolid(size_t width_in, size_t height_in, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, size_t border_width /*= 0*/, bool dark_mode/* = false*/)
{
wxVector<wxBitmap> bitmaps;
std::set<double> scales = { 1.0 };
#ifndef __linux__
#ifdef __APPLE__
scales.emplace(m_scale);
#else
size_t disp_cnt = wxDisplay::GetCount();
for (size_t disp = 0; disp < disp_cnt; ++disp)
scales.emplace(wxDisplay(disp).GetScaleFactor());
#endif
#endif // !__linux__
for (double scale : scales) {
size_t width = width_in * scale;
size_t height = height_in * scale;
wxImage image(width, height);
image.InitAlpha();
unsigned char* imgdata = image.GetData();
unsigned char* imgalpha = image.GetAlpha();
for (size_t i = 0; i < width * height; ++i) {
*imgdata++ = r;
*imgdata++ = g;
*imgdata++ = b;
*imgalpha++ = transparency;
}
// Add border, make white/light spools easier to see
if (border_width > 0) {
// Restrict to width of image
if (border_width > height) border_width = height - 1;
if (border_width > width) border_width = width - 1;
auto px_data = (uint8_t*)image.GetData();
auto a_data = (uint8_t*)image.GetAlpha();
for (size_t x = 0; x < width; ++x) {
for (size_t y = 0; y < height; ++y) {
if (x < border_width || y < border_width ||
x >= (width - border_width) || y >= (height - border_width)) {
const size_t idx = (x + y * width);
const size_t idx_rgb = (x + y * width) * 3;
px_data[idx_rgb] = px_data[idx_rgb + 1] = px_data[idx_rgb + 2] = dark_mode ? 245u : 110u;
a_data[idx] = 255u;
}
}
}
}
bitmaps.push_back(wxImage_to_wxBitmap_with_alpha(std::move(image), scale));
}
return wxBitmapBundle::FromBitmaps(bitmaps);
}
wxBitmapBundle* BitmapCache::mksolid_bndl(size_t width, size_t height, const std::string& color, size_t border_width, bool dark_mode)
{
std::string bitmap_key = (color.empty() ? "empty" : color) + "-h" + std::to_string(height) + "-w" + std::to_string(width) + (dark_mode ? "-dm" : "");
wxBitmapBundle* bndl = nullptr;
auto it = m_bndl_map.find(bitmap_key);
if (it == m_bndl_map.end()) {
if (color.empty())
bndl = new wxBitmapBundle(mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT, size_t(0)));
else {
ColorRGB rgb;// [3]
decode_color(color, rgb);
bndl = new wxBitmapBundle(mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, border_width, dark_mode));
}
m_bndl_map[bitmap_key] = bndl;
}
else
return it->second;
return bndl;
}
bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
{

View file

@ -12,8 +12,7 @@
#include "libslic3r/Color.hpp"
struct NSVGimage;
namespace Slic3r {
namespace GUI {
namespace Slic3r { namespace GUI {
class BitmapCache
{
@ -23,23 +22,15 @@ public:
void clear();
double scale() { return m_scale; }
wxBitmapBundle* find_bndl(const std::string &name) { auto it = m_bndl_map.find(name); return (it == m_bndl_map.end()) ? nullptr : it->second; }
const wxBitmapBundle* find_bndl(const std::string &name) const { return const_cast<BitmapCache*>(this)->find_bndl(name); }
wxBitmap* find(const std::string &name) { auto it = m_map.find(name); return (it == m_map.end()) ? nullptr : it->second; }
const wxBitmap* find(const std::string &name) const { return const_cast<BitmapCache*>(this)->find(name); }
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const char* data, size_t width, size_t height);
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const wxBitmapBundle &bmp);
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const wxVector<wxBitmap>& bmps);
wxBitmapBundle* insert_bndl(const std::string& name, const std::vector<wxBitmapBundle*>& bmps);
wxBitmapBundle* insert_raw_rgba_bndl(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale = false);
wxBitmap* insert(const std::string &name, size_t width, size_t height, double scale = -1.0);
wxBitmap* insert(const std::string &name, size_t width, size_t height);
wxBitmap* insert(const std::string &name, const wxBitmap &bmp);
// wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2);
// wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3);
// wxBitmap* insert(const std::string &name, const std::vector<wxBitmap> &bmps) { return this->insert(name, &bmps.front(), &bmps.front() + bmps.size()); }
// wxBitmap* insert(const std::string &name, const wxBitmap *begin, const wxBitmap *end);
wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2);
wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3);
wxBitmap* insert(const std::string &name, const std::vector<wxBitmap> &bmps) { return this->insert(name, &bmps.front(), &bmps.front() + bmps.size()); }
wxBitmap* insert(const std::string &name, const wxBitmap *begin, const wxBitmap *end);
wxBitmap* insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale = false);
// BBS: support resize by fill border (scale_in_center)
@ -50,28 +41,19 @@ public:
// And makes replases befor parsing
// replace_map containes old_value->new_value
static NSVGimage* nsvgParseFromFileWithReplace(const char* filename, const char* units, float dpi, const std::map<std::string, std::string>& replaces);
// Gets a data from SVG file and makes replases
// replace_map containes old_value->new_value
static void nsvgGetDataFromFileWithReplace(const char* filename, std::string& data_str, const std::map<std::string, std::string>& replaces);
wxBitmapBundle* from_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height, const bool dark_mode, const std::string& new_color = "");
wxBitmapBundle* from_png(const std::string& bitmap_name, unsigned width, unsigned height);
// Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width.
wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false, const std::string& new_color = "", const float scale_in_center = 0.f);
// wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
// wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
// wxBitmap mksolid(size_t width, size_t height, const ColorRGB& rgb, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
// wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT, true, 0); }
wxBitmapBundle mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, size_t border_width = 0, bool dark_mode = false);
wxBitmapBundle* mksolid_bndl(size_t width, size_t height, const std::string& color = std::string(), size_t border_width = 0, bool dark_mode = false);
wxBitmapBundle* mkclear_bndl(size_t width, size_t height) { return mksolid_bndl(width, height); }
wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
wxBitmap mksolid(size_t width, size_t height, const ColorRGB& rgb, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT); }
static bool parse_color(const std::string& scolor, unsigned char* rgb_out);
static bool parse_color4(const std::string& scolor, unsigned char* rgba_out);
private:
std::map<std::string, wxBitmap*> m_map;
std::map<std::string, wxBitmapBundle*> m_bndl_map;
double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs)
double m_scale = 1.0; // value, used for correct scaling of SVG icons on Retina display
};

View file

@ -54,6 +54,17 @@ using Slic3r::GUI::format_wxstr;
namespace Slic3r {
namespace GUI {
/* For PresetComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
* "please scale this to such and such" but rather
* "the wxImage is already sized for backing scale such and such". )
* Unfortunately, the constructor changes the size of wxBitmap too.
* Thus We need to use unscaled size value for bitmaps that we use
* to avoid scaled size of control items.
* For this purpose control drawing methods and
* control size calculation methods (virtual) are overridden.
**/
BitmapComboBox::BitmapComboBox(wxWindow* parent,
wxWindowID id/* = wxID_ANY*/,
const wxString& value/* = wxEmptyString*/,
@ -79,6 +90,72 @@ BitmapComboBox::~BitmapComboBox()
{
}
#ifdef __APPLE__
bool BitmapComboBox::OnAddBitmap(const wxBitmap& bitmap)
{
if (bitmap.IsOk())
{
// we should use scaled! size values of bitmap
int width = (int)bitmap.GetScaledWidth();
int height = (int)bitmap.GetScaledHeight();
if (m_usedImgSize.x < 0)
{
// If size not yet determined, get it from this image.
m_usedImgSize.x = width;
m_usedImgSize.y = height;
// Adjust control size to vertically fit the bitmap
wxWindow* ctrl = GetControl();
ctrl->InvalidateBestSize();
wxSize newSz = ctrl->GetBestSize();
wxSize sz = ctrl->GetSize();
if (newSz.y > sz.y)
ctrl->SetSize(sz.x, newSz.y);
else
DetermineIndent();
}
wxCHECK_MSG(width == m_usedImgSize.x && height == m_usedImgSize.y,
false,
"you can only add images of same size");
return true;
}
return false;
}
void BitmapComboBox::OnDrawItem(wxDC& dc,
const wxRect& rect,
int item,
int flags) const
{
const wxBitmap& bmp = *(static_cast<wxBitmap*>(m_bitmaps[item]));
if (bmp.IsOk())
{
// we should use scaled! size values of bitmap
wxCoord w = bmp.GetScaledWidth();
wxCoord h = bmp.GetScaledHeight();
const int imgSpacingLeft = 4;
// Draw the image centered
dc.DrawBitmap(bmp,
rect.x + (m_usedImgSize.x - w) / 2 + imgSpacingLeft,
rect.y + (rect.height - h) / 2,
true);
}
wxString text = GetString(item);
if (!text.empty())
dc.DrawText(text,
rect.x + m_imgAreaWidth + 1,
rect.y + (rect.height - dc.GetCharHeight()) / 2);
}
#endif
#ifdef _WIN32
int BitmapComboBox::Append(const wxString& item)
@ -89,11 +166,18 @@ int BitmapComboBox::Append(const wxString& item)
//2. But then set width to 0 value for no using of bitmap left and right spacing
//3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
wxBitmapBundle bitmap = *get_empty_bmp_bundle(1, 16);
wxBitmap bitmap(1, int(1.6 * wxGetApp().em_unit() + 1));
{
// bitmap.SetWidth(0); is depricated now
// so, use next code
bitmap.UnShare();// AllocExclusive();
bitmap.GetGDIImageData()->m_width = 0;
}
OnAddBitmap(bitmap);
const int n = wxComboBox::Append(item);
if (n != wxNOT_FOUND)
DoSetItemBitmap(n, bitmap);
return n;
}

View file

@ -29,13 +29,28 @@ BitmapComboBox(wxWindow* parent,
#ifdef _WIN32
int Append(const wxString& item);
#endif
int Append(const wxString& item, const wxBitmapBundle& bitmap)
int Append(const wxString& item, const wxBitmap& bitmap)
{
return wxBitmapComboBox::Append(item, bitmap);
}
protected:
#ifdef __APPLE__
/* For PresetComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
* "please scale this to such and such" but rather
* "the wxImage is already sized for backing scale such and such". )
* Unfortunately, the constructor changes the size of wxBitmap too.
* Thus We need to use unscaled size value for bitmaps that we use
* to avoid scaled size of control items.
* For this purpose control drawing methods and
* control size calculation methods (virtual) are overridden.
**/
bool OnAddBitmap(const wxBitmap& bitmap) override;
void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const override;
#endif
#ifdef _WIN32
bool MSWOnDraw(WXDRAWITEMSTRUCT* item) override;
void DrawBackground_(wxDC& dc, const wxRect& rect, int WXUNUSED(item), int flags) const;

View file

@ -102,9 +102,9 @@ void MObjectPanel::doRender(wxDC& dc)
if (m_state == PrinterState::IN_LAN) { dwbitmap = m_printer_in_lan; }
// dc.DrawCircle(left, size.y / 2, 3);
dc.DrawBitmap(dwbitmap.get_bitmap(), wxPoint(left, (size.y - dwbitmap.GetSize().y) / 2));
dc.DrawBitmap(dwbitmap.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2));
left += dwbitmap.GetSize().x + 8;
left += dwbitmap.GetBmpSize().x + 8;
dc.SetFont(Label::Body_13);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));

View file

@ -371,7 +371,7 @@ CaliPageCaption::CaliPageCaption(wxWindow* parent, CalibMode cali_mode,
auto top_sizer = new wxBoxSizer(wxVERTICAL);
auto caption_sizer = new wxBoxSizer(wxHORIZONTAL);
m_prev_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_prev",
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 30);
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 30);
m_prev_btn->SetBackgroundColour(*wxWHITE);
caption_sizer->Add(m_prev_btn, 0, wxALIGN_CENTER | wxRIGHT, FromDIP(10));
@ -382,7 +382,7 @@ CaliPageCaption::CaliPageCaption(wxWindow* parent, CalibMode cali_mode,
caption_sizer->Add(title_text, 0, wxALIGN_CENTER | wxRIGHT, FromDIP(10));
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help",
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 30);
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 30);
m_help_btn->Hide();
m_help_btn->SetBackgroundColour(*wxWHITE);
caption_sizer->Add(m_help_btn, 0, wxALIGN_CENTER);
@ -472,12 +472,12 @@ void CaliPageCaption::show_help_icon(bool show)
void CaliPageCaption::on_sys_color_changed()
{
m_prev_btn->sys_color_changed();
m_prev_btn->msw_rescale();
}
void CaliPageCaption::msw_rescale()
{
m_prev_btn->sys_color_changed();
m_prev_btn->msw_rescale();
}
CaliPageStepGuide::CaliPageStepGuide(wxWindow* parent, wxArrayString steps,
@ -593,7 +593,7 @@ PAPageHelpPanel::PAPageHelpPanel(wxWindow* parent, bool ground_panel, wxWindowID
wxBoxSizer* help_text_sizer = new wxBoxSizer(wxHORIZONTAL);
auto help_text = new Label(this, _L("You could change the Flow Dynamics Calibration Factor in material editing"));
help_text->SetFont(Label::Body_14);
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 24);
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 24);
m_help_btn->SetBackgroundColour(m_help_btn->GetParent()->GetBackgroundColour());
help_text_sizer->Add(help_text, 0, wxALIGN_CENTER | wxLEFT, left_align_padding);
help_text_sizer->Add(m_help_btn, 0, wxALIGN_CENTER | wxLEFT, FromDIP(8));
@ -611,8 +611,8 @@ PAPageHelpPanel::PAPageHelpPanel(wxWindow* parent, bool ground_panel, wxWindowID
void PAPageHelpPanel::msw_rescale()
{
m_help_btn->sys_color_changed();
m_bmp.sys_color_changed();
m_help_btn->msw_rescale();
m_bmp.msw_rescale();
m_img->SetBitmap(m_bmp.bmp());
}

View file

@ -448,7 +448,7 @@ CalibrationPresetPage::CalibrationPresetPage(
void CalibrationPresetPage::msw_rescale()
{
CalibrationWizardPage::msw_rescale();
m_ams_sync_button->sys_color_changed();
m_ams_sync_button->msw_rescale();
m_virtual_tray_comboBox->msw_rescale();
for (auto& comboBox : m_filament_comboBox_list) {
comboBox->msw_rescale();
@ -458,7 +458,7 @@ void CalibrationPresetPage::msw_rescale()
void CalibrationPresetPage::on_sys_color_changed()
{
CalibrationWizardPage::on_sys_color_changed();
m_ams_sync_button->sys_color_changed();
m_ams_sync_button->msw_rescale();
}
void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
@ -507,7 +507,7 @@ void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
filament_for_text->SetFont(Label::Head_14);
filament_for_title_sizer->Add(filament_for_text, 0, wxALIGN_CENTER);
filament_for_title_sizer->AddSpacer(FromDIP(25));
m_ams_sync_button = new ScalableButton(parent, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 18);
m_ams_sync_button = new ScalableButton(parent, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 18);
m_ams_sync_button->SetBackgroundColour(*wxWHITE);
m_ams_sync_button->SetToolTip(_L("Synchronize filament list from AMS"));
filament_for_title_sizer->Add(m_ams_sync_button, 0, wxALIGN_CENTER);

View file

@ -470,8 +470,8 @@ CameraItem::CameraItem(wxWindow *parent, std::string normal, std::string hover)
CameraItem::~CameraItem() {}
void CameraItem::msw_rescale() {
m_bitmap_normal.sys_color_changed();
m_bitmap_hover.sys_color_changed();
m_bitmap_normal.msw_rescale();
m_bitmap_hover.msw_rescale();
}
void CameraItem::on_enter_win(wxMouseEvent &evt)
@ -519,9 +519,9 @@ void CameraItem::render(wxDC &dc)
void CameraItem::doRender(wxDC &dc)
{
if (m_hover) {
dc.DrawBitmap(m_bitmap_hover.get_bitmap(), wxPoint((GetSize().x - m_bitmap_hover.GetSize().x) / 2, (GetSize().y - m_bitmap_hover.GetSize().y) / 2));
dc.DrawBitmap(m_bitmap_hover.bmp(), wxPoint((GetSize().x - m_bitmap_hover.GetBmpSize().x) / 2, (GetSize().y - m_bitmap_hover.GetBmpSize().y) / 2));
} else {
dc.DrawBitmap(m_bitmap_normal.get_bitmap(), wxPoint((GetSize().x - m_bitmap_normal.GetSize().x) / 2, (GetSize().y - m_bitmap_normal.GetSize().y) / 2));
dc.DrawBitmap(m_bitmap_normal.bmp(), wxPoint((GetSize().x - m_bitmap_normal.GetBmpSize().x) / 2, (GetSize().y - m_bitmap_normal.GetBmpSize().y) / 2));
}
}

View file

@ -1499,7 +1499,7 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
#ifndef __WXOSX__
SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
#endif //__WXOSX__
SetMinSize(bg.GetSize());
SetMinSize(bg.bmp().GetSize());
const wxSize size = GetTextExtent("m");
em_w = size.x;
@ -1626,8 +1626,8 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
wxPaintDC dc(this);
const auto bullet_w = bullet_black.GetWidth();
const auto bullet_h = bullet_black.GetHeight();
const auto bullet_w = bullet_black.bmp().GetSize().GetWidth();
const auto bullet_h = bullet_black.bmp().GetSize().GetHeight();
const int yoff_icon = bullet_h < em_h ? (em_h - bullet_h) / 2 : 0;
const int yoff_text = bullet_h > em_h ? (bullet_h - em_h) / 2 : 0;
const int yinc = item_height();
@ -1640,10 +1640,10 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
unsigned x = em_w/2 + item.indent * em_w;
if (i == item_active || (item_hover >= 0 && i == (size_t)item_hover)) {
dc.DrawBitmap(bullet_blue.get_bitmap(), x, y + yoff_icon, false);
dc.DrawBitmap(bullet_blue.bmp(), x, y + yoff_icon, false);
}
else if (i < item_active) { dc.DrawBitmap(bullet_black.get_bitmap(), x, y + yoff_icon, false); }
else if (i > item_active) { dc.DrawBitmap(bullet_white.get_bitmap(), x, y + yoff_icon, false); }
else if (i < item_active) { dc.DrawBitmap(bullet_black.bmp(), x, y + yoff_icon, false); }
else if (i > item_active) { dc.DrawBitmap(bullet_white.bmp(), x, y + yoff_icon, false); }
x += + bullet_w + em_w/2;
const auto text_size = dc.GetTextExtent(item.label);
@ -1655,9 +1655,9 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
}
//draw logo
if (int y = size.y - bg.GetHeight(); y>=0) {
dc.DrawBitmap(bg.get_bitmap(), 0, y, false);
index_width = std::max(index_width, bg.GetWidth() + em_w / 2);
if (int y = size.y - bg.GetBmpHeight(); y>=0) {
dc.DrawBitmap(bg.bmp(), 0, y, false);
index_width = std::max(index_width, bg.GetBmpWidth() + em_w / 2);
}
if (GetMinSize().x < index_width) {
@ -1689,12 +1689,12 @@ void ConfigWizardIndex::msw_rescale()
em_w = size.x;
em_h = size.y;
bg.sys_color_changed();
SetMinSize(bg.GetSize());
bg.msw_rescale();
SetMinSize(bg.bmp().GetSize());
bullet_black.sys_color_changed();
bullet_blue.sys_color_changed();
bullet_white.sys_color_changed();
bullet_black.msw_rescale();
bullet_blue.msw_rescale();
bullet_white.msw_rescale();
Refresh();
}

View file

@ -510,7 +510,7 @@ private:
ssize_t item_hover;
size_t last_page;
int item_height() const { return std::max(bullet_black.GetHeight(), em_w) + em_w; }
int item_height() const { return std::max(bullet_black.bmp().GetSize().GetHeight(), em_w) + em_w; }
void on_paint(wxPaintEvent &evt);
void on_mouse_move(wxMouseEvent &evt);

View file

@ -46,8 +46,8 @@ void DragCanvas::set_shape_list(const std::vector<std::string>& colors, const st
m_dragshape_list.clear();
for (int i = 0; i < order.size(); i++) {
wxBitmap bmp = get_extruder_color_icon(colors[order[i] - 1], std::to_string(order[i]), SHAPE_SIZE, SHAPE_SIZE)->GetBitmapFor(m_parent);
DragShape* shape = new DragShape(bmp, order[i]);
wxBitmap* bmp = get_extruder_color_icon(colors[order[i] - 1], std::to_string(order[i]), SHAPE_SIZE, SHAPE_SIZE);
DragShape* shape = new DragShape(*bmp, order[i]);
m_dragshape_list.push_back(shape);
}

View file

@ -33,15 +33,6 @@ wxIMPLEMENT_DYNAMIC_CLASS(DataViewBitmapText, wxObject)
IMPLEMENT_VARIANT_OBJECT(DataViewBitmapText)
static wxSize get_size(const wxBitmap& icon)
{
#ifdef __WIN32__
return icon.GetSize();
#else
return icon.GetScaledSize();
#endif
}
// ---------------------------------------------------------
// BitmapTextRenderer
// ---------------------------------------------------------
@ -133,7 +124,11 @@ bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state)
const wxBitmap& icon = m_value.GetBitmap();
if (icon.IsOk())
{
wxSize icon_sz = get_size(icon);
#ifdef __APPLE__
wxSize icon_sz = icon.GetScaledSize();
#else
wxSize icon_sz = icon.GetSize();
#endif
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.y) / 2);
xoffset = icon_sz.x + 4;
}
@ -275,12 +270,11 @@ bool BitmapChoiceRenderer::Render(wxRect rect, wxDC* dc, int state)
const wxBitmap& icon = m_value.GetBitmap();
if (icon.IsOk())
{
wxSize icon_sz = get_size(icon);
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.GetHeight()) / 2);
// xoffset = icon_sz.GetWidth() + 4;
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
// xoffset = icon.GetWidth() + 4;
if (rect.height == 0)
rect.height = icon_sz.GetHeight();
rect.height = icon.GetHeight();
}
#ifdef _WIN32
@ -311,7 +305,7 @@ wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelR
if (can_create_editor_ctrl && !can_create_editor_ctrl())
return nullptr;
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons();
std::vector<wxBitmap*> icons = get_extruder_color_icons();
if (icons.empty())
return nullptr;

View file

@ -1127,7 +1127,7 @@ void Choice::BUILD()
auto icon_name = "param_" + m_opt.enum_values[i];
if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) {
ScalableBitmap bm(temp, icon_name, 24);
temp->Append(_(el), bm.get_bitmap());
temp->Append(_(el), bm.bmp());
} else {
temp->Append(_(el));
}
@ -1529,7 +1529,7 @@ void Choice::msw_rescale()
auto icon_name = "param_" + m_opt.enum_values[i];
if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) {
ScalableBitmap bm(window, icon_name, 24);
temp->SetItemBitmap(i, bm.get_bitmap());
temp->SetItemBitmap(i, bm.bmp());
}
++i;
}

View file

@ -28,8 +28,8 @@
#define STB_DXT_IMPLEMENTATION
#include "stb_dxt/stb_dxt.h"
#include <nanosvg/nanosvg.h>
#include <nanosvg/nanosvgrast.h>
#include "nanosvg/nanosvg.h"
#include "nanosvg/nanosvgrast.h"
#include "libslic3r/Utils.hpp"
#include "GUI_App.hpp"

View file

@ -369,7 +369,7 @@ public:
// See https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/font.cpp
// void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew)
wxNativeFontInfo nfi= *font.GetNativeFontInfo();
float pointSizeNew = wxDisplay(this).GetScaleFactor() * scale * font.GetPointSize();
float pointSizeNew = scale * font.GetPointSize();
nfi.lf.lfHeight = nfi.GetLogFontHeightAtPPI(pointSizeNew, get_dpi_for_window(this));
nfi.pointSize = pointSizeNew;
font = wxFont(nfi);

View file

@ -267,13 +267,14 @@ std::map<std::string, std::string> SettingsFactory::CATEGORY_ICON =
// BBS: remove SLA categories
};
wxBitmapBundle* SettingsFactory::get_category_bitmap(const std::string& category_name)
wxBitmap SettingsFactory::get_category_bitmap(const std::string& category_name, bool menu_bmp)
{
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
return get_bmp_bundle("empty");
return get_bmp_bundle(CATEGORY_ICON.at(category_name));
return wxNullBitmap;
return create_scaled_bitmap(CATEGORY_ICON.at(category_name));
}
//-------------------------------------
// MenuFactory
//-------------------------------------
@ -434,30 +435,31 @@ static void create_freq_settings_popupmenu(wxMenu* menu, const bool is_object_se
}
}
std::vector<wxBitmapBundle*> MenuFactory::get_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_volume_bitmaps()
{
std::vector<wxBitmapBundle*> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(ADD_VOLUME_MENU_ITEMS.size());
for (const auto& item : ADD_VOLUME_MENU_ITEMS)
volume_bmps.push_back(get_bmp_bundle(item.second));
for (const auto& item : ADD_VOLUME_MENU_ITEMS) {
volume_bmps.push_back(create_scaled_bitmap(item.second));
}
return volume_bmps;
}
std::vector<wxBitmapBundle*> MenuFactory::get_text_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_text_volume_bitmaps()
{
std::vector<wxBitmapBundle*> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(TEXT_VOLUME_ICONS.size());
for (const auto& item : TEXT_VOLUME_ICONS)
volume_bmps.push_back(get_bmp_bundle(item.second));
volume_bmps.push_back(create_scaled_bitmap(item.second));
return volume_bmps;
}
std::vector<wxBitmapBundle*> MenuFactory::get_svg_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_svg_volume_bitmaps()
{
std::vector<wxBitmapBundle *> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(SVG_VOLUME_ICONS.size());
for (const auto &item : SVG_VOLUME_ICONS)
volume_bmps.push_back(get_bmp_bundle(item.second));
volume_bmps.push_back(create_scaled_bitmap(item.second));
return volume_bmps;
}
@ -698,7 +700,7 @@ wxMenuItem* MenuFactory::append_menu_item_settings(wxMenu* menu_)
// Add full settings list
auto menu_item = new wxMenuItem(menu, wxID_ANY, menu_name);
menu_item->SetBitmap(*get_bmp_bundle("cog"));
menu_item->SetBitmap(create_scaled_bitmap("cog"));
menu_item->SetSubMenu(create_settings_popupmenu(menu, is_object_settings, item));
return menu->Append(menu_item);
@ -847,7 +849,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
if (sels.IsEmpty())
return;
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
wxMenu* extruder_selection_menu = new wxMenu();
const wxString& name = sels.Count() == 1 ? names[0] : names[1];
@ -868,7 +870,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
if (icon_idx >= 0 && icon_idx < icons.size()) {
append_menu_item(
extruder_selection_menu, wxID_ANY, item_name, "", [i](wxCommandEvent &) { obj_list()->set_extruder_for_selected_items(i); }, icons[icon_idx], menu,
extruder_selection_menu, wxID_ANY, item_name, "", [i](wxCommandEvent &) { obj_list()->set_extruder_for_selected_items(i); }, *icons[icon_idx], menu,
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
} else {
append_menu_item(
@ -1806,7 +1808,7 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
return;
}
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
if (icons.size() < filaments_cnt) {
BOOST_LOG_TRIVIAL(warning) << boost::format("Warning: icons size %1%, filaments_cnt=%2%")%icons.size()%filaments_cnt;
if (icons.size() <= 1)
@ -1846,9 +1848,8 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
const wxString& item_name = (i == 0 ? _L("Default") : wxString::Format(_L("Filament %d"), i)) +
(is_active_extruder ? " (" + _L("current") + ")" : "");
//OcraftyoneTODO: determine if nullptr in place of icon causes issues
append_menu_item(extruder_selection_menu, wxID_ANY, item_name, "",
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, i == 0 ? nullptr : icons[i - 1], menu,
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, i == 0 ? wxNullBitmap : *icons[i - 1], menu,
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
}
menu->Append(wxID_ANY, name, extruder_selection_menu, _L("Change Filament"));
@ -1966,6 +1967,12 @@ void MenuFactory::update_default_menu()
create_default_menu();
}
void MenuFactory::msw_rescale()
{
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu })
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));
}
#ifdef _WIN32
// For this class is used code from stackoverflow:
// https://stackoverflow.com/questions/257288/is-it-possible-to-write-a-template-to-check-for-a-functions-existence
@ -1995,7 +2002,7 @@ static void update_menu_item_def_colors(T* item)
void MenuFactory::sys_color_changed()
{
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu }) {
sys_color_changed_menu(dynamic_cast<wxMenu *>(menu));// msw_rescale_menu updates just icons, so use it
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));// msw_rescale_menu updates just icons, so use it
#ifdef _WIN32
// but under MSW we have to update item's bachground color
for (wxMenuItem* item : menu->GetMenuItems())
@ -2010,17 +2017,14 @@ void MenuFactory::sys_color_changed(wxMenuBar* menubar)
#if 0
for (size_t id = 0; id < menubar->GetMenuCount(); id++) {
wxMenu* menu = menubar->GetMenu(id);
sys_color_changed_menu(menu);
#ifndef __linux__
menu->SetupBitmaps();
msw_rescale_menu(menu);
#ifdef _WIN32
// but under MSW we have to update item's bachground color
for (wxMenuItem* item : menu->GetMenuItems())
update_menu_item_def_colors(item);
#endif
}
// menubar->Refresh();
#endif
menubar->Refresh();
#endif
}

View file

@ -40,7 +40,7 @@ struct SettingsFactory
static std::map<std::string, std::vector<SimpleSettingData>> OBJECT_CATEGORY_SETTINGS;
static std::map<std::string, std::vector<SimpleSettingData>> PART_CATEGORY_SETTINGS;
static wxBitmapBundle* get_category_bitmap(const std::string& category_name);
static wxBitmap get_category_bitmap(const std::string& category_name, bool menu_bmp = true);
static Bundle get_bundle(const DynamicPrintConfig* config, bool is_object_settings, bool is_layer_settings = false);
static std::vector<std::string> get_options(bool is_part);
//BBS: add api to get options for catogary
@ -51,9 +51,9 @@ struct SettingsFactory
class MenuFactory
{
public:
static std::vector<wxBitmapBundle*> get_volume_bitmaps();
static std::vector<wxBitmapBundle*> get_text_volume_bitmaps();
static std::vector<wxBitmapBundle*> get_svg_volume_bitmaps();
static std::vector<wxBitmap> get_volume_bitmaps();
static std::vector<wxBitmap> get_text_volume_bitmaps();
static std::vector<wxBitmap> get_svg_volume_bitmaps();
MenuFactory();
~MenuFactory() = default;
@ -62,6 +62,7 @@ public:
void update();
void update_object_menu();
void update_default_menu();
void msw_rescale();
void sys_color_changed();
static void sys_color_changed(wxMenuBar* menu_bar);

View file

@ -248,14 +248,47 @@ void ObjectLayers::UpdateAndShow(const bool show)
void ObjectLayers::msw_rescale()
{
//Orca: deleted what PS commented out
m_bmp_delete.msw_rescale();
m_bmp_add.msw_rescale();
m_grid_sizer->SetHGap(wxGetApp().em_unit());
// rescale edit-boxes
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
for (int i = 0; i < cells_cnt; ++i) {
const wxSizerItem* item = m_grid_sizer->GetItem(i);
if (item->IsWindow()) {
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(item->GetWindow());
if (editor != nullptr)
editor->msw_rescale();
}
else if (item->IsSizer()) // case when we have editor with buttons
{
wxSizerItem* e_item = item->GetSizer()->GetItem(size_t(0)); // editor
if (e_item->IsWindow()) {
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(e_item->GetWindow());
if (editor != nullptr)
editor->msw_rescale();
}
if (item->GetSizer()->GetItemCount() > 2) // if there are Add/Del buttons
for (size_t btn : {2, 3}) { // del_btn, add_btn
wxSizerItem* b_item = item->GetSizer()->GetItem(btn);
if (b_item->IsWindow()) {
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
if (button != nullptr)
button->msw_rescale();
}
}
}
}
m_grid_sizer->Layout();
}
void ObjectLayers::sys_color_changed()
{
m_bmp_delete.sys_color_changed();
m_bmp_add.sys_color_changed();
m_bmp_delete.msw_rescale();
m_bmp_add.msw_rescale();
// rescale edit-boxes
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
@ -267,7 +300,7 @@ void ObjectLayers::sys_color_changed()
if (b_item && b_item->IsWindow()) {
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
if (button != nullptr)
button->sys_color_changed();
button->msw_rescale();
}
}
}

View file

@ -1368,11 +1368,12 @@ void ObjectList::extruder_editing()
if (!item || !(m_objects_model->GetItemType(item) & (itVolume | itObject)))
return;
wxRect rect = this->GetItemRect(item, GetColumn(colFilament));
wxPoint pos = rect.GetPosition();
pos.y -= 4;
wxSize size = rect.GetSize();
size.SetWidth(size.GetWidth() + 8);
const int column_width = GetColumn(colFilament)->GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 5;
wxPoint pos = this->get_mouse_position_in_control();
wxSize size = wxSize(column_width, -1);
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
pos.y -= GetTextExtent("m").y;
apply_extruder_selector(&m_extruder_editor, this, "1", pos, size);
@ -3160,21 +3161,6 @@ bool ObjectList::can_merge_to_single_object() const
return (*m_objects)[obj_idx]->volumes.size() > 1;
}
wxPoint ObjectList::get_mouse_position_in_control() const
{
wxPoint pt = wxGetMousePosition() - this->GetScreenPosition();
#ifdef __APPLE__
// Workaround for OSX. From wxWidgets 3.1.6 Hittest doesn't respect to the header of wxDataViewCtrl
if (wxDataViewItem top_item = this->GetTopItem(); top_item.IsOk()) {
auto rect = this->GetItemRect(top_item, this->GetColumn(0));
pt.y -= rect.y;
}
#endif // __APPLE__
return pt;
}
bool ObjectList::can_mesh_boolean() const
{
int obj_idx = get_selected_obj_idx();
@ -5486,6 +5472,9 @@ void ObjectList::msw_rescale()
GetColumn(colSinking)->SetWidth(3 * em);
GetColumn(colEditing )->SetWidth( 3 * em);
// rescale/update existing items with bitmaps
m_objects_model->Rescale();
Layout();
}
@ -5493,10 +5482,7 @@ void ObjectList::sys_color_changed()
{
wxGetApp().UpdateDVCDarkUI(this, true);
// rescale/update existing items with bitmaps
m_objects_model->UpdateBitmaps();
Layout();
msw_rescale();
if (m_objects_model) { m_objects_model->sys_color_changed(); }
}
@ -5597,15 +5583,6 @@ void ObjectList::OnEditingStarted(wxDataViewEvent &event)
SetCustomRendererPtr(dynamic_cast<wxDataViewCustomRenderer*>(renderer));
#endif
#endif //__WXMSW__
// Orca: Automatically show drop down on editing start and finish editing when the combobox is closed
// Note: this must placed AFTER the above `renderer->StartEditing` call, otherwise `c` will be nullptr on MacOS,
// due to the code in MacDarkMode.mm
if (event.GetColumn() == colFilament) {
::ComboBox*c = static_cast<::ComboBox *>(event.GetDataViewColumn()->GetRenderer()->GetEditorCtrl());
c->ToggleDropDown();
c->Bind(wxEVT_COMBOBOX_CLOSEUP, [event](wxCommandEvent& evt){ event.GetDataViewColumn()->GetRenderer()->FinishEditing(); });
}
}
void ObjectList::OnEditingDone(wxDataViewEvent &event)

View file

@ -319,7 +319,7 @@ public:
void delete_all_connectors_for_selection();
void delete_all_connectors_for_object(int obj_idx);
wxPoint get_mouse_position_in_control() const;
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
int get_selected_obj_idx() const;
ModelConfig& get_item_config(const wxDataViewItem& item) const;

View file

@ -112,7 +112,7 @@ bool ObjectSettings::update_settings_list()
btn->SetToolTip(_(L("Remove parameter")));
btn->SetBitmapFocus(m_bmp_delete_focus.bmp());
btn->SetBitmapCurrent(m_bmp_delete_focus.bmp());
btn->SetBitmapHover(m_bmp_delete_focus.bmp());
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
wxGetApp().plater()->take_snapshot(from_u8((boost::format("Delete Option %s") % opt_key).str()).ToStdString());
@ -146,7 +146,7 @@ bool ObjectSettings::update_settings_list()
return;
ctrl->SetBitmap_(m_bmp_delete);
ctrl->SetBitmapFocus(m_bmp_delete_focus.bmp());
ctrl->SetBitmapCurrent(m_bmp_delete_focus.bmp());
ctrl->SetBitmapHover(m_bmp_delete_focus.bmp());
};
const bool is_extruders_cat = cat.first == "Extruders";
@ -415,13 +415,21 @@ void ObjectSettings::UpdateAndShow(const bool show)
#endif
}
void ObjectSettings::msw_rescale()
{
#if !NEW_OBJECT_SETTING
m_bmp_delete.msw_rescale();
m_bmp_delete_focus.msw_rescale();
for (auto group : m_og_settings)
group->msw_rescale();
#endif
}
void ObjectSettings::sys_color_changed()
{
#if !NEW_OBJECT_SETTING
m_og->sys_color_changed(); // not in old msw_rescale. is it needed?
// moved from old msw_rescale
m_bmp_delete.sys_color_changed();
m_bmp_delete_focus.sys_color_changed();
m_og->sys_color_changed();
for (auto group : m_og_settings)
group->sys_color_changed();

View file

@ -68,6 +68,7 @@ public:
bool add_missed_options(ModelConfig *config_to, const DynamicPrintConfig &config_from);
void update_config_values(ModelConfig *config);
void UpdateAndShow(const bool show);
void msw_rescale();
void sys_color_changed();
};

View file

@ -77,7 +77,7 @@ void GridCellIconRenderer::Draw(wxGrid& grid,
table->m_icon_row_height = grid.GetRowSize(row);
table->m_icon_col_width = grid.GetColSize(col);
//}
wxBitmap bitmap = table->get_undo_bitmap().GetBitmapFor(dc.GetWindow());
wxBitmap& bitmap = table->get_undo_bitmap();
int bitmap_width = bitmap.GetWidth();
int bitmap_height = bitmap.GetHeight();
int offset_x = (table->m_icon_col_width - bitmap_width)/2;
@ -125,7 +125,7 @@ GridCellIconRenderer *GridCellIconRenderer::Clone() const
GridCellFilamentsEditor::GridCellFilamentsEditor(const wxArrayString& choices,
bool allowOthers,
std::vector<wxBitmapBundle*>* bitmaps)
std::vector<wxBitmap*>* bitmaps)
: wxGridCellChoiceEditor(choices, allowOthers), m_icons(bitmaps)
{
}
@ -133,7 +133,7 @@ GridCellFilamentsEditor::GridCellFilamentsEditor(const wxArrayString& choices,
GridCellFilamentsEditor::GridCellFilamentsEditor(size_t count,
const wxString choices[],
bool allowOthers,
std::vector<wxBitmapBundle*>* bitmaps)
std::vector<wxBitmap*>* bitmaps)
: wxGridCellChoiceEditor(count, choices, allowOthers), m_icons(bitmaps)
{
}
@ -159,14 +159,13 @@ void GridCellFilamentsEditor::Create(wxWindow* parent,
if ( !m_allowOthers )
style |= wxCB_READONLY;
::ComboBox *bitmap_combo = new ComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxSize(get_preferred_size(*((*m_icons)[0]), wxGetApp().mainframe).GetWidth() + 10, -1),
0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY); //Unsure
wxDefaultPosition, wxSize(((*m_icons)[0])->GetWidth() + 10, -1), 0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY);
if (m_icons) {
int array_count = m_choices.GetCount();
int icon_count = m_icons->size();
for (int i = 0; i < array_count; i++)
{
wxBitmapBundle* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
wxBitmap* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
bitmap_combo->Append(m_choices[i], *bitmap);
}
}
@ -240,9 +239,6 @@ void GridCellFilamentsEditor::BeginEdit(int row, int col, wxGrid* grid)
Combo()->SetFocus();
// Orca: Show dropdown on editing start
Combo()->ToggleDropDown();
#ifdef __WXOSX_COCOA__
// This is a work around for the combobox being simply dismissed when a
// choice is made in it under OS X. The bug is almost certainly due to a
@ -339,9 +335,9 @@ void GridCellFilamentsRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &d
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionInt & cur_option = dynamic_cast<ConfigOptionInt &>((*grid_row)[(ObjectGridTable::GridColType) col]);
wxBitmapBundle *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetBitmapFor(dc.GetWindow()).GetWidth();
int bitmap_height = bitmap->GetBitmapFor(dc.GetWindow()).GetHeight();
wxBitmap *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
@ -349,7 +345,7 @@ void GridCellFilamentsRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &d
dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
dc.DrawRectangle(rect);
if ( grid_row->model_volume_type != ModelVolumeType::NEGATIVE_VOLUME) {
dc.DrawBitmap(bitmap->GetBitmapFor(dc.GetWindow()), wxPoint(rect.x + offset_x, rect.y + offset_y));//TODO: determine if this way of getting bitmap works well
dc.DrawBitmap(*bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
}
text_rect.x += bitmap_width + grid_cell_border_width * 2;
@ -435,9 +431,6 @@ void GridCellChoiceEditor::BeginEdit(int row, int col, wxGrid *grid)
Combo()->SetFocus();
// Orca: Show dropdown on editing start
Combo()->ToggleDropDown();
#ifdef __WXOSX_COCOA__
// This is a work around for the combobox being simply dismissed when a
// choice is made in it under OS X. The bug is almost certainly due to a
@ -525,16 +518,16 @@ void GridCellComboBoxRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionInt & cur_option = dynamic_cast<ConfigOptionInt &>((*grid_row)[(ObjectGridTable::GridColType) col]);
wxBitmapBundle *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetBitmapFor(dc.GetWindow()).GetWidth();
int bitmap_height = bitmap->GetBitmapFor(dc.GetWindow()).GetHeight();
wxBitmap *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
dc.DrawRectangle(rect);
dc.DrawBitmap(bitmap->GetBitmapFor(dc.GetWindow()), wxPoint(rect.x + offset_x, rect.y + offset_y));
dc.DrawBitmap(*bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
text_rect.x += bitmap_width + grid_cell_border_width * 2;
text_rect.width -= (bitmap_width + grid_cell_border_width * 2);
}
@ -2648,12 +2641,12 @@ void ObjectGridTable::OnCellValueChanged(int row, int col)
}
}
wxBitmapBundle& ObjectGridTable::get_undo_bitmap(bool selected)
wxBitmap& ObjectGridTable::get_undo_bitmap(bool selected)
{
return m_panel->m_undo_bitmap;
}
wxBitmapBundle* ObjectGridTable::get_color_bitmap(int color_index)
wxBitmap* ObjectGridTable::get_color_bitmap(int color_index)
{
if (color_index < m_panel->m_color_bitmaps.size())
return m_panel->m_color_bitmaps[color_index];

View file

@ -82,10 +82,10 @@ public:
GridCellFilamentsEditor(size_t count = 0,
const wxString choices[] = NULL,
bool allowOthers = false,
std::vector<wxBitmapBundle*>* bitmaps = NULL);
std::vector<wxBitmap*>* bitmaps = NULL);
GridCellFilamentsEditor(const wxArrayString& choices,
bool allowOthers = false,
std::vector<wxBitmapBundle*>* bitmaps = NULL);
std::vector<wxBitmap*>* bitmaps = NULL);
virtual void Create(wxWindow* parent,
wxWindowID id,
@ -105,7 +105,7 @@ protected:
::ComboBox *Combo() const { return (::ComboBox *)m_control; }
void OnComboCloseUp(wxCommandEvent& evt);
std::vector<wxBitmapBundle*>* m_icons;
std::vector<wxBitmap*>* m_icons;
wxDECLARE_NO_COPY_CLASS(GridCellFilamentsEditor);
private:
@ -498,8 +498,8 @@ public:
void update_filament_to_config(ModelConfig* config, std::string& key, ConfigOption& new_value, ConfigOption& ori_value, bool is_object);
void update_volume_values_from_object(int row, int col);
void update_value_to_object(Model* model, ObjectGridRow* grid_row, int col);
wxBitmapBundle& get_undo_bitmap(bool selected = false);
wxBitmapBundle* get_color_bitmap(int color_index);
wxBitmap& get_undo_bitmap(bool selected = false);
wxBitmap* get_color_bitmap(int color_index);
bool OnCellLeftClick(int row, int col, ConfigOptionType &type);
void OnSelectCell(int row, int col);
void OnRangeSelected(int row, int col, int row_count, int col_count);
@ -610,10 +610,10 @@ private:
int init_filaments_and_colors();
wxFloatingPointValidator<float> m_float_validator;
wxBitmapBundle m_undo_bitmap;
std::vector<wxBitmapBundle*> m_color_bitmaps;
wxBitmapBundle m_bmp_reset;
wxBitmapBundle m_bmp_reset_disable;
wxBitmap m_undo_bitmap;
std::vector<wxBitmap*> m_color_bitmaps;
ScalableBitmap m_bmp_reset;
ScalableBitmap m_bmp_reset_disable;
private:
wxDECLARE_ABSTRACT_CLASS(ObjectGrid);
wxDECLARE_EVENT_TABLE();

View file

@ -173,7 +173,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
btn->SetBitmapFocus(m_bmp_reset_focus.bmp());
btn->SetBitmapHover(m_bmp_reset_focus.get_bitmap());
btn->SetBitmapHover(m_bmp_reset_focus.bmp());
#ifdef __WINDOWS__
btn->SetBitmapDisabled(m_bmp_reset_disable.bmp());
@ -236,7 +236,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
return;
ctrl->SetBitmap_(m_bmp_reset);
ctrl->SetBitmapFocus(m_bmp_reset_focus.bmp());
ctrl->SetBitmapHover(m_bmp_reset_focus.get_bitmap());
ctrl->SetBitmapHover(m_bmp_reset_focus.bmp());
#ifdef __WINDOWS__
ctrl->SetBitmapDisabled(m_bmp_reset_disable.bmp());
#endif

View file

@ -508,10 +508,10 @@ void ImageGrid::render(wxDC& dc)
if (!m_file_sys || m_file_sys->GetCount() == 0) {
dc.DrawRectangle({ 0, 0, size.x, size.y });
if (!m_status_msg.IsEmpty()) {
auto si = m_status_icon.GetSize();
auto si = m_status_icon.GetBmpSize();
auto st = dc.GetTextExtent(m_status_msg);
auto rect = wxRect{0, 0, max(st.x, si.x), si.y + 26 + st.y}.CenterIn(wxRect({0, 0}, size));
dc.DrawBitmap(m_status_icon.get_bitmap(), rect.x + (rect.width - si.x) / 2, rect.y);
dc.DrawBitmap(m_status_icon.bmp(), rect.x + (rect.width - si.x) / 2, rect.y);
dc.SetTextForeground(wxColor(0x909090));
dc.DrawText(m_status_msg, rect.x + (rect.width - st.x) / 2, rect.GetBottom() - st.y);
}
@ -602,7 +602,7 @@ void Slic3r::GUI::ImageGrid::renderContent1(wxDC &dc, wxPoint const &pt, int ind
bool show_download_state_always = true;
// Draw checked icon
if (m_selecting && !show_download_state_always)
dc.DrawBitmap(selected ? m_checked_icon.get_bitmap() : m_unchecked_icon.get_bitmap(), pt + wxPoint{10, m_content_rect.GetHeight() - m_checked_icon.GetHeight() - 10});
dc.DrawBitmap(selected ? m_checked_icon.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
// can't handle alpha
// dc.GradientFillLinear({pt.x, pt.y, m_border_size.GetWidth(), 60}, wxColour(0x6F, 0x6F, 0x6F, 0x99), wxColour(0x6F, 0x6F, 0x6F, 0), wxBOTTOM);
else if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) {
@ -653,7 +653,7 @@ void Slic3r::GUI::ImageGrid::renderContent1(wxDC &dc, wxPoint const &pt, int ind
dc.DrawText(date, pt + wxPoint{24, 16});
}
if (m_selecting && show_download_state_always)
dc.DrawBitmap(selected ? m_checked_icon.get_bitmap() : m_unchecked_icon.get_bitmap(), pt + wxPoint{10, m_content_rect.GetHeight() - m_checked_icon.GetHeight() - 10});
dc.DrawBitmap(selected ? m_checked_icon.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
}
void Slic3r::GUI::ImageGrid::renderContent2(wxDC &dc, wxPoint const &pt, int index, bool hit)
@ -745,8 +745,8 @@ void Slic3r::GUI::ImageGrid::renderText2(wxDC &dc, wxString text, wxRect const &
void Slic3r::GUI::ImageGrid::renderIconText(wxDC & dc, ScalableBitmap const & icon, wxString text, wxRect const & rect)
{
dc.DrawBitmap(icon.get_bitmap(), rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
renderText2(dc, text, {rect.x + icon.GetWidth() + 4, rect.y, rect.width - icon.GetWidth() - 4, rect.height});
dc.DrawBitmap(icon.bmp(), rect.x, rect.y + (rect.height - icon.GetBmpHeight()) / 2);
renderText2(dc, text, {rect.x + icon.GetBmpWidth() + 4, rect.y, rect.width - icon.GetBmpWidth() - 4, rect.height});
}
}}

View file

@ -155,7 +155,7 @@ wxWindow *KBShortcutsDialog::create_button(int id, wxString text)
void KBShortcutsDialog::on_dpi_changed(const wxRect& suggested_rect)
{
m_logo_bmp.sys_color_changed();
m_logo_bmp.msw_rescale();
m_header_bitmap->SetBitmap(m_logo_bmp.bmp());
msw_buttons_rescale(this, em_unit(), { wxID_OK });

View file

@ -1970,6 +1970,11 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
m_monitor->msw_rescale();
m_calibration->msw_rescale();
// BBS
#if 0
for (size_t id = 0; id < m_menubar->GetMenuCount(); id++)
msw_rescale_menu(m_menubar->GetMenu(id));
#endif
// Workarounds for correct Window rendering after rescale
@ -2011,7 +2016,7 @@ void MainFrame::on_sys_color_changed()
#ifdef _MSW_DARK_MODE
// update common mode sizer
if (!wxGetApp().tabs_as_menu())
dynamic_cast<Notebook*>(m_tabpanel)->OnColorsChanged();
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
#endif
#endif

View file

@ -354,9 +354,9 @@ void MediaFilePanel::SwitchStorage(bool external)
void MediaFilePanel::Rescale()
{
m_bmp_loading.sys_color_changed();
m_bmp_failed.sys_color_changed();
m_bmp_empty.sys_color_changed();
m_bmp_loading.msw_rescale();
m_bmp_failed.msw_rescale();
m_bmp_empty.msw_rescale();
auto top_sizer = GetSizer()->GetItem((size_t) 0)->GetSizer();
top_sizer->SetMinSize({-1, 75 * em_unit(this) / 10});

View file

@ -36,7 +36,7 @@ namespace GUI {
wxBoxSizer* m_sizer_web_control = new wxBoxSizer(wxHORIZONTAL);
auto m_control_back = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_back", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_back = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_back", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_back->SetBackgroundColour(*wxWHITE);
m_control_back->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_back->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));
@ -47,7 +47,7 @@ namespace GUI {
m_control_back->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_ARROW));});
auto m_control_forward = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_forward", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_forward = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_forward", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_forward->SetBackgroundColour(*wxWHITE);
m_control_forward->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_forward->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));
@ -57,7 +57,7 @@ namespace GUI {
m_control_forward->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_HAND)); });
m_control_forward->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_ARROW)); });
auto m_control_refresh = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_refresh", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_refresh = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_refresh", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_refresh->SetBackgroundColour(*wxWHITE);
m_control_refresh->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_refresh->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));

View file

@ -227,10 +227,10 @@ void MsgDialog::apply_style(long style)
if (style & wxNO) add_button(wxID_NO, false,_L("No"));
if (style & wxCANCEL) add_button(wxID_CANCEL, false, _L("Cancel"));
logo->SetBitmap( *get_bmp_bundle(style & wxAPPLY ? "completed" :
logo->SetBitmap( create_scaled_bitmap(style & wxAPPLY ? "completed" :
style & wxICON_WARNING ? "obj_warning" :
style & wxICON_INFORMATION ? "info" :
style & wxICON_QUESTION ? "question" : "OrcaSlicer", 64));
style & wxICON_QUESTION ? "question" : "OrcaSlicer", this, 64, style & wxICON_ERROR));
}
void MsgDialog::finalize()
@ -339,7 +339,7 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, bool monospaced_
add_msg_content(this, content_sizer, msg, monospaced_font);
// Use a small bitmap with monospaced font, as the error text will not be wrapped.
logo->SetBitmap(*get_bmp_bundle("OrcaSlicer_192px_grayscale.png", monospaced_font ? 48 : /*1*/84));
logo->SetBitmap(create_scaled_bitmap("OrcaSlicer_192px_grayscale.png", this, monospaced_font ? 48 : /*1*/84));
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));

View file

@ -122,8 +122,6 @@ void ButtonsListCtrl::Rescale()
{
//m_mode_sizer->msw_rescale();
int em = em_unit(this);
// Orca: following is removed by PS in wx 3.16 refactor.
// doesn't seem to be doing anything rn so leaving it alone
for (Button* btn : m_pageButtons) {
//BBS
btn->SetMinSize({(btn->GetLabel().empty() ? 40 : 132) * em / 10, 36 * em / 10});
@ -139,14 +137,6 @@ void ButtonsListCtrl::Rescale()
m_sizer->Layout();
}
void ButtonsListCtrl::OnColorsChanged()
{
for (Button* btn : m_pageButtons)
btn->Rescale();
m_sizer->Layout();
}
void ButtonsListCtrl::SetSelection(int sel)
{
if (m_selection == sel)

View file

@ -23,7 +23,6 @@ public:
void SetSelection(int sel);
void UpdateMode();
void Rescale();
void OnColorsChanged();
bool InsertPage(size_t n, const wxString &text, bool bSelect = false, const std::string &bmp_name = "", const std::string &inactive_bmp_name = "");
void RemovePage(size_t n);
bool SetPageImage(size_t n, const std::string& bmp_name) const;
@ -262,11 +261,6 @@ public:
GetBtnsListCtrl()->Rescale();
}
void OnColorsChanged()
{
GetBtnsListCtrl()->OnColorsChanged();
}
void OnNavigationKey(wxNavigationKeyEvent& event)
{
if (event.IsWindowChange()) {

View file

@ -28,12 +28,12 @@ static bool is_point_in_rect(const wxPoint& pt, const wxRect& rect)
rect.GetTop() <= pt.y && pt.y <= rect.GetBottom();
}
static wxSize get_bitmap_size(const wxBitmapBundle* bmp, wxWindow* parent)
static wxSize get_bitmap_size(const wxBitmap& bmp)
{
#ifndef __WIN32__
return bmp->GetBitmapFor(parent).GetSize();
#ifdef __APPLE__
return bmp.GetScaledSize();
#else
return bmp->GetDefaultSize();
return bmp.GetSize();
#endif
}
@ -58,8 +58,8 @@ OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
m_v_gap2 = lround(0.8 * m_em_unit);
m_h_gap = lround(0.2 * m_em_unit);
//m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("blank_16"), this);
//m_bmp_mode_sz = get_bitmap_size(create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12));
m_bmp_blinking_sz = get_bitmap_size(create_scaled_bitmap("blank_16", this));
init_ctrl_lines();// from og.lines()
@ -572,8 +572,8 @@ void OG_CustomCtrl::msw_rescale()
m_v_gap2 = lround(0.8 * m_em_unit);
m_h_gap = lround(0.2 * m_em_unit);
//m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("blank_16"), this);
//m_bmp_mode_sz = create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12).GetSize();
m_bmp_blinking_sz = create_scaled_bitmap("blank_16", this).GetSize();
m_max_win_width = 0;
@ -666,7 +666,7 @@ void OG_CustomCtrl::CtrlLine::msw_rescale()
{
// if we have a single option with no label, no sidetext
if (draw_just_act_buttons)
height = get_bitmap_size(get_bmp_bundle("empty"), ctrl).GetHeight();
height = get_bitmap_size(create_scaled_bitmap("empty")).GetHeight();
if (ctrl->opt_group->label_width != 0 && !og_line.label.IsEmpty()) {
wxSize label_sz = ctrl->GetTextExtent(og_line.label);
@ -748,7 +748,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
if (field && field->undo_bitmap())
//if (field)
// BBS: new layout
draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->get_bitmap(), field->undo_bitmap()->get_bitmap(), field->blink());
draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink());
return;
}
@ -802,7 +802,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
auto draw_buttons = [&h_pos, &dc, &v_pos, this](Field* field, size_t bmp_rect_id = 0) {
if (field && field->undo_to_sys_bitmap()) {
h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->get_bitmap(), field->undo_bitmap()->get_bitmap(), field->blink(), bmp_rect_id);
h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink(), bmp_rect_id);
}
#ifndef DISABLE_BLINKING
else if (field && !field->undo_to_sys_bitmap() && field->blink())
@ -933,19 +933,19 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC &dc, wxPoint pos, const wxString
wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking)
{
wxBitmapBundle* bmp_blinking = get_bmp_bundle(is_blinking ? "blank_16" : "empty");
wxBitmap bmp_blinking = create_scaled_bitmap(is_blinking ? "blank_16" : "empty", ctrl);
wxCoord h_pos = pos.x;
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking, ctrl).GetHeight()) / 2);
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking).GetHeight()) / 2);
dc.DrawBitmap(bmp_blinking->GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(bmp_blinking, h_pos, v_pos);
int bmp_dim = get_bitmap_size(bmp_blinking, ctrl).GetWidth();
int bmp_dim = get_bitmap_size(bmp_blinking).GetWidth();
h_pos += bmp_dim + ctrl->m_h_gap;
return wxPoint(h_pos, v_pos);
}
wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmapBundle& bmp_undo_to_sys, const wxBitmapBundle& bmp_undo, bool is_blinking, size_t rect_id)
wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id)
{
#ifndef DISABLE_BLINKING
pos = draw_blinking_bmp(dc, pos, is_blinking);
@ -953,11 +953,11 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
if (ctrl->opt_group->split_multi_line) { // BBS
const std::vector<Option> &option_set = og_line.get_options();
if (option_set.size() > 1)
pos.y += lround(((height - ctrl->m_v_gap + ctrl->m_v_gap2) / option_set.size() - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround(((height - ctrl->m_v_gap + ctrl->m_v_gap2) / option_set.size() - get_bitmap_size(bmp_undo).GetHeight()) / 2);
else
pos.y += lround((height - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround((height - get_bitmap_size(bmp_undo).GetHeight()) / 2);
} else {
pos.y += lround((height - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround((height - get_bitmap_size(bmp_undo).GetHeight()) / 2);
}
#endif
wxCoord h_pos = pos.x;
@ -965,16 +965,16 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
#ifndef DISABLE_UNDO_SYS
//BBS: GUI refactor
dc.DrawBitmap(bmp_undo_to_sys.GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(bmp_undo_to_sys, h_pos, v_pos);
int bmp_dim = get_bitmap_size(&bmp_undo_to_sys, ctrl).GetWidth();
int bmp_dim = get_bitmap_size(bmp_undo_to_sys).GetWidth();
rects_undo_to_sys_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
h_pos += bmp_dim + ctrl->m_h_gap;
#endif
dc.DrawBitmap(og_line.undo_to_sys ? bmp_undo_to_sys.GetBitmapFor(ctrl) : bmp_undo.GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(og_line.undo_to_sys ? bmp_undo_to_sys : bmp_undo, h_pos, v_pos);
int bmp_dim2 = get_bitmap_size(&bmp_undo, ctrl).GetWidth();
int bmp_dim2 = get_bitmap_size(bmp_undo).GetWidth();
(og_line.undo_to_sys ? rects_undo_to_sys_icon[rect_id] : rects_undo_icon[rect_id]) = wxRect(h_pos, v_pos, bmp_dim2, bmp_dim2);
h_pos += bmp_dim2 + ctrl->m_h_gap;

View file

@ -64,7 +64,7 @@ class OG_CustomCtrl :public wxPanel
void render(wxDC& dc, wxCoord h_pos, wxCoord v_pos);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false, bool is_main = false);
wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking);
wxCoord draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmapBundle& bmp_undo_to_sys, const wxBitmapBundle& bmp_undo, bool is_blinking, size_t rect_id = 0);
wxCoord draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id = 0);
bool launch_browser() const;
bool is_separator() const { return og_line.is_separator(); }

View file

@ -4,6 +4,7 @@
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
///|/
#include "ObjectDataViewModel.hpp"
#include "slic3r/GUI/wxExtensions.hpp"
#include "wxExtensions.hpp"
#include "BitmapCache.hpp"
#include "GUI_App.hpp"
@ -26,13 +27,6 @@ wxDEFINE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent);
BitmapCache* m_bitmap_cache = nullptr;
wxBitmapBundle* find_bndl(const std::string& bmp_name)
{
if (!m_bitmap_cache)
m_bitmap_cache = new BitmapCache;
return m_bitmap_cache->find_bndl(bmp_name);
}
// *****************************************************************************
// ----------------------------------------------------------------------------
@ -138,7 +132,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
else if (type == itLayerRoot)
{
//BBS do not support layer range edit
m_bmp = *get_bmp_bundle(LayerRootIcon);
m_bmp = create_scaled_bitmap(LayerRootIcon);
m_name = _(L("Layers"));
}
else if (type == itInfo)
@ -169,7 +163,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
}
const std::string label_range = (boost::format(" %.2f-%.2f ") % layer_range.first % layer_range.second).str();
m_name = _(L("Range")) + label_range + "(" + _(L("mm")) + ")";
m_bmp = *get_bmp_bundle(LayerIcon);
m_bmp = create_scaled_bitmap(LayerIcon);
set_icons();
init_container();
@ -187,15 +181,7 @@ bool ObjectDataViewModelNode::valid()
void ObjectDataViewModelNode::sys_color_changed()
{
m_printable_icon = m_printable == piUndef ? m_empty_bmp : *get_bmp_bundle(m_printable == piPrintable ? "check_on" : "check_off_focused");
if (!m_action_icon_name.empty())
m_action_icon = *get_bmp_bundle(m_action_icon_name);
if (!m_opt_categories.empty())
update_settings_digest_bitmaps();
set_extruder_icon();
m_printable_icon = m_printable == piUndef ? m_empty_bmp : create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
}
void ObjectDataViewModelNode::set_icons()
@ -224,7 +210,7 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
return;
m_printable = printable;
m_printable_icon = m_printable == piUndef ? m_empty_bmp :
*get_bmp_bundle(m_printable == piPrintable ? "check_on" : "check_off_focused");
create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
}
void ObjectDataViewModelNode::set_action_icon(bool enable)
@ -236,7 +222,7 @@ void ObjectDataViewModelNode::set_action_icon(bool enable)
m_action_icon_name = m_type & itPlate ? undo :
m_type & itObject ? undo :
m_type & (itVolume | itLayer) ? undo : /*m_type & itInstance*/ "set_separate_obj";
m_action_icon = *get_bmp_bundle(m_action_icon_name); // FIXME: pass window ptr
m_action_icon = create_scaled_bitmap(m_action_icon_name); // FIXME: pass window ptr
}
// BBS
@ -246,9 +232,9 @@ void ObjectDataViewModelNode::set_color_icon(bool enable)
return;
m_color_enable = enable;
if ((m_type & itObject) && enable)
m_color_icon = *get_bmp_bundle("mmu_segmentation");
m_color_icon = create_scaled_bitmap("mmu_segmentation");
else
m_color_icon = *get_bmp_bundle("dot");
m_color_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_support_icon(bool enable)
@ -257,9 +243,9 @@ void ObjectDataViewModelNode::set_support_icon(bool enable)
return;
m_support_enable = enable;
if ((m_type & itObject) && enable)
m_support_icon = *get_bmp_bundle("toolbar_support");
m_support_icon = create_scaled_bitmap("toolbar_support");
else
m_support_icon = *get_bmp_bundle("dot");
m_support_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_sinking_icon(bool enable)
@ -268,9 +254,9 @@ void ObjectDataViewModelNode::set_sinking_icon(bool enable)
return;
m_sink_enable = enable;
if ((m_type & itObject) && enable)
m_sinking_icon = *get_bmp_bundle("objlist_sinking");
m_sinking_icon = create_scaled_bitmap("objlist_sinking");
else
m_sinking_icon = *get_bmp_bundle("dot");
m_sinking_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_warning_icon(const std::string& warning_icon_name)
@ -285,14 +271,14 @@ void ObjectDataViewModelNode::update_settings_digest_bitmaps()
m_bmp = m_empty_bmp;
std::string scaled_bitmap_name = m_name.ToUTF8().data();
scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "");
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "");
wxBitmapBundle *bmp = find_bndl(scaled_bitmap_name);
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
if (bmp == nullptr) {
std::vector<wxBitmapBundle*> bmps;
std::vector<wxBitmap> bmps;
for (auto& category : m_opt_categories)
bmps.emplace_back(SettingsFactory::get_category_bitmap(category));
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
bmps.emplace_back(SettingsFactory::get_category_bitmap(category, false));
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
}
m_bmp = *bmp;
@ -316,12 +302,26 @@ bool ObjectDataViewModelNode::update_settings_digest(const std::vector<std::stri
return true;
}
void ObjectDataViewModelNode::msw_rescale()
{
if (!m_action_icon_name.empty())
m_action_icon = create_scaled_bitmap(m_action_icon_name);
if (m_printable != piUndef)
m_printable_icon = create_scaled_bitmap(m_printable == piPrintable ? "obj_printable" : "obj_unprintable");
if (!m_opt_categories.empty())
update_settings_digest_bitmaps();
set_extruder_icon();
}
bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
{
switch (col)
{
case colPrint:
// m_printable_icon << variant;
m_printable_icon << variant;
return true;
case colName: {
DataViewBitmapText data;
@ -346,7 +346,7 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
m_color_icon << variant;
break;
case colEditing:
// m_action_icon << variant;
m_action_icon << variant;
return true;
default:
printf("MyObjectTreeModel::SetValue: wrong column");
@ -413,7 +413,7 @@ void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= "
if (extruder_idx > 0) --extruder_idx;
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps = get_extruder_color_icons();// use wide icons
std::vector<wxBitmap*> bmps = get_extruder_color_icons(false);// use wide icons
if (bmps.empty()) {
m_extruder_bmp = wxNullBitmap;
return;
@ -450,12 +450,12 @@ ObjectDataViewModel::ObjectDataViewModel()
m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_text_volume_bmps = MenuFactory::get_text_volume_bitmaps();
m_svg_volume_bmps = MenuFactory::get_svg_volume_bitmaps();
m_warning_bmp = *get_bmp_bundle(WarningIcon);
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
m_lock_bmp = *get_bmp_bundle(LockIcon);
m_warning_bmp = create_scaled_bitmap(WarningIcon);
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
m_lock_bmp = create_scaled_bitmap(LockIcon);
for (auto item : INFO_ITEMS)
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
m_plate_outside = nullptr;
@ -538,9 +538,9 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
if (!node->has_warning_icon() && !node->has_lock()) {
node->SetBitmap(is_volume_node ? (
node->is_text_volume() ? *m_text_volume_bmps.at(vol_type) :
node->is_svg_volume() ? *m_svg_volume_bmps.at(vol_type) :
*m_volume_bmps.at(vol_type)) : m_empty_bmp);
node->is_text_volume() ? m_text_volume_bmps.at(vol_type) :
node->is_svg_volume() ? m_svg_volume_bmps.at(vol_type) :
m_volume_bmps.at(vol_type)) : m_empty_bmp);
return;
}
@ -553,19 +553,19 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
scaled_bitmap_name += std::to_string(vol_type);
scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "-lm");
wxBitmapBundle* bmp = find_bndl(scaled_bitmap_name);
if (!bmp) {
std::vector<wxBitmapBundle*> bmps;
wxBitmap* bmp = m_bitmap_cache->find(scaled_bitmap_name);
if (bmp == nullptr) {
std::vector<wxBitmap> bmps;
if (node->has_warning_icon())
bmps.emplace_back(node->warning_icon_name() == WarningIcon ? &m_warning_bmp : &m_warning_manifold_bmp);
bmps.emplace_back(node->warning_icon_name() == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp);
if (node->has_lock())
bmps.emplace_back(&m_lock_bmp);
bmps.emplace_back(m_lock_bmp);
if (is_volume_node)
bmps.emplace_back(
node->is_text_volume() ? m_text_volume_bmps[vol_type] :
node->is_svg_volume() ? m_svg_volume_bmps[vol_type] :
m_volume_bmps[vol_type]);
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
}
node->SetBitmap(*bmp);
@ -705,7 +705,7 @@ wxDataViewItem ObjectDataViewModel::AddInfoChild(const wxDataViewItem &parent_it
}
root->Insert(node, idx+1);
node->SetBitmap(*m_info_bmps.at(info_type));
node->SetBitmap(m_info_bmps.at(info_type));
// notify control
const wxDataViewItem child((void*)node);
ItemAdded(parent_item, child);
@ -1693,7 +1693,7 @@ wxString ObjectDataViewModel::GetName(const wxDataViewItem &item) const
return node->m_name;
}
wxBitmapBundle& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
wxBitmap& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
{
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
return node->m_bmp;
@ -1735,13 +1735,13 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
switch (col)
{
case colPrint:
variant << node->m_printable_icon.GetBitmapFor(m_ctrl);
variant << node->m_printable_icon;
break;
case colName:
variant << DataViewBitmapText(node->m_name, node->m_bmp.GetBitmapFor(m_ctrl));
variant << DataViewBitmapText(node->m_name, node->m_bmp);
break;
case colFilament:
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp.GetBitmapFor(m_ctrl));
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp);
break;
// BBS
case colSupportPaint:
@ -1754,7 +1754,7 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
variant << node->m_color_icon;
break;
case colEditing:
variant << node->m_action_icon.GetBitmapFor(m_ctrl);
variant << node->m_action_icon;
break;
default:
;
@ -2207,7 +2207,7 @@ void ObjectDataViewModel::SetVolumeType(const wxDataViewItem &item, const Slic3r
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
node->SetVolumeType(volume_type);
node->SetBitmap(*m_volume_bmps[int(volume_type)]);
node->SetBitmap(m_volume_bmps[int(volume_type)]);
if (volume_type != Slic3r::ModelVolumeType::MODEL_PART && volume_type != Slic3r::ModelVolumeType::PARAMETER_MODIFIER)
node->SetExtruder(""); // hide extruder
else if (node->GetExtruder().IsEmpty())
@ -2320,17 +2320,17 @@ void ObjectDataViewModel::SetSinkState(const bool painted, wxDataViewItem obj_it
ItemChanged(obj_item);
}
void ObjectDataViewModel::UpdateBitmaps()
void ObjectDataViewModel::Rescale()
{
m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_text_volume_bmps = MenuFactory::get_text_volume_bitmaps();
m_svg_volume_bmps = MenuFactory::get_svg_volume_bitmaps();
m_warning_bmp = *get_bmp_bundle(WarningIcon);
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
m_lock_bmp = *get_bmp_bundle(LockIcon);
m_warning_bmp = create_scaled_bitmap(WarningIcon);
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
m_lock_bmp = create_scaled_bitmap(LockIcon);
for (auto item : INFO_ITEMS)
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
wxDataViewItemArray all_items;
GetAllChildren(wxDataViewItem(0), all_items);
@ -2341,7 +2341,7 @@ void ObjectDataViewModel::UpdateBitmaps()
continue;
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
node->sys_color_changed();
node->msw_rescale();
switch (node->m_type)
{
@ -2350,13 +2350,13 @@ void ObjectDataViewModel::UpdateBitmaps()
UpdateBitmapForNode(node);
break;
case itLayerRoot:
node->m_bmp = *get_bmp_bundle(LayerRootIcon);
node->m_bmp = create_scaled_bitmap(LayerRootIcon);
break;
case itLayer:
node->m_bmp = *get_bmp_bundle(LayerIcon);
node->m_bmp = create_scaled_bitmap(LayerIcon);
break;
case itInfo:
node->m_bmp = *m_info_bmps.at(node->m_info_item_type);
node->m_bmp = m_info_bmps.at(node->m_info_item_type);
break;
default: break;
}

View file

@ -75,27 +75,27 @@ class ObjectDataViewModelNode
{
ObjectDataViewModelNode* m_parent;
MyObjectTreeModelNodePtrArray m_children;
wxBitmapBundle m_empty_bmp;
wxBitmap m_empty_bmp;
size_t m_volumes_cnt = 0;
std::vector< std::string > m_opt_categories;
t_layer_height_range m_layer_range = { 0.0f, 0.0f };
wxString m_name;
wxBitmapBundle& m_bmp = m_empty_bmp;
wxBitmap& m_bmp = m_empty_bmp;
ItemType m_type;
int m_idx = -1;
int m_plate_idx = -1;
bool m_container = false;
// BBS
wxString m_extruder = wxEmptyString;
wxBitmapBundle m_extruder_bmp;
wxBitmapBundle m_action_icon;
wxBitmap m_extruder_bmp;
wxBitmap m_action_icon;
// BBS
wxBitmapBundle m_support_icon;
wxBitmapBundle m_color_icon;
wxBitmapBundle m_sinking_icon;
wxBitmap m_support_icon;
wxBitmap m_color_icon;
wxBitmap m_sinking_icon;
PrintIndicator m_printable {piUndef};
wxBitmapBundle m_printable_icon;
wxBitmap m_printable_icon;
std::string m_warning_icon_name{ "" };
bool m_has_lock{false}; // for cut object icon
@ -229,11 +229,11 @@ public:
void SetName(const wxString &);
bool SetValue(const wxVariant &variant, unsigned int col);
void SetVolumeType(ModelVolumeType type) { m_volume_type = type; }
void SetBitmap(const wxBitmapBundle &icon) { m_bmp = icon; }
void SetBitmap(const wxBitmap &icon) { m_bmp = icon; }
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
void SetWarningIconName(const std::string& warning_icon_name) { m_warning_icon_name = warning_icon_name; }
void SetLock(bool has_lock) { m_has_lock = has_lock; }
const wxBitmapBundle& GetBitmap() const { return m_bmp; }
const wxBitmap& GetBitmap() const { return m_bmp; }
const wxString& GetName() const { return m_name; }
ItemType GetType() const { return m_type; }
InfoItemType GetInfoItemType() const { return m_info_item_type; }
@ -302,6 +302,7 @@ public:
bool is_text_volume() const { return m_is_text_volume; }
bool is_svg_volume() const { return m_is_svg_volume; }
void sys_color_changed();
void msw_rescale();
#ifndef NDEBUG
bool valid();
@ -327,14 +328,14 @@ class ObjectDataViewModel :public wxDataViewModel
{
std::vector<ObjectDataViewModelNode*> m_plates;
std::vector<ObjectDataViewModelNode*> m_objects;
std::vector<wxBitmapBundle*> m_volume_bmps;
std::vector<wxBitmapBundle*> m_text_volume_bmps;
std::vector<wxBitmapBundle*> m_svg_volume_bmps;
std::map<InfoItemType, wxBitmapBundle*> m_info_bmps;
wxBitmapBundle m_empty_bmp;
wxBitmapBundle m_warning_bmp;
wxBitmapBundle m_warning_manifold_bmp;
wxBitmapBundle m_lock_bmp;
std::vector<wxBitmap> m_volume_bmps;
std::vector<wxBitmap> m_text_volume_bmps;
std::vector<wxBitmap> m_svg_volume_bmps;
std::map<InfoItemType, wxBitmap> m_info_bmps;
wxBitmap m_empty_bmp;
wxBitmap m_warning_bmp;
wxBitmap m_warning_manifold_bmp;
wxBitmap m_lock_bmp;
ObjectDataViewModelNode* m_plate_outside;
@ -399,7 +400,7 @@ public:
// helper method for wxLog
wxString GetName(const wxDataViewItem &item) const;
wxBitmapBundle& GetBitmap(const wxDataViewItem &item) const;
wxBitmap& GetBitmap(const wxDataViewItem &item) const;
wxString GetExtruder(const wxDataViewItem &item) const;
int GetExtruderNumber(const wxDataViewItem &item) const;
@ -479,7 +480,7 @@ public:
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
// Rescale bitmaps for existing Items
void UpdateBitmaps();
void Rescale();
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);

View file

@ -836,6 +836,7 @@ void ConfigOptionsGroup::msw_rescale()
// check if window is ScalableButton
ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win);
if (sc_btn) {
sc_btn->msw_rescale();
sc_btn->SetSize(sc_btn->GetBestSize());
return;
}
@ -883,7 +884,7 @@ void ConfigOptionsGroup::sys_color_changed()
wxWindow* win = item->GetWindow();
// check if window is ScalableButton
if (ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win)) {
sc_btn->sys_color_changed();
sc_btn->msw_rescale();
return;
}
wxGetApp().UpdateDarkUI(win, dynamic_cast<wxButton*>(win) != nullptr);

View file

@ -233,11 +233,11 @@ ParamsPanel::ParamsPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
//m_search_btn->SetToolTip(format_wxstr(_L("Search in settings [%1%]"), "Ctrl+F"));
//m_search_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { wxGetApp().plater()->search(false); });
m_compare_btn = new ScalableButton(m_top_panel, wxID_ANY, "compare", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_compare_btn = new ScalableButton(m_top_panel, wxID_ANY, "compare", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_compare_btn->SetToolTip(_L("Compare presets"));
m_compare_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { wxGetApp().mainframe->diff_dialog.show(); }));
m_setting_btn = new ScalableButton(m_top_panel, wxID_ANY, "table", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_setting_btn = new ScalableButton(m_top_panel, wxID_ANY, "table", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_setting_btn->SetToolTip(_L("View all object's settings"));
m_setting_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { wxGetApp().plater()->PopupObjectTable(-1, -1, {0, 0}); });
@ -646,11 +646,11 @@ void ParamsPanel::update_mode()
void ParamsPanel::msw_rescale()
{
if (m_process_icon) m_process_icon->sys_color_changed();
if (m_setting_btn) m_setting_btn->sys_color_changed();
if (m_search_btn) m_search_btn->sys_color_changed();
if (m_compare_btn) m_compare_btn->sys_color_changed();
if (m_tips_arrow) m_tips_arrow->sys_color_changed();
if (m_process_icon) m_process_icon->msw_rescale();
if (m_setting_btn) m_setting_btn->msw_rescale();
if (m_search_btn) m_search_btn->msw_rescale();
if (m_compare_btn) m_compare_btn->msw_rescale();
if (m_tips_arrow) m_tips_arrow->msw_rescale();
m_left_sizer->SetMinSize(wxSize(40 * em_unit(this), -1));
if (m_mode_sizer)
m_mode_sizer->SetMinSize(-1, 3 * em_unit(this));

View file

@ -515,6 +515,11 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
{
const int& em = em_unit();
m_printhost_browse_btn->msw_rescale();
m_printhost_test_btn->msw_rescale();
if (m_printhost_cafile_browse_btn)
m_printhost_cafile_browse_btn->msw_rescale();
m_optgroup->msw_rescale();
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
@ -526,15 +531,6 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
Refresh();
}
void PhysicalPrinterDialog::on_sys_color_changed()
{
m_printhost_browse_btn->sys_color_changed();
m_printhost_test_btn->sys_color_changed();
if (m_printhost_cafile_browse_btn)
m_printhost_cafile_browse_btn->sys_color_changed();
}
void PhysicalPrinterDialog::OnOK(wxEvent& event)
{
wxGetApp().get_tab(Preset::TYPE_PRINTER)->save_preset("", false, false, true, m_preset_name );

View file

@ -64,7 +64,7 @@ public:
protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
void on_sys_color_changed() override;
void on_sys_color_changed() override {};
};

View file

@ -494,7 +494,7 @@ void Sidebar::priv::hide_rich_tip(wxButton* btn)
static struct DynamicFilamentList : DynamicList
{
std::vector<std::pair<wxString, wxBitmapBundle *>> items;
std::vector<std::pair<wxString, wxBitmap *>> items;
void apply_on(Choice *c) override
{
@ -533,8 +533,7 @@ static struct DynamicFilamentList : DynamicList
std::string type;
wxGetApp().preset_bundle->filaments.find_preset(presets[i])->get_filament_type(type);
str << type;
wxBitmapBundle* bmp = icons[i];
items.push_back({str, bmp});
items.push_back({str, icons[i]});
}
DynamicList::update();
}
@ -818,7 +817,9 @@ Sidebar::Sidebar(Plater *parent)
if (dlg.ShowModal() == wxID_OK) {
std::vector<float> matrix = dlg.get_matrix();
std::vector<float> extruders = dlg.get_extruders();
(project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values = std::vector<double>(matrix.begin(), matrix.end());
(project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values = std::vector<double>(extruders.begin(), extruders.end());
(project_config.option<ConfigOptionFloat>("flush_multiplier"))->set(new ConfigOptionFloat(dlg.get_flush_multiplier()));
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
@ -879,7 +880,7 @@ Sidebar::Sidebar(Plater *parent)
bSizer39->Add(FromDIP(20), 0, 0, 0, 0);
ams_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 18);
wxBU_EXACTFIT | wxNO_BORDER, false, 18);
ams_btn->SetToolTip(_L("Synchronize filament list from AMS"));
ams_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
sync_ams_list();
@ -1341,20 +1342,20 @@ void Sidebar::msw_rescale()
p->m_panel_printer_title->GetSizer()->SetMinSize(-1, 3 * wxGetApp().em_unit());
p->m_panel_filament_title->GetSizer()
->SetMinSize(-1, 3 * wxGetApp().em_unit());
p->m_printer_icon->sys_color_changed();
p->m_printer_setting->sys_color_changed();
p->m_filament_icon->sys_color_changed();
p->m_bpButton_add_filament->sys_color_changed();
p->m_bpButton_del_filament->sys_color_changed();
p->m_bpButton_ams_filament->sys_color_changed();
p->m_bpButton_set_filament->sys_color_changed();
p->m_printer_icon->msw_rescale();
p->m_printer_setting->msw_rescale();
p->m_filament_icon->msw_rescale();
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
p->m_bpButton_ams_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->Rescale();
//BBS
m_bed_type_list->Rescale();
m_bed_type_list->SetMinSize({-1, 3 * wxGetApp().em_unit()});
#if 0
if (p->mode_sizer)
p->mode_sizer->sys_color_changed();
p->mode_sizer->msw_rescale();
#endif
//for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*> { p->combo_print,
@ -1373,14 +1374,15 @@ void Sidebar::msw_rescale()
// BBS TODO: add msw_rescale for newly added windows
// BBS
//p->object_manipulation->msw_rescale();
p->object_settings->msw_rescale();
// BBS
#if 0
p->object_info->msw_rescale();
p->btn_send_gcode->sys_color_changed();
p->btn_send_gcode->msw_rescale();
// p->btn_eject_device->msw_rescale();
p->btn_export_gcode_removable->sys_color_changed();
p->btn_export_gcode_removable->msw_rescale();
#ifdef _WIN32
const int scaled_height = p->btn_export_gcode_removable->GetBitmapHeight();
#else
@ -1401,26 +1403,26 @@ void Sidebar::sys_color_changed()
#if 0
for (wxWindow* win : std::vector<wxWindow*>{ this, p->sliced_info->GetStaticBox(), p->object_info->GetStaticBox(), p->btn_reslice, p->btn_export_gcode })
wxGetApp().UpdateDarkUI(win);
p->object_info->sys_color_changed();
p->object_info->msw_rescale();
for (wxWindow* win : std::vector<wxWindow*>{ p->scrolled, p->presets_panel })
wxGetApp().UpdateAllStaticTextDarkUI(win);
#endif
//for (wxWindow* btn : std::vector<wxWindow*>{ p->btn_reslice, p->btn_export_gcode })
// wxGetApp().UpdateDarkUI(btn, true);
p->m_printer_icon->sys_color_changed();
p->m_printer_setting->sys_color_changed();
p->m_filament_icon->sys_color_changed();
p->m_bpButton_add_filament->sys_color_changed();
p->m_bpButton_del_filament->sys_color_changed();
p->m_bpButton_ams_filament->sys_color_changed();
p->m_bpButton_set_filament->sys_color_changed();
p->m_printer_icon->msw_rescale();
p->m_printer_setting->msw_rescale();
p->m_filament_icon->msw_rescale();
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
p->m_bpButton_ams_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->Rescale();
// BBS
#if 0
if (p->mode_sizer)
p->mode_sizer->sys_color_changed();
p->mode_sizer->msw_rescale();
p->frequently_changed_parameters->sys_color_changed();
#endif
p->object_settings->sys_color_changed();
@ -1448,7 +1450,6 @@ void Sidebar::sys_color_changed()
//p->btn_export_gcode_removable->msw_rescale();
p->scrolled->Layout();
p->scrolled->Refresh();
p->searcher.dlg_sys_color_changed();
}
@ -12459,6 +12460,8 @@ void Plater::msw_rescale()
p->sidebar->msw_rescale();
p->menus.msw_rescale();
Layout();
GetParent()->Layout();
}

View file

@ -112,8 +112,8 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
default: break;
}
m_bitmapCompatible = get_bmp_bundle("flag_green");
m_bitmapIncompatible = get_bmp_bundle("flag_red");
m_bitmapCompatible = ScalableBitmap(this, "flag_green");
m_bitmapIncompatible = ScalableBitmap(this, "flag_red");
// parameters for an icon's drawing
fill_width_height();
@ -295,12 +295,12 @@ void PresetComboBox::update(std::string select_preset_name)
const std::deque<Preset>& presets = m_collection->get_presets();
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
std::map<wxString, wxBitmapBundle*> incomp_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
std::map<wxString, wxBitmap*> incomp_presets;
wxString selected = "";
if (!presets.front().is_visible)
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
{
@ -313,7 +313,7 @@ void PresetComboBox::update(std::string select_preset_name)
if (select_preset_name.empty() && is_enabled)
select_preset_name = preset.name;
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (!is_enabled)
@ -325,17 +325,17 @@ void PresetComboBox::update(std::string select_preset_name)
}
else
{
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
if (preset.name == select_preset_name || (select_preset_name.empty() && is_enabled))
selected = get_preset_name(preset);
}
if (i + 1 == m_collection->num_default_presets())
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
}
if (!nonsys_presets.empty())
{
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -345,8 +345,8 @@ void PresetComboBox::update(std::string select_preset_name)
}
if (!incomp_presets.empty())
{
set_label_marker(Append(separator(L("Incompatible presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
set_label_marker(Append(separator(L("Incompatible presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
set_label_marker(Append(it->first, *it->second), LABEL_ITEM_DISABLED);
}
}
@ -363,8 +363,7 @@ void PresetComboBox::show_all(bool show_all)
void PresetComboBox::update()
{
int n = this->GetSelection();
this->update(n < 0 ? "" : into_u8(this->GetString(n)));
this->update(into_u8(this->GetString(this->GetSelection())));
}
void PresetComboBox::update_from_bundle()
@ -400,7 +399,9 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
const_cast<Preset&>(*iter).is_visible = true;
auto color = tray.opt_string("filament_colour", 0u);
auto name = tray.opt_string("tray_name", 0u);
int item_id = Append(get_preset_name(*iter), *get_extruder_color_icon(color, name, 24, 16), &m_first_ams_filament + entry.first);
wxBitmap bmp(*get_extruder_color_icon(color, name, 24, 16));
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
//validate_selection(id->value == selected); // can not select
}
m_last_ams_filament = GetCount();
}
@ -418,24 +419,29 @@ void PresetComboBox::msw_rescale()
{
m_em_unit = em_unit(this);
Rescale();
m_bitmapIncompatible.msw_rescale();
m_bitmapCompatible.msw_rescale();
// parameters for an icon's drawing
fill_width_height();
// update the control to redraw the icons
update();
}
void PresetComboBox::sys_color_changed()
{
m_bitmapCompatible = get_bmp_bundle("flag_green");
m_bitmapIncompatible = get_bmp_bundle("flag_red");
wxGetApp().UpdateDarkUI(this);
// update the control to redraw the icons
update();
msw_rescale();
}
void PresetComboBox::fill_width_height()
{
// To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size, so
// set a bitmap's height to m_bitmapCompatible->GetHeight() and norm_icon_width to m_bitmapCompatible->GetWidth()
icon_height = 16;
norm_icon_width = 16;
icon_height = m_bitmapCompatible.GetBmpHeight();
norm_icon_width = m_bitmapCompatible.GetBmpWidth();
/* It's supposed that standard size of an icon is 16px*16px for 100% scaled display.
* So set sizes for solid_colored icons used for filament preset
@ -446,11 +452,9 @@ void PresetComboBox::fill_width_height()
thin_icon_width = lroundf(8 * scale_f); // analogue to 8px;
wide_icon_width = norm_icon_width + thin_icon_width;
null_icon_width = 2 * norm_icon_width;
space_icon_width = 2;
thin_space_icon_width = 4;
wide_space_icon_width = 6;
space_icon_width = lroundf(2 * scale_f);
thin_space_icon_width = lroundf(4 * scale_f);
wide_space_icon_width = lroundf(6 * scale_f);
}
wxString PresetComboBox::separator(const std::string& label)
@ -458,15 +462,15 @@ wxString PresetComboBox::separator(const std::string& label)
return wxString::FromUTF8(separator_head()) + _(label) + wxString::FromUTF8(separator_tail());
}
wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
bool is_compatible/* = true*/, bool is_system/* = false*/, bool is_single_bar/* = false*/,
const std::string& filament_rgb/* = ""*/, const std::string& extruder_rgb/* = ""*/, const std::string& material_rgb/* = ""*/)
{
// BBS: no icon
#if 1
static wxBitmapBundle bmp;
static wxBitmap bmp;
return &bmp;
#else // if this is updated, refer to PrusaSlicer for updates
#else
// If the filament preset is not compatible and there is a "red flag" icon loaded, show it left
// to the filament color image.
if (wide_icons)
@ -479,52 +483,52 @@ wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icon
bitmap_key += ",dark";
bitmap_key += material_rgb;
wxBitmapBundle* bmp_bndl = bitmap_cache().find_bndl(bitmap_key);
if (bmp_bndl == nullptr) {
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps;
std::vector<wxBitmap> bmps;
if (wide_icons)
// Paint a red flag for incompatible presets.
bmps.emplace_back(is_compatible ? get_empty_bmp_bundle(norm_icon_width, icon_height) : m_bitmapIncompatible);
bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp());
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty())
{
// BBS
// Paint a lock at the system presets.
bmps.emplace_back(get_empty_bmp_bundle(space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
}
else
{
// BBS
#if 0
// Paint the color bars.
bmps.emplace_back(get_empty_bmp_bundle(thin_space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(thin_space_icon_width, icon_height));
if (m_type == Preset::TYPE_SLA_MATERIAL)
bmps.emplace_back(bitmap_cache().from_svg(main_icon_name, 16, 16, dark_mode, material_rgb));
bmps.emplace_back(create_scaled_bitmap(main_icon_name, this, 16, false, material_rgb));
else
bmps.emplace_back(get_bmp_bundle(main_icon_name));
bmps.emplace_back(create_scaled_bitmap(main_icon_name));
#endif
// Paint a lock at the system presets.
bmps.emplace_back(get_empty_bmp_bundle(wide_space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(wide_space_icon_width, icon_height));
}
bmps.emplace_back(is_system ? get_bmp_bundle("unlock_normal") : get_empty_bmp_bundle(norm_icon_width, icon_height));
bmp_bndl = bitmap_cache().insert_bndl(bitmap_key, bmps);
bmps.emplace_back(is_system ? create_scaled_bitmap("unlock_normal") : bitmap_cache().mkclear(norm_icon_width, icon_height));
bmp = bitmap_cache().insert(bitmap_key, bmps);
}
return bmp_bndl;
return bmp;
#endif
}
wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
wxBitmap *PresetComboBox::get_bmp(Preset const &preset)
{
static wxBitmapBundle sbmp;
static wxBitmap sbmp;
if (m_type == Preset::TYPE_FILAMENT) {
Preset const & preset2 = &m_collection->get_selected_preset() == &preset ? m_collection->get_edited_preset() : preset;
wxString color = preset2.config.opt_string("default_filament_colour", 0);
wxColour clr(color);
if (clr.IsOk()) {
std::string bitmap_key = "default_filament_colour_" + color.ToStdString();
wxBitmapBundle *bmp = bitmap_cache().find_bndl(bitmap_key);
wxBitmap *bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
wxImage img(16, 16);
if (clr.Red() > 224 && clr.Blue() > 224 && clr.Green() > 224) {
@ -533,8 +537,8 @@ wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
} else {
img.SetRGB(wxRect({0, 0}, img.GetSize()), clr.Red(), clr.Green(), clr.Blue());
}
bmp = new wxBitmapBundle(img);
bmp = bitmap_cache().insert_bndl(bitmap_key, *bmp);
bmp = new wxBitmap(img);
bmp = bitmap_cache().insert(bitmap_key, *bmp);
}
return bmp;
}
@ -542,14 +546,14 @@ wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
return &sbmp;
}
wxBitmapBundle *PresetComboBox::get_bmp(std::string bitmap_key,
wxBitmap *PresetComboBox::get_bmp(std::string bitmap_key,
const std::string &main_icon_name,
const std::string &next_icon_name,
bool is_enabled/* = true*/, bool is_compatible/* = true*/, bool is_system/* = false*/)
{
// BBS: no icon
#if 1
static wxBitmapBundle bmp;
static wxBitmap bmp;
return &bmp;
#else
bitmap_key += !is_enabled ? "_disabled" : "";
@ -559,27 +563,21 @@ wxBitmapBundle *PresetComboBox::get_bmp(std::string bitmap_key,
if (wxGetApp().dark_mode())
bitmap_key += ",dark";
wxBitmapBundle* bmp = bitmap_cache().find_bndl(bitmap_key);
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps;
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? get_bmp_bundle(main_icon_name, this, 16, !is_enabled) :
is_compatible ? m_bitmapCompatible : m_bitmapIncompatible);
std::vector<wxBitmap> bmps;
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? create_scaled_bitmap(main_icon_name, this, 16, !is_enabled) :
is_compatible ? m_bitmapCompatible.bmp() : m_bitmapIncompatible.bmp());
// Paint a lock at the system presets.
bmps.emplace_back(is_system ? get_bmp_bundle(next_icon_name) : get_empty_bmp_bundle(norm_icon_width, icon_height));
bmp = bitmap_cache().insert_bndl(bitmap_key, bmps);
bmps.emplace_back(is_system ? create_scaled_bitmap(next_icon_name, this, 16, !is_enabled) : bitmap_cache().mkclear(norm_icon_width, icon_height));
bmp = bitmap_cache().insert(bitmap_key, bmps);
}
return bmp;
#endif
}
wxBitmapBundle PresetComboBox::NullBitmapBndl()
{
assert(null_icon_width > 0);
return *get_empty_bmp_bundle(null_icon_width, icon_height);
}
bool PresetComboBox::is_selected_physical_printer()
{
auto selected_item = this->GetSelection();
@ -946,12 +944,10 @@ void PlaterPresetComboBox::update()
// and draw a red flag in front of the selected preset.
bool wide_icons = selected_preset && !selected_preset->is_compatible;
null_icon_width = (wide_icons ? 3 : 2) * norm_icon_width + thin_space_icon_width + wide_space_icon_width;
std::map<wxString, wxBitmapBundle*> nonsys_presets;
std::map<wxString, wxBitmap*> nonsys_presets;
//BBS: add project embedded presets logic
std::map<wxString, wxBitmapBundle*> project_embedded_presets;
std::map<wxString, wxBitmapBundle*> system_presets;
std::map<wxString, wxBitmap*> project_embedded_presets;
std::map<wxString, wxBitmap*> system_presets;
//BBS: move system to the end
wxString selected_system_preset;
@ -961,7 +957,7 @@ void PlaterPresetComboBox::update()
//BBS: move system to the end
/*if (!presets.front().is_visible)
this->set_label_marker(this->Append(separator(L("System presets")), NullBitmapBndl()));*/
this->set_label_marker(this->Append(separator(L("System presets")), wxNullBitmap));*/
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
{
@ -989,7 +985,7 @@ void PlaterPresetComboBox::update()
#endif
}
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
const std::string name = preset.alias.empty() ? preset.name : preset.alias;
@ -1034,16 +1030,16 @@ void PlaterPresetComboBox::update()
//BBS: add project embedded preset logic
if (!project_embedded_presets.empty())
{
set_label_marker(Append(separator(L("Project-inside presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
set_label_marker(Append(separator(L("Project-inside presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_user_preset);
}
}
if (!nonsys_presets.empty())
{
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_user_preset);
}
@ -1051,8 +1047,8 @@ void PlaterPresetComboBox::update()
//BBS: move system to the end
if (!system_presets.empty())
{
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_system_preset);
}
@ -1063,7 +1059,7 @@ void PlaterPresetComboBox::update()
{
// add Physical printers, if any exists
if (!m_preset_bundle->physical_printers.empty()) {
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@ -1072,7 +1068,7 @@ void PlaterPresetComboBox::update()
if (!preset || !preset->is_visible)
continue;
std::string main_icon_name, bitmap_key = main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
auto bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
wxBitmap* bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
assert(bmp);
set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
@ -1083,7 +1079,7 @@ void PlaterPresetComboBox::update()
}*/
if (m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) {
wxBitmapBundle* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
wxBitmap* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
assert(bmp);
if (m_type == Preset::TYPE_FILAMENT)
@ -1125,23 +1121,12 @@ void PlaterPresetComboBox::msw_rescale()
if (clr_picker)
clr_picker->SetSize(20 * m_em_unit / 10, 20 * m_em_unit / 10);
#ifdef __WXMSW__
// Use this part of code just on Windows to avoid of some layout issues on Linux
// see https://github.com/prusa3d/PrusaSlicer/issues/5163 and https://github.com/prusa3d/PrusaSlicer/issues/5505
// Update control min size after rescale (changed Display DPI under MSW)
if (GetMinWidth() != 20 * m_em_unit)
SetMinSize(wxSize(20 * m_em_unit, GetSize().GetHeight()));
#endif //__WXMSW__
}
void PlaterPresetComboBox::sys_color_changed()
{
PresetComboBox::sys_color_changed();
// BBS
if (edit_btn != nullptr)
edit_btn->sys_color_changed();
edit_btn->msw_rescale();
}
// ---------------------------------
// *** TabPresetComboBox ***
// ---------------------------------
@ -1208,16 +1193,16 @@ void TabPresetComboBox::update()
const std::deque<Preset>& presets = m_collection->get_presets();
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
//BBS: add project embedded presets logic
std::map<wxString, std::pair<wxBitmapBundle*, bool>> project_embedded_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> project_embedded_presets;
//BBS: move system to the end
std::map<wxString, std::pair<wxBitmapBundle*, bool>> system_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> system_presets;
wxString selected = "";
//BBS: move system to the end
/*if (!presets.front().is_visible)
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));*/
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));*/
size_t idx_selected = m_collection->get_selected_idx();
if (m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection()) {
@ -1236,12 +1221,12 @@ void TabPresetComboBox::update()
// marker used for disable incompatible printer models for the selected physical printer
bool is_enabled = true;
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (preset.is_default || preset.is_system) {
//BBS: move system to the end
system_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle *, bool>(bmp, is_enabled));
system_presets.emplace(get_preset_name(preset), std::pair<wxBitmap *, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
//int item_id = Append(get_preset_name(preset), *bmp);
@ -1253,20 +1238,20 @@ void TabPresetComboBox::update()
else if (preset.is_project_embedded)
{
//std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
project_embedded_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle *, bool>(bmp, is_enabled));
project_embedded_presets.emplace(get_preset_name(preset), std::pair<wxBitmap *, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
}
else
{
std::pair<wxBitmapBundle*, bool> pair(bmp, is_enabled);
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
}
//BBS: move system to the end
//if (i + 1 == m_collection->num_default_presets())
// set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
// set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
}
if (m_type == Preset::TYPE_FILAMENT && m_preset_bundle->is_bbl_vendor())
@ -1276,7 +1261,7 @@ void TabPresetComboBox::update()
if (!project_embedded_presets.empty())
{
set_label_marker(Append(separator(L("Project-inside presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1286,8 +1271,8 @@ void TabPresetComboBox::update()
}
if (!nonsys_presets.empty())
{
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1299,7 +1284,7 @@ void TabPresetComboBox::update()
if (!system_presets.empty())
{
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1313,7 +1298,7 @@ void TabPresetComboBox::update()
//BBS: remove unused pysical printer logic
/*// add Physical printers, if any exists
if (!m_preset_bundle->physical_printers.empty()) {
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@ -1323,7 +1308,7 @@ void TabPresetComboBox::update()
continue;
std::string main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
auto bmp = get_bmp(main_icon_name, main_icon_name, "", true, true, false);
wxBitmap* bmp = get_bmp(main_icon_name, main_icon_name, "", true, true, false);
assert(bmp);
set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
@ -1334,14 +1319,14 @@ void TabPresetComboBox::update()
// add "Add/Remove printers" item
//std::string icon_name = "edit_uni";
//auto bmp = get_bmp("edit_preset_list, tab,", icon_name, "");
//wxBitmap* bmp = get_bmp("edit_preset_list, tab,", icon_name, "");
//assert(bmp);
//set_label_marker(Append(separator(L("Add/Remove printers")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
}
// BBS Add/Remove filaments select
//wxBitmapBundle* bmp = get_bmp("edit_preset_list", false, "edit_uni");
//wxBitmap* bmp = get_bmp("edit_preset_list", false, "edit_uni");
//assert(bmp);
//if (m_type == Preset::TYPE_FILAMENT)
// set_label_marker(Append(separator(L("Add/Remove filaments")), *bmp), LABEL_ITEM_WIZARD_FILAMENTS);
@ -1501,7 +1486,7 @@ void GUI::CalibrateFilamentComboBox::update()
tooltip = get_tooltip(preset);
}
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (preset.is_default || preset.is_system) {
@ -1544,7 +1529,7 @@ void GUI::CalibrateFilamentComboBox::msw_rescale()
}
// BBS
if (edit_btn != nullptr)
edit_btn->sys_color_changed();
edit_btn->msw_rescale();
}
void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt)

View file

@ -1,7 +1,7 @@
#ifndef slic3r_PresetComboBoxes_hpp_
#define slic3r_PresetComboBoxes_hpp_
#include <wx/bmpbndl.h>
//#include <wx/bmpcbox.h>
#include <wx/gdicmn.h>
#include <wx/clrpicker.h>
@ -37,7 +37,7 @@ public:
PresetComboBox(wxWindow* parent, Preset::Type preset_type, const wxSize& size = wxDefaultSize, PresetBundle* preset_bundle = nullptr);
~PresetComboBox();
enum LabelItemType : size_t {
enum LabelItemType {
LABEL_ITEM_PHYSICAL_PRINTER = 0xffffff01,
LABEL_ITEM_DISABLED,
LABEL_ITEM_MARKER,
@ -99,9 +99,9 @@ protected:
static BitmapCache& bitmap_cache();
// Indicator, that the preset is compatible with the selected printer.
wxBitmapBundle* m_bitmapCompatible;
ScalableBitmap m_bitmapCompatible;
// Indicator, that the preset is NOT compatible with the selected printer.
wxBitmapBundle* m_bitmapIncompatible;
ScalableBitmap m_bitmapIncompatible;
int m_last_selected;
int m_em_unit;
@ -115,7 +115,6 @@ protected:
// parameters for an icon's drawing
int icon_height;
int norm_icon_width;
int null_icon_width;
int thin_icon_width;
int wide_icon_width;
int space_icon_width;
@ -140,16 +139,14 @@ protected:
#endif // __linux__
static wxString separator(const std::string& label);
wxBitmapBundle* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
wxBitmap* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
bool is_compatible = true, bool is_system = false, bool is_single_bar = false,
const std::string& filament_rgb = "", const std::string& extruder_rgb = "", const std::string& material_rgb = "");
wxBitmapBundle* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
wxBitmap* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
bool is_enabled = true, bool is_compatible = true, bool is_system = false);
wxBitmapBundle* get_bmp(Preset const &preset);
wxBitmapBundle NullBitmapBndl();
wxBitmap *get_bmp(Preset const &preset);
private:
void fill_width_height();
@ -182,7 +179,6 @@ public:
wxString get_preset_name(const Preset& preset) override;
void update() override;
void msw_rescale() override;
void sys_color_changed() override;
void OnSelect(wxCommandEvent& evt) override;
private:
@ -249,8 +245,8 @@ private:
bool m_filament_exist{false};
bool m_is_compatible{true};
const Preset* m_selected_preset = nullptr;
std::map<wxString, std::pair<std::string, wxBitmapBundle*>> m_nonsys_presets;
std::map<wxString, std::pair<std::string, wxBitmapBundle*>> m_system_presets;
std::map<wxString, std::pair<std::string, wxBitmap*>> m_nonsys_presets;
std::map<wxString, std::pair<std::string, wxBitmap*>> m_system_presets;
};
} // namespace GUI

View file

@ -94,16 +94,16 @@ void RecenterDialog::render(wxDC& dc) {
wxSize hint1_size = dc.GetTextExtent(hint1);
wxPoint pos_hint1 = pos_start;
pos_hint1.y += (m_home_bmp.GetWidth() - hint1_size.y) / 2;
pos_hint1.y += (m_home_bmp.GetBmpWidth() - hint1_size.y) / 2;
dc.DrawText(hint1, pos_hint1);
wxPoint pos_bmp = pos_start;
pos_bmp.x += hint1_size.x;
dc.DrawBitmap(m_home_bmp.get_bitmap(), pos_bmp);
dc.DrawBitmap(m_home_bmp.bmp(), pos_bmp);
wxSize hint2_size = dc.GetTextExtent(hint2);
wxPoint pos_hint2 = pos_hint1;
pos_hint2.x = pos_hint2.x + hint1_size.x + m_home_bmp.GetWidth();
pos_hint2.x = pos_hint2.x + hint1_size.x + m_home_bmp.GetBmpWidth();
if (hint2_size.x + pos_hint2.x + BORDER > DRAW_PANEL_SIZE.x) {
bool is_ch = false;

View file

@ -57,7 +57,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
label_top->SetForegroundColour(wxColour(38,46,48));
// m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, *get_bmp_bundle("blank_16"));
// m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, create_scaled_bitmap("blank_16", m_parent));
//
// m_combo = new wxComboBox(m_parent, wxID_ANY, from_u8(preset_name), wxDefaultPosition, wxSize(35 * wxGetApp().em_unit(), -1));
// for (const std::string& value : values)
@ -268,7 +268,7 @@ void SavePresetDialog::Item::update()
void SavePresetDialog::Item::update_valid_bmp()
{
std::string bmp_name = m_valid_type == Warning ? "obj_warning" : m_valid_type == NoValid ? "cross" : "blank_16";
m_valid_bmp->SetBitmap(*get_bmp_bundle(bmp_name));
m_valid_bmp->SetBitmap(create_scaled_bitmap(bmp_name, m_parent));
}
void SavePresetDialog::Item::accept()

View file

@ -829,9 +829,12 @@ void SearchDialog::msw_rescale()
{
/* const int &em = GUI::wxGetApp().em_unit();
search_list_model->msw_rescale();
search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em);
search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(45 * em);
msw_buttons_rescale(this, em, { wxID_CANCEL });
const wxSize& size = wxSize(40 * em, 30 * em);
SetMinSize(size);
@ -849,7 +852,7 @@ void SearchDialog::msw_rescale()
//#endif
//
// // msw_rescale updates just icons, so use it
// search_list_model->sys_color_changed();
// search_list_model->msw_rescale();
//
// Refresh();
//}
@ -881,10 +884,9 @@ void SearchListModel::Prepend(const std::string &label)
RowPrepended();
}
void SearchListModel::sys_color_changed()
void SearchListModel::msw_rescale()
{
for (ScalableBitmap &bmp : m_icon)
bmp.sys_color_changed();
for (ScalableBitmap &bmp : m_icon) bmp.msw_rescale();
}
wxString SearchListModel::GetColumnType(unsigned int col) const
@ -896,7 +898,7 @@ wxString SearchListModel::GetColumnType(unsigned int col) const
void SearchListModel::GetValueByRow(wxVariant &variant, unsigned int row, unsigned int col) const
{
switch (col) {
case colIcon: variant << m_icon[m_values[row].second].bmp().GetBitmapFor(m_icon[m_values[row].second].parent()); break;
case colIcon: variant << m_icon[m_values[row].second].bmp(); break;
case colMarkedText: variant = m_values[row].first; break;
case colMax: wxFAIL_MSG("invalid column");
default: break;

View file

@ -270,7 +270,7 @@ public:
void Clear();
void Prepend(const std::string &text);
void sys_color_changed();
void msw_rescale();
// implementation of base class virtuals to define model

View file

@ -212,9 +212,9 @@ void MachineObjectPanel::doRender(wxDC &dc)
if (m_state == PrinterState::IN_LAN) { dwbitmap = m_printer_in_lan; }
// dc.DrawCircle(left, size.y / 2, 3);
dc.DrawBitmap(dwbitmap.get_bitmap(), wxPoint(left, (size.y - dwbitmap.GetSize().y) / 2));
dc.DrawBitmap(dwbitmap.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2));
left += dwbitmap.GetSize().x + 8;
left += dwbitmap.GetBmpSize().x + 8;
dc.SetFont(Label::Body_13);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
@ -230,10 +230,10 @@ void MachineObjectPanel::doRender(wxDC &dc)
auto text_end = 0;
if (m_show_edit) {
text_end = size.x - m_unbind_img.GetSize().x - 30;
text_end = size.x - m_unbind_img.GetBmpSize().x - 30;
}
else {
text_end = size.x - m_unbind_img.GetSize().x;
text_end = size.x - m_unbind_img.GetBmpSize().x;
}
wxString finally_name = dev_name;
@ -261,14 +261,14 @@ void MachineObjectPanel::doRender(wxDC &dc)
if (m_show_bind) {
if (m_bind_state == ALLOW_UNBIND) {
left = size.x - m_unbind_img.GetSize().x - 6;
dc.DrawBitmap(m_unbind_img.get_bitmap(), left, (size.y - m_unbind_img.GetSize().y) / 2);
left = size.x - m_unbind_img.GetBmpSize().x - 6;
dc.DrawBitmap(m_unbind_img.bmp(), left, (size.y - m_unbind_img.GetBmpSize().y) / 2);
}
}
if (m_show_edit) {
left = size.x - m_unbind_img.GetSize().x - 6 - m_edit_name_img.GetSize().x - 6;
dc.DrawBitmap(m_edit_name_img.get_bitmap(), left, (size.y - m_edit_name_img.GetSize().y) / 2);
left = size.x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6;
dc.DrawBitmap(m_edit_name_img.bmp(), left, (size.y - m_edit_name_img.GetBmpSize().y) / 2);
}
}
@ -298,10 +298,10 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
if (m_is_my_devices) {
// show edit
if (m_show_edit) {
auto edit_left = GetSize().x - m_unbind_img.GetSize().x - 6 - m_edit_name_img.GetSize().x - 6;
auto edit_right = edit_left + m_edit_name_img.GetSize().x;
auto edit_top = (GetSize().y - m_edit_name_img.GetSize().y) / 2;
auto edit_bottom = (GetSize().y - m_edit_name_img.GetSize().y) / 2 + m_edit_name_img.GetSize().y;
auto edit_left = GetSize().x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6;
auto edit_right = edit_left + m_edit_name_img.GetBmpSize().x;
auto edit_top = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2;
auto edit_bottom = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2 + m_edit_name_img.GetBmpSize().y;
if ((evt.GetPosition().x >= edit_left && evt.GetPosition().x <= edit_right) && evt.GetPosition().y >= edit_top && evt.GetPosition().y <= edit_bottom) {
wxCommandEvent event(EVT_EDIT_PRINT_NAME);
event.SetEventObject(this);
@ -310,10 +310,10 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
}
}
if (m_show_bind) {
auto left = GetSize().x - m_unbind_img.GetSize().x - 6;
auto right = left + m_unbind_img.GetSize().x;
auto top = (GetSize().y - m_unbind_img.GetSize().y) / 2;
auto bottom = (GetSize().y - m_unbind_img.GetSize().y) / 2 + m_unbind_img.GetSize().y;
auto left = GetSize().x - m_unbind_img.GetBmpSize().x - 6;
auto right = left + m_unbind_img.GetBmpSize().x;
auto top = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2;
auto bottom = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2 + m_unbind_img.GetBmpSize().y;
if ((evt.GetPosition().x >= left && evt.GetPosition().x <= right) && evt.GetPosition().y >= top && evt.GetPosition().y <= bottom) {
wxCommandEvent event(EVT_UNBIND_MACHINE, GetId());
@ -3631,16 +3631,16 @@ void SelectMachineDialog::Enable_Send_Button(bool en)
void SelectMachineDialog::on_dpi_changed(const wxRect &suggested_rect)
{
print_time->sys_color_changed();
print_time->msw_rescale();
timeimg->SetBitmap(print_time->bmp());
print_weight->sys_color_changed();
print_weight->msw_rescale();
weightimg->SetBitmap(print_weight->bmp());
m_rename_button->sys_color_changed();
ams_editable->sys_color_changed();
ams_editable_light->sys_color_changed();
enable_ams_mapping->sys_color_changed();
m_rename_button->msw_rescale();
ams_editable->msw_rescale();
ams_editable_light->msw_rescale();
enable_ams_mapping->msw_rescale();
img_amsmapping_tip->SetBitmap(enable_ams_mapping->bmp());
enable_ams->sys_color_changed();
enable_ams->msw_rescale();
img_use_ams_tip->SetBitmap(enable_ams->bmp());
m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
@ -4442,7 +4442,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
wxMemoryDC dc;
bitmap_with_background.Create(wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()));
dc.SelectObject(bitmap_with_background);
dc.DrawBitmap(m_background_bitmap.get_bitmap(), 0, 0);
dc.DrawBitmap(m_background_bitmap.bmp(), 0, 0);
dc.DrawBitmap(m_bitmap, 0, 0);
dc.SelectObject(wxNullBitmap);

View file

@ -271,7 +271,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
bSizer_task_btn->Add(FromDIP(10), 0, 0);
m_button_pause_resume = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_pause", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_button_pause_resume = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_pause", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER,true);
m_button_pause_resume->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
if (m_button_pause_resume->GetToolTipText() == _L("Pause")) {
@ -294,7 +294,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
}
});
m_button_abort = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_stop", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_button_abort = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_stop", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_button_abort->SetToolTip(_L("Stop"));
m_button_abort->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
@ -498,7 +498,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
m_score_star.resize(5);
for (int i = 0; i < m_score_star.size(); ++i) {
m_score_star[i] = new ScalableButton(m_score_subtask_info, wxID_ANY, "score_star_dark", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
m_score_star[i]->Bind(wxEVT_LEFT_DOWN, [this, i](auto &e) {
for (int j = 0; j < m_score_star.size(); ++j) {
ScalableBitmap light_star = ScalableBitmap(nullptr, "score_star_light", 26);
@ -555,7 +555,7 @@ void PrintingTaskPanel::paint(wxPaintEvent&)
{
wxPaintDC dc(m_bitmap_thumbnail);
if (wxGetApp().dark_mode())
dc.DrawBitmap(m_bitmap_background.get_bitmap(), 0, 0);
dc.DrawBitmap(m_bitmap_background.bmp(), 0, 0);
dc.DrawBitmap(m_thumbnail_bmp_display, wxPoint(0, 0));
dc.SetTextForeground(*wxBLACK);
dc.SetFont(Label::Body_12);
@ -583,7 +583,7 @@ void PrintingTaskPanel::msw_rescale()
//m_staticText_printing->SetMinSize(wxSize(PAGE_TITLE_TEXT_WIDTH, PAGE_TITLE_HEIGHT));
m_gauge_progress->SetHeight(PROGRESSBAR_HEIGHT);
m_gauge_progress->Rescale();
m_button_abort->sys_color_changed();
m_button_abort->msw_rescale();
m_bitmap_thumbnail->SetSize(TASK_THUMBNAIL_SIZE);
}
@ -619,7 +619,7 @@ void PrintingTaskPanel::show_error_msg(wxString msg)
void PrintingTaskPanel::reset_printing_value()
{
this->set_thumbnail_img(m_thumbnail_placeholder.get_bitmap());
this->set_thumbnail_img(m_thumbnail_placeholder.bmp());
this->set_plate_index(-1);
}
@ -913,15 +913,15 @@ void StatusBasePanel::init_bitmaps()
m_bitmap_extruder_empty_unload = *cache.load_png("monitor_extruder_empty_unload", FromDIP(28), FromDIP(70), false, false);
m_bitmap_extruder_filled_unload = *cache.load_png("monitor_extruder_filled_unload", FromDIP(28), FromDIP(70), false, false);
m_bitmap_sdcard_state_abnormal = ScalableBitmap(this, wxGetApp().dark_mode() ? "sdcard_state_abnormal_dark" : "sdcard_state_abnormal",{38, 20});
m_bitmap_sdcard_state_normal = ScalableBitmap(this, wxGetApp().dark_mode() ? "sdcard_state_normal_dark" : "sdcard_state_normal", {38, 20});
m_bitmap_sdcard_state_no = ScalableBitmap(this, wxGetApp().dark_mode() ? "sdcard_state_no_dark" : "sdcard_state_no", {38, 20});
m_bitmap_recording_on = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_recording_on_dark" : "monitor_recording_on", {38, 20});
m_bitmap_recording_off = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_recording_off_dark" : "monitor_recording_off", {38, 20});
m_bitmap_timelapse_on = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_timelapse_on_dark" : "monitor_timelapse_on", {38, 20});
m_bitmap_timelapse_off = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_timelapse_off_dark" : "monitor_timelapse_off", {38, 20});
m_bitmap_vcamera_on = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_vcamera_on_dark" : "monitor_vcamera_on", {38, 20});
m_bitmap_vcamera_off = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_vcamera_off_dark" : "monitor_vcamera_off", {38, 20});
m_bitmap_sdcard_state_abnormal = ScalableBitmap(this, wxGetApp().dark_mode() ? "sdcard_state_abnormal_dark" : "sdcard_state_abnormal", 20);
m_bitmap_sdcard_state_normal = ScalableBitmap(this, wxGetApp().dark_mode() ? "sdcard_state_normal_dark" : "sdcard_state_normal", 20);
m_bitmap_sdcard_state_no = ScalableBitmap(this, wxGetApp().dark_mode() ? "sdcard_state_no_dark" : "sdcard_state_no", 20);
m_bitmap_recording_on = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_recording_on_dark" : "monitor_recording_on", 20);
m_bitmap_recording_off = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_recording_off_dark" : "monitor_recording_off", 20);
m_bitmap_timelapse_on = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_timelapse_on_dark" : "monitor_timelapse_on", 20);
m_bitmap_timelapse_off = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_timelapse_off_dark" : "monitor_timelapse_off", 20);
m_bitmap_vcamera_on = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_vcamera_on_dark" : "monitor_vcamera_on", 20);
m_bitmap_vcamera_off = ScalableBitmap(this, wxGetApp().dark_mode() ? "monitor_vcamera_off_dark" : "monitor_vcamera_off", 20);
}
@ -1920,7 +1920,7 @@ void StatusPanel::on_webrequest_state(wxWebRequestEvent &evt)
case wxWebRequest::State_Failed:
case wxWebRequest::State_Cancelled:
case wxWebRequest::State_Unauthorized: {
m_project_task_panel->set_thumbnail_img(m_thumbnail_brokenimg.get_bitmap());
m_project_task_panel->set_thumbnail_img(m_thumbnail_brokenimg.bmp());
m_project_task_panel->set_plate_index(-1);
task_thumbnail_state = ThumbnailState::BROKEN_IMG;
break;
@ -4001,15 +4001,15 @@ void StatusPanel::rescale_camera_icons()
m_setting_button->msw_rescale();
m_bitmap_sdcard_state_abnormal = ScalableBitmap(this, wxGetApp().dark_mode()?"sdcard_state_abnormal_dark":"sdcard_state_abnormal", {38, 20});
m_bitmap_sdcard_state_normal = ScalableBitmap(this, wxGetApp().dark_mode()?"sdcard_state_normal_dark":"sdcard_state_normal", {38, 20});
m_bitmap_sdcard_state_no = ScalableBitmap(this, wxGetApp().dark_mode()?"sdcard_state_no_dark":"sdcard_state_no", {38, 20});
m_bitmap_recording_on = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_recording_on_dark":"monitor_recording_on", {38, 20});
m_bitmap_recording_off = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_recording_off_dark":"monitor_recording_off", {38, 20});
m_bitmap_timelapse_on = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_timelapse_on_dark":"monitor_timelapse_on", {38, 20});
m_bitmap_timelapse_off = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_timelapse_off_dark":"monitor_timelapse_off", {38, 20});
m_bitmap_vcamera_on = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_vcamera_on_dark":"monitor_vcamera_on", {38, 20});
m_bitmap_vcamera_off = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_vcamera_off_dark":"monitor_vcamera_off", {38, 20});
m_bitmap_sdcard_state_abnormal = ScalableBitmap(this, wxGetApp().dark_mode()?"sdcard_state_abnormal_dark":"sdcard_state_abnormal", 20);
m_bitmap_sdcard_state_normal = ScalableBitmap(this, wxGetApp().dark_mode()?"sdcard_state_normal_dark":"sdcard_state_normal", 20);
m_bitmap_sdcard_state_no = ScalableBitmap(this, wxGetApp().dark_mode()?"sdcard_state_no_dark":"sdcard_state_no", 20);
m_bitmap_recording_on = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_recording_on_dark":"monitor_recording_on", 20);
m_bitmap_recording_off = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_recording_off_dark":"monitor_recording_off", 20);
m_bitmap_timelapse_on = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_timelapse_on_dark":"monitor_timelapse_on", 20);
m_bitmap_timelapse_off = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_timelapse_off_dark":"monitor_timelapse_off", 20);
m_bitmap_vcamera_on = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_vcamera_on_dark":"monitor_vcamera_on", 20);
m_bitmap_vcamera_off = ScalableBitmap(this, wxGetApp().dark_mode()?"monitor_vcamera_off_dark":"monitor_vcamera_off", 20);
if (m_media_play_ctrl->IsStreaming()) {
m_bitmap_vcamera_img->SetBitmap(m_bitmap_vcamera_on.bmp());
@ -4046,8 +4046,8 @@ void StatusPanel::rescale_camera_icons()
void StatusPanel::on_sys_color_changed()
{
m_project_task_panel->msw_rescale();
m_bitmap_speed.sys_color_changed();
m_bitmap_speed_active.sys_color_changed();
m_bitmap_speed.msw_rescale();
m_bitmap_speed_active.msw_rescale();
m_switch_speed->SetImages(m_bitmap_speed, m_bitmap_speed);
m_ams_control->msw_rescale();
if (m_print_error_dlg) { m_print_error_dlg->msw_rescale(); }
@ -4086,8 +4086,8 @@ void StatusPanel::msw_rescale()
m_tempCtrl_chamber->SetMinSize(TEMP_CTRL_MIN_SIZE);
m_tempCtrl_chamber->Rescale();
m_bitmap_speed.sys_color_changed();
m_bitmap_speed_active.sys_color_changed();
m_bitmap_speed.msw_rescale();
m_bitmap_speed_active.msw_rescale();
m_switch_speed->SetImages(m_bitmap_speed, m_bitmap_speed);
m_switch_speed->SetMinSize(MISC_BUTTON_2FAN_SIZE);
@ -4352,10 +4352,10 @@ wxBoxSizer *ScoreDialog::get_star_sizer()
}
if (i < m_star_count) {
m_score_star[i] = new ScalableButton(this, wxID_ANY, "score_star_light", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
} else
m_score_star[i] = new ScalableButton(this, wxID_ANY, "score_star_dark", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
m_score_star[i]->Bind(wxEVT_LEFT_DOWN, [this, i](auto &e) {
if (!m_success_printed && i >= 3) {

View file

@ -95,8 +95,8 @@ SysInfoDialog::SysInfoDialog()
main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10);
// logo
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 192));
m_logo_bmp = ScalableBitmap(this, wxGetApp().logo_name(), 192);
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);

View file

@ -229,6 +229,8 @@ void Tab::create_preset_tab()
// add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
m_show_incompatible_presets = false;
add_scaled_bitmap(this, m_bmp_show_incompatible_presets, "flag_red");
add_scaled_bitmap(this, m_bmp_hide_incompatible_presets, "flag_green");
//add_scaled_button(panel, &m_btn_hide_incompatible_presets, m_bmp_hide_incompatible_presets.name());
@ -393,7 +395,7 @@ void Tab::create_preset_tab()
#endif
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
const float scale_factor = em_unit(this)*0.1;// GetContentScaleFactor();
const float scale_factor = /*wxGetApp().*/em_unit(this)*0.1;// GetContentScaleFactor();
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_hsizer, 0, wxEXPAND | wxBOTTOM, 3);
m_hsizer->Add(m_presets_choice, 0, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
@ -442,8 +444,11 @@ void Tab::create_preset_tab()
m_tabctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable right select
m_tabctrl->SetFont(Label::Body_14);
//m_left_sizer->Add(m_tabctrl, 1, wxEXPAND);
// Index of the last icon inserted into m_tabctrl.
const int img_sz = int(32 * scale_factor + 0.5f);
m_icons = new wxImageList(img_sz, img_sz, false, 1);
// Index of the last icon inserted into $self->{icons}.
m_icon_count = -1;
m_tabctrl->AssignImageList(m_icons);
wxGetApp().UpdateDarkUI(m_tabctrl);
// Delay processing of the following handler until the message queue is flushed.
@ -521,22 +526,6 @@ void Tab::create_preset_tab()
// Initialize the DynamicPrintConfig by default keys/values.
build();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
// This instance was added by PS when updating wx
/* if (!m_scaled_icons_list.empty()) {
// update icons for tree_ctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);
}*/
// ys_FIXME: Following should not be needed, the function will be called later
// (update_mode->update_visibility->rebuild_page_tree). This does not work, during the
// second call of rebuild_page_tree m_tabctrl->GetFirstVisibleItem(); returns zero
@ -552,7 +541,7 @@ void Tab::add_scaled_button(wxWindow* parent,
const wxString& label/* = wxEmptyString*/,
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/)
{
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style);
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style, true);
(*btn)->SetBackgroundColour(parent->GetBackgroundColour());
m_scaled_buttons.push_back(*btn);
}
@ -583,6 +572,7 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
if (icon_idx == -1) {
// Add a new icon to the icon list.
m_scaled_icons_list.push_back(ScalableBitmap(this, icon, 32, false, true));
//m_icons->Add(m_scaled_icons_list.back().bmp());
icon_idx = ++m_icon_count;
m_icon_index[icon] = icon_idx;
}
@ -897,6 +887,18 @@ void TabPrinter::init_options_list()
m_options_list.emplace("extruders_count", m_opt_status_value);
}
void TabPrinter::msw_rescale()
{
Tab::msw_rescale();
if (m_reset_to_filament_color)
m_reset_to_filament_color->msw_rescale();
//BBS: GUI refactor
//Layout();
m_parent->Layout();
}
void TabSLAMaterial::init_options_list()
{
if (!m_options_list.empty())
@ -1172,30 +1174,35 @@ void Tab::msw_rescale()
m_top_sizer->SetMinSize(-1, 3 * m_em_unit);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->msw_rescale();
if (m_presets_choice)
m_presets_choice->msw_rescale();
m_tabctrl->SetMinSize(wxSize(20 * m_em_unit, -1));
// rescale buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->msw_rescale();
for (const auto bmp : m_scaled_bitmaps)
bmp->sys_color_changed();
bmp->msw_rescale();
if (m_mode_view)
m_mode_view->Rescale();
if (m_detach_preset_btn)
m_detach_preset_btn->sys_color_changed();
m_detach_preset_btn->msw_rescale();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
/* // update icons for m_tabctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);*/
// rescale icons for tree_ctrl
for (ScalableBitmap& bmp : m_scaled_icons_list)
bmp.msw_rescale();
// recreate and set new ImageList for tree_ctrl
m_icons->RemoveAll();
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight(), false);
for (ScalableBitmap& bmp : m_scaled_icons_list)
//m_icons->Add(bmp.bmp());
m_tabctrl->AssignImageList(m_icons);
// rescale options_groups
if (m_active_page)
@ -1215,24 +1222,21 @@ void Tab::sys_color_changed()
// update buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->sys_color_changed();
btn->msw_rescale();
for (const auto bmp : m_scaled_bitmaps)
bmp->sys_color_changed();
bmp->msw_rescale();
if (m_detach_preset_btn)
m_detach_preset_btn->sys_color_changed();
m_detach_preset_btn->msw_rescale();
update_show_hide_incompatible_button();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
/* // update icons for m_tabctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);*/
// update icons for tree_ctrl
for (ScalableBitmap& bmp : m_scaled_icons_list)
bmp.msw_rescale();
// recreate and set new ImageList for tree_ctrl
m_icons->RemoveAll();
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight(), false);
for (ScalableBitmap& bmp : m_scaled_icons_list)
//m_icons->Add(bmp.bmp());
m_tabctrl->AssignImageList(m_icons);
// Colors for ui "decoration"
update_label_colours();
@ -1240,7 +1244,7 @@ void Tab::sys_color_changed()
wxWindowUpdateLocker noUpdates(this);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->sys_color_changed();
// m_mode_sizer->msw_rescale();
wxGetApp().UpdateDarkUI(this);
wxGetApp().UpdateDarkUI(m_tabctrl);
#endif
@ -1253,7 +1257,6 @@ void Tab::sys_color_changed()
//BBS: GUI refactor
//Layout();
m_parent->Layout();
m_parent->Refresh();
}
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
@ -1734,7 +1737,7 @@ void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup)
auto detach_preset_btn = [this](wxWindow* parent) {
m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_normal_sys", "",
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
ScalableButton* btn = m_detach_preset_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -2200,7 +2203,7 @@ void TabPrint::build()
optgroup->append_single_option_line(option);
#if 0
//page = add_options_page(L("Dependencies"), "advanced");
//page = add_options_page(L("Dependencies"), "advanced.png");
// optgroup = page->new_optgroup(L("Profile dependencies"));
// create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -3611,7 +3614,7 @@ void TabPrinter::build_sla()
//optgroup->append_single_option_line("min_initial_exposure_time");
//optgroup->append_single_option_line("max_initial_exposure_time");
//page = add_options_page(L("Dependencies"), "wrench");
//page = add_options_page(L("Dependencies"), "wrench.png");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//build_preset_description_line(optgroup.get());
@ -3885,7 +3888,7 @@ if (is_marlin_flavor)
//auto reset_to_filament_color = [this, extruder_idx](wxWindow* parent) {
// m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
// wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
// wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
// ScalableButton* btn = m_reset_to_filament_color;
// btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
// btn->SetSize(btn->GetBestSize());
@ -5248,7 +5251,8 @@ void Tab::toggle_show_hide_incompatible()
void Tab::update_show_hide_incompatible_button()
{
//BBS: GUI refactor
/*m_btn_hide_incompatible_presets->SetBitmap(*get_bmp_bundle(m_show_incompatible_presets ? "flag_red" : "flag_green"));
/*m_btn_hide_incompatible_presets->SetBitmap_(m_show_incompatible_presets ?
m_bmp_show_incompatible_presets : m_bmp_hide_incompatible_presets);
m_btn_hide_incompatible_presets->SetToolTip(m_show_incompatible_presets ?
"Both compatible an incompatible presets are shown. Click to hide presets not compatible with the current printer." :
"Only compatible presets are shown. Click to show both the presets compatible and not compatible with the current printer.");*/
@ -5295,7 +5299,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
wxGetApp().UpdateDarkUI(deps.checkbox, false, true);
deps.btn = new ScalableButton(parent, wxID_ANY, "printer", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()),
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
deps.btn->SetSize(deps.btn->GetBestSize());
@ -5370,7 +5374,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
{
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "printer", " " + _(L("Set")) + " " + dots,
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
btn->SetFont(wxGetApp().normal_font());
btn->SetSize(btn->GetBestSize());
@ -5788,7 +5792,7 @@ void TabSLAMaterial::build()
//optgroup->append_line(line);
//page = add_options_page(L("Dependencies"), "wrench");
//page = add_options_page(L("Dependencies"), "wrench.png");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -5809,7 +5813,7 @@ void TabSLAMaterial::build()
//build_preset_description_line(optgroup.get());
//page = add_options_page(L("Material printing profile"), "printer");
//page = add_options_page(L("Material printing profile"), "printer.png");
//optgroup = page->new_optgroup(L("Material printing profile"));
//option = optgroup->get_option("material_print_speed");
//optgroup->append_single_option_line(option);

View file

@ -154,6 +154,7 @@ protected:
//wxBoxSizer* m_hsizer;
//wxBoxSizer* m_left_sizer;
TabCtrl* m_tabctrl;
wxImageList* m_icons;
wxScrolledWindow* m_page_view {nullptr};
//wxBoxSizer* m_page_sizer {nullptr};
@ -188,6 +189,10 @@ protected:
StaticBox * m_search_item;
TextInput * m_search_input;
// Cached bitmaps.
// A "flag" icon to be displayned next to the preset name in the Tab's combo box.
ScalableBitmap m_bmp_show_incompatible_presets;
ScalableBitmap m_bmp_hide_incompatible_presets;
// Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field.
ScalableBitmap m_bmp_value_lock;
ScalableBitmap m_bmp_value_unlock;
@ -605,6 +610,7 @@ public:
void build_unregular_pages(bool from_initial_build = false);
void on_preset_loaded() override;
void init_options_list() override;
void msw_rescale() override;
bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; }
wxSizer* create_bed_shape_widget(wxWindow* parent);

View file

@ -148,7 +148,7 @@ void TabButton::render(wxDC &dc)
// BBS norrow size between text and icon
szContent.x += 5;
}
szIcon = icon.GetSize();
szIcon = icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}
@ -169,9 +169,9 @@ void TabButton::render(wxDC &dc)
}
if (icon.bmp().IsOk()) {
pt.x = size.x - icon.GetWidth() - paddingSize.y;
pt.y = (size.y - icon.GetHeight()) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.x = size.x - icon.GetBmpWidth() - paddingSize.y;
pt.y = (size.y - icon.GetBmpHeight()) / 2;
dc.DrawBitmap(icon.bmp(), pt);
}
}
@ -189,7 +189,7 @@ void TabButton::messureSize()
// BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->icon.GetSize();
wxSize szIcon = this->icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}

View file

@ -117,21 +117,29 @@ wxIcon ModelNode::get_bitmap(const wxString& color)
wxBitmap ModelNode::get_bitmap(const wxString& color)
#endif // __linux__
{
wxBitmap bmp = get_solid_bmp_bundle(64, 16, into_u8(color))->GetBitmapFor(m_parent_win);
if (!m_toggle)
bmp = bmp.ConvertToDisabled();
/* It's supposed that standard size of an icon is 48px*16px for 100% scaled display.
* So set sizes for solid_colored icons used for filament preset
* and scale them in respect to em_unit value
*/
const double em = em_unit(m_parent_win);
const int icon_width = lround(6.4 * em);
const int icon_height = lround(1.6 * em);
BitmapCache bmp_cache;
ColorRGB rgb;
decode_color(into_u8(color), rgb);
// there is no need to scale created solid bitmap
#ifndef __linux__
return bmp;
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
#else
wxIcon icon;
icon.CopyFromBitmap(bmp);
icon.CopyFromBitmap(bmp_cache.mksolid(icon_width, icon_height, rgb, true));
return icon;
#endif // __linux__
}
// option node
ModelNode::ModelNode(ModelNode* parent, const wxString& text, const wxString& old_value, const wxString& new_value) :
m_parent_win(parent->m_parent_win),
m_parent(parent),
m_old_color(old_value.StartsWith("#") ? old_value : ""),
m_new_color(new_value.StartsWith("#") ? new_value : ""),
@ -196,22 +204,18 @@ void ModelNode::UpdateIcons()
{
// update icons for the colors, if any exists
if (!m_old_color.IsEmpty())
m_old_color_bmp = get_bitmap(m_old_color);
m_old_color_bmp = get_bitmap(m_toggle ? m_old_color : wxString::FromUTF8(grey.c_str()));
if (!m_new_color.IsEmpty())
m_new_color_bmp = get_bitmap(m_new_color);
m_new_color_bmp = get_bitmap(m_toggle ? m_new_color : wxString::FromUTF8(grey.c_str()));
// update main icon, if any exists
if (m_icon_name.empty())
return;
wxBitmap bmp = get_bmp_bundle(m_icon_name)->GetBitmapFor(m_parent_win);
if (!m_toggle)
bmp = bmp.ConvertToDisabled();
#ifdef __linux__
m_icon.CopyFromBitmap(bmp);
m_icon.CopyFromBitmap(create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle));
#else
m_icon = bmp;
m_icon = create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle);
#endif //__linux__
}
@ -1017,7 +1021,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
// "Save" button
if (ActionButtons::SAVE & m_buttons) add_btn(&m_save_btn, m_save_btn_id, "save", Action::Save, _L("Save"), false);
/* ScalableButton *cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, 24);
/* ScalableButton *cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, true, 24);
buttons->Add(cancel_btn, 1, wxLEFT | wxRIGHT, 5);
cancel_btn->SetFont(btn_font);*/
/* m_cancel_btn = new Button(this, _L("Cancel"));
@ -1704,7 +1708,7 @@ void UnsavedChangesDialog::on_dpi_changed(const wxRect& suggested_rect)
void UnsavedChangesDialog::on_sys_color_changed()
{
//for (auto btn : { m_save_btn, m_transfer_btn, m_discard_btn } )
//btn->sys_color_changed();
//btn->msw_rescale();
// msw_rescale updates just icons, so use it
//m_tree->Rescale();
@ -2111,16 +2115,10 @@ void DiffPresetDialog::on_dpi_changed(const wxRect&)
const wxSize& size = wxSize(80 * em, 30 * em);
SetMinSize(size);
auto rescale = [em](PresetComboBox* pcb) {
pcb->msw_rescale();
wxSize sz = wxSize(35 * em, -1);
pcb->SetMinSize(sz);
pcb->SetSize(sz);
};
for (auto preset_combos : m_preset_combos) {
rescale(preset_combos.presets_left);
rescale(preset_combos.presets_right);
preset_combos.presets_left->msw_rescale();
preset_combos.equal_bmp->msw_rescale();
preset_combos.presets_right->msw_rescale();
}
m_tree->Rescale(em);
@ -2138,9 +2136,9 @@ void DiffPresetDialog::on_sys_color_changed()
#endif
for (auto preset_combos : m_preset_combos) {
preset_combos.presets_left->sys_color_changed();
preset_combos.equal_bmp->sys_color_changed();
preset_combos.presets_right->sys_color_changed();
preset_combos.presets_left->msw_rescale();
preset_combos.equal_bmp->msw_rescale();
preset_combos.presets_right->msw_rescale();
}
// msw_rescale updates just icons, so use it
m_tree->Rescale();

View file

@ -341,15 +341,15 @@ void MachineInfoPanel::init_bitmaps()
void MachineInfoPanel::rescale_bitmaps()
{
m_img_printer.sys_color_changed();
m_img_printer.msw_rescale();
m_printer_img->SetBitmap(m_img_printer.bmp());
m_img_monitor_ams.sys_color_changed();
m_img_monitor_ams.msw_rescale();
m_ams_img->SetBitmap(m_img_monitor_ams.bmp());
m_img_ext.sys_color_changed();
m_img_ext.msw_rescale();
m_ext_img->SetBitmap(m_img_ext.bmp());
upgrade_green_icon.sys_color_changed();
upgrade_gray_icon.sys_color_changed();
upgrade_yellow_icon.sys_color_changed();
upgrade_green_icon.msw_rescale();
upgrade_gray_icon.msw_rescale();
upgrade_yellow_icon.msw_rescale();
m_ota_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}
@ -1288,7 +1288,7 @@ bool UpgradePanel::Show(bool show)
}
void AmsPanel::msw_rescale() {
upgrade_green_icon.sys_color_changed();
upgrade_green_icon.msw_rescale();
m_ams_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}
@ -1362,7 +1362,7 @@ bool UpgradePanel::Show(bool show)
void ExtensionPanel::msw_rescale()
{
upgrade_green_icon.sys_color_changed();
upgrade_green_icon.msw_rescale();
m_ext_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}

View file

@ -230,11 +230,11 @@ void AMSrefresh::paintEvent(wxPaintEvent &evt)
auto colour = StateColor::darkModeColorFor(AMS_CONTROL_GRAY700);
if (!wxWindow::IsEnabled()) { colour = AMS_CONTROL_GRAY500; }
auto pot = wxPoint((size.x - m_bitmap_selected.GetSize().x) / 2, (size.y - m_bitmap_selected.GetSize().y) / 2);
auto pot = wxPoint((size.x - m_bitmap_selected.GetBmpSize().x) / 2, (size.y - m_bitmap_selected.GetBmpSize().y) / 2);
if (!m_disable_mode) {
if (!m_play_loading) {
dc.DrawBitmap(m_selected ? m_bitmap_selected.get_bitmap() : m_bitmap_normal.get_bitmap(), pot);
dc.DrawBitmap(m_selected ? m_bitmap_selected.bmp() : m_bitmap_normal.bmp(), pot);
}
else {
/* m_bitmap_rotation = ScalableBitmap(this, "ams_refresh_normal", 30);
@ -249,7 +249,7 @@ void AMSrefresh::paintEvent(wxPaintEvent &evt)
m_rotation_angle = 0;
}
if (m_rfid_bitmap_list.size() <= 0)return;
dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].get_bitmap(), pot);
dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].bmp(), pot);
}
}
@ -360,7 +360,7 @@ void AMSextruderImage::doRender(wxDC &dc)
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(m_colour);
dc.DrawRectangle(0, FromDIP(18), size.x, size.y - FromDIP(18) - FromDIP(5));
dc.DrawBitmap(m_ams_extruder.get_bitmap(), wxPoint((size.x - m_ams_extruder.GetSize().x) / 2, (size.y - m_ams_extruder.GetSize().y) / 2));
dc.DrawBitmap(m_ams_extruder.bmp(), wxPoint((size.x - m_ams_extruder.GetBmpSize().x) / 2, (size.y - m_ams_extruder.GetBmpSize().y) / 2));
}
@ -688,11 +688,11 @@ void AMSLib::on_left_down(wxMouseEvent &evt)
auto bottom = 0;
if (m_ams_model == AMSModel::GENERIC_AMS) {
top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetSize().y);
top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetBmpSize().y);
bottom = size.y - FromDIP(15);
}
else if (m_ams_model == AMSModel::EXTRA_AMS) {
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetSize().y);
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetBmpSize().y);
bottom = size.y - FromDIP(20);
}
@ -1022,21 +1022,21 @@ void AMSLib::render_extra_lib(wxDC& dc)
if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE)
{
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL)
dc.DrawBitmap(temp_bitmap_third.get_bitmap(), (size.x - temp_bitmap_third.GetSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetSize().y));
dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetBmpSize().y));
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
dc.DrawBitmap(temp_bitmap_brand.get_bitmap(), (size.x - temp_bitmap_brand.GetSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_brand.GetSize().y));
dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_brand.GetBmpSize().y));
}
}
// selected & hover
if (m_selected) {
dc.DrawBitmap(tray_bitmap_selected.get_bitmap(), (size.x - tray_bitmap_selected.GetSize().x) / 2, (size.y - tray_bitmap_selected.GetSize().y) / 2);
dc.DrawBitmap(tray_bitmap_selected.bmp(), (size.x - tray_bitmap_selected.GetBmpSize().x) / 2, (size.y - tray_bitmap_selected.GetBmpSize().y) / 2);
}
else if (!m_selected && m_hover) {
dc.DrawBitmap(tray_bitmap_hover.get_bitmap(), (size.x - tray_bitmap_hover.GetSize().x) / 2, (size.y - tray_bitmap_hover.GetSize().y) / 2);
dc.DrawBitmap(tray_bitmap_hover.bmp(), (size.x - tray_bitmap_hover.GetBmpSize().x) / 2, (size.y - tray_bitmap_hover.GetBmpSize().y) / 2);
}
else {
dc.DrawBitmap(tray_bitmap.get_bitmap(), (size.x - tray_bitmap.GetSize().x) / 2, (size.y - tray_bitmap.GetSize().y) / 2);
dc.DrawBitmap(tray_bitmap.bmp(), (size.x - tray_bitmap.GetBmpSize().x) / 2, (size.y - tray_bitmap.GetBmpSize().y) / 2);
}
}
@ -1116,7 +1116,7 @@ void AMSLib::render_generic_lib(wxDC &dc)
//transparent
auto alpha = m_info.material_colour.Alpha();
if (alpha == 0) {
dc.DrawBitmap(m_bitmap_transparent.get_bitmap(), FromDIP(4), FromDIP(4));
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
}
//gradient
@ -1187,9 +1187,9 @@ void AMSLib::render_generic_lib(wxDC &dc)
if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE)
{
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL)
dc.DrawBitmap(temp_bitmap_third.get_bitmap(), (size.x - temp_bitmap_third.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetSize().y));
dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y));
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
dc.DrawBitmap(temp_bitmap_brand.get_bitmap(), (size.x - temp_bitmap_brand.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetSize().y));
dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y));
}
}
}
@ -1244,7 +1244,8 @@ void AMSLib::UnSelected()
bool AMSLib::Enable(bool enable) { return wxWindow::Enable(enable); }
void AMSLib::msw_rescale()
{ m_bitmap_transparent.sys_color_changed();
{
m_bitmap_transparent.msw_rescale();
}
/*************************************************
@ -1451,20 +1452,20 @@ void AMSRoad::doRender(wxDC &dc)
else {m_show_humidity = false;}
if (m_amsinfo.ams_humidity == 5) {
dc.DrawBitmap(ams_humidity_4.get_bitmap(), wxPoint(size.x - ams_humidity_4.GetSize().x - FromDIP(4), size.y - ams_humidity_4.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_4.bmp(), wxPoint(size.x - ams_humidity_4.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_4.GetBmpSize().y - FromDIP(8)));
}
else if (m_amsinfo.ams_humidity == 4) {
dc.DrawBitmap(ams_humidity_3.get_bitmap(), wxPoint(size.x - ams_humidity_3.GetSize().x - FromDIP(4), size.y - ams_humidity_3.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_3.bmp(), wxPoint(size.x - ams_humidity_3.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_3.GetBmpSize().y - FromDIP(8)));
}
else if (m_amsinfo.ams_humidity == 3) {
dc.DrawBitmap(ams_humidity_2.get_bitmap(), wxPoint(size.x - ams_humidity_2.GetSize().x - FromDIP(4), size.y - ams_humidity_2.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_2.bmp(), wxPoint(size.x - ams_humidity_2.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_2.GetBmpSize().y - FromDIP(8)));
}
else if (m_amsinfo.ams_humidity == 2) {
dc.DrawBitmap(ams_humidity_1.get_bitmap(), wxPoint(size.x - ams_humidity_1.GetSize().x - FromDIP(4), size.y - ams_humidity_1.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_1.bmp(), wxPoint(size.x - ams_humidity_1.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_1.GetBmpSize().y - FromDIP(8)));
}
else if (m_amsinfo.ams_humidity == 1) {
dc.DrawBitmap(ams_humidity_0.get_bitmap(), wxPoint(size.x - ams_humidity_0.GetSize().x - FromDIP(4), size.y - ams_humidity_0.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_0.bmp(), wxPoint(size.x - ams_humidity_0.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_0.GetBmpSize().y - FromDIP(8)));
}
else {
/*dc.DrawBitmap(ams_humidity_4.bmp(), wxPoint(size.x - ams_humidity_4.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_4.GetBmpSize().y - FromDIP(8)));*/
@ -1661,7 +1662,7 @@ void AMSItem::doRender(wxDC &dc)
}else {
if (iter->material_colour.Alpha() == 0) {
dc.DrawBitmap(m_ts_bitmap_cube->get_bitmap(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
dc.DrawBitmap(m_ts_bitmap_cube->bmp(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
}
else {
wxRect rect(left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, AMS_ITEM_CUBE_SIZE.x, AMS_ITEM_CUBE_SIZE.y);
@ -2091,7 +2092,7 @@ void AmsCans::render(wxDC& dc)
void AmsCans::doRender(wxDC& dc)
{
wxSize size = GetSize();
dc.DrawBitmap(m_bitmap_extra_framework.get_bitmap(), (size.x - m_bitmap_extra_framework.GetSize().x) / 2, (size.y - m_bitmap_extra_framework.GetSize().y) / 2);
dc.DrawBitmap(m_bitmap_extra_framework.bmp(), (size.x - m_bitmap_extra_framework.GetBmpSize().x) / 2, (size.y - m_bitmap_extra_framework.GetBmpSize().y) / 2);
//road for extra
if (m_ams_model == AMSModel::EXTRA_AMS) {
@ -2981,9 +2982,9 @@ void AMSControl::StopRridLoading(wxString amsid, wxString canid)
void AMSControl::msw_rescale()
{
m_button_ams_setting_normal.sys_color_changed();
m_button_ams_setting_hover.sys_color_changed();
m_button_ams_setting_press.sys_color_changed();
m_button_ams_setting_normal.msw_rescale();
m_button_ams_setting_hover.msw_rescale();
m_button_ams_setting_press.msw_rescale();
m_button_ams_setting->SetBitmap(m_button_ams_setting_normal.bmp());
m_extruder->msw_rescale();

View file

@ -212,8 +212,7 @@ void AxisCtrlButton::render(wxDC& dc)
gc->DrawPath(home_path);
if (m_icon.bmp().IsOk()) {
gc->DrawBitmap(m_icon.get_bitmap(), -1 * m_icon.GetWidth() / 2, -1 * m_icon.GetHeight() / 2, m_icon.GetWidth(),
m_icon.GetHeight());
gc->DrawBitmap(m_icon.bmp(), -1 * m_icon.GetBmpWidth() / 2, -1 * m_icon.GetBmpHeight() / 2, m_icon.GetBmpWidth(), m_icon.GetBmpHeight());
}
gc->PopState();

View file

@ -146,10 +146,10 @@ bool Button::GetValue() const { return state_handler.states() & StateHandler::Ch
void Button::Rescale()
{
if (this->active_icon.bmp().IsOk())
this->active_icon.sys_color_changed();
this->active_icon.msw_rescale();
if (this->inactive_icon.bmp().IsOk())
this->inactive_icon.sys_color_changed();
this->inactive_icon.msw_rescale();
messureSize();
}
@ -187,7 +187,7 @@ void Button::render(wxDC& dc)
//BBS norrow size between text and icon
szContent.x += padding;
}
szIcon = icon.GetSize();
szIcon = icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y)
szContent.y = szIcon.y;
@ -206,7 +206,7 @@ void Button::render(wxDC& dc)
wxPoint pt = rcContent.GetLeftTop();
if (icon.bmp().IsOk()) {
pt.y += (rcContent.height - szIcon.y) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
dc.DrawBitmap(icon.bmp(), pt);
//BBS norrow size between text and icon
pt.x += szIcon.x + padding;
pt.y = rcContent.y;
@ -239,7 +239,7 @@ void Button::messureSize()
//BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->active_icon.GetSize();
wxSize szIcon = this->active_icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y)
szContent.y = szIcon.y;

View file

@ -24,8 +24,8 @@ CheckBox::CheckBox(wxWindow *parent, int id)
Bind(wxEVT_ENTER_WINDOW, &CheckBox::updateBitmap, this);
Bind(wxEVT_LEAVE_WINDOW, &CheckBox::updateBitmap, this);
#endif
SetSize(m_on.GetSize());
SetMinSize(m_on.GetSize());
SetSize(m_on.GetBmpSize());
SetMinSize(m_on.GetBmpSize());
update();
}
@ -43,16 +43,16 @@ void CheckBox::SetHalfChecked(bool value)
void CheckBox::Rescale()
{
m_on.sys_color_changed();
m_half.sys_color_changed();
m_off.sys_color_changed();
m_on_disabled.sys_color_changed();
m_half_disabled.sys_color_changed();
m_off_disabled.sys_color_changed();
m_on_focused.sys_color_changed();
m_half_focused.sys_color_changed();
m_off_focused.sys_color_changed();
SetSize(m_on.GetSize());
m_on.msw_rescale();
m_half.msw_rescale();
m_off.msw_rescale();
m_on_disabled.msw_rescale();
m_half_disabled.msw_rescale();
m_off_disabled.msw_rescale();
m_on_focused.msw_rescale();
m_half_focused.msw_rescale();
m_off_focused.msw_rescale();
SetSize(m_on.GetBmpSize());
update();
}

View file

@ -98,13 +98,6 @@ void ComboBox::Rescale()
drop.Rescale();
}
bool ComboBox::Enable(bool enable) {
bool ret = TextInput::Enable(enable);
if (ret && drop.selection >= 0 && drop.iconSize.y > 0)
SetIcon(icons[drop.selection]);
return ret;
}
wxString ComboBox::GetValue() const
{
return drop.GetSelection() >= 0 ? drop.GetValue() : GetLabel();
@ -152,17 +145,13 @@ bool ComboBox::SetFont(wxFont const& font)
return TextInput::SetFont(font);
}
void ComboBox::SetIcon(const wxBitmapBundle &icon) {
TextInput::SetIcon(m_isEnabled ? icon : icon.GetBitmapFor(this).ConvertToDisabled(128));
}
int ComboBox::Append(const wxString &item, const wxBitmapBundle &bitmap)
int ComboBox::Append(const wxString &item, const wxBitmap &bitmap)
{
return Append(item, bitmap, nullptr);
}
int ComboBox::Append(const wxString &item,
const wxBitmapBundle &bitmap,
const wxBitmap &bitmap,
void * clientData)
{
texts.push_back(item);
@ -207,9 +196,9 @@ void ComboBox::SetString(unsigned int n, wxString const &value)
if (n == drop.GetSelection()) SetLabel(value);
}
wxBitmap ComboBox::GetItemBitmap(unsigned int n) { return icons[n].GetBitmapFor(m_parent); }
wxBitmap ComboBox::GetItemBitmap(unsigned int n) { return icons[n]; }
void ComboBox::SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap)
void ComboBox::SetItemBitmap(unsigned int n, wxBitmap const &bitmap)
{
if (n >= texts.size()) return;
icons[n] = bitmap;
@ -241,7 +230,9 @@ void ComboBox::DoSetItemClientData(unsigned int n, void *data)
datas[n] = data;
}
void ComboBox::ToggleDropDown(){
void ComboBox::mouseDown(wxMouseEvent &event)
{
SetFocus();
if (drop_down) {
drop.Hide();
} else if (drop.HasDismissLongTime()) {
@ -253,12 +244,6 @@ void ComboBox::ToggleDropDown(){
}
}
void ComboBox::mouseDown(wxMouseEvent &event)
{
SetFocus();
ToggleDropDown();
}
void ComboBox::mouseWheelMoved(wxMouseEvent &event)
{
event.Skip();
@ -276,7 +261,15 @@ void ComboBox::keyDown(wxKeyEvent& event)
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_SPACE:
ToggleDropDown();
if (drop_down) {
drop.DismissAndNotify();
} else if (drop.HasDismissLongTime()) {
drop.autoPosition();
drop_down = true;
drop.Popup();
wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
GetEventHandler()->ProcessEvent(e);
}
break;
case WXK_UP:
case WXK_DOWN:

View file

@ -10,7 +10,7 @@
class ComboBox : public wxWindowWithItems<TextInput, wxItemContainer>
{
std::vector<wxString> texts;
std::vector<wxBitmapBundle> icons;
std::vector<wxBitmap> icons;
std::vector<void *> datas;
std::vector<wxClientDataType> types;
@ -32,9 +32,10 @@ public:
virtual bool SetFont(wxFont const & font) override;
int Append(const wxString &item, const wxBitmapBundle &bitmap = wxNullBitmap);
public:
int Append(const wxString &item, const wxBitmap &bitmap = wxNullBitmap);
int Append(const wxString &item, const wxBitmapBundle &bitmap, void *clientData);
int Append(const wxString &item, const wxBitmap &bitmap, void *clientData);
unsigned int GetCount() const override;
@ -59,12 +60,8 @@ public:
void SetString(unsigned int n, wxString const &value) override;
wxBitmap GetItemBitmap(unsigned int n);
void SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap);
void ToggleDropDown();
bool Enable(bool enable = true) override;
void SetIcon(const wxBitmapBundle &icon) override;
void SetItemBitmap(unsigned int n, wxBitmap const &bitmap);
bool is_drop_down(){return drop_down;}
protected:
virtual int DoInsertItems(const wxArrayStringsAdapter &items,
unsigned int pos,

View file

@ -29,7 +29,7 @@ END_EVENT_TABLE()
*/
DropDown::DropDown(std::vector<wxString> &texts,
std::vector<wxBitmapBundle> &icons)
std::vector<wxBitmap> &icons)
: texts(texts)
, icons(icons)
, state_handler(this)
@ -44,7 +44,7 @@ DropDown::DropDown(std::vector<wxString> &texts,
DropDown::DropDown(wxWindow * parent,
std::vector<wxString> &texts,
std::vector<wxBitmapBundle> &icons,
std::vector<wxBitmap> &icons,
long style)
: DropDown(texts, icons)
{
@ -188,6 +188,15 @@ void DropDown::paintNow()
Refresh();
}
static wxSize GetBmpSize(wxBitmap & bmp)
{
#ifdef __APPLE__
return bmp.GetScaledSize();
#else
return bmp.GetSize();
#endif
}
/*
* Here we do the actual rendering. I put it in a separate
* method so that it can work no matter what type of DC
@ -256,13 +265,13 @@ void DropDown::render(wxDC &dc)
rcContent.x += 5;
rcContent.width -= 5;
if (check_bitmap.bmp().IsOk()) {
auto szBmp = check_bitmap.GetSize();
auto szBmp = check_bitmap.GetBmpSize();
if (selection >= 0) {
wxPoint pt = rcContent.GetLeftTop();
pt.y += (rcContent.height - szBmp.y) / 2;
pt.y += rowSize.y * selection;
if (pt.y + szBmp.y > 0 && pt.y < size.y)
dc.DrawBitmap(check_bitmap.get_bitmap(), pt);
dc.DrawBitmap(check_bitmap.bmp(), pt);
}
rcContent.x += szBmp.x + 5;
rcContent.width -= szBmp.x + 5;
@ -277,17 +286,17 @@ void DropDown::render(wxDC &dc)
if (rcContent.y > size.y) break;
wxPoint pt = rcContent.GetLeftTop();
auto & icon = icons[i];
auto size2 = get_preferred_size(icon, m_parent);
auto size2 = GetBmpSize(icon);
if (iconSize.x > 0) {
if (icon.IsOk()) {
pt.y += (rcContent.height - size2.y) / 2;
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
dc.DrawBitmap(icon, pt);
}
pt.x += iconSize.x + 5;
pt.y = rcContent.y;
} else if (icon.IsOk()) {
pt.y += (rcContent.height - size2.y) / 2;
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
dc.DrawBitmap(icon, pt);
pt.x += size2.x + 5;
pt.y = rcContent.y;
}
@ -317,7 +326,7 @@ void DropDown::messureSize()
for (size_t i = 0; i < texts.size(); ++i) {
wxSize size1 = text_off ? wxSize() : dc.GetMultiLineTextExtent(texts[i]);
if (icons[i].IsOk()) {
wxSize size2 = get_preferred_size(icons[i], m_parent);
wxSize size2 = GetBmpSize(icons[i]);
if (size2.x > iconSize.x) iconSize = size2;
if (!align_icon) {
size1.x += size2.x + (text_off ? 0 : 5);
@ -329,7 +338,7 @@ void DropDown::messureSize()
wxSize szContent = textSize;
szContent.x += 10;
if (check_bitmap.bmp().IsOk()) {
auto szBmp = check_bitmap.GetSize();
auto szBmp = check_bitmap.GetBmpSize();
szContent.x += szBmp.x + 5;
}
if (iconSize.x > 0) szContent.x += iconSize.x + (text_off ? 0 : 5);

View file

@ -15,7 +15,7 @@ wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent);
class DropDown : public PopupWindow
{
std::vector<wxString> & texts;
std::vector<wxBitmapBundle> & icons;
std::vector<wxBitmap> & icons;
bool need_sync = false;
int selection = -1;
int hover_item = -1;
@ -44,11 +44,11 @@ class DropDown : public PopupWindow
public:
DropDown(std::vector<wxString> &texts,
std::vector<wxBitmapBundle> &icons);
std::vector<wxBitmap> &icons);
DropDown(wxWindow * parent,
std::vector<wxString> &texts,
std::vector<wxBitmapBundle> &icons,
std::vector<wxBitmap> &icons,
long style = 0);
void Create(wxWindow * parent,

View file

@ -62,8 +62,8 @@ void Fan::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSi
// SetMinSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
// SetMaxSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
//#else
SetMinSize(wxSize(m_bitmap_bk.GetSize().x, m_bitmap_bk.GetSize().y + FromDIP(6)));
SetMaxSize(wxSize(m_bitmap_bk.GetSize().x, m_bitmap_bk.GetSize().y + FromDIP(6)));
SetMinSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
SetMaxSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
//#endif // __APPLE__
Bind(wxEVT_PAINT, &Fan::paintEvent, this);
@ -115,7 +115,7 @@ void Fan::doRender(wxDC& dc)
auto rpm = wxT("rpm");
wxSize size = GetSize();
dc.DrawBitmap(m_bitmap_bk.get_bitmap(), wxPoint(0,0));
dc.DrawBitmap(m_bitmap_bk.bmp(), wxPoint(0,0));
//fan scale
/*auto central_point = wxPoint(size.x / 2, size.y / 2 + FromDIP(15));
@ -133,8 +133,8 @@ void Fan::doRender(wxDC& dc)
//fan pointer
//auto pointer_central_point = wxPoint((size.x - m_img_pointer.GetSize().x) / 2, (size.y - m_img_pointer.GetSize().y) / 2);
//auto bmp = m_img_pointer.Rotate(m_rotate_offsets[m_current_speeds].rotate, wxPoint(size.x / 2,size.y / 2));
auto central_point = wxPoint((size.x - m_bitmap_scales[m_current_speeds].GetSize().x) / 2, (size.y - m_bitmap_scales[m_current_speeds].GetSize().y) / 2 - FromDIP(4));
dc.DrawBitmap(m_bitmap_scales[m_current_speeds].get_bitmap(), central_point.x, central_point.y);
auto central_point = wxPoint((size.x - m_bitmap_scales[m_current_speeds].GetBmpSize().x) / 2, (size.y - m_bitmap_scales[m_current_speeds].GetBmpSize().y) / 2 - FromDIP(4));
dc.DrawBitmap(m_bitmap_scales[m_current_speeds].bmp(), central_point.x, central_point.y);
//fan val
dc.SetTextForeground(DRAW_TEXT_COLOUR);
@ -147,7 +147,8 @@ void Fan::doRender(wxDC& dc)
//dc.DrawText(rpm, (size.x - dc.GetTextExtent(rpm).x) / 2, size.y - dc.GetTextExtent(rpm).y);
}
void Fan::msw_rescale() { m_bitmap_bk.sys_color_changed();
void Fan::msw_rescale() {
m_bitmap_bk.msw_rescale();
}
void Fan::DoSetSize(int x, int y, int width, int height, int sizeFlags)
@ -279,8 +280,8 @@ void FanOperate::doRender(wxDC& dc)
dc.DrawLine(left_fir, FromDIP(4), left_fir, size.y - FromDIP(4));
dc.DrawLine(left_fir * 2, FromDIP(4), left_fir * 2, size.y - FromDIP(4));
dc.DrawBitmap(m_bitmap_decrease.get_bitmap(), (left_fir - m_bitmap_decrease.GetSize().x) / 2, (size.y - m_bitmap_decrease.GetSize().y) / 2);
dc.DrawBitmap(m_bitmap_add.get_bitmap(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetSize().x) / 2), (size.y - m_bitmap_add.GetSize().y) / 2);
dc.DrawBitmap(m_bitmap_decrease.bmp(), (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2, (size.y - m_bitmap_decrease.GetBmpSize().y) / 2);
dc.DrawBitmap(m_bitmap_add.bmp(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2), (size.y - m_bitmap_add.GetBmpSize().y) / 2);
//txt
dc.SetFont(::Label::Body_12);

View file

@ -110,12 +110,12 @@ void ImageSwitchButton::render(wxDC& dc)
wxSize szContent = textSize;
ScalableBitmap &icon = GetValue() ? m_on : m_off;
int content_height = icon.GetHeight() + textSize.y + m_padding;
int content_height = icon.GetBmpHeight() + textSize.y + m_padding;
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 2, (size.y - content_height) / 2);
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
if (icon.bmp().IsOk()) {
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.y += m_padding + icon.GetHeight();
dc.DrawBitmap(icon.bmp(), pt);
pt.y += m_padding + icon.GetBmpHeight();
}
pt.x = (size.x - textSize.x) / 2;
dc.SetFont(GetFont());
@ -273,7 +273,7 @@ void FanSwitchButton::render(wxDC& dc)
//int content_height = icon.GetBmpHeight() + textSize.y + m_padding;
int content_height = m_padding;
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 2, (size.y - content_height) / 2);
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
pt.x = (size.x - textSize.x) / 2;
dc.SetFont(GetFont());
@ -298,10 +298,10 @@ void FanSwitchButton::render(wxDC& dc)
dc.DrawText(fina_txt, wxPoint(pt.x, content_height));
}
pt = wxPoint((size.x - icon.GetWidth()) / 2, content_height + textSize.y);
pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, content_height + textSize.y);
if (icon.bmp().IsOk()) {
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.y += m_padding + icon.GetHeight();
dc.DrawBitmap(icon.bmp(), pt);
pt.y += m_padding + icon.GetBmpHeight();
}
auto speed = wxString::Format("%d%%", m_speed);

View file

@ -10,8 +10,8 @@ RadioBox::RadioBox(wxWindow *parent)
// SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
if (parent) SetBackgroundColour(parent->GetBackgroundColour());
// Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { update(); e.Skip(); });
SetSize(m_on.GetSize());
SetMinSize(m_on.GetSize());
SetSize(m_on.GetBmpSize());
SetMinSize(m_on.GetBmpSize());
update();
}
@ -29,9 +29,9 @@ bool RadioBox::GetValue()
void RadioBox::Rescale()
{
m_on.sys_color_changed();
m_off.sys_color_changed();
SetSize(m_on.GetSize());
m_on.msw_rescale();
m_off.msw_rescale();
SetSize(m_on.GetBmpSize());
update();
}

View file

@ -157,7 +157,7 @@ bool SideButton::Enable(bool enable)
void SideButton::Rescale()
{
if (this->icon.bmp().IsOk())
this->icon.sys_color_changed();
this->icon.msw_rescale();
messureSize();
}
@ -246,7 +246,7 @@ void SideButton::dorender(wxDC& dc, wxDC& text_dc)
//BBS norrow size between text and icon
szContent.x += 5;
}
szIcon = icon.GetSize();
szIcon = icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y)
szContent.y = szIcon.y;
@ -270,7 +270,7 @@ void SideButton::dorender(wxDC& dc, wxDC& text_dc)
//BBS extra pixels for icon
pt.x += icon_offset;
pt.y += (rcContent.height - szIcon.y) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
dc.DrawBitmap(icon.bmp(), pt);
//BBS norrow size between text and icon
pt.x += szIcon.x + 5;
pt.y = rcContent.y;
@ -299,7 +299,7 @@ void SideButton::messureSize()
if (szContent.y > 0) {
szContent.x += 5;
}
wxSize szIcon = this->icon.GetSize();
wxSize szIcon = this->icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y)
szContent.y = szIcon.y;

View file

@ -150,19 +150,19 @@ void SideToolsPanel::doRender(wxDC &dc)
dc.SetBrush(SIDE_TOOLS_BRAND);
dc.DrawRectangle(0, 0, size.x, size.y);
dc.DrawBitmap(m_none_printing_img.get_bitmap(), left, (size.y - m_none_printing_img.GetSize().y) / 2);
dc.DrawBitmap(m_none_printing_img.bmp(), left, (size.y - m_none_printing_img.GetBmpSize().y) / 2);
left += (m_none_printing_img.GetSize().x + FromDIP(15));
dc.DrawBitmap(m_none_arrow_img.get_bitmap(), left, (size.y - m_none_arrow_img.GetSize().y) / 2);
left += (m_none_printing_img.GetBmpSize().x + FromDIP(15));
dc.DrawBitmap(m_none_arrow_img.bmp(), left, (size.y - m_none_arrow_img.GetBmpSize().y) / 2);
left += (m_none_arrow_img.GetSize().x + FromDIP(6));
left += (m_none_arrow_img.GetBmpSize().x + FromDIP(6));
dc.SetFont(::Label::Body_14);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(*wxWHITE);
wxString no_printer_str = _L("No printer");
auto sizet = dc.GetTextExtent(no_printer_str);
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetSize().x - m_none_add_img.GetSize().x;
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetBmpSize().x - m_none_add_img.GetBmpSize().x;
auto size_width = left_add_bitmap - left;
if (sizet.x > size_width) {
@ -181,21 +181,21 @@ void SideToolsPanel::doRender(wxDC &dc)
dc.DrawText(no_printer_str, wxPoint(left, (size.y - sizet.y) / 2));
left = size.x - FromDIP(30) - m_wifi_none_img.GetSize().x;
dc.DrawBitmap(m_none_add_img.get_bitmap(), left, (size.y - m_none_add_img.GetSize().y) / 2);
left = size.x - FromDIP(30) - m_wifi_none_img.GetBmpSize().x;
dc.DrawBitmap(m_none_add_img.bmp(), left, (size.y - m_none_add_img.GetBmpSize().y) / 2);
} else {
dc.DrawBitmap(m_printing_img.get_bitmap(), left, (size.y - m_printing_img.GetSize().y) / 2);
dc.DrawBitmap(m_printing_img.bmp(), left, (size.y - m_printing_img.GetBmpSize().y) / 2);
left += (m_printing_img.GetSize().x + FromDIP(5));
dc.DrawBitmap(m_arrow_img.get_bitmap(), left, (size.y - m_arrow_img.GetSize().y) / 2);
left += (m_printing_img.GetBmpSize().x + FromDIP(5));
dc.DrawBitmap(m_arrow_img.bmp(), left, (size.y - m_arrow_img.GetBmpSize().y) / 2);
left += (m_arrow_img.GetSize().x + FromDIP(6));
left += (m_arrow_img.GetBmpSize().x + FromDIP(6));
dc.SetFont(::Label::Body_14);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SIDE_TOOLS_GREY900));
auto sizet = dc.GetTextExtent(m_dev_name);
auto text_end = size.x - m_wifi_none_img.GetSize().x - 20;
auto text_end = size.x - m_wifi_none_img.GetBmpSize().x - 20;
std::string finally_name = m_dev_name.ToStdString();
if (sizet.x > (text_end - left)) {
@ -212,12 +212,12 @@ void SideToolsPanel::doRender(wxDC &dc)
dc.DrawText(finally_name, wxPoint(left, (size.y - sizet.y) / 2));
left = size.x - FromDIP(18) - m_wifi_none_img.GetSize().x;
if (m_wifi_type == WifiSignal::NONE) dc.DrawBitmap(m_wifi_none_img.get_bitmap(), left, (size.y - m_wifi_none_img.GetSize().y) / 2);
if (m_wifi_type == WifiSignal::WEAK) dc.DrawBitmap(m_wifi_weak_img.get_bitmap(), left, (size.y - m_wifi_weak_img.GetSize().y) / 2);
if (m_wifi_type == WifiSignal::MIDDLE) dc.DrawBitmap(m_wifi_middle_img.get_bitmap(), left, (size.y - m_wifi_middle_img.GetSize().y) / 2);
if (m_wifi_type == WifiSignal::STRONG) dc.DrawBitmap(m_wifi_strong_img.get_bitmap(), left, (size.y - m_wifi_strong_img.GetSize().y) / 2);
if (m_wifi_type == WifiSignal::WIRED) dc.DrawBitmap(m_network_wired_img.get_bitmap(), left, (size.y - m_network_wired_img.GetSize().y) / 2);
left = size.x - FromDIP(18) - m_wifi_none_img.GetBmpSize().x;
if (m_wifi_type == WifiSignal::NONE) dc.DrawBitmap(m_wifi_none_img.bmp(), left, (size.y - m_wifi_none_img.GetBmpSize().y) / 2);
if (m_wifi_type == WifiSignal::WEAK) dc.DrawBitmap(m_wifi_weak_img.bmp(), left, (size.y - m_wifi_weak_img.GetBmpSize().y) / 2);
if (m_wifi_type == WifiSignal::MIDDLE) dc.DrawBitmap(m_wifi_middle_img.bmp(), left, (size.y - m_wifi_middle_img.GetBmpSize().y) / 2);
if (m_wifi_type == WifiSignal::STRONG) dc.DrawBitmap(m_wifi_strong_img.bmp(), left, (size.y - m_wifi_strong_img.GetBmpSize().y) / 2);
if (m_wifi_type == WifiSignal::WIRED) dc.DrawBitmap(m_network_wired_img.bmp(), left, (size.y - m_network_wired_img.GetBmpSize().y) / 2);
}
if (m_hover) {

View file

@ -46,7 +46,7 @@ void StaticLine::SetLineColour(wxColour color)
void StaticLine::Rescale()
{
if (this->icon.bmp().IsOk())
this->icon.sys_color_changed();
this->icon.msw_rescale();
messureSize();
}
@ -67,7 +67,7 @@ void StaticLine::messureSize()
// BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->icon.GetSize();
wxSize szIcon = this->icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}
@ -90,13 +90,13 @@ void StaticLine::render(wxDC& dc)
auto label = GetLabel();
if (!label.IsEmpty()) textSize = dc.GetTextExtent(label);
wxRect titleRect{{0, 0}, size};
titleRect.height = wxMax(icon.GetHeight(), textSize.GetHeight());
int contentWidth = icon.GetWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
titleRect.height = wxMax(icon.GetBmpHeight(), textSize.GetHeight());
int contentWidth = icon.GetBmpWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
textSize.GetWidth();
if (vertical) titleRect.Deflate((size.GetWidth() - contentWidth) / 2, 0);
if (icon.bmp().IsOk()) {
dc.DrawBitmap(icon.get_bitmap(), {0, (size.y - icon.GetHeight()) / 2});
titleRect.x += icon.GetWidth() + 5;
dc.DrawBitmap(icon.bmp(), {0, (size.y - icon.GetBmpHeight()) / 2});
titleRect.x += icon.GetBmpWidth() + 5;
}
if (!label.IsEmpty()) {
dc.SetTextForeground(StateColor::darkModeColorFor(GetForegroundColour()));

View file

@ -122,15 +122,15 @@ StepCtrl::StepCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wx
, bmp_thumb(this, "step_thumb", 36)
{
StaticBox::border_width = 3;
radius = radius * bmp_thumb.GetHeight() / 36;
bar_width = bar_width * bmp_thumb.GetHeight() / 36;
radius = radius * bmp_thumb.GetBmpHeight() / 36;
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
}
void StepCtrl::Rescale()
{
bmp_thumb.sys_color_changed();
radius = radius * bmp_thumb.GetHeight() / 36;
bar_width = bar_width * bmp_thumb.GetHeight() / 36;
bmp_thumb.msw_rescale();
radius = radius * bmp_thumb.GetBmpHeight() / 36;
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
}
void StepCtrl::mouseDown(wxMouseEvent &event)
@ -141,7 +141,7 @@ void StepCtrl::mouseDown(wxMouseEvent &event)
int itemWidth = size.x / steps.size();
wxRect rcBar = {0, (size.y - 60) / 2, size.x, 60};
int circleX = itemWidth / 2 + itemWidth * step;
wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetSize()};
wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetBmpSize()};
rcThumb.x -= rcThumb.width / 2;
rcThumb.y -= rcThumb.height / 2;
if (rcThumb.Contains(pt)) {
@ -235,8 +235,8 @@ void StepCtrl::doRender(wxDC &dc)
dc.SetTextForeground(clr_tip.colorForStates(states));
wxSize sz = dc.GetTextExtent(tips[i]);
dc.DrawText(tips[i], circleX - sz.x / 2, circleY - 20 - sz.y);
sz = bmp_thumb.GetSize();
dc.DrawBitmap(bmp_thumb.get_bitmap(), circleX - sz.x / 2, circleY - sz.y / 2);
sz = bmp_thumb.GetBmpSize();
dc.DrawBitmap(bmp_thumb.bmp(), circleX - sz.x / 2, circleY - sz.y / 2);
}
circleX += itemWidth;
}
@ -260,16 +260,16 @@ StepIndicator::StepIndicator(wxWindow *parent, wxWindowID id, const wxPoint &pos
std::make_pair(0x6B6B6B, 0));
clr_tip = *wxWHITE;
StaticBox::border_width = 0;
radius = bmp_ok.GetHeight() / 2;
bar_width = bmp_ok.GetHeight() / 20;
radius = bmp_ok.GetBmpHeight() / 2;
bar_width = bmp_ok.GetBmpHeight() / 20;
if (bar_width < 2) bar_width = 2;
}
void StepIndicator::Rescale()
{
bmp_ok.sys_color_changed();
radius = bmp_ok.GetHeight() / 2;
bar_width = bmp_ok.GetHeight() / 20;
bmp_ok.msw_rescale();
radius = bmp_ok.GetBmpHeight() / 2;
bar_width = bmp_ok.GetBmpHeight() / 20;
if (bar_width < 2) bar_width = 2;
}
@ -319,8 +319,8 @@ void StepIndicator::doRender(wxDC &dc)
dc.DrawEllipse(circleX - radius, circleY - radius, radius * 2, radius * 2);
// Draw content ( icon or text ) in circle
if (disabled) {
wxSize sz = bmp_ok.GetSize();
dc.DrawBitmap(bmp_ok.get_bitmap(), circleX - radius, circleY - radius);
wxSize sz = bmp_ok.GetBmpSize();
dc.DrawBitmap(bmp_ok.bmp(), circleX - radius, circleY - radius);
} else {
dc.SetFont(font_tip);
dc.SetTextForeground(clr_tip.colorForStates(states));

View file

@ -9,8 +9,8 @@
SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id)
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxBU_EXACTFIT)
, m_on(this, "toggle_on", {28, 16})
, m_off(this, "toggle_off", {28, 16})
, m_on(this, "toggle_on", 16)
, m_off(this, "toggle_off", 16)
, text_color(std::pair{0xfffffe, (int) StateColor::Checked}, std::pair{0x6B6B6B, (int) StateColor::Normal})
, track_color(0xD9D9D9)
, thumb_color(std::pair{0x009688, (int) StateColor::Checked}, std::pair{0xD9D9D9, (int) StateColor::Normal})
@ -58,8 +58,8 @@ void SwitchButton::SetValue(bool value)
void SwitchButton::Rescale()
{
if (labels[0].IsEmpty()) {
m_on.sys_color_changed();
m_off.sys_color_changed();
m_on.msw_rescale();
m_off.msw_rescale();
}
else {
SetBackgroundColour(StaticBox::GetParentBackgroundColor(GetParent()));
@ -101,8 +101,7 @@ void SwitchButton::Rescale()
for (int i = 0; i < 2; ++i) {
wxMemoryDC memdc(&dc);
#ifdef __WXMSW__
wxBitmap bmp;
bmp.CreateWithDIPSize(ToDIP(trackSize), GetDPIScaleFactor());
wxBitmap bmp(trackSize.x, trackSize.y);
memdc.SelectObject(bmp);
memdc.SetBackground(wxBrush(GetBackgroundColour()));
memdc.Clear();
@ -139,12 +138,11 @@ void SwitchButton::Rescale()
(i == 0 ? m_off : m_on).bmp() = bmp;
}
}
SetSize(m_on.GetSize());
SetSize(m_on.GetBmpSize());
update();
}
void SwitchButton::update()
{
SetBitmap((GetValue() ? m_on : m_off).bmp());
}

View file

@ -43,7 +43,9 @@ TabCtrl::TabCtrl(wxWindow * parent,
}
TabCtrl::~TabCtrl()
{}
{
delete images;
}
int TabCtrl::GetSelection() const { return sel; }
@ -165,6 +167,13 @@ void TabCtrl::SetItemData(unsigned int item, void* clientData)
btns[item]->SetClientData(clientData);
}
void TabCtrl::AssignImageList(wxImageList* imageList)
{
if (images == imageList) return;
delete images;
images = imageList;
}
void TabCtrl::SetItemTextColour(unsigned int item, const StateColor &col)
{
if (item >= btns.size()) return;

View file

@ -9,6 +9,7 @@ wxDECLARE_EVENT( wxEVT_TAB_SEL_CHANGED, wxCommandEvent );
class TabCtrl : public StaticBox
{
std::vector<Button*> btns;
wxImageList* images = nullptr;
wxBoxSizer * sizer = nullptr;
int sel = -1;
@ -52,6 +53,8 @@ public:
void* GetItemData(unsigned int item) const;
void SetItemData(unsigned int item, void *clientData);
void AssignImageList(wxImageList *imageList);
void SetItemTextColour(unsigned int item, const StateColor& col);
/* fakes */

View file

@ -280,10 +280,8 @@ void TempInput::SetLabelColor(StateColor const &color)
void TempInput::Rescale()
{
if (this->normal_icon.bmp().IsOk())
this->normal_icon.sys_color_changed();
if (this->degree_icon.bmp().IsOk())
this->degree_icon.sys_color_changed();
if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
if (this->degree_icon.bmp().IsOk()) this->degree_icon.msw_rescale();
messureSize();
}
@ -319,7 +317,7 @@ void TempInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
auto left = padding_left;
wxClientDC dc(this);
if (normal_icon.bmp().IsOk()) {
wxSize szIcon = normal_icon.GetSize();
wxSize szIcon = normal_icon.GetBmpSize();
left += szIcon.x;
}
@ -381,18 +379,18 @@ void TempInput::render(wxDC &dc)
// start draw
wxPoint pt = {padding_left, 0};
if (actice_icon.bmp().IsOk() && actice) {
wxSize szIcon = actice_icon.GetSize();
wxSize szIcon = actice_icon.GetBmpSize();
pt.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(actice_icon.get_bitmap(), pt);
dc.DrawBitmap(actice_icon.bmp(), pt);
pt.x += szIcon.x + 9;
} else {
actice = false;
}
if (normal_icon.bmp().IsOk() && !actice) {
wxSize szIcon = normal_icon.GetSize();
wxSize szIcon = normal_icon.GetBmpSize();
pt.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(normal_icon.get_bitmap(), pt);
dc.DrawBitmap(normal_icon.bmp(), pt);
pt.x += szIcon.x + 9;
}
@ -437,10 +435,10 @@ void TempInput::render(wxDC &dc)
// flag
if (degree_icon.bmp().IsOk()) {
auto pos = text_ctrl->GetPosition();
wxSize szIcon = degree_icon.GetSize();
wxSize szIcon = degree_icon.GetBmpSize();
pt.y = (size.y - szIcon.y) / 2;
pt.x = pos.x + text_ctrl->GetSize().x;
dc.DrawBitmap(degree_icon.get_bitmap(), pt);
dc.DrawBitmap(degree_icon.bmp(), pt);
}
}
@ -454,7 +452,7 @@ void TempInput::messureMiniSize()
wxClientDC dc(this);
if (normal_icon.bmp().IsOk()) {
wxSize szIcon = normal_icon.GetSize();
wxSize szIcon = normal_icon.GetBmpSize();
width += szIcon.x;
height = szIcon.y;
}
@ -483,7 +481,7 @@ void TempInput::messureMiniSize()
height = textSize.y > height ? textSize.y : height;
// flag flag
auto flagSize = degree_icon.GetSize();
auto flagSize = degree_icon.GetBmpSize();
width += flagSize.x;
height = flagSize.y > height ? flagSize.y : height;
@ -508,7 +506,7 @@ void TempInput::messureSize()
wxClientDC dc(this);
if (normal_icon.bmp().IsOk()) {
wxSize szIcon = normal_icon.GetSize();
wxSize szIcon = normal_icon.GetBmpSize();
width += szIcon.x;
height = szIcon.y;
}
@ -537,7 +535,7 @@ void TempInput::messureSize()
height = textSize.y > height ? textSize.y : height;
// flag flag
auto flagSize = degree_icon.GetSize();
auto flagSize = degree_icon.GetBmpSize();
width += flagSize.x;
height = flagSize.y > height ? flagSize.y : height;

View file

@ -76,7 +76,7 @@ void TextInput::Create(wxWindow * parent,
});
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
if (!icon.IsEmpty()) {
this->drop_down_icon = ScalableBitmap(this, icon.ToStdString(), 16);
this->icon = ScalableBitmap(this, icon.ToStdString(), 16);
}
messureSize();
}
@ -94,9 +94,11 @@ void TextInput::SetLabel(const wxString& label)
Refresh();
}
void TextInput::SetIcon(const wxBitmapBundle &icon_in)
void TextInput::SetIcon(const wxBitmap &icon)
{
icon = icon_in;
this->icon = ScalableBitmap();
this->icon.bmp() = icon;
Rescale();
}
void TextInput::SetLabelColor(StateColor const &color)
@ -113,9 +115,8 @@ void TextInput::SetTextColor(StateColor const& color)
void TextInput::Rescale()
{
if (text_ctrl)
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
if (!this->icon.name().empty())
this->icon.msw_rescale();
messureSize();
Refresh();
}
@ -151,22 +152,16 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (sizeFlags & wxSIZE_USE_EXISTING) return;
wxSize size = GetSize();
wxPoint textPos = {5, 0};
if (this->icon.IsOk()) {
wxSize szIcon = get_preferred_size(icon, m_parent);
if (this->icon.bmp().IsOk()) {
wxSize szIcon = this->icon.GetBmpSize();
textPos.x += szIcon.x;
}
wxSize dd_icon_size = wxSize(0,0);
if (this->drop_down_icon.bmp().IsOk())
dd_icon_size = this->drop_down_icon.GetSize();
bool align_right = GetWindowStyle() & wxRIGHT;
if (align_right)
textPos.x += labelSize.x;
if (text_ctrl) {
wxSize textSize = text_ctrl->GetSize();
wxClientDC dc(this);
const int r_shift = int((dd_icon_size.x == 0 ? 3. : 2.) * dc.GetContentScaleFactor());
textSize.x = size.x - textPos.x - labelSize.x - dd_icon_size.x - r_shift;
textSize.x = size.x - textPos.x - labelSize.x - 10;
text_ctrl->SetSize(textSize);
text_ctrl->SetPosition({textPos.x, (size.y - textSize.y) / 2});
}
@ -198,26 +193,12 @@ void TextInput::render(wxDC& dc)
bool align_right = GetWindowStyle() & wxRIGHT;
// start draw
wxPoint pt = {5, 0};
if (icon.IsOk()) {
wxSize szIcon = get_preferred_size(icon, m_parent);
if (icon.bmp().IsOk()) {
wxSize szIcon = icon.GetBmpSize();
pt.y = (size.y - szIcon.y) / 2;
#ifdef __WXGTK3__
dc.DrawBitmap(icon.GetBitmap(szIcon), pt);
#else
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
#endif
dc.DrawBitmap(icon.bmp(), pt);
pt.x += szIcon.x + 0;
}
// drop_down_icon draw
wxPoint pt_r = {size.x, 0};
if (drop_down_icon.bmp().IsOk()) {
wxSize szIcon = drop_down_icon.GetSize();
pt_r.x -= szIcon.x + 2;
pt_r.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(drop_down_icon.get_bitmap(), pt_r);
}
auto text = wxWindow::GetLabel();
if (!text.IsEmpty()) {
wxSize textSize = text_ctrl->GetSize();

View file

@ -8,11 +8,10 @@ class TextInput : public wxNavigationEnabled<StaticBox>
{
wxSize labelSize;
wxBitmapBundle icon;
ScalableBitmap drop_down_icon;
ScalableBitmap icon;
StateColor label_color;
StateColor text_color;
wxTextCtrl* text_ctrl{nullptr};
wxTextCtrl * text_ctrl;
static const int TextInputWidth = 200;
static const int TextInputHeight = 50;
@ -41,7 +40,7 @@ public:
void SetLabel(const wxString& label);
virtual void SetIcon(const wxBitmapBundle & icon);
void SetIcon(const wxBitmap & icon);
void SetLabelColor(StateColor const &color);

View file

@ -14,6 +14,7 @@
#include <wx/sizer.h>
using namespace Slic3r::GUI;
int scale(const int val) { return val * Slic3r::GUI::wxGetApp().em_unit() / 10; }
@ -253,7 +254,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
);
if (flags & wxRESET) {
Button *calc_btn = new Button(this, _L("Recalculate"));
Button *calc_btn = new Button(this, _L("Auto-Calc"));
calc_btn->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
calc_btn->SetCornerRadius(FromDIP(12));
calc_btn->SetBackgroundColor(calc_btn_bg);
@ -261,7 +262,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
calc_btn->SetTextColor(calc_btn_text);
calc_btn->SetFocus();
calc_btn->SetId(wxID_RESET);
btn_sizer->Add(calc_btn, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
btn_sizer->Add(calc_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxRESET] = calc_btn;
}
if (flags & wxOK) {
@ -284,7 +285,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
cancel_btn->SetBorderColor(cancel_btn_bd_);
cancel_btn->SetTextColor(cancel_btn_text);
cancel_btn->SetId(wxID_CANCEL);
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP / 2);
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxCANCEL] = cancel_btn;
}
@ -292,6 +293,35 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
}
wxBoxSizer* WipingPanel::create_calc_btn_sizer(wxWindow* parent) {
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
StateColor calc_btn_bg(
std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
);
StateColor calc_btn_bd(
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
);
StateColor calc_btn_text(
std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal)
);
Button* calc_btn = new Button(parent, _L("Re-calculate"));
calc_btn->SetFont(Label::Body_13);
calc_btn->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
calc_btn->SetCornerRadius(FromDIP(12));
calc_btn->SetBackgroundColor(calc_btn_bg);
calc_btn->SetBorderColor(calc_btn_bd);
calc_btn->SetTextColor(calc_btn_text);
calc_btn->SetFocus();
btn_sizer->Add(calc_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
calc_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { calc_flushing_volumes(); });
return btn_sizer;
}
void WipingDialog::on_dpi_changed(const wxRect &suggested_rect)
{
for (auto button_item : m_button_list)
@ -345,7 +375,7 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
main_sizer->SetMinSize(wxSize(sizer_width, -1));
main_sizer->Add(m_panel_wiping, 1, wxEXPAND | wxALL, 0);
auto btn_sizer = create_btn_sizer(wxOK | wxCANCEL | wxRESET);
auto btn_sizer = create_btn_sizer(wxOK | wxCANCEL);
main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BTN_GAP);
SetSizer(main_sizer);
main_sizer->SetSizeHints(this);
@ -353,6 +383,7 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
if (this->FindWindowById(wxID_OK, this)) {
this->FindWindowById(wxID_OK, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { // if OK button is clicked..
m_output_matrix = m_panel_wiping->read_matrix_values(); // ..query wiping panel and save returned values
m_output_extruders = m_panel_wiping->read_extruders_values(); // so they can be recovered later by calling get_...()
EndModal(wxID_OK);
}, wxID_OK);
}
@ -362,9 +393,11 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
}
/*
if (this->FindWindowById(wxID_RESET, this)) {
this->FindWindowById(wxID_RESET, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { m_panel_wiping->calc_flushing_volumes(); });
}
*/
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
@ -394,7 +427,6 @@ void WipingPanel::create_panels(wxWindow* parent, const int num) {
icon->SetCanFocus(false);
icon_list2.push_back(icon);
sizer->AddStretchSpacer();
sizer->AddSpacer(ROW_BEG_PADDING);
sizer->Add(icon, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, ROW_VERT_PADDING);
@ -406,9 +438,8 @@ void WipingPanel::create_panels(wxWindow* parent, const int num) {
sizer->Add(edit_boxes[j][i], 0, wxALIGN_CENTER_VERTICAL, 0);
}
sizer->AddSpacer(ROW_END_PADDING);
sizer->AddStretchSpacer();
m_sizer->Add(panel, 0, wxRIGHT | wxLEFT | wxEXPAND, TABLE_BORDER);
m_sizer_advanced->Add(panel, 0, wxRIGHT | wxLEFT | wxEXPAND, TABLE_BORDER);
panel->Layout();
}
}
@ -426,12 +457,22 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
Slic3r::decode_color(color, rgb);
m_colours.push_back(wxColor(rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar()));
}
auto sizer_width = (int)((sqrt(matrix.size())) * ITEM_WIDTH() + (sqrt(matrix.size()) + 1) * HEADER_BEG_PADDING);
sizer_width = sizer_width > MIN_WIPING_DIALOG_WIDTH ? sizer_width : MIN_WIPING_DIALOG_WIDTH;
m_sizer = new wxBoxSizer(wxVERTICAL);
this->SetBackgroundColour(*wxWHITE);
update_ui(this);
// Create two switched panels with their own sizers
m_sizer_simple = new wxBoxSizer(wxVERTICAL);
m_sizer_advanced = new wxBoxSizer(wxVERTICAL);
m_page_simple = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_page_advanced = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_page_simple->SetSizer(m_sizer_simple);
m_page_advanced->SetSizer(m_sizer_advanced);
m_page_advanced->SetBackgroundColour(*wxWHITE);
update_ui(m_page_simple);
update_ui(m_page_advanced);
auto gridsizer_simple = new wxGridSizer(3, 5, 10);
m_gridsizer_advanced = new wxGridSizer(m_number_of_extruders + 1, 5, 1);
// First create controls for advanced mode and assign them to m_page_advanced:
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
@ -439,17 +480,17 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
for (unsigned int j = 0; j < m_number_of_extruders; ++j) {
#ifdef _WIN32
wxTextCtrl* text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), wxTE_CENTER | wxBORDER_NONE | wxTE_PROCESS_ENTER);
wxTextCtrl* text = new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), wxTE_CENTER | wxBORDER_NONE | wxTE_PROCESS_ENTER);
update_ui(text);
edit_boxes.back().push_back(text);
#else
edit_boxes.back().push_back(new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1)));
edit_boxes.back().push_back(new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1)));
#endif
if (i == j) {
edit_boxes[i][j]->SetValue(wxString("-"));
edit_boxes[i][j]->SetEditable(false);
edit_boxes[i][j]->Bind(wxEVT_KILL_FOCUS, [](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_SET_FOCUS, [](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_SET_FOCUS, [this](wxFocusEvent&) {});
}
else {
edit_boxes[i][j]->SetValue(wxString("") << int(m_matrix[m_number_of_extruders * j + i] * flush_multiplier));
@ -478,13 +519,13 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
}
// BBS
m_sizer->AddSpacer(FromDIP(10));
auto tip_message_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
tip_message_panel->SetBackgroundColour(*wxWHITE);
m_sizer_advanced->AddSpacer(FromDIP(10));
auto tip_message_panel = new wxPanel(m_page_advanced, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
tip_message_panel->SetBackgroundColour(wxColour(238, 238, 238));
auto message_sizer = new wxBoxSizer(wxVERTICAL);
tip_message_panel->SetSizer(message_sizer);
{
wxString message = _L("Orca recalculates your flushing volumes everytime the filament colors change. You can change this behavior in Preferences.");
wxString message = _L("Studio would re-calculate your flushing volumes everytime the filaments color changed. You could disable the auto-calculate in Bambu Studio > Preferences");
m_tip_message_label = new Label(tip_message_panel, wxEmptyString);
wxClientDC dc(tip_message_panel);
wxString multiline_message;
@ -492,20 +533,21 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
m_tip_message_label->SetLabel(multiline_message);
m_tip_message_label->SetFont(Label::Body_13);
message_sizer->Add(m_tip_message_label, 0, wxEXPAND | wxALL, TIP_MESSAGES_PADDING);
update_ui(m_tip_message_label);
}
m_sizer->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
m_sizer_advanced->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
bool is_show = wxGetApp().app_config->get("auto_calculate") == "true";
tip_message_panel->Show(is_show);
m_sizer->AddSpacer(FromDIP(10));
m_sizer_advanced->AddSpacer(FromDIP(10));
auto calc_btn_sizer = create_calc_btn_sizer(m_page_advanced);
m_sizer_advanced->Add(calc_btn_sizer, 0, wxEXPAND | wxLEFT, FromDIP(30));
m_sizer->AddSpacer(FromDIP(5));
header_line_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
//m_sizer_advanced->AddSpacer(FromDIP(10));
m_sizer_advanced->AddSpacer(FromDIP(5));
header_line_panel = new wxPanel(m_page_advanced, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
header_line_panel->SetBackgroundColour(wxColour(238, 238, 238));
auto header_line_sizer = new wxBoxSizer(wxHORIZONTAL);
header_line_panel->SetSizer(header_line_sizer);
wxSizerItem* stretch_spacer = header_line_sizer->AddStretchSpacer();
header_line_sizer->AddSpacer(HEADER_BEG_PADDING);
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
wxButton* icon = new wxButton(header_line_panel, wxID_ANY, {}, wxDefaultPosition, ICON_SIZE, wxBORDER_NONE | wxBU_AUTODRAW);
@ -517,24 +559,23 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
header_line_sizer->Add(icon, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, HEADER_VERT_PADDING);
}
header_line_sizer->AddSpacer(HEADER_END_PADDING);
header_line_sizer->AddStretchSpacer();
m_sizer->Add(header_line_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
m_sizer_advanced->Add(header_line_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
create_panels(this, m_number_of_extruders);
create_panels(m_page_advanced, m_number_of_extruders);
m_sizer->AddSpacer(FromDIP(5));
//m_sizer_advanced->AddSpacer(BTN_SIZE.y);
// BBS: for tunning flush volumes
{
auto multi_desc_label = new wxStaticText(this, wxID_ANY, _(L("Flushing volume (mm³) for each filament pair.")), wxDefaultPosition, wxDefaultSize, 0);
auto multi_desc_label = new wxStaticText(m_page_advanced, wxID_ANY, _(L("Flushing volume (mm³) for each filament pair.")), wxDefaultPosition, wxDefaultSize, 0);
multi_desc_label->SetForegroundColour(g_text_color);
m_sizer->Add(multi_desc_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer_advanced->Add(multi_desc_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
wxString min_flush_str = wxString::Format(_L("Suggestion: Flushing Volume in range [%d, %d]"), m_min_flush_volume, m_max_flush_volume);
m_min_flush_label = new wxStaticText( this, wxID_ANY, min_flush_str, wxDefaultPosition, wxDefaultSize, 0);
m_min_flush_label = new wxStaticText(m_page_advanced, wxID_ANY, min_flush_str, wxDefaultPosition, wxDefaultSize, 0);
m_min_flush_label->SetForegroundColour(g_text_color);
m_sizer->Add(m_min_flush_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer_advanced->Add(m_min_flush_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
auto on_apply_text_modify = [this](wxEvent& e) {
wxString str = m_flush_multiplier_ebox->GetValue();
@ -549,8 +590,6 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
}
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
for (unsigned int j = 0; j < m_number_of_extruders; ++j) {
if (i == j)
continue; // if it is from/to the same extruder, don't change the value and continue
edit_boxes[i][j]->SetValue(to_string(int(m_matrix[m_number_of_extruders * j + i] * multiplier)));
}
}
@ -559,32 +598,91 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
e.Skip();
};
m_sizer->AddSpacer(10);
m_sizer_advanced->AddSpacer(10);
wxBoxSizer* param_sizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticText* flush_multiplier_title = new wxStaticText(this, wxID_ANY, _L("Multiplier"));
wxStaticText* flush_multiplier_title = new wxStaticText(m_page_advanced, wxID_ANY, _L("Multiplier"));
param_sizer->Add(flush_multiplier_title, 0, wxALIGN_CENTER | wxALL, 0);
param_sizer->AddSpacer(FromDIP(5));
m_flush_multiplier_ebox = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(50), -1), wxTE_PROCESS_ENTER);
m_flush_multiplier_ebox = new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(50), -1), wxTE_PROCESS_ENTER);
char flush_multi_str[32] = { 0 };
snprintf(flush_multi_str, sizeof(flush_multi_str), "%.2f", flush_multiplier);
m_flush_multiplier_ebox->SetValue(flush_multi_str);
param_sizer->Add(m_flush_multiplier_ebox, 0, wxALIGN_CENTER | wxALL, 0);
param_sizer->AddStretchSpacer(1);
m_sizer->Add(param_sizer, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer->AddSpacer(BTN_SIZE.y);
m_sizer_advanced->Add(param_sizer, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_flush_multiplier_ebox->Bind(wxEVT_TEXT_ENTER, on_apply_text_modify);
m_flush_multiplier_ebox->Bind(wxEVT_KILL_FOCUS, on_apply_text_modify);
}
this->update_warning_texts();
m_page_advanced->Hide();
// Now the same for simple mode:
gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString("")), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("unloaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(new wxStaticText(m_page_simple,wxID_ANY,wxString(_(L("loaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
auto add_spin_ctrl = [this](std::vector<wxSpinCtrl*>& vec, float initial)
{
wxSpinCtrl* spin_ctrl = new wxSpinCtrl(m_page_simple, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), style | wxALIGN_RIGHT, 0, 300, (int)initial);
update_ui(spin_ctrl);
vec.push_back(spin_ctrl);
#ifdef __WXOSX__
// On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value
// when it was changed from the text control, so the on_change callback
// gets the old one, and on_kill_focus resets the control to the old value.
// As a workaround, we get the new value from $event->GetString and store
// here temporarily so that we can return it from get_value()
spin_ctrl->Bind(wxEVT_TEXT, ([spin_ctrl](wxCommandEvent e)
{
long value;
const bool parsed = e.GetString().ToLong(&value);
int tmp_value = parsed && value >= INT_MIN && value <= INT_MAX ? (int)value : INT_MIN;
// Forcibly set the input value for SpinControl, since the value
// inserted from the keyboard or clipboard is not updated under OSX
if (tmp_value != INT_MIN) {
spin_ctrl->SetValue(tmp_value);
// But in SetValue() is executed m_text_ctrl->SelectAll(), so
// discard this selection and set insertion point to the end of string
spin_ctrl->GetText()->SetInsertionPointEnd();
}
}), spin_ctrl->GetId());
#endif
};
for (unsigned int i=0;i<m_number_of_extruders;++i) {
add_spin_ctrl(m_old, extruders[2 * i]);
add_spin_ctrl(m_new, extruders[2 * i+1]);
auto hsizer = new wxBoxSizer(wxHORIZONTAL);
wxWindow* w = new wxWindow(m_page_simple, wxID_ANY, wxDefaultPosition, ICON_SIZE, wxBORDER_SIMPLE);
w->SetCanFocus(false);
w->SetBackgroundColour(m_colours[i]);
hsizer->Add(w, wxALIGN_CENTER_VERTICAL);
hsizer->AddSpacer(10);
hsizer->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("Filament #"))) << i + 1 << ": "), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(hsizer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(m_old.back(),0);
gridsizer_simple->Add(m_new.back(),0);
}
m_sizer = new wxBoxSizer(wxVERTICAL);
m_sizer->Add(m_page_simple, 0, wxEXPAND, 0);
m_sizer->Add(m_page_advanced, 0, wxEXPAND, 0);
m_sizer->SetSizeHints(this);
SetSizer(m_sizer);
this->Layout();
header_line_panel->Bind(wxEVT_PAINT, [this, stretch_spacer](wxPaintEvent&) {
toggle_advanced(); // to show/hide what is appropriate
header_line_panel->Bind(wxEVT_PAINT, [this](wxPaintEvent&) {
wxPaintDC dc(header_line_panel);
wxString from_text = _L("From");
wxString to_text = _L("To");
@ -593,7 +691,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
int base_y = (header_line_panel->GetSize().y - from_text_size.y - to_text_size.y) / 2;
int vol_width = ROW_BEG_PADDING + EDIT_BOXES_GAP / 2 + ICON_SIZE.x;
int base_x = stretch_spacer->GetSize().x + (vol_width - from_text_size.x - to_text_size.x) / 2;
int base_x = (vol_width - from_text_size.x - to_text_size.x) / 2;
// draw from text
int x = base_x;
@ -635,7 +733,7 @@ void WipingPanel::update_warning_texts()
auto& box_vec = edit_boxes[i];
for (int j = 0; j < box_vec.size(); j++) {
if (i == j)
continue; // if it is from/to the same extruder, don't change the value and continue
continue;
auto text_box = box_vec[j];
wxString str = text_box->GetValue();
@ -660,8 +758,8 @@ void WipingPanel::update_warning_texts()
m_min_flush_label->SetForegroundColour(g_warning_color);
m_min_flush_label->Refresh();
}
else if (!has_exception_flush && m_min_flush_label->GetForegroundColour() != StateColor::darkModeColorFor(g_text_color)) {
m_min_flush_label->SetForegroundColour(StateColor::darkModeColorFor(g_text_color));
else if (!has_exception_flush && m_min_flush_label->GetForegroundColour() != g_text_color) {
m_min_flush_label->SetForegroundColour(g_text_color);
m_min_flush_label->Refresh();
}
}
@ -672,10 +770,11 @@ void WipingPanel::calc_flushing_volumes()
const wxColour& from = m_colours[from_idx];
bool is_from_support = is_support_filament(from_idx);
for (int to_idx = 0; to_idx < m_colours.size(); to_idx++) {
if (from_idx == to_idx)
continue; // if it is from/to the same extruder, don't change the value and continue
bool is_to_support = is_support_filament(to_idx);
if (from_idx == to_idx) {
edit_boxes[to_idx][from_idx]->SetValue(std::to_string(0));
}
else {
int flushing_volume = 0;
if (is_to_support) {
flushing_volume = Slic3r::g_flush_volume_to_support;
@ -687,11 +786,13 @@ void WipingPanel::calc_flushing_volumes()
flushing_volume = std::max(Slic3r::g_min_flush_volume_from_support, flushing_volume);
}
}
m_matrix[m_number_of_extruders * from_idx + to_idx] = flushing_volume;
flushing_volume = int(flushing_volume * get_flush_multiplier());
edit_boxes[to_idx][from_idx]->SetValue(std::to_string(flushing_volume));
}
}
}
this->update_warning_texts();
}
@ -707,6 +808,8 @@ void WipingPanel::msw_rescale()
// Reads values from the (advanced) wiping matrix:
std::vector<float> WipingPanel::read_matrix_values() {
if (!m_advanced)
fill_in_matrix();
std::vector<float> output;
for (unsigned int i=0;i<m_number_of_extruders;++i) {
for (unsigned int j=0;j<m_number_of_extruders;++j) {
@ -723,3 +826,58 @@ std::vector<float> WipingPanel::read_matrix_values() {
}
return output;
}
// Reads values from simple mode to save them for next time:
std::vector<float> WipingPanel::read_extruders_values() {
std::vector<float> output;
for (unsigned int i=0;i<m_number_of_extruders;++i) {
output.push_back(m_old[i]->GetValue());
output.push_back(m_new[i]->GetValue());
}
return output;
}
// This updates the "advanced" matrix based on values from "simple" mode
void WipingPanel::fill_in_matrix() {
for (unsigned i=0;i<m_number_of_extruders;++i) {
for (unsigned j=0;j<m_number_of_extruders;++j) {
if (i==j) continue;
edit_boxes[j][i]->SetValue(wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue()));
}
}
}
// Function to check if simple and advanced settings are matching
bool WipingPanel::advanced_matches_simple() {
for (unsigned i=0;i<m_number_of_extruders;++i) {
for (unsigned j=0;j<m_number_of_extruders;++j) {
if (i==j) continue;
if (edit_boxes[j][i]->GetValue() != (wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue())))
return false;
}
}
return true;
}
// Switches the dialog from simple to advanced mode and vice versa
void WipingPanel::toggle_advanced(bool user_action) {
if (user_action)
m_advanced = !m_advanced; // user demands a change -> toggle
else {
// BBS: show advanced mode by default
//m_advanced = !advanced_matches_simple(); // if called from constructor, show what is appropriate
m_advanced = true;
}
(m_advanced ? m_page_advanced : m_page_simple)->Show();
(!m_advanced ? m_page_advanced : m_page_simple)->Hide();
if (m_advanced)
if (user_action) fill_in_matrix(); // otherwise keep values loaded from config
m_sizer->Layout();
Refresh();
}

View file

@ -48,9 +48,12 @@ public:
WipingPanel(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours, Button* calc_button,
int extra_flush_volume, float flush_multiplier);
std::vector<float> read_matrix_values();
std::vector<float> read_extruders_values();
void toggle_advanced(bool user_action = false);
void create_panels(wxWindow* parent, const int num);
void calc_flushing_volumes();
void msw_rescale();
wxBoxSizer* create_calc_btn_sizer(wxWindow* parent);
float get_flush_multiplier()
{
@ -61,14 +64,25 @@ public:
}
private:
void fill_in_matrix();
bool advanced_matches_simple();
int calc_flushing_volume(const wxColour& from, const wxColour& to);
void update_warning_texts();
std::vector<wxSpinCtrl*> m_old;
std::vector<wxSpinCtrl*> m_new;
std::vector<std::vector<wxTextCtrl*>> edit_boxes;
std::vector<wxColour> m_colours;
unsigned int m_number_of_extruders = 0;
bool m_advanced = false;
wxPanel* m_page_simple = nullptr;
wxPanel* m_page_advanced = nullptr;
wxPanel* header_line_panel = nullptr;
wxBoxSizer* m_sizer = nullptr;
wxBoxSizer* m_sizer_simple = nullptr;
wxBoxSizer* m_sizer_advanced = nullptr;
wxGridSizer* m_gridsizer_advanced = nullptr;
wxButton* m_widget_button = nullptr;
Label* m_tip_message_label = nullptr;
std::vector<wxButton *> icon_list1;
@ -93,6 +107,7 @@ public:
WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours,
int extra_flush_volume, float flush_multiplier);
std::vector<float> get_matrix() const { return m_output_matrix; }
std::vector<float> get_extruders() const { return m_output_extruders; }
wxBoxSizer* create_btn_sizer(long flags);
float get_flush_multiplier()
@ -108,6 +123,7 @@ public:
private:
WipingPanel* m_panel_wiping = nullptr;
std::vector<float> m_output_matrix;
std::vector<float> m_output_extruders;
std::unordered_map<int, Button *> m_button_list;
};

View file

@ -22,15 +22,16 @@
#ifndef __linux__
// msw_menuitem_bitmaps is used for MSW and OSX
static std::map<int, std::string> msw_menuitem_bitmaps;
void sys_color_changed_menu(wxMenu* menu)
#ifdef __WXMSW__
void msw_rescale_menu(wxMenu* menu)
{
struct update_icons {
static void run(wxMenuItem* item) {
const auto it = msw_menuitem_bitmaps.find(item->GetId());
if (it != msw_menuitem_bitmaps.end()) {
const wxBitmapBundle* item_icon = get_bmp_bundle(it->second);
if (item_icon->IsOk())
item->SetBitmap(*item_icon);
const wxBitmap& item_icon = create_menu_bitmap(it->second);
if (item_icon.IsOk())
item->SetBitmap(item_icon);
}
if (item->IsSubMenu())
for (wxMenuItem *sub_item : item->GetSubMenu()->GetMenuItems())
@ -41,24 +42,35 @@ void sys_color_changed_menu(wxMenu* menu)
for (wxMenuItem *item : menu->GetMenuItems())
update_icons::run(item);
}
#endif /* no __linux__ */
#endif /* __WXMSW__ */
#endif /* no __WXGTK__ */
void enable_menu_item(wxUpdateUIEvent& evt, std::function<bool()> const cb_condition, wxMenuItem* item, wxWindow* win)
{
const bool enable = cb_condition();
evt.Enable(enable);
#ifdef __WXOSX__
const auto it = msw_menuitem_bitmaps.find(item->GetId());
if (it != msw_menuitem_bitmaps.end())
{
const wxBitmap& item_icon = create_scaled_bitmap(it->second, win, 16, !enable);
if (item_icon.IsOk())
item->SetBitmap(item_icon);
}
#endif // __WXOSX__
}
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* icon, wxEvtHandler* event_handler,
std::function<void(wxCommandEvent& event)> cb, const wxBitmap& icon, wxEvtHandler* event_handler,
std::function<bool()> const cb_condition, wxWindow* parent, int insert_pos/* = wxNOT_FOUND*/)
{
if (id == wxID_ANY)
id = wxNewId();
auto *item = new wxMenuItem(menu, id, string, description);
if (icon && icon->IsOk()) {
item->SetBitmap(*icon);
if (icon.IsOk()) {
item->SetBitmap(icon);
}
if (insert_pos == wxNOT_FOUND)
menu->Append(item);
@ -87,12 +99,12 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const
if (id == wxID_ANY)
id = wxNewId();
wxBitmapBundle* bmp = icon.empty() ? nullptr : get_bmp_bundle(icon);
#ifndef __linux__
if (bmp && bmp->IsOk())
const wxBitmap& bmp = !icon.empty() ? create_menu_bitmap(icon) : wxNullBitmap; // FIXME: pass window ptr
//#ifdef __WXMSW__
#ifndef __WXGTK__
if (bmp.IsOk())
msw_menuitem_bitmaps[id] = icon;
#endif /* no __linux__ */
#endif /* __WXMSW__ */
return append_menu_item(menu, id, string, description, cb, bmp, event_handler, cb_condition, parent, insert_pos);
}
@ -105,11 +117,11 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin
wxMenuItem* item = new wxMenuItem(menu, id, string, description, wxITEM_NORMAL, sub_menu);
if (!icon.empty()) {
item->SetBitmap(*get_bmp_bundle(icon));
#ifndef __linux__
item->SetBitmap(create_menu_bitmap(icon)); // FIXME: pass window ptr
//#ifdef __WXMSW__
#ifndef __WXGTK__
msw_menuitem_bitmaps[id] = icon;
#endif // no __linux__
#endif /* __WXMSW__ */
}
menu->Append(item);
@ -406,58 +418,9 @@ int mode_icon_px_size()
#endif
}
#ifdef __WXGTK2__
static int scale()
wxBitmap create_menu_bitmap(const std::string& bmp_name)
{
return int(em_unit(nullptr) * 0.1f + 0.5f);
}
#endif // __WXGTK2__
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int width/* = 16*/, int height/* = -1*/)
{
#ifdef __WXGTK2__
width *= scale();
if (height > 0)
height *= scale();
#endif // __WXGTK2__
static Slic3r::GUI::BitmapCache cache;
std::string bmp_name = bmp_name_in;
boost::replace_last(bmp_name, ".png", "");
if (height < 0)
height = width;
// Try loading an SVG first, then PNG if SVG is not found:
wxBitmapBundle* bmp = cache.from_svg(bmp_name, width, height, Slic3r::GUI::wxGetApp().dark_mode());
if (bmp == nullptr) {
bmp = cache.from_png(bmp_name, width, height);
if (!bmp)
// Neither SVG nor PNG has been found, raise error
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
}
return bmp;
}
wxBitmapBundle* get_empty_bmp_bundle(int width, int height)
{
static Slic3r::GUI::BitmapCache cache;
#ifdef __WXGTK2__
return cache.mkclear_bndl(width * scale(), height * scale());
#else
return cache.mkclear_bndl(width, height);
#endif // __WXGTK2__
}
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color )
{
static Slic3r::GUI::BitmapCache cache;
#ifdef __WXGTK2__
return cache.mksolid_bndl(width * scale(), height * scale(), color, 1, Slic3r::GUI::wxGetApp().dark_mode());
#else
return cache.mksolid_bndl(width, height, color, 1, Slic3r::GUI::wxGetApp().dark_mode());
#endif // __WXGTK2__
return create_scaled_bitmap(bmp_name, nullptr, 16, false, "", true);
}
// win is used to get a correct em_unit value
@ -471,10 +434,6 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
const bool menu_bitmap/* = false*/,
const bool resize/* = false*/)
{
#ifdef __WXGTK2__
px_cnt *= scale();
#endif // __WXGTK2__
static Slic3r::GUI::BitmapCache cache;
unsigned int width = 0;
@ -541,46 +500,54 @@ wxBitmap* get_default_extruder_color_icon(bool thin_icon/* = false*/)
return bitmap;
}
std::vector<wxBitmapBundle*> get_extruder_color_icons(bool thin_icon/* = false*/)
std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
{
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps;
std::vector<wxBitmap*> bmps;
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
if (colors.empty())
return bmps;
/* It's supposed that standard size of an icon is 36px*16px for 100% scaled display.
* So set sizes for solid_colored icons used for filament preset
* and scale them in respect to em_unit value
*/
const double em = Slic3r::GUI::wxGetApp().em_unit();
const int icon_width = lround((thin_icon ? 2 : 4.4) * em);
const int icon_height = lround(2 * em);
int index = 0;
for (const std::string &color : colors) {
for (const std::string &color : colors)
{
auto label = std::to_string(++index);
bmps.emplace_back(get_extruder_color_icon(color, label, thin_icon ? 16 : 36, 16));
bmps.push_back(get_extruder_color_icon(color, label, icon_width, icon_height));
}
return bmps;
}
wxBitmapBundle *get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height)
wxBitmap *get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height)
{
static Slic3r::GUI::BitmapCache bmp_cache;
std::string bitmap_key = color + "-h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width) + "-i" + label;
wxBitmapBundle *bmpbndl = bmp_cache.find_bndl(bitmap_key);
if (bmpbndl == nullptr) {
wxBitmap *bitmap = bmp_cache.find(bitmap_key);
if (bitmap == nullptr) {
// Paint the color icon.
// Slic3r::GUI::BitmapCache::parse_color(color, rgb);
// there is no neede to scale created solid bitmap
wxColor clr(color);
bmpbndl = bmp_cache.insert_bndl(bitmap_key, wxBitmap(icon_width, icon_height));
bitmap = bmp_cache.insert(bitmap_key, wxBitmap(icon_width, icon_height));
#ifndef __WXMSW__
wxMemoryDC dc;
#else
wxClientDC cdc((wxWindow *) Slic3r::GUI::wxGetApp().mainframe);
wxMemoryDC dc(&cdc);
#endif
wxBitmap bmp = bmpbndl->GetBitmap(wxSize(icon_width, icon_height));
dc.SetFont(::Label::Body_12);
dc.SelectObject(bmp);
dc.SelectObject(*bitmap);
if (clr.Alpha() == 0) {
int size = icon_height * 2;
static wxBitmap transparent = *Slic3r::GUI::BitmapCache().load_svg("transparent", size, size);
@ -605,9 +572,8 @@ wxBitmapBundle *get_extruder_color_icon(std::string color, std::string label, in
dc.SetTextForeground(clr.GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK);
dc.DrawText(label, (icon_width - size.x) / 2, (icon_height - size.y) / 2);
dc.SelectObject(wxNullBitmap);
bmpbndl = bmp_cache.insert_bndl(bitmap_key, bmp);
}
return bmpbndl;
return bitmap;
}
@ -618,7 +584,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
wxSize size/* = wxDefaultSize*/,
bool use_thin_icon/* = false*/)
{
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(use_thin_icon);
std::vector<wxBitmap*> icons = get_extruder_color_icons(use_thin_icon);
if (!*ctrl) {
*ctrl = new Slic3r::GUI::BitmapComboBox(parent, wxID_ANY, wxEmptyString, pos, size, 0, nullptr, wxCB_READONLY);
@ -644,7 +610,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
int i = 0;
wxString str = _(L("Extruder"));
for (wxBitmapBundle* bmp : icons) {
for (wxBitmap* bmp : icons) {
if (i == 0) {
if (!first_item.empty())
(*ctrl)->Append(_(first_item), *bmp);
@ -678,7 +644,7 @@ LockButton::LockButton( wxWindow *parent,
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
SetBitmap(m_bmp_lock_open.bmp());
SetBitmapDisabled(m_bmp_lock_open.bmp());
SetBitmapCurrent(m_bmp_lock_closed_f.bmp());
SetBitmapHover(m_bmp_lock_closed_f.bmp());
//button events
Bind(wxEVT_BUTTON, &LockButton::OnButton, this);
@ -701,14 +667,12 @@ void LockButton::SetLock(bool lock)
update_button_bitmaps();
}
void LockButton::sys_color_changed()
void LockButton::msw_rescale()
{
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
m_bmp_lock_closed.sys_color_changed();
m_bmp_lock_closed_f.sys_color_changed();
m_bmp_lock_open.sys_color_changed();
m_bmp_lock_open_f.sys_color_changed();
m_bmp_lock_closed.msw_rescale();
m_bmp_lock_closed_f.msw_rescale();
m_bmp_lock_open.msw_rescale();
m_bmp_lock_open_f.msw_rescale();
update_button_bitmaps();
}
@ -717,7 +681,7 @@ void LockButton::update_button_bitmaps()
{
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
SetBitmap(m_is_pushed ? m_bmp_lock_closed.bmp() : m_bmp_lock_open.bmp());
SetBitmapCurrent(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp());
SetBitmapHover(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp());
Refresh();
Update();
@ -744,7 +708,7 @@ ModeButton::ModeButton( wxWindow* parent,
const wxString& mode/* = wxEmptyString*/,
const std::string& icon_name/* = ""*/,
int px_cnt/* = 16*/) :
ScalableButton(parent, wxID_ANY, icon_name, mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT, px_cnt)
ScalableButton(parent, wxID_ANY, ScalableBitmap(parent, icon_name, px_cnt), mode, wxBU_EXACTFIT)
{
Init(mode);
}
@ -853,10 +817,11 @@ void ModeSizer::set_items_border(int border)
item->SetBorder(border);
}
void ModeSizer::sys_color_changed()
void ModeSizer::msw_rescale()
{
this->SetHGap(std::lround(m_hgap_unscaled * em_unit(m_parent)));
for (size_t m = 0; m < m_mode_btns.size(); m++)
m_mode_btns[m]->sys_color_changed();
m_mode_btns[m]->msw_rescale();
}
// ----------------------------------------------------------------------------
@ -893,45 +858,51 @@ ScalableBitmap::ScalableBitmap( wxWindow *parent,
const std::string& icon_name/* = ""*/,
const int px_cnt/* = 16*/,
const bool grayscale/* = false*/,
const bool resize/* = false*/,
const bool use_legacy_bmp/* = false*/):
m_parent(parent), m_icon_name(icon_name), m_legacy_bmp(use_legacy_bmp),
m_size({px_cnt, px_cnt}), m_grayscale(grayscale), m_resize(resize) // BBS: support resize by fill border
{
// Orca: there is currently an issue causing the advanced SwitchButton to not scale properly
// when using get_bmp_bundle. This allows for the older method of getting a scaled bitmap to be
// used in this edge case while the underlying issue is determined.
if (m_legacy_bmp) {
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, m_grayscale, std::string(), false, resize);
if (px_cnt == 0) {
m_size.x = m_size.y = GetHeight(); // scale
unsigned int height = (unsigned int) (parent->FromDIP(px_cnt) + 0.5f);
if (height != GetHeight())
sys_color_changed();
}
} else {
m_bmp = *get_bmp_bundle(icon_name, px_cnt);
}
}
ScalableBitmap::ScalableBitmap( wxWindow *parent,
const std::string& icon_name,
const wxSize size,
const bool grayscale/* = false*/,
const bool resize/* = false*/):
m_parent(parent), m_icon_name(icon_name),
m_size(size), m_grayscale(grayscale), m_resize(resize) // BBS: support resize by fill border
m_px_cnt(px_cnt), m_grayscale(grayscale), m_resize(resize) // BBS: support resize by fill border
{
m_bmp = *get_bmp_bundle(icon_name, size.x, size.y);
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, m_grayscale, std::string(), false, resize);
if (px_cnt == 0) {
m_px_cnt = m_bmp.GetHeight(); // scale
unsigned int height = (unsigned int) (parent->FromDIP(m_px_cnt) + 0.5f);
if (height != GetBmpHeight())
msw_rescale();
}
}
void ScalableBitmap::sys_color_changed()
wxSize ScalableBitmap::GetBmpSize() const
{
#ifdef __APPLE__
return m_bmp.GetScaledSize();
#else
return m_bmp.GetSize();
#endif
}
int ScalableBitmap::GetBmpWidth() const
{
#ifdef __APPLE__
return m_bmp.GetScaledWidth();
#else
return m_bmp.GetWidth();
#endif
}
int ScalableBitmap::GetBmpHeight() const
{
#ifdef __APPLE__
return m_bmp.GetScaledHeight();
#else
return m_bmp.GetHeight();
#endif
}
void ScalableBitmap::msw_rescale()
{
if (m_legacy_bmp) {
// BBS: support resize by fill border
m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_size.x, m_grayscale, std::string(), false, m_resize);
} else
m_bmp = *get_bmp_bundle(m_icon_name, m_size.x, m_size.y);
m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_px_cnt, m_grayscale, std::string(), false, m_resize);
}
// ----------------------------------------------------------------------------
@ -945,9 +916,11 @@ ScalableButton::ScalableButton( wxWindow * parent,
const wxSize& size /* = wxDefaultSize*/,
const wxPoint& pos /* = wxDefaultPosition*/,
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/,
bool use_default_disabled_bitmap/* = false*/,
int bmp_px_cnt/* = 16*/) :
m_parent(parent),
m_current_icon_name(icon_name),
m_use_default_disabled_bitmap (use_default_disabled_bitmap),
m_px_cnt(bmp_px_cnt),
m_has_border(!(style & wxNO_BORDER))
{
@ -956,7 +929,9 @@ ScalableButton::ScalableButton( wxWindow * parent,
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
if (!icon_name.empty()) {
SetBitmap(*get_bmp_bundle(icon_name, m_px_cnt));
SetBitmap(create_scaled_bitmap(icon_name, parent, m_px_cnt));
if (m_use_default_disabled_bitmap)
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
if (!label.empty())
SetBitmapMargins(int(0.5* em_unit(parent)), 0);
}
@ -998,12 +973,13 @@ bool ScalableButton::SetBitmap_(const std::string& bmp_name)
if (m_current_icon_name.empty())
return false;
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
SetBitmap(bmp);
SetBitmapCurrent(bmp);
SetBitmapPressed(bmp);
SetBitmapFocus(bmp);
SetBitmapDisabled(bmp);
if (m_use_default_disabled_bitmap)
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
return true;
}
@ -1022,22 +998,38 @@ int ScalableButton::GetBitmapHeight()
#endif
}
void ScalableButton::sys_color_changed()
void ScalableButton::UseDefaultBitmapDisabled()
{
m_use_default_disabled_bitmap = true;
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
}
void ScalableButton::msw_rescale()
{
Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
if (!m_current_icon_name.empty()) {
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
SetBitmap(bmp);
SetBitmapCurrent(bmp);
SetBitmapPressed(bmp);
SetBitmapFocus(bmp);
// BBS: why disappear on hover? why current HBITMAP differ from other
//SetBitmapCurrent(bmp);
//SetBitmapPressed(bmp);
//SetBitmapFocus(bmp);
if (!m_disabled_icon_name.empty())
SetBitmapDisabled(*get_bmp_bundle(m_disabled_icon_name, m_px_cnt));
if (!GetLabelText().IsEmpty())
SetBitmapMargins(int(0.5 * em_unit(m_parent)), 0);
SetBitmapDisabled(create_scaled_bitmap(m_disabled_icon_name, m_parent, m_px_cnt));
else if (m_use_default_disabled_bitmap)
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
}
if (m_width > 0 || m_height>0)
{
const int em = em_unit(m_parent);
wxSize size(m_width * em, m_height * em);
SetMinSize(size);
}
}
// ----------------------------------------------------------------------------
// BlinkingBitmap
// ----------------------------------------------------------------------------
@ -1048,6 +1040,13 @@ BlinkingBitmap::BlinkingBitmap(wxWindow* parent, const std::string& icon_name) :
bmp = ScalableBitmap(parent, icon_name);
}
void BlinkingBitmap::msw_rescale()
{
bmp.msw_rescale();
this->SetSize(bmp.GetBmpSize());
this->SetMinSize(bmp.GetBmpSize());
}
void BlinkingBitmap::invalidate()
{
this->SetBitmap(wxNullBitmap);

View file

@ -18,17 +18,14 @@
#include "Widgets/PopupWindow.hpp"
#ifndef __linux__
void sys_color_changed_menu(wxMenu* menu);
#else
inline void sys_color_changed_menu(wxMenu* /* menu */) {}
#endif // no __linux__
[[deprecated("Function renamed to sys_color_changed_menu. This function now redirects to sys_color_changed_menu")]]
inline void msw_rescale_menu(wxMenu* menu) { sys_color_changed_menu(menu); }
#ifdef __WXMSW__
void msw_rescale_menu(wxMenu* menu);
#else /* __WXMSW__ */
inline void msw_rescale_menu(wxMenu* /* menu */) {}
#endif /* __WXMSW__ */
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* icon, wxEvtHandler* event_handler = nullptr,
std::function<void(wxCommandEvent& event)> cb, const wxBitmap& icon, wxEvtHandler* event_handler = nullptr,
std::function<bool()> const cb_condition = []() { return true;}, wxWindow* parent = nullptr, int insert_pos = wxNOT_FOUND);
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
std::function<void(wxCommandEvent& event)> cb, const std::string& icon = "", wxEvtHandler* event_handler = nullptr,
@ -55,9 +52,7 @@ void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<
int em_unit(wxWindow* win);
int mode_icon_px_size();
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int width = 16, int height = -1);
wxBitmapBundle* get_empty_bmp_bundle(int width, int height);
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color);
wxBitmap create_menu_bitmap(const std::string& bmp_name);
// BBS: support resize by fill border
#if 1
@ -71,8 +66,8 @@ wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullp
#endif
wxBitmap* get_default_extruder_color_icon(bool thin_icon = false);
std::vector<wxBitmapBundle *> get_extruder_color_icons(bool thin_icon = false);
wxBitmapBundle * get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height);
std::vector<wxBitmap *> get_extruder_color_icons(bool thin_icon = false);
wxBitmap * get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height);
namespace Slic3r {
namespace GUI {
@ -145,17 +140,6 @@ public:
void SetItemsCnt(int cnt) { m_cnt_open_items = cnt; }
};
inline wxSize get_preferred_size(const wxBitmapBundle& bmp, wxWindow* parent)
{
if (!bmp.IsOk())
return wxSize(0, 0);
#ifdef __WIN32__
return bmp.GetPreferredBitmapSizeFor(parent);
#else
return bmp.GetDefaultSize();
#endif
}
// ----------------------------------------------------------------------------
// ScalableBitmap
@ -169,45 +153,29 @@ public:
const std::string& icon_name = "",
const int px_cnt = 16,
const bool grayscale = false,
const bool resize = false,
const bool use_legacy_bmp = true);
ScalableBitmap( wxWindow *parent,
const std::string& icon_name,
const wxSize size,
const bool grayscale = false,
const bool resize = false);
const bool resize = false); // BBS: support resize by fill border
~ScalableBitmap() {}
[[deprecated("Function renamed to sys_color_changed. This function now redirects to sys_color_changed")]]
inline void msw_rescale() { sys_color_changed(); }
void sys_color_changed();
wxSize GetBmpSize() const;
int GetBmpWidth() const;
int GetBmpHeight() const;
const wxBitmapBundle& bmp() const { return m_bmp; }
wxBitmapBundle& bmp() { return m_bmp; }
wxBitmap get_bitmap() const { return m_bmp.GetBitmapFor(m_parent); }
wxWindow* parent() const { return m_parent;}
void msw_rescale();
const wxBitmap& bmp() const { return m_bmp; }
wxBitmap& bmp() { return m_bmp; }
const std::string& name() const{ return m_icon_name; }
int px_cnt() const { return m_size.x; }
wxSize GetSize() const {
#ifdef __WIN32__
return m_bmp.GetPreferredBitmapSizeFor(m_parent);
#else
return m_bmp.GetDefaultSize();
#endif
}
int GetWidth() const { return GetSize().GetWidth(); }
int GetHeight() const { return GetSize().GetHeight(); }
int px_cnt()const {return m_px_cnt;}
private:
wxWindow* m_parent{ nullptr };
wxBitmapBundle m_bmp = wxBitmapBundle();
wxBitmap m_bmp = wxBitmap();
std::string m_icon_name = "";
wxSize m_size {16, 16};
int m_px_cnt {16};
bool m_grayscale{ false };
bool m_resize{ false };
bool m_legacy_bmp{ false };
};
@ -234,9 +202,7 @@ public:
void enable() { m_disabled = false; }
void disable() { m_disabled = true; }
[[deprecated("Function renamed to sys_color_changed. This function now redirects to sys_color_changed")]]
inline void msw_rescale() { sys_color_changed(); }
void sys_color_changed();
void msw_rescale();
protected:
void update_button_bitmaps();
@ -268,6 +234,7 @@ public:
const wxSize& size = wxDefaultSize,
const wxPoint& pos = wxDefaultPosition,
long style = wxBU_EXACTFIT | wxNO_BORDER,
bool use_default_disabled_bitmap = false,
int bmp_px_cnt = 16);
ScalableButton(
@ -283,10 +250,9 @@ public:
bool SetBitmap_(const std::string& bmp_name);
void SetBitmapDisabled_(const ScalableBitmap &bmp);
int GetBitmapHeight();
void UseDefaultBitmapDisabled();
[[deprecated("Function renamed to sys_color_changed. This function now redirects to sys_color_changed")]]
inline void msw_rescale() { sys_color_changed(); }
void sys_color_changed();
void msw_rescale();
private:
wxWindow* m_parent { nullptr };
@ -295,6 +261,8 @@ private:
int m_width {-1}; // should be multiplied to em_unit
int m_height{-1}; // should be multiplied to em_unit
bool m_use_default_disabled_bitmap {false};
// bitmap dimensions
int m_px_cnt{ 16 };
bool m_has_border {false};
@ -360,9 +328,7 @@ public:
void set_items_flag(int flag);
void set_items_border(int border);
[[deprecated("Function renamed to sys_color_changed. This function now redirects to sys_color_changed")]]
inline void msw_rescale() { sys_color_changed(); }
void sys_color_changed();
void msw_rescale();
const std::vector<ModeButton*>& get_btns() { return m_mode_btns; }
private:
@ -410,11 +376,12 @@ public:
~BlinkingBitmap() {}
void msw_rescale();
void invalidate();
void activate();
void blink();
const wxBitmapBundle& get_bmp() const { return bmp.bmp(); }
const wxBitmap& get_bmp() const { return bmp.bmp(); }
private:
ScalableBitmap bmp;