Update wxWidgets to v3.2.1 (#2905)

* Upgrade wxWidgets to 3.2.1
Based on prusa3d/PrusaSlicer@9a7e024

Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>

* Implement BitmapCache

* update wxExtensions while keeping legacy items

* update dc.DrawBitmap calls to use get_bitmap

* Fix GetSize/Width/Height calls

* update BitmapComboBox

* fix ifndef in wxExtensions.hpp

* update my todos to OcraftyoneTODO

* Get to a compilable state
Everything seems to be working (including the plater). I am not seeing any graphical issues

* fix extruder color icons

* fix crash on opening support tab

* remove GetBmpSize method from DropDown.cpp

* Update TextInput to use bitmap bundles

* update a TODO after testing

* fix the rendering of the icons on combobox

* fix a few todos

* fix WipeTowerDialog.cpp

* Overhaul WipeTowerDialog

Removed simple version of the dialog since BBS removed the functionality but left the code.
Center the table (only seen when the table is smaller than the minimum size of the dialog)
Fix issue where editing a value causes the m_min_flush_label to change colors slightly
Fix an issue where changing a value or running an auto calc changes the disabled value from "-" to "0"

* update a few todos

* Update some todos

* Show dropdown when editing is started

* Update NanoSVG.cmake

Update NanoSVG to work with PR #2780

* Dim the icon on ComboBox when disabled

* solve ObjectDataViewModel todos

leaving colPrint and colEditing cases alone as it does not seem to impact anything

* Update names in wxExtensions

-Rename msw_rescale to sys_color_changed
-Replace GetBmpSize, GetBmpWidth, GetBmpHeight with renamed version (same name without "Bmp")

Both of these changes were also made by PrusaSlicer.

Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>

* update BitmapCache::from_svg

disable finding bundle in the cache to match load_svg
update to match values used in load_svg

* Update ScalableButton

change the signature and remove functions/vars pertaining to a default bmp
fix TODOs in ScalableButton

Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>

* fix up some more todos in wxExtensions

* update ScalableBitmap to use bmp bundles

use wxBitmapBundle by default
add flag to use old scaled bitmap function (specifically to solve issue with advanced toggle)

* attempt to fix macos deps build

* fix ubuntu build

* Revert "attempt to fix macos deps build"

Mistakenly made change to wrong file

This reverts commit d9c20b5121.

* update wxWidgets patch

an attempt to fix macOS build

* Remove duplicate variable from OrcaSlicer.cpp

* Fix macOS build issue

* Fix blank DataViewItem being added to objects list

* Filament ComboBox editor updates

-Add show drop down feature to ObjectTable
-Call finish editing when ComboBox is closed in ObjectList

* remove Apple specific declarations missed during refactor

* delete old wxWidgets patch

* fix ubuntu seg fault

* include patch from #2926

* update patch to include wxWidgets/wxWidgets@991a74c

* fix deps not compiling on Windows

* update WipeTowerDialog

relocates the recalculate button back to its previous position
changes the wording of the tip message label
add spacing below the matrix

* finish patching wxWidgets

from prusa3d/PrusaSlicer@f8477d1 and prusa3d/PrusaSlicer@066b567

Co-authored-by: YuSanka <yusanka@gmail.com>

* fix combobox crash

* revert outside plate changes

---------

Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
Co-authored-by: YuSanka <yusanka@gmail.com>
This commit is contained in:
Ocraftyone 2023-12-04 10:21:49 -05:00 committed by GitHub
parent 0bf65aa217
commit 25a055491e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
98 changed files with 1639 additions and 6221 deletions

1
deps/CMakeLists.txt vendored
View file

@ -236,6 +236,7 @@ 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)

9
deps/NanoSVG/NanoSVG.cmake vendored Normal file
View file

@ -0,0 +1,9 @@
# In PrusaSlicer 2.6.0 we switched from https://github.com/memononen/nanosvg to its fork https://github.com/fltk/nanosvg
# because this last implements the new function nsvgRasterizeXY() which we now use in GLTexture::load_from_svg()
# for rasterizing svg files from their original size to a squared power of two texture on Windows systems using
# AMD Radeon graphics cards
orcaslicer_add_cmake_project(NanoSVG
URL https://github.com/fltk/nanosvg/archive/abcd277ea45e9098bed752cf9c6875b533c0892f.zip
URL_HASH SHA256=e859938fbaee4b351bd8a8b3d3c7a75b40c36885ce00b73faa1ce0b98aa0ad34
)

View file

@ -1,24 +1,36 @@
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})
From f4fef135f0a58ca2916c45cd539923ab096935b6 Mon Sep 17 00:00:00 2001
From: Ocraftyone <Ocraftyone@users.noreply.github.com>
Date: Thu, 30 Nov 2023 03:25:54 -0500
Subject: [PATCH] patch v3.2.1 for OrcaSlicer
---
build/cmake/lib/webview/CMakeLists.txt | 4 +-
include/wx/fontutil.h | 15 +++++++-
include/wx/gdicmn.h | 3 ++
include/wx/generic/grid.h | 4 +-
include/wx/msw/font.h | 2 +-
include/wx/msw/tooltip.h | 4 +-
include/wx/osx/app.h | 2 +-
src/common/combocmn.cpp | 11 +++++-
src/common/datavcmn.cpp | 6 ++-
src/common/dcbufcmn.cpp | 6 +++
src/common/gdicmn.cpp | 14 +++++++
src/common/image.cpp | 6 +--
src/generic/grid.cpp | 50 ++++++++++++++++++++-----
src/msw/bmpcbox.cpp | 9 ++++-
src/msw/font.cpp | 14 +++----
src/msw/menuitem.cpp | 2 +
src/msw/window.cpp | 52 +++++++++++++++++---------
src/osx/cocoa/dataview.mm | 26 +++++++++++--
src/osx/cocoa/settings.mm | 6 +--
src/osx/cocoa/window.mm | 4 ++
20 files changed, 184 insertions(+), 56 deletions(-)
diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt
index cc3298ff33..8adbeaea4f 100644
index 085381d785..62146abc04 100644
--- a/build/cmake/lib/webview/CMakeLists.txt
+++ b/build/cmake/lib/webview/CMakeLists.txt
@@ -56,7 +56,7 @@ if(APPLE)
@@ -46,9 +46,9 @@ if(APPLE)
elseif(WXMSW)
if(wxUSE_WEBVIEW_EDGE)
# Update the following variables if updating WebView2 SDK
@ -31,7 +43,7 @@ index cc3298ff33..8adbeaea4f 100644
set(WEBVIEW2_DEFAULT_PACKAGE_DIR "${CMAKE_BINARY_DIR}/packages/Microsoft.Web.WebView2.${WEBVIEW2_VERSION}")
diff --git a/include/wx/fontutil.h b/include/wx/fontutil.h
index 09ad8c8ef3..3c0c2d8f7e 100644
index 30529db8ce..e6a12366d5 100644
--- a/include/wx/fontutil.h
+++ b/include/wx/fontutil.h
@@ -294,7 +294,11 @@ public:
@ -69,7 +81,7 @@ index 09ad8c8ef3..3c0c2d8f7e 100644
}
diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h
index e29a77627c..dc48cf9451 100644
index 2f5f8ee99f..39e9317d40 100644
--- a/include/wx/gdicmn.h
+++ b/include/wx/gdicmn.h
@@ -38,6 +38,7 @@ class WXDLLIMPEXP_FWD_CORE wxRegion;
@ -80,7 +92,7 @@ index e29a77627c..dc48cf9451 100644
// ---------------------------------------------------------------------------
// constants
@@ -1092,7 +1093,9 @@ extern int WXDLLIMPEXP_CORE wxDisplayDepth();
@@ -1106,7 +1107,9 @@ extern int WXDLLIMPEXP_CORE wxDisplayDepth();
// get the display size
extern void WXDLLIMPEXP_CORE wxDisplaySize(int *width, int *height);
@ -91,13 +103,13 @@ index e29a77627c..dc48cf9451 100644
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
index 1bd58bbf04..903cb81319 100644
--- a/include/wx/generic/grid.h
+++ b/include/wx/generic/grid.h
@@ -2951,9 +2951,11 @@ private:
wxGridWindow* gridWindow);
@@ -3029,9 +3029,11 @@ private:
// Update the width/height of the column/row being drag-resized.
// Should be only called when m_dragRowOrCol != -1, i.e. dragging is
// actually in progress.
+ //BBS: add cursor mode for DoGridDragResize's paremeters
void DoGridDragResize(const wxPoint& position,
const wxGridOperations& oper,
@ -151,19 +163,10 @@ index 317a0ca96f..58014ec1d4 100644
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
index 80408c6677..aa07caebdc 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()
@@ -2061,6 +2061,9 @@ void wxComboCtrlBase::ShowPopup()
SetFocus();
@ -173,7 +176,7 @@ index b61aac35bf..d12b745e8c 100644
// Space above and below
int screenHeight;
wxPoint scrPos;
@@ -2407,9 +2410,13 @@ void wxComboCtrlBase::ShowPopup()
@@ -2183,9 +2186,13 @@ void wxComboCtrlBase::ShowPopup()
int showFlags = CanDeferShow;
@ -190,10 +193,10 @@ index b61aac35bf..d12b745e8c 100644
}
diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp
index 1f5fd4d66b..14ea2f8ef1 100644
index 0a1e43ad51..6c492aedab 100644
--- a/src/common/datavcmn.cpp
+++ b/src/common/datavcmn.cpp
@@ -1322,7 +1322,11 @@ wxDataViewItem wxDataViewCtrlBase::GetSelection() const
@@ -1334,7 +1334,11 @@ wxDataViewItem wxDataViewCtrlBase::GetSelection() const
wxDataViewItemArray selections;
GetSelections(selections);
@ -207,28 +210,27 @@ index 1f5fd4d66b..14ea2f8ef1 100644
namespace
diff --git a/src/common/dcbufcmn.cpp b/src/common/dcbufcmn.cpp
index 74958fce10..59844f4526 100644
index 9b1c1f3159..ef5865ed4b 100644
--- a/src/common/dcbufcmn.cpp
+++ b/src/common/dcbufcmn.cpp
@@ -82,9 +82,15 @@ private:
@@ -83,9 +83,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);
+ 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->CreateWithDIPSize(wxMax(w, 1), wxMax(h, 1), scale);
+#endif
return buffer;
}
diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp
index 20442bbc73..9a24951ec7 100644
index db8a01f961..162c1ce2dc 100644
--- a/src/common/gdicmn.cpp
+++ b/src/common/gdicmn.cpp
@@ -863,11 +863,25 @@ void wxDisplaySize(int *width, int *height)
@ -257,72 +259,57 @@ index 20442bbc73..9a24951ec7 100644
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,
diff --git a/src/common/image.cpp b/src/common/image.cpp
index 19fe34ec91..a449b60930 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -390,11 +390,11 @@ wxImage wxImage::ShrinkBy( int xFactor , int yFactor ) const
unsigned char red = pixel[0] ;
unsigned char green = pixel[1] ;
unsigned char blue = pixel[2] ;
- unsigned char alpha = 255 ;
- if ( source_alpha )
- alpha = *(source_alpha + y_offset + x * xFactor + x1) ;
if ( !hasMask || red != maskRed || green != maskGreen || blue != maskBlue )
{
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;
+ unsigned char alpha = 255 ;
+ if ( source_alpha )
+ alpha = *(source_alpha + y_offset + x * xFactor + x1) ;
if ( alpha > 0 )
{
avgRed += red ;
diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp
index 41fd4524cf..f4a15cb839 100644
index ed3d988994..d71cda122d 100644
--- a/src/generic/grid.cpp
+++ b/src/generic/grid.cpp
@@ -3824,7 +3824,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
@@ -4068,7 +4068,8 @@ void wxGrid::ProcessRowColLabelMouseEvent( const wxGridOperations &oper, wxMouse
{
case WXGRID_CURSOR_RESIZE_ROW:
if ( m_cursorMode == oper.GetCursorModeResize() )
{
- DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
- DoGridDragResize(event.GetPosition(), oper, gridWindow);
+ //BBS: add cursor mode for DoGridDragResize's paremeters
+ DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow, WXGRID_CURSOR_RESIZE_ROW);
+ DoGridDragResize(event.GetPosition(), oper, gridWindow, m_cursorMode);
}
break;
@@ -4166,7 +4167,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
switch ( m_cursorMode )
else if ( m_cursorMode == oper.GetCursorModeSelect() && line >=0 )
{
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);
@@ -4691,12 +4692,14 @@ bool wxGrid::DoGridDragEvent(wxMouseEvent& event,
case WXGRID_CURSOR_RESIZE_ROW:
if ( m_dragRowOrCol != -1 )
- 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:
if ( m_dragRowOrCol != -1 )
- 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,
@@ -4791,6 +4794,8 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
case wxGridSelectCells:
case wxGridSelectRowsOrColumns:
// nothing to do in these cases
@ -331,7 +318,7 @@ index 41fd4524cf..f4a15cb839 100644
break;
case wxGridSelectRows:
@@ -5044,9 +5050,11 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event, wxGridWindow *eventG
@@ -5049,9 +5054,11 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event, wxGridWindow *eventG
}
}
@ -342,9 +329,9 @@ index 41fd4524cf..f4a15cb839 100644
+ 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,
wxCHECK_RET( m_dragRowOrCol != -1,
"shouldn't be called when not drag resizing" );
@@ -5064,10 +5071,28 @@ void wxGrid::DoGridDragResize(const wxPoint& position,
// orthogonal direction.
const int linePos = oper.Dual().Select(logicalPos);
@ -375,7 +362,7 @@ index 41fd4524cf..f4a15cb839 100644
// TODO: generate RESIZING event, see #10754, if the size has changed.
}
@@ -5082,7 +5108,8 @@ wxPoint wxGrid::GetPositionForResizeEvent(int width) const
@@ -5090,7 +5115,8 @@ wxPoint wxGrid::GetPositionForResizeEvent(int width) const
void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow* gridWindow)
{
@ -383,9 +370,9 @@ index 41fd4524cf..f4a15cb839 100644
+ //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);
SendGridSizeEvent(wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, event);
@@ -5091,7 +5118,8 @@ void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow* gridWin
@@ -5099,7 +5125,8 @@ void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow* gridWin
void wxGrid::DoEndDragResizeCol(const wxMouseEvent& event, wxGridWindow* gridWindow)
{
@ -393,9 +380,9 @@ index 41fd4524cf..f4a15cb839 100644
+ //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);
SendGridSizeEvent(wxEVT_GRID_COL_SIZE, m_dragRowOrCol, event);
@@ -5105,9 +5133,10 @@ void wxGrid::DoHeaderStartDragResizeCol(int col)
@@ -5113,9 +5140,10 @@ void wxGrid::DoHeaderStartDragResizeCol(int col)
void wxGrid::DoHeaderDragResizeCol(int width)
{
@ -407,7 +394,7 @@ index 41fd4524cf..f4a15cb839 100644
}
void wxGrid::DoHeaderEndDragResizeCol(int width)
@@ -5891,6 +5920,10 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
@@ -6013,6 +6041,10 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
DisableCellEditControl();
MoveCursorDown( event.ShiftDown() );
@ -419,7 +406,7 @@ index 41fd4524cf..f4a15cb839 100644
break;
diff --git a/src/msw/bmpcbox.cpp b/src/msw/bmpcbox.cpp
index 0a2d167ad7..0aeba45ea9 100644
index 011bd4f534..17e7f18740 100644
--- a/src/msw/bmpcbox.cpp
+++ b/src/msw/bmpcbox.cpp
@@ -156,13 +156,20 @@ void wxBitmapComboBox::RecreateControl()
@ -445,7 +432,7 @@ index 0a2d167ad7..0aeba45ea9 100644
for ( i = 0; i < numItems; i++ )
{
diff --git a/src/msw/font.cpp b/src/msw/font.cpp
index 0bd240d79f..d38b1b00f5 100644
index 434876939c..91d4603018 100644
--- a/src/msw/font.cpp
+++ b/src/msw/font.cpp
@@ -54,7 +54,7 @@ static const int PITCH_MASK = FIXED_PITCH | VARIABLE_PITCH;
@ -503,7 +490,7 @@ index 0bd240d79f..d38b1b00f5 100644
bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp
index 9bb397d472..30af7154a7 100644
index 0bd017a36a..3b98bf1678 100644
--- a/src/msw/menuitem.cpp
+++ b/src/msw/menuitem.cpp
@@ -368,6 +368,8 @@ void MenuDrawData::Init(wxWindow const* window)
@ -516,10 +503,10 @@ index 9bb397d472..30af7154a7 100644
else
#endif // wxUSE_UXTHEME
diff --git a/src/msw/window.cpp b/src/msw/window.cpp
index eadc2f5700..f64fea4446 100644
index c529a4fa3b..7e547c64df 100644
--- a/src/msw/window.cpp
+++ b/src/msw/window.cpp
@@ -4773,33 +4773,49 @@ static wxSize GetWindowDPI(HWND hwnd)
@@ -4809,33 +4809,49 @@ static wxSize GetWindowDPI(HWND hwnd)
}
/*extern*/
@ -588,18 +575,10 @@ index eadc2f5700..f64fea4446 100644
return ::GetSystemMetrics(nIndex);
diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm
index 6ff0cc3088..4943f3ea38 100644
index f188e61089..7b867002d1 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
@@ -1604,6 +1604,15 @@ outlineView:(NSOutlineView*)outlineView
}
}
@ -615,7 +594,17 @@ index 6ff0cc3088..4943f3ea38 100644
//
// contextual menus
//
@@ -2672,12 +2682,22 @@ void wxCocoaDataViewControl::DoSetIndent(int indent)
@@ -2006,7 +2015,8 @@ void wxCocoaDataViewControl::keyEvent(WX_NSEvent event, WXWidget slf, void *_cmd
if ( !dvc->GetEventHandler()->ProcessEvent(eventDV) )
wxWidgetCocoaImpl::keyEvent(event, slf, _cmd);
}
- else
+ //FIXME Vojtech's hack to get the accelerators assigned to the wxDataViewControl working.
+ else if (! DoHandleKeyEvent(event))
{
wxWidgetCocoaImpl::keyEvent(event, slf, _cmd); // all other keys
}
@@ -2540,12 +2550,22 @@ void wxCocoaDataViewControl::DoSetIndent(int indent)
void wxCocoaDataViewControl::HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
{
@ -641,10 +630,10 @@ index 6ff0cc3088..4943f3ea38 100644
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
index c819deeb0c..dc3c3b0b53 100644
--- a/src/osx/cocoa/settings.mm
+++ b/src/osx/cocoa/settings.mm
@@ -224,7 +224,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
@@ -222,7 +222,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
// ----------------------------------------------------------------------------
// Get a system metric, e.g. scrollbar size
@ -653,7 +642,7 @@ index de5f52860c..a9581174a4 100644
{
int value;
@@ -259,11 +259,11 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, const wxWindow* WXUN
@@ -257,11 +257,11 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, const wxWindow* WXUN
// TODO case wxSYS_WINDOWMIN_Y:
case wxSYS_SCREEN_X:
@ -667,3 +656,28 @@ index de5f52860c..a9581174a4 100644
return value;
// TODO case wxSYS_FRAMESIZE_X:
diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm
index 635ea286d4..42ae67e27a 100644
--- a/src/osx/cocoa/window.mm
+++ b/src/osx/cocoa/window.mm
@@ -191,6 +191,9 @@ NSRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
- (BOOL)isEnabled;
- (void)setEnabled:(BOOL)flag;
+- (BOOL)clipsToBounds;
+- (void)setClipsToBounds:(BOOL)clipsToBounds;
+
- (void)setImage:(NSImage *)image;
- (void)setControlSize:(NSControlSize)size;
@@ -2559,6 +2562,7 @@ wxWidgetImpl( peer, flags )
if ( m_osxView )
CFRetain(m_osxView);
[m_osxView release];
+ m_osxView.clipsToBounds = YES;
}
--
2.42.0.windows.2

View file

@ -1,4 +1,5 @@
set(_wx_git_tag v3.1.5)
set(_wx_git_tag v3.2.1)
set(_wx_patch_name 0001-patch-v3.2.1-for-OrcaSlicer.patch)
set(_wx_toolkit "")
set(_wx_private_font "-DwxUSE_PRIVATE_FONTS=1")
@ -17,13 +18,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}/0001-wxWidget-fix.patch && 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}/${_wx_patch_name} && type nul > WXWIDGETS_PATCHED ) )
else ()
set(_patch_cmd test -f WXWIDGETS_PATCHED || ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch && touch WXWIDGETS_PATCHED)
set(_patch_cmd test -f WXWIDGETS_PATCHED || ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/${_wx_patch_name} && touch WXWIDGETS_PATCHED)
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(_patch_cmd ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-wxWidget-fix.patch)
set(_patch_cmd ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/${_wx_patch_name})
endif ()
orcaslicer_add_cmake_project(
@ -31,7 +32,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
DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} dep_TIFF dep_JPEG dep_NanoSVG
CMAKE_ARGS
-DwxBUILD_PRECOMP=ON
${_wx_toolkit}
@ -47,7 +48,9 @@ orcaslicer_add_cmake_project(
-DwxUSE_WEBVIEW=ON
${_wx_edge}
-DwxUSE_WEBVIEW_IE=OFF
-DwxUSE_REGEX=builtin
-DwxUSE_NANOSVG=sys
-DwxUSE_NANOSVG_EXTERNAL=ON
-DwxUSE_REGEX=OFF
-DwxUSE_LIBXPM=builtin
-DwxUSE_LIBSDL=OFF
-DwxUSE_XTEST=OFF

View file

@ -95,6 +95,9 @@ 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}")

