mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 04:12:04 +08:00
UI improvements:
- Increase margin around the toolbar icons - Fixed layout for search button in search control - Fixed background for Scene / Preview buttons - Fix for #12576 - Show "collapse sidebar" button, even if "Show sidebar expand/collapse button" wasn't enabled but sidebar is collapsed - Account button: "Anonymous" default name is changed to "Log in"
This commit is contained in:
parent
615329b1f6
commit
8590e34aaf
@ -4302,7 +4302,7 @@ void GLCanvas3D::update_ui_from_settings()
|
|||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
|
|
||||||
if (wxGetApp().is_editor())
|
if (wxGetApp().is_editor())
|
||||||
wxGetApp().plater()->enable_collapse_toolbar(wxGetApp().app_config->get_bool("show_collapse_button"));
|
wxGetApp().plater()->enable_collapse_toolbar(wxGetApp().app_config->get_bool("show_collapse_button") || !wxGetApp().sidebar().IsShown());
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3D::WipeTowerInfo GLCanvas3D::get_wipe_tower_info() const
|
GLCanvas3D::WipeTowerInfo GLCanvas3D::get_wipe_tower_info() const
|
||||||
@ -5023,9 +5023,9 @@ bool GLCanvas3D::_init_main_toolbar()
|
|||||||
m_main_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
m_main_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
||||||
m_main_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
|
m_main_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
|
||||||
m_main_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
m_main_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
||||||
m_main_toolbar.set_border(5.0f);
|
//m_main_toolbar.set_border(5.0f);
|
||||||
m_main_toolbar.set_separator_size(5);
|
//m_main_toolbar.set_separator_size(5.f);
|
||||||
m_main_toolbar.set_gap_size(4);
|
//m_main_toolbar.set_gap_size(5.f);
|
||||||
|
|
||||||
GLToolbarItem::Data item;
|
GLToolbarItem::Data item;
|
||||||
|
|
||||||
@ -5164,7 +5164,9 @@ bool GLCanvas3D::_init_main_toolbar()
|
|||||||
item.icon_filename = "layers_white.svg";
|
item.icon_filename = "layers_white.svg";
|
||||||
item.tooltip = _u8L("Variable layer height");
|
item.tooltip = _u8L("Variable layer height");
|
||||||
item.sprite_id = sprite_id++;
|
item.sprite_id = sprite_id++;
|
||||||
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); };
|
item.left.action_callback = [this]() {
|
||||||
|
if (m_canvas != nullptr)
|
||||||
|
wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); };
|
||||||
item.visibility_callback = [this]()->bool {
|
item.visibility_callback = [this]()->bool {
|
||||||
bool res = current_printer_technology() == ptFFF;
|
bool res = current_printer_technology() == ptFFF;
|
||||||
// turns off if changing printer technology
|
// turns off if changing printer technology
|
||||||
@ -5207,9 +5209,9 @@ bool GLCanvas3D::_init_undoredo_toolbar()
|
|||||||
m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
||||||
m_undoredo_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
|
m_undoredo_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
|
||||||
m_undoredo_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
m_undoredo_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
||||||
m_undoredo_toolbar.set_border(5.0f);
|
//m_undoredo_toolbar.set_border(5.f);
|
||||||
m_undoredo_toolbar.set_separator_size(5);
|
//m_undoredo_toolbar.set_separator_size(5.f);
|
||||||
m_undoredo_toolbar.set_gap_size(4);
|
//m_undoredo_toolbar.set_gap_size(5.f);
|
||||||
|
|
||||||
GLToolbarItem::Data item;
|
GLToolbarItem::Data item;
|
||||||
|
|
||||||
@ -5982,6 +5984,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
|
|||||||
const Size cnv_size = get_canvas_size();
|
const Size cnv_size = get_canvas_size();
|
||||||
|
|
||||||
int size = int(GLToolbar::Default_Icons_Size * scale);
|
int size = int(GLToolbar::Default_Icons_Size * scale);
|
||||||
|
int gizmo_size = int(GLGizmosManager::Default_Icons_Size * scale);
|
||||||
|
|
||||||
// Set current size for all top toolbars. It will be used for next calculations
|
// Set current size for all top toolbars. It will be used for next calculations
|
||||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||||
@ -5991,6 +5994,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
|
|||||||
m_undoredo_toolbar.set_scale(sc);
|
m_undoredo_toolbar.set_scale(sc);
|
||||||
collapse_toolbar.set_scale(sc);
|
collapse_toolbar.set_scale(sc);
|
||||||
size *= int(m_retina_helper->get_scale_factor());
|
size *= int(m_retina_helper->get_scale_factor());
|
||||||
|
gizmo_size *= int(m_retina_helper->get_scale_factor());
|
||||||
#else
|
#else
|
||||||
m_main_toolbar.set_icons_size(size);
|
m_main_toolbar.set_icons_size(size);
|
||||||
m_undoredo_toolbar.set_icons_size(size);
|
m_undoredo_toolbar.set_icons_size(size);
|
||||||
@ -6008,10 +6012,14 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
|
|||||||
// https://github.com/supermerill/SuperSlicer/issues/854
|
// https://github.com/supermerill/SuperSlicer/issues/854
|
||||||
const float new_h_scale = std::max((cnv_size.get_width() - noitems_width), 1.0f) / (items_cnt * GLToolbar::Default_Icons_Size);
|
const float new_h_scale = std::max((cnv_size.get_width() - noitems_width), 1.0f) / (items_cnt * GLToolbar::Default_Icons_Size);
|
||||||
|
|
||||||
items_cnt = m_gizmos.get_selectable_icons_cnt() + 3; // +3 means a place for top and view toolbars and separators in gizmos toolbar
|
float gizmos_height = m_gizmos.get_scaled_total_height();
|
||||||
|
int giz_items_cnt = m_gizmos.get_selectable_icons_cnt();
|
||||||
|
float noitems_height = gizmos_height - gizmo_size * giz_items_cnt; // height of separators and borders in gizmos toolbars
|
||||||
|
|
||||||
// calculate scale needed for items in the gizmos toolbar
|
noitems_height += m_main_toolbar.get_height(); // increase its value to main_toolbar height
|
||||||
const float new_v_scale = cnv_size.get_height() / (items_cnt * GLGizmosManager::Default_Icons_Size);
|
giz_items_cnt += 2; // +2 means a place for view toolbar
|
||||||
|
|
||||||
|
const float new_v_scale = std::max((cnv_size.get_height() - noitems_height), 1.0f) / (giz_items_cnt * GLGizmosManager::Default_Icons_Size);
|
||||||
|
|
||||||
// set minimum scale as a auto scale for the toolbars
|
// set minimum scale as a auto scale for the toolbars
|
||||||
float new_scale = std::min(new_h_scale, new_v_scale);
|
float new_scale = std::min(new_h_scale, new_v_scale);
|
||||||
|
@ -96,7 +96,10 @@ void GLToolbarItem::render(const GLCanvas3D& parent, unsigned int tex_id, float
|
|||||||
GLTexture::Quad_UVs ret;
|
GLTexture::Quad_UVs ret;
|
||||||
// tiles in the texture are spaced by 1 pixel
|
// tiles in the texture are spaced by 1 pixel
|
||||||
const float icon_size_px = (float)(tex_width - 1) / ((float)Num_States + (float)Num_Rendered_Highlight_States);
|
const float icon_size_px = (float)(tex_width - 1) / ((float)Num_States + (float)Num_Rendered_Highlight_States);
|
||||||
const char render_state = (m_highlight_state == NotHighlighted ? m_state : Num_States + m_highlight_state);
|
const char render_state = m_highlight_state == NotHighlighted ?
|
||||||
|
(m_state==Pressed ? Normal : // use regular icon, without black background
|
||||||
|
m_state==HoverPressed ? Hover : m_state ) : // use regular icon, without black background
|
||||||
|
Num_States + m_highlight_state;
|
||||||
const float inv_tex_width = 1.0f / (float)tex_width;
|
const float inv_tex_width = 1.0f / (float)tex_width;
|
||||||
const float inv_tex_height = 1.0f / (float)tex_height;
|
const float inv_tex_height = 1.0f / (float)tex_height;
|
||||||
// tiles in the texture are spaced by 1 pixel
|
// tiles in the texture are spaced by 1 pixel
|
||||||
@ -142,7 +145,7 @@ BackgroundTexture::Metadata::Metadata()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const float GLToolbar::Default_Icons_Size = 40.0f;
|
const float GLToolbar::Default_Icons_Size = 35.f;// 40.0f;
|
||||||
|
|
||||||
GLToolbar::Layout::Layout()
|
GLToolbar::Layout::Layout()
|
||||||
: type(Horizontal)
|
: type(Horizontal)
|
||||||
@ -150,9 +153,9 @@ GLToolbar::Layout::Layout()
|
|||||||
, vertical_orientation(VO_Center)
|
, vertical_orientation(VO_Center)
|
||||||
, top(0.0f)
|
, top(0.0f)
|
||||||
, left(0.0f)
|
, left(0.0f)
|
||||||
, border(0.0f)
|
, border(5.0f)
|
||||||
, separator_size(0.0f)
|
, separator_size(5.0f)
|
||||||
, gap_size(0.0f)
|
, gap_size(6.0f)
|
||||||
, icons_size(Default_Icons_Size)
|
, icons_size(Default_Icons_Size)
|
||||||
, scale(1.0f)
|
, scale(1.0f)
|
||||||
, width(0.0f)
|
, width(0.0f)
|
||||||
@ -556,12 +559,12 @@ float GLToolbar::get_width_horizontal() const
|
|||||||
|
|
||||||
float GLToolbar::get_width_vertical() const
|
float GLToolbar::get_width_vertical() const
|
||||||
{
|
{
|
||||||
return (2.0f * m_layout.border + m_layout.icons_size) * m_layout.scale;
|
return (2.0f * (m_layout.border + m_layout.gap_size) + m_layout.icons_size) * m_layout.scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::get_height_horizontal() const
|
float GLToolbar::get_height_horizontal() const
|
||||||
{
|
{
|
||||||
return (2.0f * m_layout.border + m_layout.icons_size) * m_layout.scale;
|
return (2.0f * (m_layout.border + m_layout.gap_size) + m_layout.icons_size) * m_layout.scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLToolbar::get_height_vertical() const
|
float GLToolbar::get_height_vertical() const
|
||||||
@ -578,14 +581,11 @@ float GLToolbar::get_main_size() const
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (m_items[i]->is_separator())
|
if (m_items[i]->is_separator())
|
||||||
size += m_layout.separator_size;
|
size += m_layout.separator_size + m_layout.gap_size;
|
||||||
else
|
else
|
||||||
size += (float)m_layout.icons_size;
|
size += (float)m_layout.icons_size + 2.f * m_layout.gap_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_items.size() > 1)
|
|
||||||
size += ((float)m_items.size() - 1.0f) * m_layout.gap_size;
|
|
||||||
|
|
||||||
return size * m_layout.scale;
|
return size * m_layout.scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,10 +678,10 @@ void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D
|
|||||||
const float border = m_layout.border * m_layout.scale;
|
const float border = m_layout.border * m_layout.scale;
|
||||||
|
|
||||||
const float separator_stride = separator_size + gap_size;
|
const float separator_stride = separator_size + gap_size;
|
||||||
const float icon_stride = icons_size + gap_size;
|
const float icon_stride = icons_size + 2 * gap_size;
|
||||||
|
|
||||||
float left = m_layout.left + border;
|
float left = m_layout.left + border;
|
||||||
float top = m_layout.top - border;
|
float top = m_layout.top - border - gap_size;
|
||||||
|
|
||||||
for (GLToolbarItem* item : m_items) {
|
for (GLToolbarItem* item : m_items) {
|
||||||
if (!item->is_visible())
|
if (!item->is_visible())
|
||||||
@ -779,8 +779,8 @@ void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D&
|
|||||||
const float separator_stride = separator_size + gap_size;
|
const float separator_stride = separator_size + gap_size;
|
||||||
const float icon_stride = icons_size + gap_size;
|
const float icon_stride = icons_size + gap_size;
|
||||||
|
|
||||||
float left = m_layout.left + border;
|
float left = m_layout.left + border + gap_size;
|
||||||
float top = m_layout.top - border;
|
float top = m_layout.top - border - gap_size;
|
||||||
|
|
||||||
for (GLToolbarItem* item : m_items) {
|
for (GLToolbarItem* item : m_items) {
|
||||||
if (!item->is_visible())
|
if (!item->is_visible())
|
||||||
@ -900,8 +900,8 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3
|
|||||||
const float gap_size = m_layout.gap_size * m_layout.scale;
|
const float gap_size = m_layout.gap_size * m_layout.scale;
|
||||||
const float border = m_layout.border * m_layout.scale;
|
const float border = m_layout.border * m_layout.scale;
|
||||||
|
|
||||||
float left = m_layout.left + border;
|
float left = m_layout.left + border + gap_size;
|
||||||
const float top = m_layout.top - border;
|
const float top = m_layout.top - border - gap_size;
|
||||||
|
|
||||||
for (size_t id = 0; id < m_items.size(); ++id) {
|
for (size_t id = 0; id < m_items.size(); ++id) {
|
||||||
GLToolbarItem* item = m_items[id];
|
GLToolbarItem* item = m_items[id];
|
||||||
@ -957,7 +957,7 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
left = right;
|
left = right + gap_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1206,14 +1206,15 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent)
|
|||||||
const float icons_size_x = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_w;
|
const float icons_size_x = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_w;
|
||||||
const float icons_size_y = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_h;
|
const float icons_size_y = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_h;
|
||||||
const float separator_size = 2.0f * m_layout.separator_size * m_layout.scale * inv_cnv_w;
|
const float separator_size = 2.0f * m_layout.separator_size * m_layout.scale * inv_cnv_w;
|
||||||
const float gap_size = 2.0f * m_layout.gap_size * m_layout.scale * inv_cnv_w;
|
const float gap_size_x = 2.0f * m_layout.gap_size * m_layout.scale * inv_cnv_w;
|
||||||
|
const float gap_size_y = 2.0f * m_layout.gap_size * m_layout.scale * inv_cnv_h;
|
||||||
const float border_w = 2.0f * m_layout.border * m_layout.scale * inv_cnv_w;
|
const float border_w = 2.0f * m_layout.border * m_layout.scale * inv_cnv_w;
|
||||||
const float border_h = 2.0f * m_layout.border * m_layout.scale * inv_cnv_h;
|
const float border_h = 2.0f * m_layout.border * m_layout.scale * inv_cnv_h;
|
||||||
const float width = 2.0f * get_width() * inv_cnv_w;
|
const float width = 2.0f * get_width() * inv_cnv_w;
|
||||||
const float height = 2.0f * get_height() * inv_cnv_h;
|
const float height = 2.0f * get_height() * inv_cnv_h;
|
||||||
|
|
||||||
const float separator_stride = separator_size + gap_size;
|
const float separator_stride = separator_size + gap_size_x;
|
||||||
const float icon_stride = icons_size_x + gap_size;
|
const float icon_stride = icons_size_x + 2 * gap_size_x;
|
||||||
|
|
||||||
float left = 2.0f * m_layout.left * inv_cnv_w;
|
float left = 2.0f * m_layout.left * inv_cnv_w;
|
||||||
float top = 2.0f * m_layout.top * inv_cnv_h;
|
float top = 2.0f * m_layout.top * inv_cnv_h;
|
||||||
@ -1222,17 +1223,29 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent)
|
|||||||
|
|
||||||
render_background(left, top, right, bottom, border_w, border_h);
|
render_background(left, top, right, bottom, border_w, border_h);
|
||||||
|
|
||||||
left += border_w;
|
const float margin_w = border_w + gap_size_x;
|
||||||
top -= border_h;
|
const float margin_h = border_h + gap_size_y;
|
||||||
|
|
||||||
|
left += margin_w;
|
||||||
|
top -= margin_h;
|
||||||
|
|
||||||
// renders icons
|
// renders icons
|
||||||
|
int id = 0;
|
||||||
for (const GLToolbarItem* item : m_items) {
|
for (const GLToolbarItem* item : m_items) {
|
||||||
|
id++;
|
||||||
if (!item->is_visible())
|
if (!item->is_visible())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (item->is_separator())
|
if (item->is_separator())
|
||||||
left += separator_stride;
|
left += separator_stride;
|
||||||
else {
|
else {
|
||||||
|
if (item->is_pressed())
|
||||||
|
render_background(left - (id == m_items.size() ? border_w : margin_w),
|
||||||
|
top + margin_h,
|
||||||
|
left + icons_size_x + (id == 1 ? border_w : margin_w),
|
||||||
|
top - icons_size_y - margin_h,
|
||||||
|
border_w, border_h);
|
||||||
|
|
||||||
item->render(parent, tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
item->render(parent, tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
||||||
left += icon_stride;
|
left += icon_stride;
|
||||||
}
|
}
|
||||||
@ -1261,14 +1274,15 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent)
|
|||||||
const float icons_size_x = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_w;
|
const float icons_size_x = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_w;
|
||||||
const float icons_size_y = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_h;
|
const float icons_size_y = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_h;
|
||||||
const float separator_size = 2.0f * m_layout.separator_size * m_layout.scale * inv_cnv_h;
|
const float separator_size = 2.0f * m_layout.separator_size * m_layout.scale * inv_cnv_h;
|
||||||
const float gap_size = 2.0f * m_layout.gap_size * m_layout.scale * inv_cnv_h;
|
const float gap_size_x = 2.0f * m_layout.gap_size * m_layout.scale * inv_cnv_w;
|
||||||
|
const float gap_size_y = 2.0f * m_layout.gap_size * m_layout.scale * inv_cnv_h;
|
||||||
const float border_w = 2.0f * m_layout.border * m_layout.scale * inv_cnv_w;
|
const float border_w = 2.0f * m_layout.border * m_layout.scale * inv_cnv_w;
|
||||||
const float border_h = 2.0f * m_layout.border * m_layout.scale * inv_cnv_h;
|
const float border_h = 2.0f * m_layout.border * m_layout.scale * inv_cnv_h;
|
||||||
const float width = 2.0f * get_width() * inv_cnv_w;
|
const float width = 2.0f * get_width() * inv_cnv_w;
|
||||||
const float height = 2.0f * get_height() * inv_cnv_h;
|
const float height = 2.0f * get_height() * inv_cnv_h;
|
||||||
|
|
||||||
const float separator_stride = separator_size + gap_size;
|
const float separator_stride = separator_size + gap_size_y;
|
||||||
const float icon_stride = icons_size_y + gap_size;
|
const float icon_stride = icons_size_y + 2 * gap_size_y;
|
||||||
|
|
||||||
float left = 2.0f * m_layout.left * inv_cnv_w;
|
float left = 2.0f * m_layout.left * inv_cnv_w;
|
||||||
float top = 2.0f * m_layout.top * inv_cnv_h;
|
float top = 2.0f * m_layout.top * inv_cnv_h;
|
||||||
@ -1277,8 +1291,8 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent)
|
|||||||
|
|
||||||
render_background(left, top, right, bottom, border_w, border_h);
|
render_background(left, top, right, bottom, border_w, border_h);
|
||||||
|
|
||||||
left += border_w;
|
left += border_w + gap_size_y;
|
||||||
top -= border_h;
|
top -= border_h + gap_size_y;
|
||||||
|
|
||||||
// renders icons
|
// renders icons
|
||||||
for (const GLToolbarItem* item : m_items) {
|
for (const GLToolbarItem* item : m_items) {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
const float GLGizmosManager::Default_Icons_Size = 64;
|
const float GLGizmosManager::Default_Icons_Size = 48;// 64;
|
||||||
|
|
||||||
GLGizmosManager::GLGizmosManager(GLCanvas3D& parent)
|
GLGizmosManager::GLGizmosManager(GLCanvas3D& parent)
|
||||||
: m_parent(parent)
|
: m_parent(parent)
|
||||||
@ -62,6 +62,8 @@ std::vector<size_t> GLGizmosManager::get_selectable_idxs() const
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define rect_sel 1 // square_sel, if 0
|
||||||
|
|
||||||
GLGizmosManager::EType GLGizmosManager::get_gizmo_from_mouse(const Vec2d &mouse_pos) const
|
GLGizmosManager::EType GLGizmosManager::get_gizmo_from_mouse(const Vec2d &mouse_pos) const
|
||||||
{
|
{
|
||||||
if (!m_enabled) return Undefined;
|
if (!m_enabled) return Undefined;
|
||||||
@ -71,15 +73,21 @@ GLGizmosManager::EType GLGizmosManager::get_gizmo_from_mouse(const Vec2d &mouse_
|
|||||||
float icons_size = m_layout.scaled_icons_size();
|
float icons_size = m_layout.scaled_icons_size();
|
||||||
float border = m_layout.scaled_border();
|
float border = m_layout.scaled_border();
|
||||||
float stride_y = m_layout.scaled_stride_y();
|
float stride_y = m_layout.scaled_stride_y();
|
||||||
|
float gap_x = m_layout.scaled_gap_x();
|
||||||
|
float gap_y = m_layout.scaled_gap_x();
|
||||||
float top_y = 0.5f * (cnv_h - height) + border;
|
float top_y = 0.5f * (cnv_h - height) + border;
|
||||||
|
|
||||||
// is mouse horizontally in the area?
|
// is mouse horizontally in the area?
|
||||||
if ((border <= (float) mouse_pos(0) &&
|
if (border <= (float) mouse_pos(0) &&
|
||||||
((float) mouse_pos(0) <= border + icons_size))) {
|
(float) mouse_pos(0) <= (border+gap_x + icons_size)) {
|
||||||
// which icon is it on?
|
// which icon is it on?
|
||||||
size_t from_top = (size_t) ((float) mouse_pos(1) - top_y) / stride_y;
|
size_t from_top = (size_t) ((float) mouse_pos(1) - top_y) / stride_y;
|
||||||
// is it really on the icon or already past the border?
|
// is it really on the icon or already past the border?
|
||||||
|
#if rect_sel
|
||||||
if ((float) mouse_pos(1) <= top_y + from_top * stride_y + icons_size) {
|
if ((float) mouse_pos(1) <= top_y + from_top * stride_y + icons_size) {
|
||||||
|
#else
|
||||||
|
if ((float) mouse_pos(1) <= top_y + gap_y + from_top * stride_y + icons_size) {
|
||||||
|
#endif
|
||||||
std::vector<size_t> selectable = get_selectable_idxs();
|
std::vector<size_t> selectable = get_selectable_idxs();
|
||||||
if (from_top < selectable.size())
|
if (from_top < selectable.size())
|
||||||
return static_cast<EType>(selectable[from_top]);
|
return static_cast<EType>(selectable[from_top]);
|
||||||
@ -808,8 +816,15 @@ void GLGizmosManager::do_render_overlay() const
|
|||||||
|
|
||||||
render_background(top_x, top_y, top_x + width, top_y - height, border_w, border_h);
|
render_background(top_x, top_y, top_x + width, top_y - height, border_w, border_h);
|
||||||
|
|
||||||
top_x += border_w;
|
const float margin_w = border_w + m_layout.scaled_gap_x() * inv_cnv_w;
|
||||||
|
const float margin_h = border_h + m_layout.scaled_gap_y() * inv_cnv_h;
|
||||||
|
|
||||||
|
top_x += margin_w;
|
||||||
|
#if rect_sel
|
||||||
top_y -= border_h;
|
top_y -= border_h;
|
||||||
|
#else
|
||||||
|
top_y -= margin_h;
|
||||||
|
#endif
|
||||||
|
|
||||||
const float icons_size_x = 2.0f * m_layout.scaled_icons_size() * inv_cnv_w;
|
const float icons_size_x = 2.0f * m_layout.scaled_icons_size() * inv_cnv_w;
|
||||||
const float icons_size_y = 2.0f * m_layout.scaled_icons_size() * inv_cnv_h;
|
const float icons_size_y = 2.0f * m_layout.scaled_icons_size() * inv_cnv_h;
|
||||||
@ -832,9 +847,17 @@ void GLGizmosManager::do_render_overlay() const
|
|||||||
float current_y = FLT_MAX;
|
float current_y = FLT_MAX;
|
||||||
for (size_t idx : selectable_idxs) {
|
for (size_t idx : selectable_idxs) {
|
||||||
GLGizmoBase* gizmo = m_gizmos[idx].get();
|
GLGizmoBase* gizmo = m_gizmos[idx].get();
|
||||||
|
|
||||||
|
if (m_current == idx)
|
||||||
|
#if rect_sel
|
||||||
|
render_background(top_x - margin_w, top_y + border_h, top_x + icons_size_x + margin_w, top_y - icons_size_y - border_h, border_w, border_h);
|
||||||
|
#else
|
||||||
|
render_background(top_x - margin_w, top_y + margin_h, top_x + icons_size_x + margin_w, top_y - icons_size_y - margin_h, border_w, border_h);
|
||||||
|
#endif
|
||||||
|
|
||||||
const unsigned int sprite_id = gizmo->get_sprite_id();
|
const unsigned int sprite_id = gizmo->get_sprite_id();
|
||||||
// higlighted state needs to be decided first so its highlighting in every other state
|
// higlighted state needs to be decided first so its highlighting in every other state
|
||||||
const int icon_idx = (m_highlight.first == idx ? (m_highlight.second ? 4 : 5) : (m_current == idx) ? 2 : ((m_hover == idx) ? 1 : (gizmo->is_activable() ? 0 : 3)));
|
const int icon_idx = (m_highlight.first == idx ? (m_highlight.second ? 4 : 5) : (m_current == idx) ? /*2*/1 : ((m_hover == idx) ? 1 : (gizmo->is_activable() ? 0 : 3)));
|
||||||
|
|
||||||
const float u_left = u_offset + icon_idx * du;
|
const float u_left = u_offset + icon_idx * du;
|
||||||
const float u_right = u_left + du - u_offset;
|
const float u_right = u_left + du - u_offset;
|
||||||
@ -856,12 +879,16 @@ void GLGizmosManager::do_render_overlay() const
|
|||||||
|
|
||||||
float GLGizmosManager::get_scaled_total_height() const
|
float GLGizmosManager::get_scaled_total_height() const
|
||||||
{
|
{
|
||||||
return m_layout.scale * (2.0f * m_layout.border + (float)get_selectable_idxs().size() * m_layout.stride_y() - m_layout.gap_y);
|
#if rect_sel
|
||||||
|
return 2.0f * m_layout.scaled_border() + (float)get_selectable_idxs().size() * m_layout.scaled_stride_y() - m_layout.scaled_gap_y();
|
||||||
|
#else
|
||||||
|
return 2.0f * m_layout.scaled_border() + (float)get_selectable_idxs().size() * m_layout.scaled_stride_y();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLGizmosManager::get_scaled_total_width() const
|
float GLGizmosManager::get_scaled_total_width() const
|
||||||
{
|
{
|
||||||
return 2.0f * m_layout.scaled_border() + m_layout.scaled_icons_size();
|
return 2.0f * m_layout.scaled_border() + m_layout.scaled_icons_size() + m_layout.scaled_gap_x();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLGizmoBase* GLGizmosManager::get_current() const
|
GLGizmoBase* GLGizmosManager::get_current() const
|
||||||
|
@ -94,12 +94,14 @@ private:
|
|||||||
float scale{ 1.0f };
|
float scale{ 1.0f };
|
||||||
float icons_size{ Default_Icons_Size };
|
float icons_size{ Default_Icons_Size };
|
||||||
float border{ 5.0f };
|
float border{ 5.0f };
|
||||||
float gap_y{ 5.0f };
|
float gap_x{ 15.0f };
|
||||||
|
float gap_y{ 15.0f };
|
||||||
|
|
||||||
float stride_y() const { return icons_size + gap_y;}
|
float stride_y() const { return icons_size + gap_y;}
|
||||||
|
|
||||||
float scaled_icons_size() const { return scale * icons_size; }
|
float scaled_icons_size() const { return scale * icons_size; }
|
||||||
float scaled_border() const { return scale * border; }
|
float scaled_border() const { return scale * border; }
|
||||||
|
float scaled_gap_x() const { return scale * gap_x; }
|
||||||
float scaled_gap_y() const { return scale * gap_y; }
|
float scaled_gap_y() const { return scale * gap_y; }
|
||||||
float scaled_stride_y() const { return scale * stride_y(); }
|
float scaled_stride_y() const { return scale * stride_y(); }
|
||||||
};
|
};
|
||||||
@ -231,6 +233,8 @@ public:
|
|||||||
// To end highlight set gizmo = undefined
|
// To end highlight set gizmo = undefined
|
||||||
void set_highlight(EType gizmo, bool highlight_shown) { m_highlight = std::pair<EType, bool>(gizmo, highlight_shown); }
|
void set_highlight(EType gizmo, bool highlight_shown) { m_highlight = std::pair<EType, bool>(gizmo, highlight_shown); }
|
||||||
bool get_highlight_state() const { return m_highlight.second; }
|
bool get_highlight_state() const { return m_highlight.second; }
|
||||||
|
float get_scaled_total_height() const;
|
||||||
|
float get_scaled_total_width() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool gizmo_event(SLAGizmoEventType action,
|
bool gizmo_event(SLAGizmoEventType action,
|
||||||
@ -242,10 +246,6 @@ private:
|
|||||||
void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const;
|
void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const;
|
||||||
|
|
||||||
void do_render_overlay() const;
|
void do_render_overlay() const;
|
||||||
|
|
||||||
float get_scaled_total_height() const;
|
|
||||||
float get_scaled_total_width() const;
|
|
||||||
|
|
||||||
bool generate_icons_texture();
|
bool generate_icons_texture();
|
||||||
|
|
||||||
void update_hover_state(const EType &type);
|
void update_hover_state(const EType &type);
|
||||||
|
@ -1073,6 +1073,7 @@ void Plater::priv::collapse_sidebar(bool collapse)
|
|||||||
new_tooltip += " [Shift+Tab]";
|
new_tooltip += " [Shift+Tab]";
|
||||||
int id = collapse_toolbar.get_item_id("collapse_sidebar");
|
int id = collapse_toolbar.get_item_id("collapse_sidebar");
|
||||||
collapse_toolbar.set_tooltip(id, new_tooltip);
|
collapse_toolbar.set_tooltip(id, new_tooltip);
|
||||||
|
collapse_toolbar.set_enabled(collapse || wxGetApp().app_config->get_bool("show_collapse_button"));
|
||||||
|
|
||||||
notification_manager->set_sidebar_collapsed(collapse);
|
notification_manager->set_sidebar_collapsed(collapse);
|
||||||
}
|
}
|
||||||
@ -3273,8 +3274,8 @@ bool Plater::priv::init_view_toolbar()
|
|||||||
|
|
||||||
view_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
|
view_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
|
||||||
view_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Bottom);
|
view_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Bottom);
|
||||||
view_toolbar.set_border(5.0f);
|
//view_toolbar.set_border(5.0f);
|
||||||
view_toolbar.set_gap_size(1.0f);
|
//view_toolbar.set_gap_size(1.0f);
|
||||||
|
|
||||||
GLToolbarItem::Data item;
|
GLToolbarItem::Data item;
|
||||||
|
|
||||||
@ -3324,9 +3325,9 @@ bool Plater::priv::init_collapse_toolbar()
|
|||||||
collapse_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
collapse_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||||
collapse_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
|
collapse_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
|
||||||
collapse_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
collapse_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
||||||
collapse_toolbar.set_border(5.0f);
|
//collapse_toolbar.set_border(5.0f);
|
||||||
collapse_toolbar.set_separator_size(5);
|
//collapse_toolbar.set_separator_size(5);
|
||||||
collapse_toolbar.set_gap_size(2);
|
//collapse_toolbar.set_gap_size(2);
|
||||||
|
|
||||||
GLToolbarItem::Data item;
|
GLToolbarItem::Data item;
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ void TopBarItemsCtrl::ButtonWithPopup::SetLabel(const wxString& label)
|
|||||||
void TopBarItemsCtrl::UpdateAccountButton(bool avatar/* = false*/)
|
void TopBarItemsCtrl::UpdateAccountButton(bool avatar/* = false*/)
|
||||||
{
|
{
|
||||||
auto user_account = wxGetApp().plater()->get_user_account();
|
auto user_account = wxGetApp().plater()->get_user_account();
|
||||||
const wxString user_name = user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Anonymous");
|
const wxString user_name = user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Log in");
|
||||||
m_account_btn->SetLabel(m_collapsed_btns ? "" : user_name);
|
m_account_btn->SetLabel(m_collapsed_btns ? "" : user_name);
|
||||||
m_account_btn->SetToolTip(user_name);
|
m_account_btn->SetToolTip(user_name);
|
||||||
const int icon_sz = 24;
|
const int icon_sz = 24;
|
||||||
@ -479,7 +479,7 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent, TopBarMenus* menus/* = nullpt
|
|||||||
m_menus->Popup(this, &m_menus->workspaces, m_workspace_btn->get_popup_pos());
|
m_menus->Popup(this, &m_menus->workspaces, m_workspace_btn->get_popup_pos());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_account_btn = new ButtonWithPopup(this, _L("Anonymous"), "user", wxSize(180, -1));
|
m_account_btn = new ButtonWithPopup(this, _L("Log in"), "user", wxSize(180, -1));
|
||||||
right_sizer->Add(m_account_btn, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxRIGHT, m_btn_margin);
|
right_sizer->Add(m_account_btn, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxRIGHT, m_btn_margin);
|
||||||
|
|
||||||
m_account_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {
|
m_account_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {
|
||||||
|
@ -249,9 +249,9 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
if (align_right)
|
if (align_right)
|
||||||
textPos.x += labelSize.x;
|
textPos.x += labelSize.x;
|
||||||
if (text_ctrl) {
|
if (text_ctrl) {
|
||||||
wxSize textSize = text_ctrl->GetSize();
|
wxSize textSize = text_ctrl->GetBestSize();
|
||||||
wxClientDC dc(this);
|
wxClientDC dc(this);
|
||||||
const int r_shift = int((dd_icon_size.x == 0 ? 3. : 2.) * dc.GetContentScaleFactor());
|
const int r_shift = int(dd_icon_size.x == 0 ? (3. * dc.GetContentScaleFactor()) : ((size.y - dd_icon_size.y) / 2));
|
||||||
textSize.x = size.x - textPos.x - labelSize.x - dd_icon_size.x - r_shift;
|
textSize.x = size.x - textPos.x - labelSize.x - dd_icon_size.x - r_shift;
|
||||||
text_ctrl->SetSize(textSize);
|
text_ctrl->SetSize(textSize);
|
||||||
text_ctrl->SetPosition({textPos.x, (size.y - textSize.y) / 2});
|
text_ctrl->SetPosition({textPos.x, (size.y - textSize.y) / 2});
|
||||||
@ -283,7 +283,7 @@ void TextInput::render(wxDC& dc)
|
|||||||
wxSize size = GetSize();
|
wxSize size = GetSize();
|
||||||
bool align_right = GetWindowStyle() & wxRIGHT;
|
bool align_right = GetWindowStyle() & wxRIGHT;
|
||||||
// start draw
|
// start draw
|
||||||
wxPoint pt = {5, 0};
|
wxPoint pt = { 5 + text_ctrl->GetMargins().x, 0};
|
||||||
if (icon.IsOk()) {
|
if (icon.IsOk()) {
|
||||||
wxSize szIcon = get_preferred_size(icon, m_parent);
|
wxSize szIcon = get_preferred_size(icon, m_parent);
|
||||||
pt.y = (size.y - szIcon.y) / 2;
|
pt.y = (size.y - szIcon.y) / 2;
|
||||||
@ -299,14 +299,15 @@ void TextInput::render(wxDC& dc)
|
|||||||
wxPoint pt_r = {size.x, 0};
|
wxPoint pt_r = {size.x, 0};
|
||||||
if (drop_down_icon.bmp().IsOk()) {
|
if (drop_down_icon.bmp().IsOk()) {
|
||||||
wxSize szIcon = drop_down_icon.GetSize();
|
wxSize szIcon = drop_down_icon.GetSize();
|
||||||
pt_r.x -= szIcon.x + 2;
|
|
||||||
pt_r.y = (size.y - szIcon.y) / 2;
|
pt_r.y = (size.y - szIcon.y) / 2;
|
||||||
|
pt_r.x -= szIcon.x + pt_r.y;
|
||||||
dd_icon_rect = wxRect(pt_r, szIcon);
|
dd_icon_rect = wxRect(pt_r, szIcon);
|
||||||
dc.DrawBitmap(drop_down_icon.get_bitmap(), pt_r);
|
dc.DrawBitmap(drop_down_icon.get_bitmap(), pt_r);
|
||||||
|
pt_r.x -= 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto text = wxWindow::GetLabel();
|
auto text = wxWindow::GetLabel();
|
||||||
if (!text.IsEmpty()) {
|
if (!text_ctrl->IsShown() && !text.IsEmpty()) {
|
||||||
wxSize textSize = text_ctrl->GetSize();
|
wxSize textSize = text_ctrl->GetSize();
|
||||||
if (align_right) {
|
if (align_right) {
|
||||||
pt.x += textSize.x;
|
pt.x += textSize.x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user