FIX: support the dark mode AMSPreview

jira: [none]
Change-Id: If4329081535a1155588afad932403ea3615163f7
This commit is contained in:
xin.zhang 2025-01-20 19:42:38 +08:00 committed by lane.wei
parent eae81e9d95
commit 32597b43f9
5 changed files with 95 additions and 8 deletions

View File

@ -0,0 +1,12 @@
<svg width="52" height="32" viewBox="0 0 52 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_21155_56752)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 0C1.79086 0 0 1.79086 0 4V28C0 30.2091 1.79086 32 4 32H48C50.2091 32 52 30.2091 52 28V4C52 1.79086 50.2091 0 48 0H4ZM44 8H8V24H44V8Z" fill="#2F2E33"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M36.5 16H33.5V18.2617C33.5 19.9186 32.1569 21.2617 30.5 21.2617C28.8431 21.2617 27.5 19.9186 27.5 18.2617V16H24.5V18.2617C24.5 19.9186 23.1569 21.2617 21.5 21.2617C19.8431 21.2617 18.5 19.9186 18.5 18.2617V16H15.5V18.2617C15.5 19.9186 14.1569 21.2617 12.5 21.2617C10.8432 21.2617 9.5 19.9186 9.5 18.2617V16H4V28H48V16H42.5V18.2617C42.5 19.9186 41.1569 21.2617 39.5 21.2617C37.8431 21.2617 36.5 19.9186 36.5 18.2617V16Z" fill="#767676"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6 9.18382C6 6.32088 8.32088 4 11.1838 4H40.8162C43.6791 4 46 6.32088 46 9.18382V16H42.5V12.2617C42.5 10.6049 41.1569 9.26172 39.5 9.26172C37.8431 9.26172 36.5 10.6049 36.5 12.2617V16H33.5V12.2617C33.5 10.6049 32.1569 9.26172 30.5 9.26172C28.8431 9.26172 27.5 10.6049 27.5 12.2617V16H24.5V12.2617C24.5 10.6049 23.1569 9.26172 21.5 9.26172C19.8431 9.26172 18.5 10.6049 18.5 12.2617V16H15.5V12.2617C15.5 10.6049 14.1569 9.26172 12.5 9.26172C10.8432 9.26172 9.5 10.6049 9.5 12.2617V16H6V9.18382Z" fill="#BFBFBF"/>
</g>
<defs>
<clipPath id="clip0_21155_56752">
<rect width="52" height="32" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,17 @@
<svg width="28" height="32" viewBox="0 0 28 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_21155_56756)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 0C1.79086 0 0 1.79086 0 4V28C0 30.2091 1.79086 32 4 32H24C26.2091 32 28 30.2091 28 28V4C28 1.79086 26.2091 0 24 0H4ZM20.3462 8H8.63721V24H20.3462V8Z" fill="#2F2E33"/>
<mask id="mask0_21155_56756" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="4" y="3" width="20" height="26">
<path d="M24 3.5H4V28.5H24V3.5Z" fill="white"/>
</mask>
<g mask="url(#mask0_21155_56756)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11 16.2871H4V28.2871H24V16.2871H17V18.5488C17 20.2057 15.6569 21.5488 14 21.5488C12.3432 21.5488 11 20.2057 11 18.5488V16.2871Z" fill="#767676"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.1838 4.28711C8.32088 4.28711 6 6.60799 6 9.47093V16.2871H11V12.5488C11 10.8919 12.3432 9.54883 14 9.54883C15.6569 9.54883 17 10.8919 17 12.5488V16.2871H22V9.47093C22 6.60799 19.6791 4.28711 16.8162 4.28711H11.1838Z" fill="#BFBFBF"/>
</g>
</g>
<defs>
<clipPath id="clip0_21155_56756">
<rect width="28" height="32" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,11 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_21155_56764)">
<path d="M14 2C14 0.89543 13.1046 0 12 0H2C0.89543 0 0 0.895431 0 2V12C0 13.1046 0.895431 14 2 14H12C13.1046 14 14 13.1046 14 12V2Z" fill="#9D9D9D"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.9992 12.0564V11.2002H11.1992V14H12C13.0857 14 13.9693 13.1349 13.9992 12.0564ZM8.40156 14V11.2002H5.60156V14H8.40156ZM2.8 14V11.2002H0V12C0 13.1046 0.895431 14 2 14H2.8ZM0 8.4001H2.8V5.6001H0V8.4001ZM0 2.8H2.8V0H2C0.89543 0 0 0.895431 0 2V2.8ZM5.60156 0V2.8H8.39844V5.5998H11.1984V2.7998H8.40156V0H5.60156ZM11.1992 0L11.1984 2.7998L13.9992 2.8V1.94356C13.9693 0.865088 13.0857 0 12 0H11.1992ZM2.8 5.6001V2.8H5.60156L5.60078 5.5998L2.8 5.6001ZM11.1992 8.4001L11.1984 5.5998L13.9992 5.6001V8.4001H11.1992ZM2.8 11.2002V8.4001L5.60078 8.3999L5.60156 11.2002H2.8ZM5.60078 5.5998V8.3999L8.39844 8.4001V11.1999L11.1992 11.2002V8.4001L8.40156 8.3999V5.6001L5.60078 5.5998Z" fill="#767676"/>
</g>
<defs>
<clipPath id="clip0_21155_56764">
<rect width="14" height="14" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -2371,8 +2371,14 @@ void AMSPreview::Update(AMSinfo amsinfo)
void AMSPreview::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
{
m_ts_bitmap_cube = ScalableBitmap(this, "ts_bitmap_cube", 14);
m_ts_bitmap_cube_dark = ScalableBitmap(this, "ts_bitmap_cube_dark", 14);
m_four_slot_bitmap = ScalableBitmap(this, "four_slot_ams_item", 32);
m_four_slot_bitmap_dark = ScalableBitmap(this, "four_slot_ams_item_dark", 32);
m_single_slot_bitmap = ScalableBitmap(this, "single_slot_ams_item", 32);
m_single_slot_bitmap_dark = ScalableBitmap(this, "single_slot_ams_item_dark", 32);
wxWindow::Create(parent, id, pos, size);
SetMinSize(size);
SetMaxSize(size);
@ -2436,9 +2442,22 @@ void AMSPreview::render(wxDC &dc)
void AMSPreview::doRender(wxDC &dc)
{
wxSize size = GetSize();
auto color = *wxWHITE;
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
dc.SetBrush(color);
// draw background
if (wxGetApp().dark_mode())
{
dc.SetBrush(StateColor::darkModeColorFor(*wxWHITE));
}
else
{
dc.SetBrush(AMS_CONTROL_DEF_BLOCK_BK_COLOUR);
}
dc.DrawRoundedRectangle(0, 0, size.x, size.y, 0);
// draw container
auto color = *wxWHITE;
dc.SetBrush(StateColor::darkModeColorFor(color));
dc.DrawRoundedRectangle(0, 0, size.x, size.y, FromDIP(3));
auto left = 0;
@ -2483,7 +2502,14 @@ void AMSPreview::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);
if (wxGetApp().dark_mode())
{
dc.DrawBitmap(m_ts_bitmap_cube_dark.bmp(), left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
}
else
{
dc.DrawBitmap(m_ts_bitmap_cube.bmp(), left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
}
}
else {
wxRect rect(left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, AMS_ITEM_CUBE_SIZE.x, AMS_ITEM_CUBE_SIZE.y);
@ -2500,7 +2526,15 @@ void AMSPreview::doRender(wxDC &dc)
}
//auto pot = wxPoint((size.x - m_four_slot_bitmap.GetBmpSize().x) / 2, (size.y - m_four_slot_bitmap.GetBmpSize().y) / 2);
dc.DrawBitmap(m_four_slot_bitmap.bmp(), wxPoint(0,0));
if (wxGetApp().dark_mode())
{
dc.DrawBitmap(m_four_slot_bitmap_dark.bmp(), wxPoint(0, 0));
}
else
{
dc.DrawBitmap(m_four_slot_bitmap.bmp(), wxPoint(0, 0));
}
}
//single slot
@ -2553,7 +2587,15 @@ void AMSPreview::doRender(wxDC &dc)
if (m_ams_item_type == AMSModel::N3S_AMS) {
//auto pot = wxPoint(((size.x - m_single_slot_bitmap.GetBmpSize().x) / 2), ((size.y - m_single_slot_bitmap.GetBmpSize().y) / 2));
dc.DrawBitmap(m_single_slot_bitmap.bmp(), wxPoint(0,0));
if (wxGetApp().dark_mode())
{
dc.DrawBitmap(m_single_slot_bitmap_dark.bmp(), wxPoint(0, 0));
}
else
{
dc.DrawBitmap(m_single_slot_bitmap.bmp(), wxPoint(0, 0));
}
}
if (((iter.material_colour.Red() >= 238 && iter.material_colour.Green() >= 238 && iter.material_colour.Blue() >= 238)
|| iter.material_colour.Alpha() == 0) && m_ams_item_type == AMSModel::EXT_AMS) {
@ -2582,11 +2624,13 @@ void AMSPreview::doRender(wxDC &dc)
void AMSPreview::msw_rescale()
{
m_ts_bitmap_cube = ScalableBitmap(this, "ts_bitmap_cube", 14);
//m_four_slot_bitmap = ScalableBitmap(this, "four_slot_ams_item", 32);
//m_single_slot_bitmap = ScalableBitmap(this, "single_slot_ams_item", 28);
m_ts_bitmap_cube.msw_rescale();
m_ts_bitmap_cube_dark.msw_rescale();
m_four_slot_bitmap.msw_rescale();
m_four_slot_bitmap_dark.msw_rescale();
m_single_slot_bitmap.msw_rescale();
m_single_slot_bitmap_dark.msw_rescale();
Refresh();
}

View File

@ -649,8 +649,11 @@ protected:
AMSModel m_ams_item_type = AMSModel::GENERIC_AMS;
ScalableBitmap m_ts_bitmap_cube;
ScalableBitmap m_ts_bitmap_cube_dark;
ScalableBitmap m_four_slot_bitmap;
ScalableBitmap m_four_slot_bitmap_dark;
ScalableBitmap m_single_slot_bitmap;
ScalableBitmap m_single_slot_bitmap_dark;
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);