View file

@ -4744,7 +4744,6 @@ int CLI::run(int argc, char **argv)
}
}
ThumbnailsParams thumbnail_params;
GLShaderProgram* shader = opengl_mgr.get_shader("thumbnail");
if (!shader) {
BOOST_LOG_TRIVIAL(error) << boost::format("can not get shader for rendering thumbnail");

View file

@ -1 +0,0 @@
Upstream source: https://github.com/fltk/nanosvg/archive/abcd277ea45e9098bed752cf9c6875b533c0892f.zip

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -496,6 +496,8 @@ set(SLIC3R_GUI_SOURCES
Utils/CalibUtils.hpp
)
find_package(NanoSVG REQUIRED)
if (WIN32)
list(APPEND SLIC3R_GUI_SOURCES
GUI/dark_mode/dark_mode.hpp
@ -543,7 +545,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)
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 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->msw_rescale();
degree->sys_color_changed();
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.GetBmpSize());
this->SetMinSize(this->logo.GetSize());
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.GetBmpWidth();
int logo_h = this->logo.GetBmpHeight();
dc.DrawBitmap(this->logo.bmp(), (size.GetWidth() - logo_w)/2, (size.GetHeight() - logo_h)/2, true);
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);
event.Skip();
}
@ -380,7 +380,7 @@ AboutDialog::AboutDialog()
void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bitmap.msw_rescale();
m_logo_bitmap.sys_color_changed();
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.bmp(), FromDIP(1), FromDIP(1));
dc.DrawBitmap(m_transparent_mitem.get_bitmap(), 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.bmp(), GetSize().x - m_arraw_bitmap_white.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_white.GetBmpSize().y);
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);
}
else {
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);
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);
}
@ -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.bmp(), 0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
dc.DrawBitmap( m_transparent_mapping_item.get_bitmap(), 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.bmp(), wxPoint((size.x - bitmap_bg.GetBmpSize().x) / 2, (size.y - bitmap_bg.GetBmpSize().y) / 2));
dc.DrawBitmap(bitmap_bg.get_bitmap(), wxPoint((size.x - bitmap_bg.GetSize().x) / 2, (size.y - bitmap_bg.GetSize().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.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_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_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.bmp(), (size.x - m_file_bitmap.GetBmpWidth()) / 2, (size.y - m_file_bitmap.GetBmpHeight()) / 2);
dc.DrawBitmap(m_file_bitmap.get_bitmap(), (size.x - m_file_bitmap.GetWidth()) / 2, (size.y - m_file_bitmap.GetHeight()) / 2);
}
}
@ -257,7 +257,7 @@ void AuFile::PaintForeground(wxDC &dc)
}
if (m_type == MODEL_PICTURE) {
dc.DrawBitmap(m_file_edit_mask.bmp(), 0, size.y - m_file_edit_mask.GetBmpSize().y);
dc.DrawBitmap(m_file_edit_mask.get_bitmap(), 0, size.y - m_file_edit_mask.GetSize().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.GetBmpSize().y + sizet.y) / 2);
pos.y = (size.y - (m_file_edit_mask.GetSize().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.GetBmpSize().y + sizet.y) / 2);
pos.y = (size.y - (m_file_edit_mask.GetSize().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.GetBmpSize().y - FromDIP(24)) / 2;
pos.y = size.y - FromDIP(24) - (m_file_edit_mask.GetSize().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.bmp(), size.x - m_file_cover.GetBmpSize().x, 0);
dc.DrawBitmap(m_file_cover.get_bitmap(), size.x - m_file_cover.GetSize().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.bmp(), size.x - m_file_delete.GetBmpSize().x - FromDIP(10), FromDIP(10)); }
if (m_hover) { dc.DrawBitmap(m_file_delete.get_bitmap(), size.x - m_file_delete.GetSize().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.GetBmpSize().y);
auto mask_size = wxSize(GetSize().x, m_file_edit_mask.GetSize().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.GetBmpSize().x - FromDIP(10);
auto close_left = size.x - m_file_delete.GetSize().x - FromDIP(10);
auto close_top = FromDIP(10);
auto close_right = size.x - FromDIP(10);
auto close_bottom = m_file_delete.GetBmpSize().y + FromDIP(10);
auto close_bottom = m_file_delete.GetSize().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

@ -93,9 +93,7 @@ void BBLTopbarArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& i
int bmpX = 0, bmpY = 0;
int textX = 0, textY = 0;
const wxBitmap& bmp = item.GetState() & wxAUI_BUTTON_STATE_DISABLED
? item.GetDisabledBitmap()
: item.GetBitmap();
const wxBitmap &bmp = item.GetCurrentBitmapFor(wnd);
const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);

View file

@ -13,10 +13,8 @@
#include <wx/rawbmp.h>
#endif /* __WXGTK2__ */
#define NANOSVG_IMPLEMENTATION
#include "nanosvg/nanosvg.h"
#define NANOSVGRAST_IMPLEMENTATION
#include "nanosvg/nanosvgrast.h"
#include <nanosvg/nanosvg.h>
#include <nanosvg/nanosvgrast.h>
namespace Slic3r { namespace GUI {
@ -60,7 +58,168 @@ static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image, float scale = 1.
#endif
}
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height)
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 *bitmap = nullptr;
auto it = m_map.find(bitmap_key);
@ -76,7 +235,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, m_scale);
bitmap->CreateScaled(width, height, -1, scale < 0.0 ? m_scale : scale);
#endif
m_map[bitmap_key] = bitmap;
} else {
@ -105,110 +264,6 @@ 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);
@ -305,6 +360,101 @@ 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*/)
{
@ -386,7 +536,7 @@ replaces["\"#009688\""] = "\"#00675b\"";
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* /)
{
@ -430,6 +580,89 @@ 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,7 +12,8 @@
#include "libslic3r/Color.hpp"
struct NSVGimage;
namespace Slic3r { namespace GUI {
namespace Slic3r {
namespace GUI {
class BitmapCache
{
@ -22,15 +23,23 @@ 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); }
wxBitmap* insert(const std::string &name, size_t width, size_t height);
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, 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)
@ -41,19 +50,28 @@ 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); }
// 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); }
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,17 +54,6 @@ 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*/,
@ -90,72 +79,6 @@ 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)
@ -166,18 +89,11 @@ 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
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;
}
wxBitmapBundle bitmap = *get_empty_bmp_bundle(1, 16);
OnAddBitmap(bitmap);
const int n = wxComboBox::Append(item);
if (n != wxNOT_FOUND)
DoSetItemBitmap(n, bitmap);
return n;
}

View file

@ -29,28 +29,13 @@ BitmapComboBox(wxWindow* parent,
#ifdef _WIN32
int Append(const wxString& item);
#endif
int Append(const wxString& item, const wxBitmap& bitmap)
int Append(const wxString& item, const wxBitmapBundle& 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.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2));
dc.DrawBitmap(dwbitmap.get_bitmap(), wxPoint(left, (size.y - dwbitmap.GetSize().y) / 2));
left += dwbitmap.GetBmpSize().x + 8;
left += dwbitmap.GetSize().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, true, 30);
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 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, true, 30);
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 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->msw_rescale();
m_prev_btn->sys_color_changed();
}
void CaliPageCaption::msw_rescale()
{
m_prev_btn->msw_rescale();
m_prev_btn->sys_color_changed();
}
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, false, 24);
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 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->msw_rescale();
m_bmp.msw_rescale();
m_help_btn->sys_color_changed();
m_bmp.sys_color_changed();
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->msw_rescale();
m_ams_sync_button->sys_color_changed();
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->msw_rescale();
m_ams_sync_button->sys_color_changed();
}
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, false, 18);
m_ams_sync_button = new ScalableButton(parent, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 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.msw_rescale();
m_bitmap_hover.msw_rescale();
m_bitmap_normal.sys_color_changed();
m_bitmap_hover.sys_color_changed();
}
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.bmp(), wxPoint((GetSize().x - m_bitmap_hover.GetBmpSize().x) / 2, (GetSize().y - m_bitmap_hover.GetBmpSize().y) / 2));
dc.DrawBitmap(m_bitmap_hover.get_bitmap(), wxPoint((GetSize().x - m_bitmap_hover.GetSize().x) / 2, (GetSize().y - m_bitmap_hover.GetSize().y) / 2));
} else {
dc.DrawBitmap(m_bitmap_normal.bmp(), wxPoint((GetSize().x - m_bitmap_normal.GetBmpSize().x) / 2, (GetSize().y - m_bitmap_normal.GetBmpSize().y) / 2));
dc.DrawBitmap(m_bitmap_normal.get_bitmap(), wxPoint((GetSize().x - m_bitmap_normal.GetSize().x) / 2, (GetSize().y - m_bitmap_normal.GetSize().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.bmp().GetSize());
SetMinSize(bg.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.bmp().GetSize().GetWidth();
const auto bullet_h = bullet_black.bmp().GetSize().GetHeight();
const auto bullet_w = bullet_black.GetWidth();
const auto bullet_h = bullet_black.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.bmp(), x, y + yoff_icon, false);
dc.DrawBitmap(bullet_blue.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); }
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); }
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.GetBmpHeight(); y>=0) {
dc.DrawBitmap(bg.bmp(), 0, y, false);
index_width = std::max(index_width, bg.GetBmpWidth() + em_w / 2);
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 (GetMinSize().x < index_width) {
@ -1689,12 +1689,12 @@ void ConfigWizardIndex::msw_rescale()
em_w = size.x;
em_h = size.y;
bg.msw_rescale();
SetMinSize(bg.bmp().GetSize());
bg.sys_color_changed();
SetMinSize(bg.GetSize());
bullet_black.msw_rescale();
bullet_blue.msw_rescale();
bullet_white.msw_rescale();
bullet_black.sys_color_changed();
bullet_blue.sys_color_changed();
bullet_white.sys_color_changed();
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.bmp().GetSize().GetHeight(), em_w) + em_w; }
int item_height() const { return std::max(bullet_black.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);
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)->GetBitmapFor(m_parent);
DragShape* shape = new DragShape(bmp, order[i]);
m_dragshape_list.push_back(shape);
}

View file

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

View file

@ -54,7 +54,7 @@ private:
DECLARE_VARIANT_OBJECT(DataViewBitmapText)
// ----------------------------------------------------------------------------
// BitmapTextRenderer
// BitmapTextRenderer - an editable text box within a DataView item
// ----------------------------------------------------------------------------
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
class BitmapTextRenderer : public wxDataViewRenderer
@ -126,7 +126,7 @@ private:
// ----------------------------------------------------------------------------
// BitmapChoiceRenderer
// BitmapChoiceRenderer - Creates an editable ComboBox within a DataView item
// ----------------------------------------------------------------------------
class BitmapChoiceRenderer : public wxDataViewCustomRenderer

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.bmp());
temp->Append(_(el), bm.get_bitmap());
} 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.bmp());
temp->SetItemBitmap(i, bm.get_bitmap());
}
++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 = scale * font.GetPointSize();
float pointSizeNew = wxDisplay(this).GetScaleFactor() * scale * font.GetPointSize();
nfi.lf.lfHeight = nfi.GetLogFontHeightAtPPI(pointSizeNew, get_dpi_for_window(this));
nfi.pointSize = pointSizeNew;
font = wxFont(nfi);

View file

