mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 03:13:39 +00:00
Fix color & position of device info sync dialogs
This commit is contained in:
@@ -3385,6 +3385,36 @@ void Sidebar::deal_btn_sync() {
|
||||
wxGetApp().plater()->update_machine_sync_status();
|
||||
}
|
||||
|
||||
template<typename T> void setup_dialog_position(T& info)
|
||||
{
|
||||
auto plater = wxGetApp().plater();
|
||||
auto& sidebar = plater->sidebar();
|
||||
auto docking = plater->get_sidebar_docking_state();
|
||||
bool on_right = true;
|
||||
|
||||
if (docking == Sidebar::Left) {
|
||||
on_right = true;
|
||||
} else if (docking == Sidebar::Right) {
|
||||
on_right = false;
|
||||
} else {
|
||||
// If sidebar is too close to screen right edge, then move the dialog to the left side instead
|
||||
|
||||
auto screen_width = wxDisplay(&sidebar).GetClientArea().GetSize().x;
|
||||
auto right_space = screen_width - sidebar.get_sidebar_pos_right_x();
|
||||
if (right_space < sidebar.FromDIP(400)) {
|
||||
on_right = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (on_right) {
|
||||
info.dialog_pos.x = sidebar.get_sidebar_pos_right_x() + sidebar.FromDIP(5);
|
||||
info.dialog_pos_align_right = true;
|
||||
} else {
|
||||
info.dialog_pos.x = sidebar.GetScreenPosition().x - sidebar.FromDIP(5);
|
||||
info.dialog_pos_align_right = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Sidebar::pop_sync_nozzle_and_ams_dialog() {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " begin pop_sync_nozzle_and_ams_dialog";
|
||||
wxTheApp->CallAfter([this]() {
|
||||
@@ -3394,9 +3424,8 @@ void Sidebar::pop_sync_nozzle_and_ams_dialog() {
|
||||
wxGetApp().plater()->sidebar().get_big_btn_sync_pos_size(big_btn_pt, big_btn_size);
|
||||
temp_na_info.dialog_pos = big_btn_pt + wxPoint(big_btn_size.x, big_btn_size.y) + wxPoint(FromDIP(big_btn_size.x / 10.f - 5), FromDIP(big_btn_size.y / 10.f));
|
||||
|
||||
int same_dialog_pos_x = get_sidebar_pos_right_x() + FromDIP(5);
|
||||
temp_na_info.dialog_pos.x = same_dialog_pos_x;
|
||||
temp_na_info.dialog_pos.y += FromDIP(2);
|
||||
setup_dialog_position(temp_na_info);
|
||||
|
||||
wxPoint small_btn_pt;
|
||||
wxSize small_btn_size;
|
||||
@@ -3420,9 +3449,8 @@ void Sidebar::pop_finsish_sync_ams_dialog()
|
||||
get_small_btn_sync_pos_size(small_btn_pt, small_btn_size);
|
||||
|
||||
FinishSyncAmsDialog::InputInfo temp_fsa_info;
|
||||
auto same_dialog_pos_x = get_sidebar_pos_right_x() + FromDIP(5);
|
||||
temp_fsa_info.dialog_pos.x = same_dialog_pos_x;
|
||||
temp_fsa_info.dialog_pos.y = small_btn_pt.y;
|
||||
setup_dialog_position(temp_fsa_info);
|
||||
temp_fsa_info.ams_btn_pos = small_btn_pt + wxPoint(small_btn_size.x / 2, small_btn_size.y / 2);
|
||||
if (m_sna_dialog) { m_sna_dialog->on_hide(); }
|
||||
if (m_fna_dialog) {
|
||||
|
||||
@@ -909,7 +909,7 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
|
||||
|
||||
m_advace_setting_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_more_setting_tips = new wxStaticText(m_scrolledWindow, wxID_ANY, _L("Advanced settings"));
|
||||
m_more_setting_tips->SetForegroundColour(wxColour(0, 174, 100));
|
||||
m_more_setting_tips->SetForegroundColour(wxColour(0, 137, 123));
|
||||
m_more_setting_tips->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
|
||||
m_expand_more_settings = !m_expand_more_settings;
|
||||
update_more_setting(true,true);
|
||||
@@ -3306,10 +3306,24 @@ void SyncNozzleAndAmsDialog::deal_cancel()
|
||||
on_hide();
|
||||
}
|
||||
|
||||
static inline void UpdatePositionAlignment(wxWindow* w, wxPoint base_position, bool align_right) {
|
||||
if (!align_right) {
|
||||
base_position.x -= w->GetSize().x;
|
||||
}
|
||||
w->SetPosition(base_position);
|
||||
}
|
||||
|
||||
void SyncNozzleAndAmsDialog::update_info(InputInfo &info) {
|
||||
m_input_info = info;
|
||||
restart();
|
||||
SetPosition(m_input_info.dialog_pos);
|
||||
UpdatePositionAlignment(this, m_input_info.dialog_pos, m_input_info.dialog_pos_align_right);
|
||||
}
|
||||
|
||||
bool SyncNozzleAndAmsDialog::Layout()
|
||||
{
|
||||
BaseTransparentDPIFrame::Layout();
|
||||
UpdatePositionAlignment(this, m_input_info.dialog_pos, m_input_info.dialog_pos_align_right);
|
||||
return true;
|
||||
}
|
||||
|
||||
FinishSyncAmsDialog::FinishSyncAmsDialog(InputInfo &input_info)
|
||||
@@ -3337,7 +3351,14 @@ void FinishSyncAmsDialog::update_info(InputInfo &info)
|
||||
{
|
||||
m_input_info = info;
|
||||
restart();
|
||||
SetPosition(m_input_info.dialog_pos);
|
||||
UpdatePositionAlignment(this, m_input_info.dialog_pos, m_input_info.dialog_pos_align_right);
|
||||
}
|
||||
|
||||
bool FinishSyncAmsDialog::Layout()
|
||||
{
|
||||
BaseTransparentDPIFrame::Layout();
|
||||
UpdatePositionAlignment(this, m_input_info.dialog_pos, m_input_info.dialog_pos_align_right);
|
||||
return true;
|
||||
}
|
||||
|
||||
}} // namespace Slic3r
|
||||
@@ -347,12 +347,14 @@ public:
|
||||
{
|
||||
wxPoint dialog_pos{wxPoint(400, 200)};
|
||||
wxPoint ams_btn_pos{wxPoint(400, 200)};
|
||||
bool dialog_pos_align_right{true};
|
||||
};
|
||||
SyncNozzleAndAmsDialog(InputInfo &input_info);
|
||||
~SyncNozzleAndAmsDialog() override;
|
||||
void deal_ok() override;
|
||||
void deal_cancel() override;
|
||||
void update_info(InputInfo& info);
|
||||
bool Layout() override;
|
||||
|
||||
private:
|
||||
InputInfo m_input_info;
|
||||
@@ -365,11 +367,13 @@ public:
|
||||
{
|
||||
wxPoint dialog_pos{wxPoint(400, 200)};
|
||||
wxPoint ams_btn_pos{wxPoint(400, 200)};
|
||||
bool dialog_pos_align_right{true};
|
||||
};
|
||||
FinishSyncAmsDialog(InputInfo &input_info);
|
||||
~FinishSyncAmsDialog() override;
|
||||
void deal_ok();
|
||||
void update_info(InputInfo &info);
|
||||
void update_info(InputInfo& info);
|
||||
bool Layout() override;
|
||||
|
||||
private:
|
||||
InputInfo m_input_info;
|
||||
|
||||
Reference in New Issue
Block a user