mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-15 03:41:28 +00:00
Merge branch 'main' into extruder-variants-ui-2
# Conflicts: # src/slic3r/GUI/Tab.cpp
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <wx/image.h>
|
||||
#include <cstring>
|
||||
#include <wx/dc.h>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include "slic3r/GUI/Widgets/StateHandler.hpp"
|
||||
#include <wx/scrolwin.h>
|
||||
@@ -158,17 +159,16 @@ void SwitchButton::Rescale()
|
||||
}
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
wxMemoryDC memdc(&dc);
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap bmp(trackSize.x, trackSize.y);
|
||||
memdc.SelectObject(bmp);
|
||||
memdc.SetBackground(wxBrush(GetBackgroundColour()));
|
||||
memdc.Clear();
|
||||
#else
|
||||
wxImage image(trackSize);
|
||||
#ifndef __WXMSW__ // DrawText doesn't work properly on Windows with Alpha channel
|
||||
image.InitAlpha();
|
||||
memset(image.GetAlpha(), 0, trackSize.GetWidth() * trackSize.GetHeight());
|
||||
#endif
|
||||
wxBitmap bmp(std::move(image));
|
||||
memdc.SelectObject(bmp);
|
||||
#ifdef __WXMSW__
|
||||
memdc.SetBackground(wxBrush(GetBackgroundColour()));
|
||||
memdc.Clear();
|
||||
#endif
|
||||
memdc.SetFont(dc.GetFont());
|
||||
#ifdef __WXMSW__
|
||||
@@ -276,6 +276,7 @@ ModeSwitchButton::ModeSwitchButton(wxWindow* parent, wxWindowID id)
|
||||
StaticBox::Create(parent, id, wxDefaultPosition, wxDefaultSize, 0);
|
||||
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
|
||||
SetCursor(wxCursor(wxCURSOR_HAND));
|
||||
SetFont(Label::Body_12);
|
||||
|
||||
m_tooltips[0] = _L("Simple settings");
|
||||
m_tooltips[1] = _L("Advanced settings");
|
||||
@@ -374,6 +375,14 @@ void ModeSwitchButton::doRender(wxDC& dc)
|
||||
}
|
||||
}
|
||||
else { // Developer mode
|
||||
double scale = 1.00;
|
||||
#ifdef __WXOSX__
|
||||
scale = Slic3r::GUI::mac_max_scaling_factor();
|
||||
dc.SetFont(dc.GetFont().Scaled(scale));
|
||||
#elif defined(__WXMSW__)
|
||||
scale = m_parent->GetDPIScaleFactor();
|
||||
dc.SetFont(dc.GetFont().Scaled(scale));
|
||||
#endif
|
||||
wxString str = "DEV";
|
||||
int kerning = 3; // pixels between chars
|
||||
dc.SetTextForeground(text_color.colorForStates(states));
|
||||
@@ -383,8 +392,17 @@ void ModeSwitchButton::doRender(wxDC& dc)
|
||||
totalWidth += dc.GetTextExtent(wxString(c)).x + kerning;
|
||||
totalWidth -= kerning;
|
||||
|
||||
wxCoord x = bounds.x + (bounds.width - totalWidth) / 2;
|
||||
wxCoord y = bounds.y + (bounds.height - dc.GetTextExtent(str).y) / 2 - 1;
|
||||
wxCoord x = bounds.x + (bounds.width - totalWidth) * 0.50;
|
||||
|
||||
wxFontMetrics fm = dc.GetFontMetrics();
|
||||
int lineHeight = fm.ascent + fm.descent + fm.internalLeading;
|
||||
|
||||
double y_offset = scale;
|
||||
#if defined(__WXGTK__)
|
||||
y_offset = 0;
|
||||
#endif
|
||||
|
||||
wxCoord y = std::floor(v_center - lineHeight * 0.50 - y_offset);
|
||||
|
||||
for (char c : str) {
|
||||
wxString ch(c);
|
||||
|
||||
Reference in New Issue
Block a user