@ -261,14 +261,13 @@ std::map<std::string, std::string> SettingsFactory::CATEGORY_ICON =
// BBS: remove SLA categories
};
wxBitmap SettingsFactory::get_category_bitmap(const std::string& category_name, bool menu_bmp)
wxBitmapBundle* SettingsFactory::get_category_bitmap(const std::string& category_name)
{
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
return wxNullBitmap;
return create_scaled_bitmap(CATEGORY_ICON.at(category_name));
return get_bmp_bundle("empty");
return get_bmp_bundle(CATEGORY_ICON.at(category_name));
}
//-------------------------------------
// MenuFactory
//-------------------------------------
@ -425,13 +424,14 @@ static void create_freq_settings_popupmenu(wxMenu* menu, const bool is_object_se
}
}
std::vector<wxBitmap> MenuFactory::get_volume_bitmaps()
std::vector<wxBitmapBundle*> MenuFactory::get_volume_bitmaps()
{
std::vector<wxBitmap> volume_bmps;
std::vector<wxBitmapBundle*> volume_bmps;
volume_bmps.reserve(ADD_VOLUME_MENU_ITEMS.size());
for (auto item : ADD_VOLUME_MENU_ITEMS){
if(!item.second.empty()){
volume_bmps.push_back(create_scaled_bitmap(item.second));
//volume_bmps.push_back(create_menu_bitmap(item.second));
volume_bmps.push_back(get_bmp_bundle(item.second));
}
}
return volume_bmps;
@ -619,7 +619,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(create_scaled_bitmap("cog"));
menu_item->SetBitmap(*get_bmp_bundle("cog"));
menu_item->SetSubMenu(create_settings_popupmenu(menu, is_object_settings, item));
return menu->Append(menu_item);
@ -768,7 +768,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
if (sels.IsEmpty())
return;
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
wxMenu* extruder_selection_menu = new wxMenu();
const wxString& name = sels.Count() == 1 ? names[0] : names[1];
@ -789,7 +789,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(
@ -1593,7 +1593,7 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
return;
}
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
std::vector<wxBitmapBundle*> 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)
@ -1633,8 +1633,9 @@ 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 ? wxNullBitmap : *icons[i - 1], menu,
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, i == 0 ? nullptr : icons[i - 1], menu,
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
}
menu->Append(wxID_ANY, name, extruder_selection_menu, _L("Change Filament"));
@ -1752,12 +1753,6 @@ 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
@ -1787,7 +1782,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 }) {
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));// msw_rescale_menu updates just icons, so use it
sys_color_changed_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())
@ -1802,14 +1797,17 @@ void MenuFactory::sys_color_changed(wxMenuBar* menubar)
#if 0
for (size_t id = 0; id < menubar->GetMenuCount(); id++) {
wxMenu* menu = menubar->GetMenu(id);
msw_rescale_menu(menu);
sys_color_changed_menu(menu);
#ifndef __linux__
menu->SetupBitmaps();
#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();
// menubar->Refresh();
#endif
#endif
}

View file

@ -36,7 +36,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 wxBitmap get_category_bitmap(const std::string& category_name, bool menu_bmp = true);
static wxBitmapBundle* get_category_bitmap(const std::string& category_name);
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
@ -48,7 +48,7 @@ class MenuFactory
{
public:
static const std::vector<std::pair<std::string, std::string>> ADD_VOLUME_MENU_ITEMS;
static std::vector<wxBitmap> get_volume_bitmaps();
static std::vector<wxBitmapBundle*> get_volume_bitmaps();
MenuFactory();
~MenuFactory() = default;
@ -57,7 +57,6 @@ 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,47 +248,14 @@ void ObjectLayers::UpdateAndShow(const bool show)
void ObjectLayers::msw_rescale()
{
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();
}
}
}
}
//Orca: deleted what PS commented out
m_grid_sizer->Layout();
}
void ObjectLayers::sys_color_changed()
{
m_bmp_delete.msw_rescale();
m_bmp_add.msw_rescale();
m_bmp_delete.sys_color_changed();
m_bmp_add.sys_color_changed();
// rescale edit-boxes
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
@ -300,7 +267,7 @@ void ObjectLayers::sys_color_changed()
if (b_item && b_item->IsWindow()) {
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
if (button != nullptr)
button->msw_rescale();
button->sys_color_changed();
}
}
}

View file

@ -1359,12 +1359,11 @@ void ObjectList::extruder_editing()
if (!item || !(m_objects_model->GetItemType(item) & (itVolume | itObject)))
return;
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;
wxRect rect = this->GetItemRect(item, GetColumn(colFilament));
wxPoint pos = rect.GetPosition();
pos.y -= 4;
wxSize size = rect.GetSize();
size.SetWidth(size.GetWidth() + 8);
apply_extruder_selector(&m_extruder_editor, this, "1", pos, size);
@ -3196,6 +3195,21 @@ 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();
@ -5505,9 +5519,6 @@ 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();
}
@ -5515,7 +5526,10 @@ void ObjectList::sys_color_changed()
{
wxGetApp().UpdateDVCDarkUI(this, true);
msw_rescale();
// rescale/update existing items with bitmaps
m_objects_model->UpdateBitmaps();
Layout();
if (m_objects_model) { m_objects_model->sys_color_changed(); }
}
@ -5552,6 +5566,12 @@ void GUI::ObjectList::OnStartEditing(wxDataViewEvent &event)
// Here the last active column is forgotten, so when leaving the editing mode, the next mouse click will not enter the editing mode of the newly selected column.
void ObjectList::OnEditingStarted(wxDataViewEvent &event)
{
// Orca: Automatically show drop down on editing start and finish editing when the combobox is closed
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(); });
}
#ifdef __WXMSW__
m_last_selected_column = -1;
#else

View file

@ -321,7 +321,7 @@ public:
void delete_all_connectors_for_selection();
void delete_all_connectors_for_object(int obj_idx);
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
wxPoint get_mouse_position_in_control() const;
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->SetBitmapHover(m_bmp_delete_focus.bmp());
btn->SetBitmapCurrent(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->SetBitmapHover(m_bmp_delete_focus.bmp());
ctrl->SetBitmapCurrent(m_bmp_delete_focus.bmp());
};
const bool is_extruders_cat = cat.first == "Extruders";
@ -415,21 +415,13 @@ 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();
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();
for (auto group : m_og_settings)
group->sys_color_changed();

View file

@ -68,7 +68,6 @@ 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();
wxBitmap bitmap = table->get_undo_bitmap().GetBitmapFor(dc.GetWindow());
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<wxBitmap*>* bitmaps)
std::vector<wxBitmapBundle*>* 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<wxBitmap*>* bitmaps)
std::vector<wxBitmapBundle*>* bitmaps)
: wxGridCellChoiceEditor(count, choices, allowOthers), m_icons(bitmaps)
{
}
@ -159,13 +159,14 @@ void GridCellFilamentsEditor::Create(wxWindow* parent,
if ( !m_allowOthers )
style |= wxCB_READONLY;
::ComboBox *bitmap_combo = new ComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxSize(((*m_icons)[0])->GetWidth() + 10, -1), 0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY);
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
if (m_icons) {
int array_count = m_choices.GetCount();
int icon_count = m_icons->size();
for (int i = 0; i < array_count; i++)
{
wxBitmap* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
wxBitmapBundle* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
bitmap_combo->Append(m_choices[i], *bitmap);
}
}
@ -239,6 +240,9 @@ 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
@ -335,9 +339,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]);
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();
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();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
@ -345,7 +349,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, wxPoint(rect.x + offset_x, rect.y + offset_y));
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
}
text_rect.x += bitmap_width + grid_cell_border_width * 2;
@ -431,6 +435,9 @@ 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
@ -518,16 +525,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]);
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();
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();
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, wxPoint(rect.x + offset_x, rect.y + offset_y));
dc.DrawBitmap(bitmap->GetBitmapFor(dc.GetWindow()), 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);
}
@ -2641,12 +2648,12 @@ void ObjectGridTable::OnCellValueChanged(int row, int col)
}
}
wxBitmap& ObjectGridTable::get_undo_bitmap(bool selected)
wxBitmapBundle& ObjectGridTable::get_undo_bitmap(bool selected)
{
return m_panel->m_undo_bitmap;
}
wxBitmap* ObjectGridTable::get_color_bitmap(int color_index)
wxBitmapBundle* 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<wxBitmap*>* bitmaps = NULL);
std::vector<wxBitmapBundle*>* bitmaps = NULL);
GridCellFilamentsEditor(const wxArrayString& choices,
bool allowOthers = false,
std::vector<wxBitmap*>* bitmaps = NULL);
std::vector<wxBitmapBundle*>* 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<wxBitmap*>* m_icons;
std::vector<wxBitmapBundle*>* 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);
wxBitmap& get_undo_bitmap(bool selected = false);
wxBitmap* get_color_bitmap(int color_index);
wxBitmapBundle& get_undo_bitmap(bool selected = false);
wxBitmapBundle* 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;
wxBitmap m_undo_bitmap;
std::vector<wxBitmap*> m_color_bitmaps;
ScalableBitmap m_bmp_reset;
ScalableBitmap m_bmp_reset_disable;
wxBitmapBundle m_undo_bitmap;
std::vector<wxBitmapBundle*> m_color_bitmaps;
wxBitmapBundle m_bmp_reset;
wxBitmapBundle 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.bmp());
btn->SetBitmapHover(m_bmp_reset_focus.get_bitmap());
#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.bmp());
ctrl->SetBitmapHover(m_bmp_reset_focus.get_bitmap());
#ifdef __WINDOWS__
ctrl->SetBitmapDisabled(m_bmp_reset_disable.bmp());
#endif

View file

@ -43,9 +43,8 @@
#include "GUI_App.hpp"
#include "../Utils/MacDarkMode.hpp"
#include "nanosvg/nanosvg.h"
#include "nanosvg/nanosvgrast.h"
#include <nanosvg/nanosvg.h>
#include <nanosvg/nanosvgrast.h>
#include "OpenGLManager.hpp"
#include "GUI_App.hpp"

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.GetBmpSize();
auto si = m_status_icon.GetSize();
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.bmp(), rect.x + (rect.width - si.x) / 2, rect.y);
dc.DrawBitmap(m_status_icon.get_bitmap(), 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.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
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});
// 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.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
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});
}
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.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});
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});
}
}}

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.msw_rescale();
m_logo_bmp.sys_color_changed();
m_header_bitmap->SetBitmap(m_logo_bmp.bmp());
msw_buttons_rescale(this, em_unit(), { wxID_OK });

View file

@ -1968,11 +1968,6 @@ 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
@ -2014,7 +2009,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)->Rescale();
dynamic_cast<Notebook*>(m_tabpanel)->OnColorsChanged();
#endif
#endif

View file

@ -354,9 +354,9 @@ void MediaFilePanel::SwitchStorage(bool external)
void MediaFilePanel::Rescale()
{
m_bmp_loading.msw_rescale();
m_bmp_failed.msw_rescale();
m_bmp_empty.msw_rescale();
m_bmp_loading.sys_color_changed();
m_bmp_failed.sys_color_changed();
m_bmp_empty.sys_color_changed();
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, true);
auto m_control_back = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_back", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
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, true);
auto m_control_forward = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_forward", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
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, true);
auto m_control_refresh = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_refresh", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
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( create_scaled_bitmap(style & wxAPPLY ? "completed" :
logo->SetBitmap( *get_bmp_bundle(style & wxAPPLY ? "completed" :
style & wxICON_WARNING ? "obj_warning" :
style & wxICON_INFORMATION ? "info" :
style & wxICON_QUESTION ? "question" : "OrcaSlicer", this, 64, style & wxICON_ERROR));
style & wxICON_QUESTION ? "question" : "OrcaSlicer", 64));
}
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(create_scaled_bitmap("OrcaSlicer_192px_grayscale.png", this, monospaced_font ? 48 : /*1*/84));
logo->SetBitmap(*get_bmp_bundle("OrcaSlicer_192px_grayscale.png", monospaced_font ? 48 : /*1*/84));
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));

View file

@ -122,6 +122,8 @@ 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});
@ -137,6 +139,14 @@ 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,6 +23,7 @@ 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;
@ -261,6 +262,11 @@ 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 wxBitmap& bmp)
static wxSize get_bitmap_size(const wxBitmapBundle* bmp, wxWindow* parent)
{
#ifdef __APPLE__
return bmp.GetScaledSize();
#ifndef __WIN32__
return bmp->GetBitmapFor(parent).GetSize();
#else
return bmp.GetSize();
return bmp->GetDefaultSize();
#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(create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12));
m_bmp_blinking_sz = get_bitmap_size(create_scaled_bitmap("blank_16", this));
//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);
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 = create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12).GetSize();
m_bmp_blinking_sz = create_scaled_bitmap("blank_16", this).GetSize();
//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_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(create_scaled_bitmap("empty")).GetHeight();
height = get_bitmap_size(get_bmp_bundle("empty"), ctrl).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()->bmp(), field->undo_bitmap()->bmp(), field->blink());
draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->get_bitmap(), field->undo_bitmap()->get_bitmap(), 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()->bmp(), field->undo_bitmap()->bmp(), field->blink(), bmp_rect_id);
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);
}
#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)
{
wxBitmap bmp_blinking = create_scaled_bitmap(is_blinking ? "blank_16" : "empty", ctrl);
wxBitmapBundle* bmp_blinking = get_bmp_bundle(is_blinking ? "blank_16" : "empty");
wxCoord h_pos = pos.x;
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking).GetHeight()) / 2);
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking, ctrl).GetHeight()) / 2);
dc.DrawBitmap(bmp_blinking, h_pos, v_pos);
dc.DrawBitmap(bmp_blinking->GetBitmapFor(ctrl), h_pos, v_pos);
int bmp_dim = get_bitmap_size(bmp_blinking).GetWidth();
int bmp_dim = get_bitmap_size(bmp_blinking, ctrl).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 wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id)
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)
{
#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).GetHeight()) / 2);
pos.y += lround(((height - ctrl->m_v_gap + ctrl->m_v_gap2) / option_set.size() - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
else
pos.y += lround((height - get_bitmap_size(bmp_undo).GetHeight()) / 2);
pos.y += lround((height - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
} else {
pos.y += lround((height - get_bitmap_size(bmp_undo).GetHeight()) / 2);
pos.y += lround((height - get_bitmap_size(&bmp_undo, ctrl).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, h_pos, v_pos);
dc.DrawBitmap(bmp_undo_to_sys.GetBitmapFor(ctrl), h_pos, v_pos);
int bmp_dim = get_bitmap_size(bmp_undo_to_sys).GetWidth();
int bmp_dim = get_bitmap_size(&bmp_undo_to_sys, ctrl).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 : bmp_undo, h_pos, v_pos);
dc.DrawBitmap(og_line.undo_to_sys ? bmp_undo_to_sys.GetBitmapFor(ctrl) : bmp_undo.GetBitmapFor(ctrl), h_pos, v_pos);
int bmp_dim2 = get_bitmap_size(bmp_undo).GetWidth();
int bmp_dim2 = get_bitmap_size(&bmp_undo, ctrl).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 wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id = 0);
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);
bool launch_browser() const;
bool is_separator() const { return og_line.is_separator(); }

View file

@ -72,7 +72,7 @@ const std::map<InfoItemType, InfoItemAtributes> INFO_ITEMS{
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
const wxString& sub_obj_name,
Slic3r::ModelVolumeType type,
const wxBitmap& bmp,
const wxBitmapBundle& bmp,
const wxString& extruder,
const int idx/* = -1*/,
const std::string& warning_icon_name /*= std::string*/) :
@ -122,7 +122,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
else if (type == itLayerRoot)
{
//BBS do not support layer range edit
m_bmp = create_scaled_bitmap(LayerRootIcon); // FIXME: pass window ptr
m_bmp = *get_bmp_bundle(LayerRootIcon);
m_name = _(L("Layers"));
}
else if (type == itInfo)
@ -153,7 +153,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 = create_scaled_bitmap(LayerIcon); // FIXME: pass window ptr
m_bmp = *get_bmp_bundle(LayerIcon);
set_icons();
init_container();
@ -171,7 +171,15 @@ bool ObjectDataViewModelNode::valid()
void ObjectDataViewModelNode::sys_color_changed()
{
m_printable_icon = m_printable == piUndef ? m_empty_bmp : create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
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();
}
void ObjectDataViewModelNode::set_icons()
@ -200,7 +208,7 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
return;
m_printable = printable;
m_printable_icon = m_printable == piUndef ? m_empty_bmp :
create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
*get_bmp_bundle(m_printable == piPrintable ? "check_on" : "check_off_focused");
}
void ObjectDataViewModelNode::set_action_icon(bool enable)
@ -212,7 +220,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 = create_scaled_bitmap(m_action_icon_name); // FIXME: pass window ptr
m_action_icon = *get_bmp_bundle(m_action_icon_name); // FIXME: pass window ptr
}
// BBS
@ -222,9 +230,9 @@ void ObjectDataViewModelNode::set_color_icon(bool enable)
return;
m_color_enable = enable;
if ((m_type & itObject) && enable)
m_color_icon = create_scaled_bitmap("mmu_segmentation");
m_color_icon = *get_bmp_bundle("mmu_segmentation");
else
m_color_icon = create_scaled_bitmap("dot");
m_color_icon = *get_bmp_bundle("dot");
}
void ObjectDataViewModelNode::set_support_icon(bool enable)
@ -233,9 +241,9 @@ void ObjectDataViewModelNode::set_support_icon(bool enable)
return;
m_support_enable = enable;
if ((m_type & itObject) && enable)
m_support_icon = create_scaled_bitmap("toolbar_support");
m_support_icon = *get_bmp_bundle("toolbar_support");
else
m_support_icon = create_scaled_bitmap("dot");
m_support_icon = *get_bmp_bundle("dot");
}
void ObjectDataViewModelNode::set_sinking_icon(bool enable)
@ -244,9 +252,9 @@ void ObjectDataViewModelNode::set_sinking_icon(bool enable)
return;
m_sink_enable = enable;
if ((m_type & itObject) && enable)
m_sinking_icon = create_scaled_bitmap("objlist_sinking");
m_sinking_icon = *get_bmp_bundle("objlist_sinking");
else
m_sinking_icon = create_scaled_bitmap("dot");
m_sinking_icon = *get_bmp_bundle("dot");
}
void ObjectDataViewModelNode::set_warning_icon(const std::string& warning_icon_name)
@ -261,14 +269,14 @@ void ObjectDataViewModelNode::update_settings_digest_bitmaps()
m_bmp = m_empty_bmp;
std::string scaled_bitmap_name = m_name.ToUTF8().data();
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "");
scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "");
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
wxBitmapBundle *bmp = m_bitmap_cache->find_bndl(scaled_bitmap_name);
if (bmp == nullptr) {
std::vector<wxBitmap> bmps;
std::vector<wxBitmapBundle*> bmps;
for (auto& category : m_opt_categories)
bmps.emplace_back(SettingsFactory::get_category_bitmap(category, false));
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
bmps.emplace_back(SettingsFactory::get_category_bitmap(category));
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
}
m_bmp = *bmp;
@ -292,26 +300,12 @@ 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;
@ -336,7 +330,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");
@ -403,7 +397,7 @@ void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= "
if (extruder_idx > 0) --extruder_idx;
// Create the bitmap with color bars.
std::vector<wxBitmap*> bmps = get_extruder_color_icons(false);// use wide icons
std::vector<wxBitmapBundle*> bmps = get_extruder_color_icons();// use wide icons
if (bmps.empty()) {
m_extruder_bmp = wxNullBitmap;
return;
@ -438,12 +432,12 @@ ObjectDataViewModel::ObjectDataViewModel()
m_bitmap_cache = new Slic3r::GUI::BitmapCache;
m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_warning_bmp = create_scaled_bitmap(WarningIcon);
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
m_lock_bmp = create_scaled_bitmap(LockIcon);
m_warning_bmp = *get_bmp_bundle(WarningIcon);
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
m_lock_bmp = *get_bmp_bundle(LockIcon);
for (auto item : INFO_ITEMS)
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
m_plate_outside = nullptr;
@ -467,7 +461,7 @@ void ObjectDataViewModel::Init()
AddOutsidePlate();
}
wxBitmap& ObjectDataViewModel::GetWarningBitmap(const std::string& warning_icon_name)
wxBitmapBundle& ObjectDataViewModel::GetWarningBitmap(const std::string& warning_icon_name)
{
return warning_icon_name.empty() ? m_empty_bmp : warning_icon_name == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp;
}
@ -530,7 +524,7 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
is_volume_node &= (vol_type >= int(ModelVolumeType::MODEL_PART) && vol_type <= int(ModelVolumeType::SUPPORT_ENFORCER));
if (!node->has_warning_icon() && !node->has_lock()) {
node->SetBitmap(is_volume_node ? m_volume_bmps.at(vol_type) : m_empty_bmp);
node->SetBitmap(is_volume_node ? *m_volume_bmps.at(vol_type) : m_empty_bmp);
return;
}
@ -542,16 +536,16 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
if (is_volume_node)
scaled_bitmap_name += std::to_string(vol_type);
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
wxBitmapBundle *bmp = m_bitmap_cache->find_bndl(scaled_bitmap_name);
if (!bmp) {
std::vector<wxBitmap> bmps;
std::vector<wxBitmapBundle*> 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(m_volume_bmps[vol_type]);
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
}
node->SetBitmap(*bmp);
@ -685,7 +679,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);
@ -1673,7 +1667,7 @@ wxString ObjectDataViewModel::GetName(const wxDataViewItem &item) const
return node->m_name;
}
wxBitmap& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
wxBitmapBundle& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
{
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
return node->m_bmp;
@ -1715,13 +1709,13 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
switch (col)
{
case colPrint:
variant << node->m_printable_icon;
variant << node->m_printable_icon.GetBitmapFor(m_ctrl);
break;
case colName:
variant << DataViewBitmapText(node->m_name, node->m_bmp);
variant << DataViewBitmapText(node->m_name, node->m_bmp.GetBitmapFor(m_ctrl));
break;
case colFilament:
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp);
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp.GetBitmapFor(m_ctrl));
break;
// BBS
case colSupportPaint:
@ -1734,7 +1728,7 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
variant << node->m_color_icon;
break;
case colEditing:
variant << node->m_action_icon;
variant << node->m_action_icon.GetBitmapFor(m_ctrl);
break;
default:
;
@ -2187,7 +2181,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())
@ -2300,15 +2294,15 @@ void ObjectDataViewModel::SetSinkState(const bool painted, wxDataViewItem obj_it
ItemChanged(obj_item);
}
void ObjectDataViewModel::Rescale()
void ObjectDataViewModel::UpdateBitmaps()
{
m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_warning_bmp = create_scaled_bitmap(WarningIcon);
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
m_lock_bmp = create_scaled_bitmap(LockIcon);
m_warning_bmp = *get_bmp_bundle(WarningIcon);
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
m_lock_bmp = *get_bmp_bundle(LockIcon);
for (auto item : INFO_ITEMS)
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
wxDataViewItemArray all_items;
GetAllChildren(wxDataViewItem(0), all_items);
@ -2319,7 +2313,7 @@ void ObjectDataViewModel::Rescale()
continue;
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
node->msw_rescale();
node->sys_color_changed();
switch (node->m_type)
{
@ -2330,13 +2324,13 @@ void ObjectDataViewModel::Rescale()
node->m_bmp = GetVolumeIcon(node->m_volume_type, node->m_warning_icon_name);
break;
case itLayerRoot:
node->m_bmp = create_scaled_bitmap(LayerRootIcon);
node->m_bmp = *get_bmp_bundle(LayerRootIcon);
break;
case itLayer:
node->m_bmp = create_scaled_bitmap(LayerIcon);
node->m_bmp = *get_bmp_bundle(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;
}
@ -2345,22 +2339,22 @@ void ObjectDataViewModel::Rescale()
}
}
wxBitmap ObjectDataViewModel::GetVolumeIcon(const Slic3r::ModelVolumeType vol_type, const std::string& warning_icon_name/* = std::string()*/)
wxBitmapBundle ObjectDataViewModel::GetVolumeIcon(const Slic3r::ModelVolumeType vol_type, const std::string& warning_icon_name/* = std::string()*/)
{
if (warning_icon_name.empty())
return m_volume_bmps[static_cast<int>(vol_type)];
return *m_volume_bmps[static_cast<int>(vol_type)];
std::string scaled_bitmap_name = warning_icon_name + std::to_string(static_cast<int>(vol_type));
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "-lm");
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
wxBitmapBundle *bmp = m_bitmap_cache->find_bndl(scaled_bitmap_name);
if (bmp == nullptr) {
std::vector<wxBitmap> bmps;
std::vector<wxBitmapBundle*> bmps;
bmps.emplace_back(GetWarningBitmap(warning_icon_name));
bmps.emplace_back(&GetWarningBitmap(warning_icon_name));
bmps.emplace_back(m_volume_bmps[static_cast<int>(vol_type)]);
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
}
return *bmp;
@ -2395,7 +2389,7 @@ void ObjectDataViewModel::DeleteWarningIcon(const wxDataViewItem& item, const bo
return;
if (node->GetType() & itVolume) {
node->SetWarningBitmap(m_volume_bmps[static_cast<int>(node->volume_type())], "");
node->SetWarningBitmap(*m_volume_bmps[static_cast<int>(node->volume_type())], "");
return;
}

View file

@ -71,27 +71,27 @@ class ObjectDataViewModelNode
{
ObjectDataViewModelNode* m_parent;
MyObjectTreeModelNodePtrArray m_children;
wxBitmap m_empty_bmp;
wxBitmapBundle 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;
wxBitmap& m_bmp = m_empty_bmp;
wxBitmapBundle& 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;
wxBitmap m_extruder_bmp;
wxBitmap m_action_icon;
wxBitmapBundle m_extruder_bmp;
wxBitmapBundle m_action_icon;
// BBS
wxBitmap m_support_icon;
wxBitmap m_color_icon;
wxBitmap m_sinking_icon;
wxBitmapBundle m_support_icon;
wxBitmapBundle m_color_icon;
wxBitmapBundle m_sinking_icon;
PrintIndicator m_printable {piUndef};
wxBitmap m_printable_icon;
wxBitmapBundle m_printable_icon;
std::string m_warning_icon_name{ "" };
bool m_has_lock{false}; // for cut object icon
@ -127,7 +127,7 @@ public:
ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
const wxString& sub_obj_name,
Slic3r::ModelVolumeType type,
const wxBitmap& bmp,
const wxBitmapBundle& bmp,
const wxString& extruder,
const int idx = -1,
const std::string& warning_icon_name = std::string());
@ -223,11 +223,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 wxBitmap &icon) { m_bmp = icon; }
void SetBitmap(const wxBitmapBundle &icon) { m_bmp = icon; }
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
void SetWarningBitmap(const wxBitmap& icon, const std::string& warning_icon_name) { m_bmp = icon; m_warning_icon_name = warning_icon_name; }
void SetWarningBitmap(const wxBitmapBundle& icon, const std::string& warning_icon_name) { m_bmp = icon; m_warning_icon_name = warning_icon_name; }
void SetLock(bool has_lock) { m_has_lock = has_lock; }
const wxBitmap& GetBitmap() const { return m_bmp; }
const wxBitmapBundle& 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; }
@ -293,7 +293,7 @@ public:
void update_settings_digest_bitmaps();
bool update_settings_digest(const std::vector<std::string>& categories);
int volume_type() const { return int(m_volume_type); }
void msw_rescale();
void sys_color_changed();
#ifndef NDEBUG
bool valid();
@ -302,7 +302,6 @@ public:
bool has_warning_icon() const { return !m_warning_icon_name.empty(); }
std::string warning_icon_name() const { return m_warning_icon_name; }
bool has_lock() const { return m_has_lock; }
void sys_color_changed();
private:
friend class ObjectDataViewModel;
@ -320,12 +319,12 @@ class ObjectDataViewModel :public wxDataViewModel
{
std::vector<ObjectDataViewModelNode*> m_plates;
std::vector<ObjectDataViewModelNode*> m_objects;
std::vector<wxBitmap> m_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;
std::vector<wxBitmapBundle*> m_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;
ObjectDataViewModelNode* m_plate_outside;
@ -388,7 +387,7 @@ public:
// helper method for wxLog
wxString GetName(const wxDataViewItem &item) const;
wxBitmap& GetBitmap(const wxDataViewItem &item) const;
wxBitmapBundle& GetBitmap(const wxDataViewItem &item) const;
wxString GetExtruder(const wxDataViewItem &item) const;
int GetExtruderNumber(const wxDataViewItem &item) const;
@ -468,9 +467,9 @@ public:
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
// Rescale bitmaps for existing Items
void Rescale();
void UpdateBitmaps();
wxBitmap GetVolumeIcon(const Slic3r::ModelVolumeType vol_type,
wxBitmapBundle GetVolumeIcon(const Slic3r::ModelVolumeType vol_type,
const std::string& warning_icon_name = std::string());
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);
@ -501,7 +500,7 @@ private:
wxDataViewItem AddInstanceRoot(const wxDataViewItem& parent_item);
void AddAllChildren(const wxDataViewItem& parent);
wxBitmap& GetWarningBitmap(const std::string& warning_icon_name);
wxBitmapBundle& GetWarningBitmap(const std::string& warning_icon_name);
void ReparentObject(ObjectDataViewModelNode* plate, ObjectDataViewModelNode* object);
wxDataViewItem AddOutsidePlate(bool refresh = true);

View file

@ -836,7 +836,6 @@ 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;
}
@ -884,7 +883,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->msw_rescale();
sc_btn->sys_color_changed();
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, true);
m_compare_btn = new ScalableButton(m_top_panel, wxID_ANY, "compare", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
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, true);
m_setting_btn = new ScalableButton(m_top_panel, wxID_ANY, "table", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
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->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();
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();
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,11 +515,6 @@ 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 });
@ -531,6 +526,15 @@ 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

@ -490,7 +490,7 @@ void Sidebar::priv::hide_rich_tip(wxButton* btn)
static struct DynamicFilamentList : DynamicList
{
std::vector<std::pair<wxString, wxBitmap *>> items;
std::vector<std::pair<wxString, wxBitmapBundle *>> items;
void apply_on(Choice *c) override
{
@ -529,7 +529,8 @@ static struct DynamicFilamentList : DynamicList
std::string type;
wxGetApp().preset_bundle->filaments.find_preset(presets[i])->get_filament_type(type);
str << type;
items.push_back({str, icons[i]});
wxBitmapBundle* bmp = icons[i];
items.push_back({str, bmp});
}
DynamicList::update();
}
@ -813,9 +814,7 @@ 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);
@ -876,7 +875,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, false, 18);
wxBU_EXACTFIT | wxNO_BORDER, 18);
ams_btn->SetToolTip(_L("Synchronize filament list from AMS"));
ams_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
sync_ams_list();
@ -1338,20 +1337,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->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_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_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->msw_rescale();
p->mode_sizer->sys_color_changed();
#endif
//for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*> { p->combo_print,
@ -1370,15 +1369,14 @@ 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->msw_rescale();
p->btn_send_gcode->sys_color_changed();
// p->btn_eject_device->msw_rescale();
p->btn_export_gcode_removable->msw_rescale();
p->btn_export_gcode_removable->sys_color_changed();
#ifdef _WIN32
const int scaled_height = p->btn_export_gcode_removable->GetBitmapHeight();
#else
@ -1399,26 +1397,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->msw_rescale();
p->object_info->sys_color_changed();
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->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_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_flushing_volume_btn->Rescale();
// BBS
#if 0
if (p->mode_sizer)
p->mode_sizer->msw_rescale();
p->mode_sizer->sys_color_changed();
p->frequently_changed_parameters->sys_color_changed();
#endif
p->object_settings->sys_color_changed();
@ -1446,6 +1444,7 @@ void Sidebar::sys_color_changed()
//p->btn_export_gcode_removable->msw_rescale();
p->scrolled->Layout();
p->scrolled->Refresh();
p->searcher.dlg_sys_color_changed();
}
@ -12161,8 +12160,6 @@ 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 = ScalableBitmap(this, "flag_green");
m_bitmapIncompatible = ScalableBitmap(this, "flag_red");
m_bitmapCompatible = get_bmp_bundle("flag_green");
m_bitmapIncompatible = get_bmp_bundle("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<wxBitmap*, bool>> nonsys_presets;
std::map<wxString, wxBitmap*> incomp_presets;
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
std::map<wxString, wxBitmapBundle*> incomp_presets;
wxString selected = "";
if (!presets.front().is_visible)
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
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;
wxBitmap* bmp = get_bmp(preset);
wxBitmapBundle* 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<wxBitmap*, bool>(bmp, is_enabled));
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, 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")), wxNullBitmap));
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
}
if (!nonsys_presets.empty())
{
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) {
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) {
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")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
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(it->first, *it->second), LABEL_ITEM_DISABLED);
}
}
@ -363,7 +363,8 @@ void PresetComboBox::show_all(bool show_all)
void PresetComboBox::update()
{
this->update(into_u8(this->GetString(this->GetSelection())));
int n = this->GetSelection();
this->update(n < 0 ? "" : into_u8(this->GetString(n)));
}
void PresetComboBox::update_from_bundle()
@ -399,9 +400,7 @@ 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);
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
int item_id = Append(get_preset_name(*iter), *get_extruder_color_icon(color, name, 24, 16), &m_first_ams_filament + entry.first);
}
m_last_ams_filament = GetCount();
}
@ -419,29 +418,24 @@ 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);
msw_rescale();
// update the control to redraw the icons
update();
}
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 = m_bitmapCompatible.GetBmpHeight();
norm_icon_width = m_bitmapCompatible.GetBmpWidth();
icon_height = 16;
norm_icon_width = 16;
/* 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
@ -452,9 +446,11 @@ void PresetComboBox::fill_width_height()
thin_icon_width = lroundf(8 * scale_f); // analogue to 8px;
wide_icon_width = norm_icon_width + thin_icon_width;
space_icon_width = lroundf(2 * scale_f);
thin_space_icon_width = lroundf(4 * scale_f);
wide_space_icon_width = lroundf(6 * scale_f);
null_icon_width = 2 * norm_icon_width;
space_icon_width = 2;
thin_space_icon_width = 4;
wide_space_icon_width = 6;
}
wxString PresetComboBox::separator(const std::string& label)
@ -462,15 +458,15 @@ wxString PresetComboBox::separator(const std::string& label)
return wxString::FromUTF8(separator_head()) + _(label) + wxString::FromUTF8(separator_tail());
}
wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
wxBitmapBundle* 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 wxBitmap bmp;
static wxBitmapBundle bmp;
return &bmp;
#else
#else // if this is updated, refer to PrusaSlicer for updates
// 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)
@ -483,52 +479,52 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con
bitmap_key += ",dark";
bitmap_key += material_rgb;
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
wxBitmapBundle* bmp_bndl = bitmap_cache().find_bndl(bitmap_key);
if (bmp_bndl == nullptr) {
// Create the bitmap with color bars.
std::vector<wxBitmap> bmps;
std::vector<wxBitmapBundle*> bmps;
if (wide_icons)
// Paint a red flag for incompatible presets.
bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp());
bmps.emplace_back(is_compatible ? get_empty_bmp_bundle(norm_icon_width, icon_height) : m_bitmapIncompatible);
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty())
{
// BBS
// Paint a lock at the system presets.
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
bmps.emplace_back(get_empty_bmp_bundle(space_icon_width, icon_height));
}
else
{
// BBS
#if 0
// Paint the color bars.
bmps.emplace_back(bitmap_cache().mkclear(thin_space_icon_width, icon_height));
bmps.emplace_back(get_empty_bmp_bundle(thin_space_icon_width, icon_height));
if (m_type == Preset::TYPE_SLA_MATERIAL)
bmps.emplace_back(create_scaled_bitmap(main_icon_name, this, 16, false, material_rgb));
bmps.emplace_back(bitmap_cache().from_svg(main_icon_name, 16, 16, dark_mode, material_rgb));
else
bmps.emplace_back(create_scaled_bitmap(main_icon_name));
bmps.emplace_back(get_bmp_bundle(main_icon_name));
#endif
// Paint a lock at the system presets.
bmps.emplace_back(bitmap_cache().mkclear(wide_space_icon_width, icon_height));
bmps.emplace_back(get_empty_bmp_bundle(wide_space_icon_width, icon_height));
}
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);
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);
}
return bmp;
return bmp_bndl;
#endif
}
wxBitmap *PresetComboBox::get_bmp(Preset const &preset)
wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
{
static wxBitmap sbmp;
static wxBitmapBundle 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();
wxBitmap *bmp = bitmap_cache().find(bitmap_key);
wxBitmapBundle *bmp = bitmap_cache().find_bndl(bitmap_key);
if (bmp == nullptr) {
wxImage img(16, 16);
if (clr.Red() > 224 && clr.Blue() > 224 && clr.Green() > 224) {
@ -537,8 +533,8 @@ wxBitmap *PresetComboBox::get_bmp(Preset const &preset)
} else {
img.SetRGB(wxRect({0, 0}, img.GetSize()), clr.Red(), clr.Green(), clr.Blue());
}
bmp = new wxBitmap(img);
bmp = bitmap_cache().insert(bitmap_key, *bmp);
bmp = new wxBitmapBundle(img);
bmp = bitmap_cache().insert_bndl(bitmap_key, *bmp);
}
return bmp;
}
@ -546,14 +542,14 @@ wxBitmap *PresetComboBox::get_bmp(Preset const &preset)
return &sbmp;
}
wxBitmap *PresetComboBox::get_bmp(std::string bitmap_key,
wxBitmapBundle *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 wxBitmap bmp;
static wxBitmapBundle bmp;
return &bmp;
#else
bitmap_key += !is_enabled ? "_disabled" : "";
@ -563,21 +559,27 @@ wxBitmap *PresetComboBox::get_bmp(std::string bitmap_key,
if (wxGetApp().dark_mode())
bitmap_key += ",dark";
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
wxBitmapBundle* bmp = bitmap_cache().find_bndl(bitmap_key);
if (bmp == nullptr) {
// Create the bitmap with color bars.
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());
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);
// Paint a lock at the system presets.
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);
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);
}
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();
@ -944,10 +946,12 @@ void PlaterPresetComboBox::update()
// and draw a red flag in front of the selected preset.
bool wide_icons = selected_preset && !selected_preset->is_compatible;
std::map<wxString, wxBitmap*> nonsys_presets;
null_icon_width = (wide_icons ? 3 : 2) * norm_icon_width + thin_space_icon_width + wide_space_icon_width;
std::map<wxString, wxBitmapBundle*> nonsys_presets;
//BBS: add project embedded presets logic
std::map<wxString, wxBitmap*> project_embedded_presets;
std::map<wxString, wxBitmap*> system_presets;
std::map<wxString, wxBitmapBundle*> project_embedded_presets;
std::map<wxString, wxBitmapBundle*> system_presets;
//BBS: move system to the end
wxString selected_system_preset;
@ -957,7 +961,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")), wxNullBitmap));*/
this->set_label_marker(this->Append(separator(L("System presets")), NullBitmapBndl()));*/
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
{
@ -985,7 +989,7 @@ void PlaterPresetComboBox::update()
#endif
}
wxBitmap* bmp = get_bmp(preset);
wxBitmapBundle* bmp = get_bmp(preset);
assert(bmp);
const std::string name = preset.alias.empty() ? preset.name : preset.alias;
@ -1030,16 +1034,16 @@ void PlaterPresetComboBox::update()
//BBS: add project embedded preset logic
if (!project_embedded_presets.empty())
{
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) {
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) {
Append(it->first, *it->second);
validate_selection(it->first == selected_user_preset);
}
}
if (!nonsys_presets.empty())
{
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_user_preset);
}
@ -1047,8 +1051,8 @@ void PlaterPresetComboBox::update()
//BBS: move system to the end
if (!system_presets.empty())
{
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_system_preset);
}
@ -1059,7 +1063,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")), wxNullBitmap));
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@ -1068,7 +1072,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;
wxBitmap* bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
auto 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);
@ -1079,7 +1083,7 @@ void PlaterPresetComboBox::update()
}*/
if (m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) {
wxBitmap* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
wxBitmapBundle* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
assert(bmp);
if (m_type == Preset::TYPE_FILAMENT)
@ -1121,11 +1125,22 @@ void PlaterPresetComboBox::msw_rescale()
if (clr_picker)
clr_picker->SetSize(20 * m_em_unit / 10, 20 * m_em_unit / 10);
// BBS
if (edit_btn != nullptr)
edit_btn->msw_rescale();
#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();
}
// ---------------------------------
// *** TabPresetComboBox ***
@ -1193,16 +1208,16 @@ void TabPresetComboBox::update()
const std::deque<Preset>& presets = m_collection->get_presets();
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
//BBS: add project embedded presets logic
std::map<wxString, std::pair<wxBitmap*, bool>> project_embedded_presets;
std::map<wxString, std::pair<wxBitmapBundle*, bool>> project_embedded_presets;
//BBS: move system to the end
std::map<wxString, std::pair<wxBitmap*, bool>> system_presets;
std::map<wxString, std::pair<wxBitmapBundle*, bool>> system_presets;
wxString selected = "";
//BBS: move system to the end
/*if (!presets.front().is_visible)
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));*/
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));*/
size_t idx_selected = m_collection->get_selected_idx();
if (m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection()) {
@ -1221,12 +1236,12 @@ void TabPresetComboBox::update()
// marker used for disable incompatible printer models for the selected physical printer
bool is_enabled = true;
wxBitmap* bmp = get_bmp(preset);
wxBitmapBundle* 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<wxBitmap *, bool>(bmp, is_enabled));
system_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle *, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
//int item_id = Append(get_preset_name(preset), *bmp);
@ -1238,20 +1253,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<wxBitmap *, bool>(bmp, is_enabled));
project_embedded_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle *, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
}
else
{
std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
std::pair<wxBitmapBundle*, bool> pair(bmp, is_enabled);
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, 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")), wxNullBitmap));
// set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
}
if (m_type == Preset::TYPE_FILAMENT && m_preset_bundle->is_bbl_vendor())
@ -1261,7 +1276,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<wxBitmap*, bool>>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
for (std::map<wxString, std::pair<wxBitmapBundle*, 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)
@ -1271,8 +1286,8 @@ void TabPresetComboBox::update()
}
if (!nonsys_presets.empty())
{
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) {
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) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1284,7 +1299,7 @@ void TabPresetComboBox::update()
if (!system_presets.empty())
{
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
for (std::map<wxString, std::pair<wxBitmapBundle*, 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)
@ -1298,7 +1313,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")), wxNullBitmap));
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@ -1308,7 +1323,7 @@ void TabPresetComboBox::update()
continue;
std::string main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
wxBitmap* bmp = get_bmp(main_icon_name, main_icon_name, "", true, true, false);
auto 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);
@ -1319,14 +1334,14 @@ void TabPresetComboBox::update()
// add "Add/Remove printers" item
//std::string icon_name = "edit_uni";
//wxBitmap* bmp = get_bmp("edit_preset_list, tab,", icon_name, "");
//auto 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
//wxBitmap* bmp = get_bmp("edit_preset_list", false, "edit_uni");
//wxBitmapBundle* 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);
@ -1486,7 +1501,7 @@ void GUI::CalibrateFilamentComboBox::update()
tooltip = get_tooltip(preset);
}
wxBitmap* bmp = get_bmp(preset);
wxBitmapBundle* bmp = get_bmp(preset);
assert(bmp);
if (preset.is_default || preset.is_system) {
@ -1529,7 +1544,7 @@ void GUI::CalibrateFilamentComboBox::msw_rescale()
}
// BBS
if (edit_btn != nullptr)
edit_btn->msw_rescale();
edit_btn->sys_color_changed();
}
void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt)

View file

@ -1,7 +1,7 @@
#ifndef slic3r_PresetComboBoxes_hpp_
#define slic3r_PresetComboBoxes_hpp_
//#include <wx/bmpcbox.h>
#include <wx/bmpbndl.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 {
enum LabelItemType : size_t {
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.
ScalableBitmap m_bitmapCompatible;
wxBitmapBundle* m_bitmapCompatible;
// Indicator, that the preset is NOT compatible with the selected printer.
ScalableBitmap m_bitmapIncompatible;
wxBitmapBundle* m_bitmapIncompatible;
int m_last_selected;
int m_em_unit;
@ -115,6 +115,7 @@ 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;
@ -139,14 +140,16 @@ protected:
#endif // __linux__
static wxString separator(const std::string& label);
wxBitmap* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
wxBitmapBundle* 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 = "");
wxBitmap* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
wxBitmapBundle* 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);
wxBitmap *get_bmp(Preset const &preset);
wxBitmapBundle* get_bmp(Preset const &preset);
wxBitmapBundle NullBitmapBndl();
private:
void fill_width_height();
@ -179,6 +182,7 @@ 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:
@ -245,8 +249,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, wxBitmap*>> m_nonsys_presets;
std::map<wxString, std::pair<std::string, wxBitmap*>> m_system_presets;
std::map<wxString, std::pair<std::string, wxBitmapBundle*>> m_nonsys_presets;
std::map<wxString, std::pair<std::string, wxBitmapBundle*>> 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.GetBmpWidth() - hint1_size.y) / 2;
pos_hint1.y += (m_home_bmp.GetWidth() - 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.bmp(), pos_bmp);
dc.DrawBitmap(m_home_bmp.get_bitmap(), 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.GetBmpWidth();
pos_hint2.x = pos_hint2.x + hint1_size.x + m_home_bmp.GetWidth();
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, create_scaled_bitmap("blank_16", m_parent));
// m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, *get_bmp_bundle("blank_16"));
//
// 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(create_scaled_bitmap(bmp_name, m_parent));
m_valid_bmp->SetBitmap(*get_bmp_bundle(bmp_name));
}
void SavePresetDialog::Item::accept()

View file

@ -829,12 +829,9 @@ 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);
@ -852,7 +849,7 @@ void SearchDialog::msw_rescale()
//#endif
//
// // msw_rescale updates just icons, so use it
// search_list_model->msw_rescale();
// search_list_model->sys_color_changed();
//
// Refresh();
//}
@ -884,9 +881,10 @@ void SearchListModel::Prepend(const std::string &label)
RowPrepended();
}
void SearchListModel::msw_rescale()
void SearchListModel::sys_color_changed()
{
for (ScalableBitmap &bmp : m_icon) bmp.msw_rescale();
for (ScalableBitmap &bmp : m_icon)
bmp.sys_color_changed();
}
wxString SearchListModel::GetColumnType(unsigned int col) const
@ -898,7 +896,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(); break;
case colIcon: variant << m_icon[m_values[row].second].bmp().GetBitmapFor(m_icon[m_values[row].second].parent()); 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 msw_rescale();
void sys_color_changed();
// implementation of base class virtuals to define model

View file

@ -210,9 +210,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.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2));
dc.DrawBitmap(dwbitmap.get_bitmap(), wxPoint(left, (size.y - dwbitmap.GetSize().y) / 2));
left += dwbitmap.GetBmpSize().x + 8;
left += dwbitmap.GetSize().x + 8;
dc.SetFont(Label::Body_13);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
@ -228,10 +228,10 @@ void MachineObjectPanel::doRender(wxDC &dc)
auto text_end = 0;
if (m_show_edit) {
text_end = size.x - m_unbind_img.GetBmpSize().x - 30;
text_end = size.x - m_unbind_img.GetSize().x - 30;
}
else {
text_end = size.x - m_unbind_img.GetBmpSize().x;
text_end = size.x - m_unbind_img.GetSize().x;
}
wxString finally_name = dev_name;
@ -259,14 +259,14 @@ void MachineObjectPanel::doRender(wxDC &dc)
if (m_show_bind) {
if (m_bind_state == ALLOW_UNBIND) {
left = size.x - m_unbind_img.GetBmpSize().x - 6;
dc.DrawBitmap(m_unbind_img.bmp(), left, (size.y - m_unbind_img.GetBmpSize().y) / 2);
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);
}
}
if (m_show_edit) {
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);
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);
}
}
@ -296,10 +296,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.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;
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;
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);
@ -308,10 +308,10 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
}
}
if (m_show_bind) {
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;
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;
if ((evt.GetPosition().x >= left && evt.GetPosition().x <= right) && evt.GetPosition().y >= top && evt.GetPosition().y <= bottom) {
wxCommandEvent event(EVT_UNBIND_MACHINE, GetId());
@ -3635,16 +3635,16 @@ void SelectMachineDialog::Enable_Send_Button(bool en)
void SelectMachineDialog::on_dpi_changed(const wxRect &suggested_rect)
{
print_time->msw_rescale();
print_time->sys_color_changed();
timeimg->SetBitmap(print_time->bmp());
print_weight->msw_rescale();
print_weight->sys_color_changed();
weightimg->SetBitmap(print_weight->bmp());
m_rename_button->msw_rescale();
ams_editable->msw_rescale();
ams_editable_light->msw_rescale();
enable_ams_mapping->msw_rescale();
m_rename_button->sys_color_changed();
ams_editable->sys_color_changed();
ams_editable_light->sys_color_changed();
enable_ams_mapping->sys_color_changed();
img_amsmapping_tip->SetBitmap(enable_ams_mapping->bmp());
enable_ams->msw_rescale();
enable_ams->sys_color_changed();
img_use_ams_tip->SetBitmap(enable_ams->bmp());
m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
@ -4446,7 +4446,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.bmp(), 0, 0);
dc.DrawBitmap(m_background_bitmap.get_bitmap(), 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,true);
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->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, true);
m_button_abort = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_stop", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
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, true, 26);
wxBU_EXACTFIT | wxNO_BORDER, 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.bmp(), 0, 0);
dc.DrawBitmap(m_bitmap_background.get_bitmap(), 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->msw_rescale();
m_button_abort->sys_color_changed();
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.bmp());
this->set_thumbnail_img(m_thumbnail_placeholder.get_bitmap());
this->set_plate_index(-1);
}
@ -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.bmp());
m_project_task_panel->set_thumbnail_img(m_thumbnail_brokenimg.get_bitmap());
m_project_task_panel->set_plate_index(-1);
task_thumbnail_state = ThumbnailState::BROKEN_IMG;
break;
@ -4046,8 +4046,8 @@ void StatusPanel::rescale_camera_icons()
void StatusPanel::on_sys_color_changed()
{
m_project_task_panel->msw_rescale();
m_bitmap_speed.msw_rescale();
m_bitmap_speed_active.msw_rescale();
m_bitmap_speed.sys_color_changed();
m_bitmap_speed_active.sys_color_changed();
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.msw_rescale();
m_bitmap_speed_active.msw_rescale();
m_bitmap_speed.sys_color_changed();
m_bitmap_speed_active.sys_color_changed();
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, true, 26);
wxBU_EXACTFIT | wxNO_BORDER, 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, true, 26);
wxBU_EXACTFIT | wxNO_BORDER, 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_bmp = ScalableBitmap(this, wxGetApp().logo_name(), 192);
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 192));
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);

View file

@ -229,8 +229,6 @@ 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());
@ -395,7 +393,7 @@ void Tab::create_preset_tab()
#endif
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
const float scale_factor = /*wxGetApp().*/em_unit(this)*0.1;// GetContentScaleFactor();
const float scale_factor = 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);
@ -444,11 +442,8 @@ 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);
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}.
// Index of the last icon inserted into m_tabctrl.
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.
@ -526,6 +521,22 @@ 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
@ -541,7 +552,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, true);
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style);
(*btn)->SetBackgroundColour(parent->GetBackgroundColour());
m_scaled_buttons.push_back(*btn);
}
@ -572,7 +583,6 @@ 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;
}
@ -887,18 +897,6 @@ 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())
@ -1174,35 +1172,30 @@ 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->msw_rescale();
bmp->sys_color_changed();
if (m_mode_view)
m_mode_view->Rescale();
if (m_detach_preset_btn)
m_detach_preset_btn->msw_rescale();
m_detach_preset_btn->sys_color_changed();
// 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);
// 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 options_groups
if (m_active_page)
@ -1222,21 +1215,24 @@ void Tab::sys_color_changed()
// update buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->msw_rescale();
btn->sys_color_changed();
for (const auto bmp : m_scaled_bitmaps)
bmp->msw_rescale();
bmp->sys_color_changed();
if (m_detach_preset_btn)
m_detach_preset_btn->msw_rescale();
m_detach_preset_btn->sys_color_changed();
// 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);
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);*/
// Colors for ui "decoration"
update_label_colours();
@ -1244,7 +1240,7 @@ void Tab::sys_color_changed()
wxWindowUpdateLocker noUpdates(this);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->msw_rescale();
// m_mode_sizer->sys_color_changed();
wxGetApp().UpdateDarkUI(this);
wxGetApp().UpdateDarkUI(m_tabctrl);
#endif
@ -1257,6 +1253,7 @@ 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
@ -1737,7 +1734,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, true);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
ScalableButton* btn = m_detach_preset_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -2197,7 +2194,7 @@ void TabPrint::build()
optgroup->append_single_option_line(option);
#if 0
//page = add_options_page(L("Dependencies"), "advanced.png");
//page = add_options_page(L("Dependencies"), "advanced");
// optgroup = page->new_optgroup(L("Profile dependencies"));
// create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -3607,7 +3604,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.png");
//page = add_options_page(L("Dependencies"), "wrench");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//build_preset_description_line(optgroup.get());
@ -3879,7 +3876,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, true);
// wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
// ScalableButton* btn = m_reset_to_filament_color;
// btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
// btn->SetSize(btn->GetBestSize());
@ -5242,8 +5239,7 @@ void Tab::toggle_show_hide_incompatible()
void Tab::update_show_hide_incompatible_button()
{
//BBS: GUI refactor
/*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->SetBitmap(*get_bmp_bundle(m_show_incompatible_presets ? "flag_red" : "flag_green"));
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.");*/
@ -5290,7 +5286,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, true);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
deps.btn->SetSize(deps.btn->GetBestSize());
@ -5365,7 +5361,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, true);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
btn->SetFont(wxGetApp().normal_font());
btn->SetSize(btn->GetBestSize());
@ -5783,7 +5779,7 @@ void TabSLAMaterial::build()
//optgroup->append_line(line);
//page = add_options_page(L("Dependencies"), "wrench.png");
//page = add_options_page(L("Dependencies"), "wrench");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -5804,7 +5800,7 @@ void TabSLAMaterial::build()
//build_preset_description_line(optgroup.get());
//page = add_options_page(L("Material printing profile"), "printer.png");
//page = add_options_page(L("Material printing profile"), "printer");
//optgroup = page->new_optgroup(L("Material printing profile"));
//option = optgroup->get_option("material_print_speed");
//optgroup->append_single_option_line(option);

View file

@ -154,7 +154,6 @@ protected:
//wxBoxSizer* m_hsizer;
//wxBoxSizer* m_left_sizer;
TabCtrl* m_tabctrl;
wxImageList* m_icons;
wxScrolledWindow* m_page_view {nullptr};
//wxBoxSizer* m_page_sizer {nullptr};
@ -189,10 +188,6 @@ 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;
@ -610,7 +605,6 @@ 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.GetBmpSize();
szIcon = icon.GetSize();
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.GetBmpWidth() - paddingSize.y;
pt.y = (size.y - icon.GetBmpHeight()) / 2;
dc.DrawBitmap(icon.bmp(), pt);
pt.x = size.x - icon.GetWidth() - paddingSize.y;
pt.y = (size.y - icon.GetHeight()) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
}
}
@ -189,7 +189,7 @@ void TabButton::messureSize()
// BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->icon.GetBmpSize();
wxSize szIcon = this->icon.GetSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}

View file

@ -117,29 +117,21 @@ wxIcon ModelNode::get_bitmap(const wxString& color)
wxBitmap ModelNode::get_bitmap(const wxString& color)
#endif // __linux__
{
/* 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
wxBitmap bmp = get_solid_bmp_bundle(64, 16, into_u8(color))->GetBitmapFor(m_parent_win);
if (!m_toggle)
bmp = bmp.ConvertToDisabled();
#ifndef __linux__
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
return bmp;
#else
wxIcon icon;
icon.CopyFromBitmap(bmp_cache.mksolid(icon_width, icon_height, rgb, true));
icon.CopyFromBitmap(bmp);
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 : ""),
@ -204,18 +196,22 @@ void ModelNode::UpdateIcons()
{
// update icons for the colors, if any exists
if (!m_old_color.IsEmpty())
m_old_color_bmp = get_bitmap(m_toggle ? m_old_color : wxString::FromUTF8(grey.c_str()));
m_old_color_bmp = get_bitmap(m_old_color);
if (!m_new_color.IsEmpty())
m_new_color_bmp = get_bitmap(m_toggle ? m_new_color : wxString::FromUTF8(grey.c_str()));
m_new_color_bmp = get_bitmap(m_new_color);
// 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(create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle));
m_icon.CopyFromBitmap(bmp);
#else
m_icon = create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle);
m_icon = bmp;
#endif //__linux__
}
@ -1021,7 +1017,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, true, 24);
/* ScalableButton *cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, 24);
buttons->Add(cancel_btn, 1, wxLEFT | wxRIGHT, 5);
cancel_btn->SetFont(btn_font);*/
/* m_cancel_btn = new Button(this, _L("Cancel"));
@ -1708,7 +1704,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->msw_rescale();
//btn->sys_color_changed();
// msw_rescale updates just icons, so use it
//m_tree->Rescale();
@ -2115,10 +2111,16 @@ 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) {
preset_combos.presets_left->msw_rescale();
preset_combos.equal_bmp->msw_rescale();
preset_combos.presets_right->msw_rescale();
rescale(preset_combos.presets_left);
rescale(preset_combos.presets_right);
}
m_tree->Rescale(em);
@ -2136,9 +2138,9 @@ void DiffPresetDialog::on_sys_color_changed()
#endif
for (auto preset_combos : m_preset_combos) {
preset_combos.presets_left->msw_rescale();
preset_combos.equal_bmp->msw_rescale();
preset_combos.presets_right->msw_rescale();
preset_combos.presets_left->sys_color_changed();
preset_combos.equal_bmp->sys_color_changed();
preset_combos.presets_right->sys_color_changed();
}
// msw_rescale updates just icons, so use it
m_tree->Rescale();

View file

@ -322,15 +322,15 @@ void MachineInfoPanel::init_bitmaps()
void MachineInfoPanel::rescale_bitmaps()
{
m_img_printer.msw_rescale();
m_img_printer.sys_color_changed();
m_printer_img->SetBitmap(m_img_printer.bmp());
m_img_monitor_ams.msw_rescale();
m_img_monitor_ams.sys_color_changed();
m_ams_img->SetBitmap(m_img_monitor_ams.bmp());
m_img_ext.msw_rescale();
m_img_ext.sys_color_changed();
m_ext_img->SetBitmap(m_img_ext.bmp());
upgrade_green_icon.msw_rescale();
upgrade_gray_icon.msw_rescale();
upgrade_yellow_icon.msw_rescale();
upgrade_green_icon.sys_color_changed();
upgrade_gray_icon.sys_color_changed();
upgrade_yellow_icon.sys_color_changed();
m_ota_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}
@ -1161,7 +1161,7 @@ bool UpgradePanel::Show(bool show)
}
void AmsPanel::msw_rescale() {
upgrade_green_icon.msw_rescale();
upgrade_green_icon.sys_color_changed();
m_ams_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}
@ -1235,7 +1235,7 @@ bool UpgradePanel::Show(bool show)
void ExtensionPanel::msw_rescale()
{
upgrade_green_icon.msw_rescale();
upgrade_green_icon.sys_color_changed();
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.GetBmpSize().x) / 2, (size.y - m_bitmap_selected.GetBmpSize().y) / 2);
auto pot = wxPoint((size.x - m_bitmap_selected.GetSize().x) / 2, (size.y - m_bitmap_selected.GetSize().y) / 2);
if (!m_disable_mode) {
if (!m_play_loading) {
dc.DrawBitmap(m_selected ? m_bitmap_selected.bmp() : m_bitmap_normal.bmp(), pot);
dc.DrawBitmap(m_selected ? m_bitmap_selected.get_bitmap() : m_bitmap_normal.get_bitmap(), 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].bmp(), pot);
dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].get_bitmap(), 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.bmp(), wxPoint((size.x - m_ams_extruder.GetBmpSize().x) / 2, (size.y - m_ams_extruder.GetBmpSize().y) / 2));
dc.DrawBitmap(m_ams_extruder.get_bitmap(), wxPoint((size.x - m_ams_extruder.GetSize().x) / 2, (size.y - m_ams_extruder.GetSize().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.GetBmpSize().y);
top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetSize().y);
bottom = size.y - FromDIP(15);
}
else if (m_ams_model == AMSModel::EXTRA_AMS) {
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetBmpSize().y);
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetSize().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.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetBmpSize().y));
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));
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
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));
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));
}
}
// selected & hover
if (m_selected) {
dc.DrawBitmap(tray_bitmap_selected.bmp(), (size.x - tray_bitmap_selected.GetBmpSize().x) / 2, (size.y - tray_bitmap_selected.GetBmpSize().y) / 2);
dc.DrawBitmap(tray_bitmap_selected.get_bitmap(), (size.x - tray_bitmap_selected.GetSize().x) / 2, (size.y - tray_bitmap_selected.GetSize().y) / 2);
}
else if (!m_selected && m_hover) {
dc.DrawBitmap(tray_bitmap_hover.bmp(), (size.x - tray_bitmap_hover.GetBmpSize().x) / 2, (size.y - tray_bitmap_hover.GetBmpSize().y) / 2);
dc.DrawBitmap(tray_bitmap_hover.get_bitmap(), (size.x - tray_bitmap_hover.GetSize().x) / 2, (size.y - tray_bitmap_hover.GetSize().y) / 2);
}
else {
dc.DrawBitmap(tray_bitmap.bmp(), (size.x - tray_bitmap.GetBmpSize().x) / 2, (size.y - tray_bitmap.GetBmpSize().y) / 2);
dc.DrawBitmap(tray_bitmap.get_bitmap(), (size.x - tray_bitmap.GetSize().x) / 2, (size.y - tray_bitmap.GetSize().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.bmp(), FromDIP(4), FromDIP(4));
dc.DrawBitmap(m_bitmap_transparent.get_bitmap(), 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.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y));
dc.DrawBitmap(temp_bitmap_third.get_bitmap(), (size.x - temp_bitmap_third.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetSize().y));
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y));
dc.DrawBitmap(temp_bitmap_brand.get_bitmap(), (size.x - temp_bitmap_brand.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetSize().y));
}
}
}
@ -1244,8 +1244,7 @@ void AMSLib::UnSelected()
bool AMSLib::Enable(bool enable) { return wxWindow::Enable(enable); }
void AMSLib::msw_rescale()
{
m_bitmap_transparent.msw_rescale();
{ m_bitmap_transparent.sys_color_changed();
}
/*************************************************
@ -1452,20 +1451,20 @@ void AMSRoad::doRender(wxDC &dc)
else {m_show_humidity = false;}
if (m_amsinfo.ams_humidity == 5) {
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)));
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)));
}
else if (m_amsinfo.ams_humidity == 4) {
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)));
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)));
}
else if (m_amsinfo.ams_humidity == 3) {
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)));
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)));
}
else if (m_amsinfo.ams_humidity == 2) {
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)));
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)));
}
else if (m_amsinfo.ams_humidity == 1) {
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)));
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)));
}
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)));*/
@ -1662,7 +1661,7 @@ void AMSItem::doRender(wxDC &dc)
}else {
if (iter->material_colour.Alpha() == 0) {
dc.DrawBitmap(m_ts_bitmap_cube->bmp(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
dc.DrawBitmap(m_ts_bitmap_cube->get_bitmap(),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);
@ -2092,7 +2091,7 @@ void AmsCans::render(wxDC& dc)
void AmsCans::doRender(wxDC& dc)
{
wxSize size = GetSize();
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);
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);
//road for extra
if (m_ams_model == AMSModel::EXTRA_AMS) {
@ -2982,9 +2981,9 @@ void AMSControl::StopRridLoading(wxString amsid, wxString canid)
void AMSControl::msw_rescale()
{
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_normal.sys_color_changed();
m_button_ams_setting_hover.sys_color_changed();
m_button_ams_setting_press.sys_color_changed();
m_button_ams_setting->SetBitmap(m_button_ams_setting_normal.bmp());
m_extruder->msw_rescale();

View file

@ -212,7 +212,8 @@ void AxisCtrlButton::render(wxDC& dc)
gc->DrawPath(home_path);
if (m_icon.bmp().IsOk()) {
gc->DrawBitmap(m_icon.bmp(), -1 * m_icon.GetBmpWidth() / 2, -1 * m_icon.GetBmpHeight() / 2, m_icon.GetBmpWidth(), m_icon.GetBmpHeight());
gc->DrawBitmap(m_icon.get_bitmap(), -1 * m_icon.GetWidth() / 2, -1 * m_icon.GetHeight() / 2, m_icon.GetWidth(),
m_icon.GetHeight());
}
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.msw_rescale();
this->active_icon.sys_color_changed();
if (this->inactive_icon.bmp().IsOk())
this->inactive_icon.msw_rescale();
this->inactive_icon.sys_color_changed();
messureSize();
}
@ -187,7 +187,7 @@ void Button::render(wxDC& dc)
//BBS norrow size between text and icon
szContent.x += padding;
}
szIcon = icon.GetBmpSize();
szIcon = icon.GetSize();
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.bmp(), pt);
dc.DrawBitmap(icon.get_bitmap(), 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.GetBmpSize();
wxSize szIcon = this->active_icon.GetSize();
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.GetBmpSize());
SetMinSize(m_on.GetBmpSize());
SetSize(m_on.GetSize());
SetMinSize(m_on.GetSize());
update();
}
@ -43,16 +43,16 @@ void CheckBox::SetHalfChecked(bool value)
void CheckBox::Rescale()
{
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());
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());
update();
}

View file

@ -98,6 +98,13 @@ 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();
@ -145,13 +152,17 @@ bool ComboBox::SetFont(wxFont const& font)
return TextInput::SetFont(font);
}
int ComboBox::Append(const wxString &item, const wxBitmap &bitmap)
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)
{
return Append(item, bitmap, nullptr);
}
int ComboBox::Append(const wxString &item,
const wxBitmap &bitmap,
const wxBitmapBundle &bitmap,
void * clientData)
{
texts.push_back(item);
@ -196,9 +207,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]; }
wxBitmap ComboBox::GetItemBitmap(unsigned int n) { return icons[n].GetBitmapFor(m_parent); }
void ComboBox::SetItemBitmap(unsigned int n, wxBitmap const &bitmap)
void ComboBox::SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap)
{
if (n >= texts.size()) return;
icons[n] = bitmap;
@ -230,9 +241,7 @@ void ComboBox::DoSetItemClientData(unsigned int n, void *data)
datas[n] = data;
}
void ComboBox::mouseDown(wxMouseEvent &event)
{
SetFocus();
void ComboBox::ToggleDropDown(){
if (drop_down) {
drop.Hide();
} else if (drop.HasDismissLongTime()) {
@ -244,6 +253,12 @@ void ComboBox::mouseDown(wxMouseEvent &event)
}
}
void ComboBox::mouseDown(wxMouseEvent &event)
{
SetFocus();
ToggleDropDown();
}
void ComboBox::mouseWheelMoved(wxMouseEvent &event)
{
event.Skip();
@ -261,15 +276,7 @@ void ComboBox::keyDown(wxKeyEvent& event)
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_SPACE:
if (drop_down) {
drop.DismissAndNotify();
} else if (drop.HasDismissLongTime()) {
drop.autoPosition();
drop_down = true;
drop.Popup();
wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
GetEventHandler()->ProcessEvent(e);
}
ToggleDropDown();
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<wxBitmap> icons;
std::vector<wxBitmapBundle> icons;
std::vector<void *> datas;
std::vector<wxClientDataType> types;
@ -32,10 +32,9 @@ public:
virtual bool SetFont(wxFont const & font) override;
public:
int Append(const wxString &item, const wxBitmap &bitmap = wxNullBitmap);
int Append(const wxString &item, const wxBitmapBundle &bitmap = wxNullBitmap);
int Append(const wxString &item, const wxBitmap &bitmap, void *clientData);
int Append(const wxString &item, const wxBitmapBundle &bitmap, void *clientData);
unsigned int GetCount() const override;
@ -60,7 +59,11 @@ public:
void SetString(unsigned int n, wxString const &value) override;
wxBitmap GetItemBitmap(unsigned int n);
void SetItemBitmap(unsigned int n, wxBitmap const &bitmap);
void SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap);
void ToggleDropDown();
bool Enable(bool enable = true) override;
void SetIcon(const wxBitmapBundle &icon) override;
protected:
virtual int DoInsertItems(const wxArrayStringsAdapter &items,

View file

@ -29,7 +29,7 @@ END_EVENT_TABLE()
*/
DropDown::DropDown(std::vector<wxString> &texts,
std::vector<wxBitmap> &icons)
std::vector<wxBitmapBundle> &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<wxBitmap> &icons,
std::vector<wxBitmapBundle> &icons,
long style)
: DropDown(texts, icons)
{
@ -188,15 +188,6 @@ 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
@ -265,13 +256,13 @@ void DropDown::render(wxDC &dc)
rcContent.x += 5;
rcContent.width -= 5;
if (check_bitmap.bmp().IsOk()) {
auto szBmp = check_bitmap.GetBmpSize();
auto szBmp = check_bitmap.GetSize();
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.bmp(), pt);
dc.DrawBitmap(check_bitmap.get_bitmap(), pt);
}
rcContent.x += szBmp.x + 5;
rcContent.width -= szBmp.x + 5;
@ -286,17 +277,17 @@ void DropDown::render(wxDC &dc)
if (rcContent.y > size.y) break;
wxPoint pt = rcContent.GetLeftTop();
auto & icon = icons[i];
auto size2 = GetBmpSize(icon);
auto size2 = get_preferred_size(icon, m_parent);
if (iconSize.x > 0) {
if (icon.IsOk()) {
pt.y += (rcContent.height - size2.y) / 2;
dc.DrawBitmap(icon, pt);
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
}
pt.x += iconSize.x + 5;
pt.y = rcContent.y;
} else if (icon.IsOk()) {
pt.y += (rcContent.height - size2.y) / 2;
dc.DrawBitmap(icon, pt);
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
pt.x += size2.x + 5;
pt.y = rcContent.y;
}
@ -326,7 +317,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 = GetBmpSize(icons[i]);
wxSize size2 = get_preferred_size(icons[i], m_parent);
if (size2.x > iconSize.x) iconSize = size2;
if (!align_icon) {
size1.x += size2.x + (text_off ? 0 : 5);
@ -338,7 +329,7 @@ void DropDown::messureSize()
wxSize szContent = textSize;
szContent.x += 10;
if (check_bitmap.bmp().IsOk()) {
auto szBmp = check_bitmap.GetBmpSize();
auto szBmp = check_bitmap.GetSize();
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<wxBitmap> & icons;
std::vector<wxBitmapBundle> & 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<wxBitmap> &icons);
std::vector<wxBitmapBundle> &icons);
DropDown(wxWindow * parent,
std::vector<wxString> &texts,
std::vector<wxBitmap> &icons,
std::vector<wxBitmapBundle> &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.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
SetMaxSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
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)));
//#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.bmp(), wxPoint(0,0));
dc.DrawBitmap(m_bitmap_bk.get_bitmap(), 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].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);
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);
//fan val
dc.SetTextForeground(DRAW_TEXT_COLOUR);
@ -147,8 +147,7 @@ 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.msw_rescale();
void Fan::msw_rescale() { m_bitmap_bk.sys_color_changed();
}
void Fan::DoSetSize(int x, int y, int width, int height, int sizeFlags)
@ -280,8 +279,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.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);
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);
//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.GetBmpHeight() + textSize.y + m_padding;
int content_height = icon.GetHeight() + textSize.y + m_padding;
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 2, (size.y - content_height) / 2);
if (icon.bmp().IsOk()) {
dc.DrawBitmap(icon.bmp(), pt);
pt.y += m_padding + icon.GetBmpHeight();
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.y += m_padding + icon.GetHeight();
}
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.GetBmpWidth()) / 2, (size.y - content_height) / 2);
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 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.GetBmpWidth()) / 2, content_height + textSize.y);
pt = wxPoint((size.x - icon.GetWidth()) / 2, content_height + textSize.y);
if (icon.bmp().IsOk()) {
dc.DrawBitmap(icon.bmp(), pt);
pt.y += m_padding + icon.GetBmpHeight();
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.y += m_padding + icon.GetHeight();
}
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.GetBmpSize());
SetMinSize(m_on.GetBmpSize());
SetSize(m_on.GetSize());
SetMinSize(m_on.GetSize());
update();
}
@ -29,9 +29,9 @@ bool RadioBox::GetValue()
void RadioBox::Rescale()
{
m_on.msw_rescale();
m_off.msw_rescale();
SetSize(m_on.GetBmpSize());
m_on.sys_color_changed();
m_off.sys_color_changed();
SetSize(m_on.GetSize());
update();
}

View file

@ -157,7 +157,7 @@ bool SideButton::Enable(bool enable)
void SideButton::Rescale()
{
if (this->icon.bmp().IsOk())
this->icon.msw_rescale();
this->icon.sys_color_changed();
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.GetBmpSize();
szIcon = icon.GetSize();
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.bmp(), pt);
dc.DrawBitmap(icon.get_bitmap(), 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.GetBmpSize();
wxSize szIcon = this->icon.GetSize();
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.bmp(), left, (size.y - m_none_printing_img.GetBmpSize().y) / 2);
dc.DrawBitmap(m_none_printing_img.get_bitmap(), left, (size.y - m_none_printing_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_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_arrow_img.GetBmpSize().x + FromDIP(6));
left += (m_none_arrow_img.GetSize().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.GetBmpSize().x - m_none_add_img.GetBmpSize().x;
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetSize().x - m_none_add_img.GetSize().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.GetBmpSize().x;
dc.DrawBitmap(m_none_add_img.bmp(), left, (size.y - m_none_add_img.GetBmpSize().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);
} else {
dc.DrawBitmap(m_printing_img.bmp(), left, (size.y - m_printing_img.GetBmpSize().y) / 2);
dc.DrawBitmap(m_printing_img.get_bitmap(), left, (size.y - m_printing_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_printing_img.GetSize().x + FromDIP(5));
dc.DrawBitmap(m_arrow_img.get_bitmap(), left, (size.y - m_arrow_img.GetSize().y) / 2);
left += (m_arrow_img.GetBmpSize().x + FromDIP(6));
left += (m_arrow_img.GetSize().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.GetBmpSize().x - 20;
auto text_end = size.x - m_wifi_none_img.GetSize().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.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);
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);
}
if (m_hover) {

View file

@ -46,7 +46,7 @@ void StaticLine::SetLineColour(wxColour color)
void StaticLine::Rescale()
{
if (this->icon.bmp().IsOk())
this->icon.msw_rescale();
this->icon.sys_color_changed();
messureSize();
}
@ -67,7 +67,7 @@ void StaticLine::messureSize()
// BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->icon.GetBmpSize();
wxSize szIcon = this->icon.GetSize();
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.GetBmpHeight(), textSize.GetHeight());
int contentWidth = icon.GetBmpWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
titleRect.height = wxMax(icon.GetHeight(), textSize.GetHeight());
int contentWidth = icon.GetWidth() + ((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.bmp(), {0, (size.y - icon.GetBmpHeight()) / 2});
titleRect.x += icon.GetBmpWidth() + 5;
dc.DrawBitmap(icon.get_bitmap(), {0, (size.y - icon.GetHeight()) / 2});
titleRect.x += icon.GetWidth() + 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.GetBmpHeight() / 36;
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
radius = radius * bmp_thumb.GetHeight() / 36;
bar_width = bar_width * bmp_thumb.GetHeight() / 36;
}
void StepCtrl::Rescale()
{
bmp_thumb.msw_rescale();
radius = radius * bmp_thumb.GetBmpHeight() / 36;
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
bmp_thumb.sys_color_changed();
radius = radius * bmp_thumb.GetHeight() / 36;
bar_width = bar_width * bmp_thumb.GetHeight() / 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.GetBmpSize()};
wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetSize()};
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.GetBmpSize();
dc.DrawBitmap(bmp_thumb.bmp(), circleX - sz.x / 2, circleY - sz.y / 2);
sz = bmp_thumb.GetSize();
dc.DrawBitmap(bmp_thumb.get_bitmap(), 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.GetBmpHeight() / 2;
bar_width = bmp_ok.GetBmpHeight() / 20;
radius = bmp_ok.GetHeight() / 2;
bar_width = bmp_ok.GetHeight() / 20;
if (bar_width < 2) bar_width = 2;
}
void StepIndicator::Rescale()
{
bmp_ok.msw_rescale();
radius = bmp_ok.GetBmpHeight() / 2;
bar_width = bmp_ok.GetBmpHeight() / 20;
bmp_ok.sys_color_changed();
radius = bmp_ok.GetHeight() / 2;
bar_width = bmp_ok.GetHeight() / 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.GetBmpSize();
dc.DrawBitmap(bmp_ok.bmp(), circleX - radius, circleY - radius);
wxSize sz = bmp_ok.GetSize();
dc.DrawBitmap(bmp_ok.get_bitmap(), 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", 16)
, m_off(this, "toggle_off", 16)
, m_on(this, "toggle_on", 16, false, false, true)
, m_off(this, "toggle_off", 16, false, false, true)
, 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.msw_rescale();
m_off.msw_rescale();
m_on.sys_color_changed();
m_off.sys_color_changed();
}
else {
SetBackgroundColour(StaticBox::GetParentBackgroundColor(GetParent()));
@ -138,7 +138,7 @@ void SwitchButton::Rescale()
(i == 0 ? m_off : m_on).bmp() = bmp;
}
}
SetSize(m_on.GetBmpSize());
SetSize(m_on.GetSize());
update();
}

View file

@ -43,9 +43,7 @@ TabCtrl::TabCtrl(wxWindow * parent,
}
TabCtrl::~TabCtrl()
{
delete images;
}
{}
int TabCtrl::GetSelection() const { return sel; }
@ -167,13 +165,6 @@ 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,7 +9,6 @@ wxDECLARE_EVENT( wxEVT_TAB_SEL_CHANGED, wxCommandEvent );
class TabCtrl : public StaticBox
{
std::vector<Button*> btns;
wxImageList* images = nullptr;
wxBoxSizer * sizer = nullptr;
int sel = -1;
@ -53,8 +52,6 @@ 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,8 +280,10 @@ void TempInput::SetLabelColor(StateColor const &color)
void TempInput::Rescale()
{
if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
if (this->degree_icon.bmp().IsOk()) this->degree_icon.msw_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();
messureSize();
}
@ -317,7 +319,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.GetBmpSize();
wxSize szIcon = normal_icon.GetSize();
left += szIcon.x;
}
@ -379,18 +381,18 @@ void TempInput::render(wxDC &dc)
// start draw
wxPoint pt = {padding_left, 0};
if (actice_icon.bmp().IsOk() && actice) {
wxSize szIcon = actice_icon.GetBmpSize();
wxSize szIcon = actice_icon.GetSize();
pt.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(actice_icon.bmp(), pt);
dc.DrawBitmap(actice_icon.get_bitmap(), pt);
pt.x += szIcon.x + 9;
} else {
actice = false;
}
if (normal_icon.bmp().IsOk() && !actice) {
wxSize szIcon = normal_icon.GetBmpSize();
wxSize szIcon = normal_icon.GetSize();
pt.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(normal_icon.bmp(), pt);
dc.DrawBitmap(normal_icon.get_bitmap(), pt);
pt.x += szIcon.x + 9;
}
@ -435,10 +437,10 @@ void TempInput::render(wxDC &dc)
// flag
if (degree_icon.bmp().IsOk()) {
auto pos = text_ctrl->GetPosition();
wxSize szIcon = degree_icon.GetBmpSize();
wxSize szIcon = degree_icon.GetSize();
pt.y = (size.y - szIcon.y) / 2;
pt.x = pos.x + text_ctrl->GetSize().x;
dc.DrawBitmap(degree_icon.bmp(), pt);
dc.DrawBitmap(degree_icon.get_bitmap(), pt);
}
}
@ -452,7 +454,7 @@ void TempInput::messureMiniSize()
wxClientDC dc(this);
if (normal_icon.bmp().IsOk()) {
wxSize szIcon = normal_icon.GetBmpSize();
wxSize szIcon = normal_icon.GetSize();
width += szIcon.x;
height = szIcon.y;
}
@ -481,7 +483,7 @@ void TempInput::messureMiniSize()
height = textSize.y > height ? textSize.y : height;
// flag flag
auto flagSize = degree_icon.GetBmpSize();
auto flagSize = degree_icon.GetSize();
width += flagSize.x;
height = flagSize.y > height ? flagSize.y : height;
@ -506,7 +508,7 @@ void TempInput::messureSize()
wxClientDC dc(this);
if (normal_icon.bmp().IsOk()) {
wxSize szIcon = normal_icon.GetBmpSize();
wxSize szIcon = normal_icon.GetSize();
width += szIcon.x;
height = szIcon.y;
}
@ -535,7 +537,7 @@ void TempInput::messureSize()
height = textSize.y > height ? textSize.y : height;
// flag flag
auto flagSize = degree_icon.GetBmpSize();
auto flagSize = degree_icon.GetSize();
width += flagSize.x;
height = flagSize.y > height ? flagSize.y : height;

View file

@ -94,10 +94,10 @@ void TextInput::SetLabel(const wxString& label)
Refresh();
}
void TextInput::SetIcon(const wxBitmap &icon)
void TextInput::SetIcon(const wxBitmapBundle &icon_in)
{
this->icon = ScalableBitmap();
this->icon.bmp() = icon;
this->icon.bmp() = icon_in;
Rescale();
}
@ -116,7 +116,7 @@ void TextInput::SetTextColor(StateColor const& color)
void TextInput::Rescale()
{
if (!this->icon.name().empty())
this->icon.msw_rescale();
this->icon.sys_color_changed();
messureSize();
Refresh();
}
@ -153,7 +153,7 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
wxSize size = GetSize();
wxPoint textPos = {5, 0};
if (this->icon.bmp().IsOk()) {
wxSize szIcon = this->icon.GetBmpSize();
wxSize szIcon = this->icon.GetSize();
textPos.x += szIcon.x;
}
bool align_right = GetWindowStyle() & wxRIGHT;
@ -194,9 +194,9 @@ void TextInput::render(wxDC& dc)
// start draw
wxPoint pt = {5, 0};
if (icon.bmp().IsOk()) {
wxSize szIcon = icon.GetBmpSize();
wxSize szIcon = get_preferred_size(icon.bmp(), m_parent);
pt.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(icon.bmp(), pt);
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.x += szIcon.x + 0;
}
auto text = wxWindow::GetLabel();

View file

@ -40,7 +40,7 @@ public:
void SetLabel(const wxString& label);
void SetIcon(const wxBitmap & icon);
virtual void SetIcon(const wxBitmapBundle & icon);
void SetLabelColor(StateColor const &color);

View file

@ -14,7 +14,6 @@
#include <wx/sizer.h>
using namespace Slic3r::GUI;
int scale(const int val) { return val * Slic3r::GUI::wxGetApp().em_unit() / 10; }
@ -254,7 +253,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
);
if (flags & wxRESET) {
Button *calc_btn = new Button(this, _L("Auto-Calc"));
Button *calc_btn = new Button(this, _L("Recalculate"));
calc_btn->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
calc_btn->SetCornerRadius(FromDIP(12));
calc_btn->SetBackgroundColor(calc_btn_bg);
@ -262,7 +261,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, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
btn_sizer->Add(calc_btn, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxRESET] = calc_btn;
}
if (flags & wxOK) {
@ -285,7 +284,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);
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP / 2);
m_button_list[wxCANCEL] = cancel_btn;
}
@ -293,35 +292,6 @@ 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)
@ -375,7 +345,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);
auto btn_sizer = create_btn_sizer(wxOK | wxCANCEL | wxRESET);
main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BTN_GAP);
SetSizer(main_sizer);
main_sizer->SetSizeHints(this);
@ -383,7 +353,6 @@ 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);
}
@ -393,11 +362,9 @@ 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) {
@ -427,6 +394,7 @@ 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);
@ -438,8 +406,9 @@ 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_advanced->Add(panel, 0, wxRIGHT | wxLEFT | wxEXPAND, TABLE_BORDER);
m_sizer->Add(panel, 0, wxRIGHT | wxLEFT | wxEXPAND, TABLE_BORDER);
panel->Layout();
}
}
@ -457,22 +426,12 @@ 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;
// 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);
m_sizer = new wxBoxSizer(wxVERTICAL);
this->SetBackgroundColour(*wxWHITE);
update_ui(this);
// First create controls for advanced mode and assign them to m_page_advanced:
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
@ -480,17 +439,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(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), wxTE_CENTER | wxBORDER_NONE | wxTE_PROCESS_ENTER);
wxTextCtrl* text = new wxTextCtrl(this, 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(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1)));
edit_boxes.back().push_back(new wxTextCtrl(this, 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, [this](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_SET_FOCUS, [this](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_KILL_FOCUS, [](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_SET_FOCUS, [](wxFocusEvent&) {});
}
else {
edit_boxes[i][j]->SetValue(wxString("") << int(m_matrix[m_number_of_extruders * j + i] * flush_multiplier));
@ -519,13 +478,13 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
}
// BBS
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));
m_sizer->AddSpacer(FromDIP(10));
auto tip_message_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
tip_message_panel->SetBackgroundColour(*wxWHITE);
auto message_sizer = new wxBoxSizer(wxVERTICAL);
tip_message_panel->SetSizer(message_sizer);
{
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");
wxString message = _L("Orca recalculates your flushing volumes everytime the filament colors change. You can change this behavior in Preferences.");
m_tip_message_label = new Label(tip_message_panel, wxEmptyString);
wxClientDC dc(tip_message_panel);
wxString multiline_message;
@ -533,21 +492,20 @@ 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_advanced->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
m_sizer->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_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(10));
//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);
m_sizer->AddSpacer(FromDIP(5));
header_line_panel = new wxPanel(this, 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);
@ -559,23 +517,24 @@ 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_advanced->Add(header_line_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
m_sizer->Add(header_line_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
create_panels(m_page_advanced, m_number_of_extruders);
create_panels(this, m_number_of_extruders);
//m_sizer_advanced->AddSpacer(BTN_SIZE.y);
m_sizer->AddSpacer(FromDIP(5));
// BBS: for tunning flush volumes
{
auto multi_desc_label = new wxStaticText(m_page_advanced, wxID_ANY, _(L("Flushing volume (mm³) for each filament pair.")), wxDefaultPosition, wxDefaultSize, 0);
auto multi_desc_label = new wxStaticText(this, wxID_ANY, _(L("Flushing volume (mm³) for each filament pair.")), wxDefaultPosition, wxDefaultSize, 0);
multi_desc_label->SetForegroundColour(g_text_color);
m_sizer_advanced->Add(multi_desc_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer->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(m_page_advanced, wxID_ANY, min_flush_str, wxDefaultPosition, wxDefaultSize, 0);
m_min_flush_label = new wxStaticText( this, wxID_ANY, min_flush_str, wxDefaultPosition, wxDefaultSize, 0);
m_min_flush_label->SetForegroundColour(g_text_color);
m_sizer_advanced->Add(m_min_flush_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer->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();
@ -590,6 +549,8 @@ 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)));
}
}
@ -598,91 +559,32 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
e.Skip();
};
m_sizer_advanced->AddSpacer(10);
m_sizer->AddSpacer(10);
wxBoxSizer* param_sizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticText* flush_multiplier_title = new wxStaticText(m_page_advanced, wxID_ANY, _L("Multiplier"));
wxStaticText* flush_multiplier_title = new wxStaticText(this, 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(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(50), -1), wxTE_PROCESS_ENTER);
m_flush_multiplier_ebox = new wxTextCtrl(this, 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_advanced->Add(param_sizer, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer->Add(param_sizer, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer->AddSpacer(BTN_SIZE.y);
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();
toggle_advanced(); // to show/hide what is appropriate
header_line_panel->Bind(wxEVT_PAINT, [this](wxPaintEvent&) {
header_line_panel->Bind(wxEVT_PAINT, [this, stretch_spacer](wxPaintEvent&) {
wxPaintDC dc(header_line_panel);
wxString from_text = _L("From");
wxString to_text = _L("To");
@ -691,7 +593,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 = (vol_width - from_text_size.x - to_text_size.x) / 2;
int base_x = stretch_spacer->GetSize().x + (vol_width - from_text_size.x - to_text_size.x) / 2;
// draw from text
int x = base_x;
@ -733,7 +635,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;
continue; // if it is from/to the same extruder, don't change the value and continue
auto text_box = box_vec[j];
wxString str = text_box->GetValue();
@ -758,8 +660,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() != g_text_color) {
m_min_flush_label->SetForegroundColour(g_text_color);
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));
m_min_flush_label->Refresh();
}
}
@ -770,11 +672,10 @@ 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;
@ -786,13 +687,11 @@ 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();
}
@ -808,8 +707,6 @@ 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) {
@ -826,58 +723,3 @@ 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,12 +48,9 @@ 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()
{
@ -64,25 +61,14 @@ 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;
@ -107,7 +93,6 @@ 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()
@ -123,7 +108,6 @@ 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,16 +22,15 @@
#ifndef __linux__
// msw_menuitem_bitmaps is used for MSW and OSX
static std::map<int, std::string> msw_menuitem_bitmaps;
#ifdef __WXMSW__
void msw_rescale_menu(wxMenu* menu)
void sys_color_changed_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 wxBitmap& item_icon = create_menu_bitmap(it->second);
if (item_icon.IsOk())
item->SetBitmap(item_icon);
const wxBitmapBundle* item_icon = get_bmp_bundle(it->second);
if (item_icon->IsOk())
item->SetBitmap(*item_icon);
}
if (item->IsSubMenu())
for (wxMenuItem *sub_item : item->GetSubMenu()->GetMenuItems())
@ -42,35 +41,24 @@ void msw_rescale_menu(wxMenu* menu)
for (wxMenuItem *item : menu->GetMenuItems())
update_icons::run(item);
}
#endif /* __WXMSW__ */
#endif /* no __WXGTK__ */
#endif /* no __linux__ */
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, const wxBitmap& icon, wxEvtHandler* event_handler,
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* 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.IsOk()) {
item->SetBitmap(icon);
if (icon && icon->IsOk()) {
item->SetBitmap(*icon);
}
if (insert_pos == wxNOT_FOUND)
menu->Append(item);
@ -99,12 +87,12 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const
if (id == wxID_ANY)
id = wxNewId();
const wxBitmap& bmp = !icon.empty() ? create_menu_bitmap(icon) : wxNullBitmap; // FIXME: pass window ptr
//#ifdef __WXMSW__
#ifndef __WXGTK__
if (bmp.IsOk())
wxBitmapBundle* bmp = icon.empty() ? nullptr : get_bmp_bundle(icon);
#ifndef __linux__
if (bmp && bmp->IsOk())
msw_menuitem_bitmaps[id] = icon;
#endif /* __WXMSW__ */
#endif /* no __linux__ */
return append_menu_item(menu, id, string, description, cb, bmp, event_handler, cb_condition, parent, insert_pos);
}
@ -117,11 +105,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(create_menu_bitmap(icon)); // FIXME: pass window ptr
//#ifdef __WXMSW__
#ifndef __WXGTK__
item->SetBitmap(*get_bmp_bundle(icon));
#ifndef __linux__
msw_menuitem_bitmaps[id] = icon;
#endif /* __WXMSW__ */
#endif // no __linux__
}
menu->Append(item);
@ -418,9 +406,49 @@ int mode_icon_px_size()
#endif
}
wxBitmap create_menu_bitmap(const std::string& bmp_name)
#ifdef __WXGTK2__
static int scale()
{
return create_scaled_bitmap(bmp_name, nullptr, 16, false, "", true);
return int(em_unit(nullptr) * 0.1f + 0.5f);
}
#endif // __WXGTK2__
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16*/)
{
static Slic3r::GUI::BitmapCache cache;
std::string bmp_name = bmp_name_in;
boost::replace_last(bmp_name, ".png", "");
// Try loading an SVG first, then PNG if SVG is not found:
wxBitmapBundle* bmp = cache.from_svg(bmp_name, px_cnt, px_cnt, Slic3r::GUI::wxGetApp().dark_mode());
if (bmp == nullptr) {
bmp = cache.from_png(bmp_name, px_cnt, px_cnt);
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__
}
// win is used to get a correct em_unit value
@ -434,6 +462,10 @@ 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;
@ -500,54 +532,46 @@ wxBitmap* get_default_extruder_color_icon(bool thin_icon/* = false*/)
return bitmap;
}
std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
std::vector<wxBitmapBundle*> get_extruder_color_icons(bool thin_icon/* = false*/)
{
// Create the bitmap with color bars.
std::vector<wxBitmap*> bmps;
std::vector<wxBitmapBundle*> 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.push_back(get_extruder_color_icon(color, label, icon_width, icon_height));
bmps.emplace_back(get_extruder_color_icon(color, label, thin_icon ? 16 : 36, 16));
}
return bmps;
}
wxBitmap *get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height)
wxBitmapBundle *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;
wxBitmap *bitmap = bmp_cache.find(bitmap_key);
if (bitmap == nullptr) {
wxBitmapBundle *bmpbndl = bmp_cache.find_bndl(bitmap_key);
if (bmpbndl == nullptr) {
// Paint the color icon.
// Slic3r::GUI::BitmapCache::parse_color(color, rgb);
// there is no neede to scale created solid bitmap
wxColor clr(color);
bitmap = bmp_cache.insert(bitmap_key, wxBitmap(icon_width, icon_height));
bmpbndl = bmp_cache.insert_bndl(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(*bitmap);
dc.SelectObject(bmp);
if (clr.Alpha() == 0) {
int size = icon_height * 2;
static wxBitmap transparent = *Slic3r::GUI::BitmapCache().load_svg("transparent", size, size);
@ -572,8 +596,9 @@ wxBitmap *get_extruder_color_icon(std::string color, std::string label, int icon
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 bitmap;
return bmpbndl;
}
@ -584,7 +609,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
wxSize size/* = wxDefaultSize*/,
bool use_thin_icon/* = false*/)
{
std::vector<wxBitmap*> icons = get_extruder_color_icons(use_thin_icon);
std::vector<wxBitmapBundle*> 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);
@ -610,7 +635,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
int i = 0;
wxString str = _(L("Extruder"));
for (wxBitmap* bmp : icons) {
for (wxBitmapBundle* bmp : icons) {
if (i == 0) {
if (!first_item.empty())
(*ctrl)->Append(_(first_item), *bmp);
@ -644,7 +669,7 @@ LockButton::LockButton( wxWindow *parent,
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
SetBitmap(m_bmp_lock_open.bmp());
SetBitmapDisabled(m_bmp_lock_open.bmp());
SetBitmapHover(m_bmp_lock_closed_f.bmp());
SetBitmapCurrent(m_bmp_lock_closed_f.bmp());
//button events
Bind(wxEVT_BUTTON, &LockButton::OnButton, this);
@ -667,12 +692,14 @@ void LockButton::SetLock(bool lock)
update_button_bitmaps();
}
void LockButton::msw_rescale()
void LockButton::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();
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();
update_button_bitmaps();
}
@ -681,7 +708,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());
SetBitmapHover(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp());
SetBitmapCurrent(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp());
Refresh();
Update();
@ -708,7 +735,7 @@ ModeButton::ModeButton( wxWindow* parent,
const wxString& mode/* = wxEmptyString*/,
const std::string& icon_name/* = ""*/,
int px_cnt/* = 16*/) :
ScalableButton(parent, wxID_ANY, ScalableBitmap(parent, icon_name, px_cnt), mode, wxBU_EXACTFIT)
ScalableButton(parent, wxID_ANY, icon_name, mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT, px_cnt)
{
Init(mode);
}
@ -817,11 +844,10 @@ void ModeSizer::set_items_border(int border)
item->SetBorder(border);
}
void ModeSizer::msw_rescale()
void ModeSizer::sys_color_changed()
{
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]->msw_rescale();
m_mode_btns[m]->sys_color_changed();
}
// ----------------------------------------------------------------------------
@ -858,51 +884,35 @@ ScalableBitmap::ScalableBitmap( wxWindow *parent,
const std::string& icon_name/* = ""*/,
const int px_cnt/* = 16*/,
const bool grayscale/* = false*/,
const bool resize/* = false*/):
m_parent(parent), m_icon_name(icon_name),
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_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_px_cnt = m_bmp.GetHeight(); // scale
m_px_cnt = GetHeight(); // scale
unsigned int height = (unsigned int) (parent->FromDIP(m_px_cnt) + 0.5f);
if (height != GetBmpHeight())
msw_rescale();
if (height != GetHeight())
sys_color_changed();
}
} else {
m_bmp = *get_bmp_bundle(icon_name, px_cnt);
}
}
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()
void ScalableBitmap::sys_color_changed()
{
if (m_legacy_bmp) {
// BBS: support resize by fill border
m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_px_cnt, m_grayscale, std::string(), false, m_resize);
} else
m_bmp = *get_bmp_bundle(m_icon_name, m_px_cnt);
}
// ----------------------------------------------------------------------------
@ -916,11 +926,9 @@ 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))
{
@ -929,9 +937,7 @@ ScalableButton::ScalableButton( wxWindow * parent,
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
if (!icon_name.empty()) {
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));
SetBitmap(*get_bmp_bundle(icon_name, m_px_cnt));
if (!label.empty())
SetBitmapMargins(int(0.5* em_unit(parent)), 0);
}
@ -973,13 +979,12 @@ bool ScalableButton::SetBitmap_(const std::string& bmp_name)
if (m_current_icon_name.empty())
return false;
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
SetBitmap(bmp);
SetBitmapCurrent(bmp);
SetBitmapPressed(bmp);
SetBitmapFocus(bmp);
if (m_use_default_disabled_bitmap)
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
SetBitmapDisabled(bmp);
return true;
}
@ -998,38 +1003,22 @@ int ScalableButton::GetBitmapHeight()
#endif
}
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()
void ScalableButton::sys_color_changed()
{
Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
if (!m_current_icon_name.empty()) {
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
SetBitmap(bmp);
// BBS: why disappear on hover? why current HBITMAP differ from other
//SetBitmapCurrent(bmp);
//SetBitmapPressed(bmp);
//SetBitmapFocus(bmp);
SetBitmapCurrent(bmp);
SetBitmapPressed(bmp);
SetBitmapFocus(bmp);
if (!m_disabled_icon_name.empty())
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));
SetBitmapDisabled(*get_bmp_bundle(m_disabled_icon_name, m_px_cnt));
if (!GetLabelText().IsEmpty())
SetBitmapMargins(int(0.5 * em_unit(m_parent)), 0);
}
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
// ----------------------------------------------------------------------------
@ -1040,13 +1029,6 @@ 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,14 +18,17 @@
#include "Widgets/PopupWindow.hpp"
#ifdef __WXMSW__
void msw_rescale_menu(wxMenu* menu);
#else /* __WXMSW__ */
inline void msw_rescale_menu(wxMenu* /* menu */) {}
#endif /* __WXMSW__ */
#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); }
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
std::function<void(wxCommandEvent& event)> cb, const wxBitmap& icon, wxEvtHandler* event_handler = nullptr,
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* 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,
@ -52,7 +55,9 @@ void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<
int em_unit(wxWindow* win);
int mode_icon_px_size();
wxBitmap create_menu_bitmap(const std::string& bmp_name);
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int px_cnt = 16);
wxBitmapBundle* get_empty_bmp_bundle(int width, int height);
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color);
// BBS: support resize by fill border
#if 1
@ -66,8 +71,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<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);
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);
namespace Slic3r {
namespace GUI {
@ -140,6 +145,17 @@ 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
@ -153,29 +169,40 @@ public:
const std::string& icon_name = "",
const int px_cnt = 16,
const bool grayscale = false,
const bool resize = false); // BBS: support resize by fill border
const bool resize = false, // BBS: support resize by fill border
const bool use_legacy_bmp = false);
~ScalableBitmap() {}
wxSize GetBmpSize() const;
int GetBmpWidth() const;
int GetBmpHeight() const;
[[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 wxBitmap& bmp() const { return m_bmp; }
wxBitmap& bmp() { return m_bmp; }
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;}
const std::string& name() const{ return m_icon_name; }
int px_cnt() const { return m_px_cnt; }
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(); }
private:
wxWindow* m_parent{ nullptr };
wxBitmap m_bmp = wxBitmap();
wxBitmapBundle m_bmp = wxBitmapBundle();
std::string m_icon_name = "";
int m_px_cnt {16};
bool m_grayscale{ false };
bool m_resize{ false };
bool m_legacy_bmp{ false };
};
@ -202,7 +229,9 @@ public:
void enable() { m_disabled = false; }
void disable() { m_disabled = true; }
void msw_rescale();
[[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();
protected:
void update_button_bitmaps();
@ -234,7 +263,6 @@ 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(
@ -250,9 +278,10 @@ public:
bool SetBitmap_(const std::string& bmp_name);
void SetBitmapDisabled_(const ScalableBitmap &bmp);
int GetBitmapHeight();
void UseDefaultBitmapDisabled();
void msw_rescale();
[[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();
private:
wxWindow* m_parent { nullptr };
@ -261,8 +290,6 @@ 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};
@ -328,7 +355,9 @@ public:
void set_items_flag(int flag);
void set_items_border(int border);
void msw_rescale();
[[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();
const std::vector<ModeButton*>& get_btns() { return m_mode_btns; }
private:
@ -376,12 +405,11 @@ public:
~BlinkingBitmap() {}
void msw_rescale();
void invalidate();
void activate();
void blink();
const wxBitmap& get_bmp() const { return bmp.bmp(); }
const wxBitmapBundle& get_bmp() const { return bmp.bmp(); }
private:
ScalableBitmap bmp;