OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::ImageGrid Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/ImageGrid.h>

Inheritance diagram for Slic3r::GUI::ImageGrid:
Collaboration diagram for Slic3r::GUI::ImageGrid:

Public Member Functions

 ImageGrid (wxWindow *parent)
void SetFileSystem (boost::shared_ptr< PrinterFileSystem > file_sys)
void SetStatus (ScalableBitmap const &icon, wxString const &msg)
boost::shared_ptr< PrinterFileSystem > GetFileSystem ()
void SetFileType (int type, std::string const &storage)
void SetGroupMode (int mode)
void SetSelecting (bool selecting)
bool IsSelecting ()
void DoActionOnSelection (int action)
void ShowDownload (bool show)
void Rescale ()

Protected Member Functions

void Select (size_t index)
void DoAction (size_t index, int action)
void UpdateFileSystem ()
void UpdateLayout ()
void UpdateFocusRange ()
std::pair< int, size_t > HitTest (wxPoint const &pt)
void changedEvent (wxCommandEvent &evt)
void paintEvent (wxPaintEvent &evt)
size_t firstItem (wxSize const &size, wxPoint &off)
wxBitmap createAlphaBitmap (wxSize size, wxColour color, int alpha1, int alpha2)
wxBitmap createShadowBorder (wxSize size, wxColour color, int radius, int shadow)
wxBitmap createCircleBitmap (wxSize size, int borderWidth, int percent, wxColour fillColor, wxColour borderColor=wxTransparentColour)
void render (wxDC &dc)
void renderContent1 (wxDC &dc, wxPoint const &pt, int index, bool hit)
void renderContent2 (wxDC &dc, wxPoint const &pt, int index, bool hit)
void renderButtons (wxDC &dc, wxArrayString const &texts, wxRect const &rect, size_t hit, int states)
void renderText (wxDC &dc, wxString const &text, wxRect const &rect, int states)
void renderText2 (wxDC &dc, wxString text, wxRect const &rect)
void renderIconText (wxDC &dc, ScalableBitmap const &icon, wxString text, wxRect const &rect)
void mouseMoved (wxMouseEvent &event)
void mouseWheelMoved (wxMouseEvent &event)
void mouseEnterWindow (wxMouseEvent &event)
void mouseLeaveWindow (wxMouseEvent &event)
void mouseDown (wxMouseEvent &event)
void mouseReleased (wxMouseEvent &event)
void resize (wxSizeEvent &event)

Private Types

enum  HitType {
  HIT_NONE , HIT_ITEM , HIT_ACTION , HIT_MODE ,
  HIT_STATUS
}

Private Attributes

boost::shared_ptr< PrinterFileSystem > m_file_sys
ScalableBitmap m_status_icon
wxString m_status_msg
ScalableBitmap m_checked_icon
ScalableBitmap m_unchecked_icon
ScalableBitmap m_model_time_icon
ScalableBitmap m_model_weight_icon
StateColor m_buttonBackgroundColor
StateColor m_buttonTextColor
bool m_hovered = false
bool m_pressed = false
wxTimer m_timer
wxBitmap m_title_mask
wxBitmap m_border_mask
wxBitmap m_buttons_background
wxBitmap m_buttons_background_checked
bool m_selecting = false
bool m_show_download = false
int m_hit_type = HIT_NONE
size_t m_hit_item = size_t(-1)
int m_scroll_offset = 0
int m_row_offset = 0
int m_row_count = 0
int m_col_count = 1
wxSize m_cell_size
wxSize m_border_size
wxRect m_content_rect

Detailed Description

Member Enumeration Documentation

◆ HitType

Enumerator
HIT_NONE 
HIT_ITEM 
HIT_ACTION 
HIT_MODE 
HIT_STATUS 
143 {
144 HIT_NONE,
145 HIT_ITEM,
146 HIT_ACTION, // implicit HTI_ITEM
147 HIT_MODE,
149 };
@ HIT_ITEM
Definition ImageGrid.h:145
@ HIT_ACTION
Definition ImageGrid.h:146
@ HIT_NONE
Definition ImageGrid.h:144
@ HIT_STATUS
Definition ImageGrid.h:148
@ HIT_MODE
Definition ImageGrid.h:147

Constructor & Destructor Documentation

◆ ImageGrid()

Slic3r::GUI::ImageGrid::ImageGrid ( wxWindow * parent)
54 : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
55 , m_buttonBackgroundColor(StateColor(
56 std::make_pair(*wxWHITE, (int) StateColor::Pressed),
57 std::make_pair(*wxRED, (int) StateColor::Normal)))
58 , m_buttonTextColor(StateColor(
59 std::make_pair(0x3B4446, (int) StateColor::Pressed),
60 std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
61 std::make_pair(*wxWHITE, (int) StateColor::Normal)))
62 , m_checked_icon(this, "check_on", 16)
63 , m_unchecked_icon(this, "check_off", 16)
64 , m_model_time_icon(this, "model_time", 14)
65 , m_model_weight_icon(this, "model_weight", 14)
66{
67 m_cell_size.Set(396, 228);
68
69 SetBackgroundStyle(wxBG_STYLE_PAINT);
70 SetBackgroundColour(0xEEEEEE);
71 SetFont(Label::Head_20);
72
73 m_timer.Bind(wxEVT_TIMER, [this](auto & e) { Refresh(); });
74 Rescale();
75}
static wxFont Head_20
Definition Label.hpp:41
ScalableBitmap m_model_weight_icon
Definition ImageGrid.h:126
void Rescale()
Definition ImageGrid.cpp:153
StateColor m_buttonBackgroundColor
Definition ImageGrid.h:127
StateColor m_buttonTextColor
Definition ImageGrid.h:128
ScalableBitmap m_checked_icon
Definition ImageGrid.h:123
wxSize m_cell_size
Definition ImageGrid.h:157
ScalableBitmap m_unchecked_icon
Definition ImageGrid.h:124
ScalableBitmap m_model_time_icon
Definition ImageGrid.h:125
wxTimer m_timer
Definition ImageGrid.h:133
@ Hovered
Definition StateColor.hpp:20
@ Normal
Definition StateColor.hpp:16
@ Pressed
Definition StateColor.hpp:21

References ImageGrid(), Label::Head_20, m_buttonBackgroundColor, m_buttonTextColor, m_cell_size, m_checked_icon, m_model_time_icon, m_model_weight_icon, m_timer, m_unchecked_icon, Slic3r::GUI::Normal, and Rescale().

Referenced by ImageGrid().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ changedEvent()

void Slic3r::GUI::ImageGrid::changedEvent ( wxCommandEvent & evt)
protected
407{
408 evt.Skip();
409 BOOST_LOG_TRIVIAL(debug) << "ImageGrid::changedEvent: " << evt.GetEventType() << " index: " << evt.GetInt()
410 << " name: " << evt.GetString().ToUTF8().data() << " extra: " << evt.GetExtraLong();
411 if (evt.GetEventType() == EVT_FILE_CHANGED) {
412 if (evt.GetInt() == -1)
413 m_file_sys->DownloadCheckFiles(wxGetApp().app_config->get("download_path"));
415 }
416 else if (evt.GetEventType() == EVT_MODE_CHANGED)
418 //else if (evt.GetEventType() == EVT_THUMBNAIL)
419 // RefreshRect(itemRect(evt.GetInt()), false);
420 else
421 Refresh();
422}
void UpdateFileSystem()
Definition ImageGrid.cpp:194
boost::shared_ptr< PrinterFileSystem > m_file_sys
Definition ImageGrid.h:119

References m_file_sys, and UpdateFileSystem().

Referenced by SetFileSystem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createAlphaBitmap()

wxBitmap Slic3r::GUI::ImageGrid::createAlphaBitmap ( wxSize size,
wxColour color,
int alpha1,
int alpha2 )
protected
450{
451 wxImage image(size);
452 image.InitAlpha();
453 unsigned char *alpha = image.GetAlpha();
454 image.SetRGB(wxRect({0, 0}, size), color.Red(), color.Green(), color.Blue());
455 int d = alpha2 - alpha1;
456 if (d == 0)
457 memset(alpha, alpha1, size.GetWidth() * size.GetHeight());
458 else
459 for (int i = 0; i < size.GetHeight(); ++i)
460 memset(alpha + i * size.GetWidth(), alpha1 + i * d / size.GetHeight(), size.GetWidth());
461 return wxBitmap(std::move(image));
462}

Referenced by Rescale(), and UpdateLayout().

Here is the caller graph for this function:

◆ createCircleBitmap()

wxBitmap Slic3r::GUI::ImageGrid::createCircleBitmap ( wxSize size,
int borderWidth,
int percent,
wxColour fillColor,
wxColour borderColor = wxTransparentColour )
protected
497{
498 wxImage image(size);
499 image.InitAlpha();
500 memset(image.GetAlpha(), 0, size.GetWidth() * size.GetHeight());
501 wxBitmap bmp(std::move(image));
502 wxRect rc(0, 0, size.x, size.y);
503 wxMemoryDC memdc;
504 memdc.SelectObject(bmp);
505#ifdef __WXMSW__
506 wxGCDC dc2(memdc);
507#else
508 wxDC &dc2(memdc);
509#endif
510 if (borderWidth && borderColor != wxTransparentColor) {
511 int d = ceil(borderWidth / 2.0);
512 rc.Deflate(d, d);
513 dc2.SetPen(wxPen(borderColor, borderWidth));
514 } else {
515 dc2.SetPen(wxPen(fillColor));
516 }
517 dc2.SetBrush(wxBrush(fillColor));
518 if (percent > 0)
519 dc2.DrawEllipticArc(rc.GetTopLeft(), rc.GetSize(), 0, percent * 360.0 / 100);
520
521 memdc.SelectObject(wxNullBitmap);
522 return bmp;
523}

◆ createShadowBorder()

wxBitmap Slic3r::GUI::ImageGrid::createShadowBorder ( wxSize size,
wxColour color,
int radius,
int shadow )
protected
465{
466 wxImage image(size);
467 image.InitAlpha();
468 memset(image.GetAlpha(), 0, size.GetWidth() * size.GetHeight());
469 wxBitmap bmp(std::move(image));
470 wxMemoryDC memdc;
471 memdc.SelectObject(bmp);
472#ifdef __WXMSW__
473 wxGCDC dc2(memdc);
474#else
475 wxDC &dc2(memdc);
476#endif
477 wxRect rc(0, 0, size.x, size.y);
478 dc2.SetBrush(*wxTRANSPARENT_BRUSH);
479 auto n = ((radius + shadow) * 1414 / 1000 - radius);
480 dc2.SetPen(wxPen(color, n | 1));
481 n = n / 2 - shadow + 1;
482 rc.Inflate(n, n);
483 dc2.DrawRoundedRectangle(rc, radius + shadow);
484 rc.Deflate(n, n);
485 rc.Deflate(shadow, shadow);
486 for (int i = 0; i < shadow; ++i) {
487 rc.Inflate(1, 1);
488 dc2.SetPen(wxColor(0, 0, 0, 100 - i * 30));
489 dc2.DrawRoundedRectangle(rc, radius + i);
490 }
491
492 memdc.SelectObject(wxNullBitmap);
493 return bmp;
494}

Referenced by UpdateLayout().

Here is the caller graph for this function:

◆ DoAction()

void Slic3r::GUI::ImageGrid::DoAction ( size_t index,
int action )
protected
186{
187 wxCommandEvent event(EVT_ITEM_ACTION);
188 event.SetEventObject(this);
189 event.SetInt(action);
190 event.SetExtraLong(long(index));
191 ProcessEventLocally(event);
192}

Referenced by DoActionOnSelection(), and mouseReleased().

Here is the caller graph for this function:

◆ DoActionOnSelection()

void Slic3r::GUI::ImageGrid::DoActionOnSelection ( int action)
145{ DoAction(-1, action); }
void DoAction(size_t index, int action)
Definition ImageGrid.cpp:185

References DoAction().

Here is the call graph for this function:

◆ firstItem()

size_t Slic3r::GUI::ImageGrid::firstItem ( wxSize const & size,
wxPoint & off )
protected
432{
433 int size_y = size.y;
434 if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE)
435 size_y -= m_title_mask.GetHeight();
436 int offx = (size.x - (m_col_count - 1) * m_cell_size.GetWidth() - m_border_size.GetWidth()) / 2;
437 int offy = (m_row_offset + 1 < m_row_count || m_row_count == 0) ?
438 m_cell_size.GetHeight() - m_border_size.GetHeight() - m_row_offset * m_cell_size.GetHeight() / 4 + m_row_offset / 4 * m_cell_size.GetHeight() :
439 size_y - (size_y + m_border_size.GetHeight() - 1) / m_cell_size.GetHeight() * m_cell_size.GetHeight();
440 int index = (m_row_offset + 1 < m_row_count || m_row_count == 0) ?
442 ((m_file_sys->GetCount() + m_col_count - 1) / m_col_count - (size_y + m_border_size.GetHeight() - 1) / m_cell_size.GetHeight()) * m_col_count;
443 if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE)
444 offy += m_title_mask.GetHeight();
445 off = wxPoint{offx, offy};
446 return index;
447}
@ G_NONE
Definition PrinterFileSystem.h:99
int m_row_offset
Definition ImageGrid.h:154
wxSize m_border_size
Definition ImageGrid.h:158
wxBitmap m_title_mask
Definition ImageGrid.h:134
int m_row_count
Definition ImageGrid.h:155
int m_col_count
Definition ImageGrid.h:156

References PrinterFileSystem::G_NONE, m_border_size, m_cell_size, m_col_count, m_file_sys, m_row_count, m_row_offset, and m_title_mask.

Referenced by HitTest(), render(), and UpdateFocusRange().

Here is the caller graph for this function:

◆ GetFileSystem()

boost::shared_ptr< PrinterFileSystem > Slic3r::GUI::ImageGrid::GetFileSystem ( )
inline
49{ return m_file_sys; }

References m_file_sys.

◆ HitTest()

std::pair< int, size_t > Slic3r::GUI::ImageGrid::HitTest ( wxPoint const & pt)
protected
268{
269 if (!m_file_sys)
270 return {HIT_NONE, -1};
271 wxSize size = GetClientSize();
272 if (m_file_sys->GetCount() == 0) {
273 if (wxRect({0, 0}, m_border_size).CenterIn(wxRect({0, 0}, size)).Contains(pt))
274 return {HIT_STATUS, 0};
275 return {HIT_NONE, -1};
276 }
277 wxPoint off;
278 size_t index = firstItem(size, off);
279 off = pt - off;
280 int n = 0;
281 while (off.x > m_cell_size.GetWidth() && n + 1 < m_col_count) {
282 ++n;
283 off.x -= m_cell_size.GetWidth();
284 }
285 index += n;
286 while (off.y > m_cell_size.GetHeight()) {
287 index += m_col_count;
288 off.y -= m_cell_size.GetHeight();
289 }
290 if (index >= m_file_sys->GetCount()) { return {HIT_NONE, -1}; }
291 if (!m_content_rect.Contains(off)) { return {HIT_NONE, -1}; }
292 if (!m_selecting) {
293 wxRect hover_rect{0, m_content_rect.GetHeight() - m_buttons_background.GetHeight(), m_content_rect.GetWidth(), m_buttons_background.GetHeight()};
294 auto & file = m_file_sys->GetFile(index);
295 int btn = file.IsDownload() && file.DownloadProgress() >= 0 ? 3 : 2;
296 if (m_file_sys->GetFileType() == PrinterFileSystem::F_MODEL) {
297 if (m_show_download)
298 btn = 3;
299 hover_rect.y -= m_content_rect.GetHeight() * 64 / 264;
300 }
301 if (hover_rect.Contains(off.x, off.y)) {
302 return {HIT_ACTION, index * 4 + off.x * btn / hover_rect.GetWidth()};
303 } // Two buttons
304 }
305 return {HIT_ITEM, index};
306}
@ F_MODEL
Definition PrinterFileSystem.h:94
bool m_show_download
Definition ImageGrid.h:141
wxRect m_content_rect
Definition ImageGrid.h:159
bool m_selecting
Definition ImageGrid.h:140
size_t firstItem(wxSize const &size, wxPoint &off)
Definition ImageGrid.cpp:431
wxBitmap m_buttons_background
Definition ImageGrid.h:136

References PrinterFileSystem::F_MODEL, firstItem(), HIT_ACTION, HIT_ITEM, HIT_NONE, HIT_STATUS, m_border_size, m_buttons_background, m_cell_size, m_col_count, m_content_rect, m_file_sys, m_selecting, and m_show_download.

Referenced by mouseDown(), mouseMoved(), and mouseReleased().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsSelecting()

bool Slic3r::GUI::ImageGrid::IsSelecting ( )
inline
57{ return m_selecting; }

References m_selecting.

◆ mouseDown()

void Slic3r::GUI::ImageGrid::mouseDown ( wxMouseEvent & event)
protected
351{
352 if (!m_pressed) {
353 m_pressed = true;
354 auto hit = HitTest(event.GetPosition());
355 m_hit_type = hit.first;
356 m_hit_item = hit.second;
357 if (m_hit_type >= HIT_ACTION)
358 Refresh();
359 SetFocus();
360 }
361}
std::pair< int, size_t > HitTest(wxPoint const &pt)
Definition ImageGrid.cpp:267
bool m_pressed
Definition ImageGrid.h:131
size_t m_hit_item
Definition ImageGrid.h:151
int m_hit_type
Definition ImageGrid.h:150

References HIT_ACTION, HitTest(), m_hit_item, m_hit_type, m_pressed, and Slic3r::GUI::wxMouseEvent.

Referenced by wxDEFINE_EVENT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseEnterWindow()

void Slic3r::GUI::ImageGrid::mouseEnterWindow ( wxMouseEvent & event)
protected
332{
333 if (!m_hovered)
334 m_hovered = true;
335}
bool m_hovered
Definition ImageGrid.h:130

References m_hovered, and Slic3r::GUI::wxMouseEvent.

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ mouseLeaveWindow()

void Slic3r::GUI::ImageGrid::mouseLeaveWindow ( wxMouseEvent & event)
protected
338{
339 if (m_hovered) {
340 m_hovered = false;
341 m_pressed = false;
342 if (m_hit_type != HIT_NONE) {
344 m_hit_item = -1;
345 Refresh();
346 }
347 }
348}

References HIT_NONE, m_hit_item, m_hit_type, m_hovered, m_pressed, and Slic3r::GUI::wxMouseEvent.

Referenced by wxDEFINE_EVENT().

Here is the caller graph for this function:

◆ mouseMoved()

void Slic3r::GUI::ImageGrid::mouseMoved ( wxMouseEvent & event)
protected
309{
310 if (!m_hovered || m_pressed)
311 return;
312 auto hit = HitTest(event.GetPosition());
313 if (hit != std::make_pair(m_hit_type, m_hit_item)) {
314 m_hit_type = hit.first;
315 m_hit_item = hit.second;
316 if (hit.first == HIT_ITEM) {
317 SetToolTip({});
318 auto & file = m_file_sys->GetFile(hit.second);
319 if (auto title = file.Title(); !title.empty()) {
320 auto tip = wxString::Format(_L("File: %s\nTitle: %s\n"), from_u8(file.name), from_u8(title));
321 SetToolTip(tip);
322 } else {
323 SetToolTip(from_u8(file.name));
324 }
325 } else
326 SetToolTip({});
327 Refresh();
328 }
329}
#define _L(s)
Definition OBJ.cpp:34
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References _L, Slic3r::GUI::from_u8(), HIT_ITEM, HitTest(), m_file_sys, m_hit_item, m_hit_type, m_hovered, m_pressed, and Slic3r::GUI::wxMouseEvent.

Referenced by wxDEFINE_EVENT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseReleased()

void Slic3r::GUI::ImageGrid::mouseReleased ( wxMouseEvent & event)
protected
364{
365 if (!m_pressed)
366 return;
367 m_pressed = false;
368 auto hit = HitTest(event.GetPosition());
369 if (hit == std::make_pair(m_hit_type, m_hit_item)) {
370 if (m_hit_type == HIT_ITEM)
372 else if (m_hit_type == HIT_ACTION)
374 else if (m_hit_type == HIT_MODE)
376 else if (m_hit_type == HIT_STATUS)
377 m_file_sys->Retry();
378 else
379 Refresh();
380 } else {
381 Refresh();
382 }
383}
GroupMode
Definition PrinterFileSystem.h:98
void Select(size_t index)
Definition ImageGrid.cpp:166
void SetGroupMode(int mode)
Definition ImageGrid.cpp:115

References DoAction(), HIT_ACTION, HIT_ITEM, HIT_MODE, HIT_STATUS, HitTest(), m_file_sys, m_hit_item, m_hit_type, m_pressed, Select(), SetGroupMode(), and Slic3r::GUI::wxMouseEvent.

Referenced by wxDEFINE_EVENT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseWheelMoved()

void Slic3r::GUI::ImageGrid::mouseWheelMoved ( wxMouseEvent & event)
protected
391{
392 auto delta = -event.GetWheelRotation();
393 m_scroll_offset += delta * 4;
394 delta = m_scroll_offset / m_cell_size.GetHeight();
395 m_row_offset += delta;
396 if (m_row_offset < 0)
397 m_row_offset = 0;
398 else if (m_row_offset >= m_row_count)
399 m_row_offset = m_row_count == 0 ? 0 : m_row_count - 1;
400 m_scroll_offset -= delta * m_cell_size.GetHeight();
401 m_timer.StartOnce(4000); // Show position bar
403 Refresh();
404}
int m_scroll_offset
Definition ImageGrid.h:153
void UpdateFocusRange()
Definition ImageGrid.cpp:253

References m_cell_size, m_row_count, m_row_offset, m_scroll_offset, m_timer, UpdateFocusRange(), and Slic3r::GUI::wxMouseEvent.

Referenced by wxDEFINE_EVENT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ paintEvent()

void Slic3r::GUI::ImageGrid::paintEvent ( wxPaintEvent & evt)
protected
425{
426 // depending on your system you may need to look at double-buffered dcs
427 wxPaintDC dc(this);
428 render(dc);
429}
void render(wxDC &dc)
Definition ImageGrid.cpp:532

References render().

Referenced by wxDEFINE_EVENT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render()

void Slic3r::GUI::ImageGrid::render ( wxDC & dc)
protected
533{
534 wxSize size = GetClientSize();
535 dc.SetPen(wxPen(GetBackgroundColour()));
536 dc.SetBrush(wxBrush(GetBackgroundColour()));
537 if (!m_file_sys || m_file_sys->GetCount() == 0) {
538 dc.DrawRectangle({ 0, 0, size.x, size.y });
539 if (!m_status_msg.IsEmpty()) {
540 auto si = m_status_icon.GetBmpSize();
541 auto st = dc.GetMultiLineTextExtent(m_status_msg);
542 auto rect = wxRect{0, 0, std::max(st.x, si.x), si.y + 26 + st.y}.CenterIn(wxRect({0, 0}, size));
543 dc.DrawBitmap(m_status_icon.bmp(), rect.x + (rect.width - si.x) / 2, rect.y);
544 dc.SetTextForeground(wxColor(0x909090));
545 dc.DrawText(m_status_msg, rect.x + (rect.width - st.x) / 2, rect.GetBottom() - st.y);
546 }
547 return;
548 }
549 wxPoint off;
550 size_t index = firstItem(size, off);
551 // Draw background: left/right side
552 dc.DrawRectangle({0, 0, off.x, size.y});
553 dc.DrawRectangle({size.x - off.x - 1, 0, off.x + 1, size.y});
554 // Draw line spacing at top
555 if (off.y > 0)
556 dc.DrawRectangle({0, 0, size.x, off.y});
557 size_t start = index;
558 size_t end = index;
559 size_t hit_image = m_selecting ? size_t(-1) : m_hit_type == HIT_ITEM ? m_hit_item : m_hit_type == HIT_ACTION ? m_hit_item / 4 :size_t(-1);
560 // Draw items with background
561 while (off.y < size.y)
562 {
563 // Draw one line
564 wxPoint pt{off.x, off.y};
565 end = (index + m_col_count) < m_file_sys->GetCount() ? index + m_col_count : m_file_sys->GetCount();
566 while (index < end) {
567 pt += m_content_rect.GetTopLeft();
568 // Draw content
569 decltype(&ImageGrid::renderContent1) contentRender[] = {
573 };
574 (this->*contentRender[m_file_sys->GetFileType()])(dc, pt, index, hit_image == index);
575 pt -= m_content_rect.GetTopLeft();
576 // Draw colume spacing at right
577 dc.DrawRectangle({pt.x + m_border_size.GetWidth(), pt.y, m_cell_size.GetWidth() - m_border_size.GetWidth(), m_border_size.GetHeight()});
578 // Draw overlay border mask
579 dc.DrawBitmap(m_border_mask, pt.x, pt.y);
580 ++index;
581 pt.x += m_cell_size.GetWidth();
582 }
583 // Draw line fill items
584 if (end < index + m_col_count)
585 dc.DrawRectangle({pt.x, pt.y, size.x - pt.x - off.x, m_border_size.GetHeight()});
586 // Draw line spacing at bottom
587 dc.DrawRectangle({off.x, pt.y + m_border_size.GetHeight(), size.x - off.x * 2, m_cell_size.GetHeight() - m_border_size.GetHeight()});
588 off.y += m_cell_size.GetHeight();
589 }
590 // Draw floating date range for non-group list
591 if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE && m_file_sys->GetCount() > 0) {
592 //dc.DrawBitmap(m_title_mask, {off.x, 0});
593 dc.DrawRectangle({off.x, 0}, m_title_mask.GetSize());
594 auto & file1 = m_file_sys->GetFile(start);
595 auto & file2 = m_file_sys->GetFile(end - 1);
596 auto date1 = wxDateTime((time_t) file1.time).Format(_L(TIME_FORMATS[m_file_sys->GetGroupMode()]));
597 auto date2 = wxDateTime((time_t) file2.time).Format(_L(TIME_FORMATS[m_file_sys->GetGroupMode()]));
598 dc.SetFont(Label::Head_16);
599 dc.SetTextForeground(StateColor::darkModeColorFor("#262E30"));
600 dc.DrawText(date1 + " - " + date2, wxPoint{off.x, 2});
601 }
602 // Draw bottom background
603 if (off.y < size.y)
604 dc.DrawRectangle({off.x, off.y, size.x - off.x * 2, size.y - off.y});
605 // Draw position bar
606 if (m_timer.IsRunning()) {
607 int total_height = (m_file_sys->GetCount() + m_col_count - 1) / m_col_count * m_cell_size.GetHeight() + m_cell_size.GetHeight() - m_border_size.GetHeight();
608 if (total_height > size.y) {
609 int offset = (m_row_offset + 1 < m_row_count || m_row_count == 0) ? m_row_offset * (m_cell_size.GetHeight() / 4) : total_height - size.y;
610 wxRect rect = {size.x - 16, offset * size.y / total_height, 8,
611 size.y * size.y / total_height};
612 dc.SetBrush(wxBrush(*wxLIGHT_GREY));
613 dc.DrawRoundedRectangle(rect, 4);
614 }
615 }
616}
static wxFont Head_16
Definition Label.hpp:43
void renderContent2(wxDC &dc, wxPoint const &pt, int index, bool hit)
Definition ImageGrid.cpp:689
void renderContent1(wxDC &dc, wxPoint const &pt, int index, bool hit)
Definition ImageGrid.cpp:618
wxBitmap m_border_mask
Definition ImageGrid.h:135
wxString m_status_msg
Definition ImageGrid.h:121
ScalableBitmap m_status_icon
Definition ImageGrid.h:120
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841
static constexpr wchar_t const * TIME_FORMATS[]
Definition ImageGrid.cpp:525
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References _L, StateColor::darkModeColorFor(), firstItem(), PrinterFileSystem::G_NONE, Label::Head_16, HIT_ACTION, HIT_ITEM, m_border_mask, m_border_size, m_cell_size, m_col_count, m_content_rect, m_file_sys, m_hit_item, m_hit_type, m_row_count, m_row_offset, m_selecting, m_status_icon, m_status_msg, m_timer, m_title_mask, Slic3r::offset(), renderContent1(), renderContent2(), and Slic3r::GUI::TIME_FORMATS.

Referenced by paintEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderButtons()

void Slic3r::GUI::ImageGrid::renderButtons ( wxDC & dc,
wxArrayString const & texts,
wxRect const & rect,
size_t hit,
int states )
protected
725{
726 // Draw background
727 {
729 dc.Blit(rect2.GetTopLeft(), rect2.GetSize(), &mdc, {0, 0});
730 }
731 // Draw buttons
732 wxRect rect(rect2);
733 rect.SetWidth(rect.GetWidth() / texts.size());
735 dc.SetFont(Label::Body_14);
736 //mdc.SelectObject(m_button_background);
737 for (size_t i = 0; i < texts.size(); ++i) {
738 int states2 = hit == i ? state : 0;
739 // Draw button background
740 //dc.Blit(rect.GetTopLeft(), rect.GetSize(), &mdc, {m_buttonBackgroundColor.colorIndexForStates(states) * 128, 0});
741 //dc.DrawBitmap(m_button_background, rect2.GetTopLeft());
742 //dc.SetBrush(m_buttonBackgroundColor.colorForStates(states2));
743 //dc.DrawRectangle(rect);
744 //rect.Deflate(10, 5);
745 // Draw button splitter
746 auto pen = dc.GetPen();
747 dc.SetPen(wxPen("#616161"));
748 if (i > 0) dc.DrawLine(rect.GetLeftTop(), rect.GetLeftBottom());
749 dc.SetPen(pen);
750 // Draw button text
751 renderText(dc, texts[i], rect, states | states2);
752 //rect.Inflate(10, 5);
753 rect.Offset(rect.GetWidth(), 0);
754 }
755 dc.SetFont(GetFont());
756}
static wxFont Body_14
Definition Label.hpp:53
void renderText(wxDC &dc, wxString const &text, wxRect const &rect, int states)
Definition ImageGrid.cpp:758
wxBitmap m_buttons_background_checked
Definition ImageGrid.h:137
@ Checked
Definition StateColor.hpp:18

References Label::Body_14, StateColor::Checked, StateColor::Hovered, m_buttons_background, m_buttons_background_checked, m_pressed, StateColor::Pressed, and renderText().

Referenced by renderContent1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderContent1()

void Slic3r::GUI::ImageGrid::renderContent1 ( wxDC & dc,
wxPoint const & pt,
int index,
bool hit )
protected
619{
620 bool selected = false;
621 auto &file = m_file_sys->GetFile(index, selected);
622 // Draw thumbnail
623 if (file.thumbnail.IsOk()) {
624 float hs = (float) m_content_rect.GetWidth() / file.thumbnail.GetWidth();
625 float vs = (float) m_content_rect.GetHeight() / file.thumbnail.GetHeight();
626 dc.SetUserScale(hs, vs);
627 dc.DrawBitmap(file.thumbnail, {(int) (pt.x / hs), (int) (pt.y / vs)});
628 dc.SetUserScale(1, 1);
629 if (m_file_sys->GetGroupMode() != PrinterFileSystem::G_NONE) { dc.DrawBitmap(m_title_mask, pt); }
630 }
631 bool show_download_state_always = true;
632 // Draw checked icon
633 if (m_selecting && !show_download_state_always)
634 dc.DrawBitmap(selected ? m_checked_icon.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
635 // can't handle alpha
636 // dc.GradientFillLinear({pt.x, pt.y, m_border_size.GetWidth(), 60}, wxColour(0x6F, 0x6F, 0x6F, 0x99), wxColour(0x6F, 0x6F, 0x6F, 0), wxBOTTOM);
637 else if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) {
638 wxString nonHoverText;
639 wxString secondAction = m_show_download ? _L("Download") : "";
640 wxString thirdAction;
641 int states = 0;
642 // Draw download progress
643 if (file.IsDownload()) {
644 int progress = file.DownloadProgress();
645 if (progress == -1) {
646 secondAction = _L("Cancel");
647 nonHoverText = _L("Download waiting...");
648 } else if (progress < 0) {
649 secondAction = _L("Retry");
650 nonHoverText = _L("Download failed");
651 states = StateColor::Checked;
652 } else if (progress >= 100) {
653 secondAction = _L("Play");
654 thirdAction = _L("Open Folder");
655 nonHoverText = _L("Download finished");
656 } else {
657 secondAction = _L("Cancel");
658 nonHoverText = wxString::Format(_L("Downloading %d%%..."), progress);
659 thirdAction = wxString::Format(L"%d%%...", progress);
660 }
661 }
662 if (m_file_sys->GetFileType() == PrinterFileSystem::F_MODEL) {
663 if (secondAction != _L("Play"))
664 thirdAction = secondAction;
665 secondAction = _L_CONTEXT("Print", "Verb");
666 }
667 // Draw buttons on hovered item
668 wxRect rect{pt.x, pt.y + m_content_rect.GetBottom() - m_buttons_background.GetHeight(), m_content_rect.GetWidth(), m_buttons_background.GetHeight()};
669 wxArrayString texts;
670 if (hit) {
671 texts.Add(_L("Delete"));
672 texts.Add(secondAction);
673 if (!thirdAction.IsEmpty())
674 texts.Add(thirdAction);
675 renderButtons(dc, texts, rect, m_hit_type == HIT_ACTION ? m_hit_item & 3 : -1, states);
676 } else if (!nonHoverText.IsEmpty()) {
677 texts.Add(nonHoverText);
678 renderButtons(dc, texts, rect, -1, states);
679 }
680 } else {
681 dc.SetTextForeground(*wxWHITE); // time text color
682 auto date = wxDateTime((time_t) file.time).Format(_L(TIME_FORMATS[m_file_sys->GetGroupMode()]));
683 dc.DrawText(date, pt + wxPoint{24, 16});
684 }
685 if (m_selecting && show_download_state_always)
686 dc.DrawBitmap(selected ? m_checked_icon.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
687}
#define L(s)
Definition ExtrusionEntity.cpp:25
void renderButtons(wxDC &dc, wxArrayString const &texts, wxRect const &rect, size_t hit, int states)
Definition ImageGrid.cpp:724
#define _L_CONTEXT(s, ctx)
Definition I18N.hpp:15

References _L, _L_CONTEXT, StateColor::Checked, PrinterFileSystem::F_MODEL, PrinterFileSystem::G_NONE, HIT_ACTION, L, m_buttons_background, m_checked_icon, m_content_rect, m_file_sys, m_hit_item, m_hit_type, m_selecting, m_show_download, m_title_mask, m_unchecked_icon, renderButtons(), and Slic3r::GUI::TIME_FORMATS.

Referenced by render(), and renderContent2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderContent2()

void Slic3r::GUI::ImageGrid::renderContent2 ( wxDC & dc,
wxPoint const & pt,
int index,
bool hit )
protected
690{
691 auto &file = m_file_sys->GetFile(index);
692 // Draw thumbnail & buttons
693 int h = m_content_rect.GetHeight() * 64 / 264;
694 m_content_rect.SetHeight(m_content_rect.GetHeight() - h);
695 auto br = dc.GetBrush();
696 auto pn = dc.GetPen();
697 dc.SetBrush(StateColor::darkModeColorFor(0xEEEEEE));
698 dc.SetPen(StateColor::darkModeColorFor(0xEEEEEE));
699 dc.DrawRectangle(pt, m_content_rect.GetSize()); // Fix translucent model thumbnail
700 renderContent1(dc, pt, index, hit);
701 m_content_rect.SetHeight(m_content_rect.GetHeight() + h);
702 // Draw info bar
703 dc.SetBrush(StateColor::darkModeColorFor(*wxWHITE));
704 dc.SetPen(StateColor::darkModeColorFor(*wxWHITE));
705 dc.DrawRectangle(pt.x, pt.y + m_content_rect.GetHeight() - h, m_content_rect.GetWidth(), h);
706 dc.SetBrush(br);
707 dc.SetPen(pn);
708 // Draw infos
709 dc.SetFont(Label::Head_16);
710 dc.SetTextForeground(StateColor::darkModeColorFor("#323A3D"));
711 auto em = em_unit(this);
712 wxRect rect{pt.x, pt.y + m_content_rect.GetHeight() - h, m_content_rect.GetWidth(), h / 2};
713 rect.Deflate(em, 0);
714 renderText2(dc, from_u8(file.name), rect);
715 rect.Offset(0, h / 2);
716 rect.SetWidth(rect.GetWidth() / 2 - em);
717 dc.SetFont(Label::Body_13);
718 dc.SetTextForeground(StateColor::darkModeColorFor("#6B6B6B"));
719 renderIconText(dc, m_model_time_icon, file.Metadata("Time", "0m"), rect);
720 rect.Offset(m_content_rect.GetWidth() / 2, 0);
721 renderIconText(dc, m_model_weight_icon, file.Metadata("Weight", "0g"), rect);
722}
static wxFont Body_13
Definition Label.hpp:54
void renderText2(wxDC &dc, wxString text, wxRect const &rect)
Definition ImageGrid.cpp:776
void renderIconText(wxDC &dc, ScalableBitmap const &icon, wxString text, wxRect const &rect)
Definition ImageGrid.cpp:786
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424

References Label::Body_13, StateColor::darkModeColorFor(), em_unit(), Slic3r::GUI::from_u8(), Label::Head_16, m_content_rect, m_file_sys, m_model_time_icon, m_model_weight_icon, renderContent1(), renderIconText(), and renderText2().

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderIconText()

void Slic3r::GUI::ImageGrid::renderIconText ( wxDC & dc,
ScalableBitmap const & icon,
wxString text,
wxRect const & rect )
protected
787{
788 dc.DrawBitmap(icon.bmp(), rect.x, rect.y + (rect.height - icon.GetBmpHeight()) / 2);
789 renderText2(dc, text, {rect.x + icon.GetBmpWidth() + 4, rect.y, rect.width - icon.GetBmpWidth() - 4, rect.height});
790}

References ScalableBitmap::bmp(), ScalableBitmap::GetBmpHeight(), ScalableBitmap::GetBmpWidth(), and renderText2().

Referenced by renderContent2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renderText()

void Slic3r::GUI::ImageGrid::renderText ( wxDC & dc,
wxString const & text,
wxRect const & rect,
int states )
protected
759{
760 dc.SetTextForeground(m_buttonTextColor.colorForStatesNoDark(states));
761 wxRect rc({0, 0}, dc.GetTextExtent(text));
762 rc = rc.CenterIn(rect);
763 float fontScale = float(rect.width - 8) / rc.width;
764 if (fontScale < 1) {
765 auto font = dc.GetFont();
766 dc.SetFont(font.Scaled(fontScale));
767 wxRect rc({0, 0}, dc.GetTextExtent(text));
768 rc = rc.CenterIn(rect);
769 dc.DrawText(text, rc.GetTopLeft());
770 dc.SetFont(font);
771 } else {
772 dc.DrawText(text, rc.GetTopLeft());
773 }
774}

References m_buttonTextColor.

Referenced by renderButtons().

Here is the caller graph for this function:

◆ renderText2()

void Slic3r::GUI::ImageGrid::renderText2 ( wxDC & dc,
wxString text,
wxRect const & rect )
protected
777{
778 wxRect rc({0, 0}, dc.GetTextExtent(text));
779 rc = rc.CenterIn(rect);
780 rc.SetLeft(rect.GetLeft());
781 if (rc.GetWidth() > rect.GetWidth())
782 text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, rect.GetWidth());
783 dc.DrawText(text, rc.GetTopLeft());
784}

Referenced by renderContent2(), and renderIconText().

Here is the caller graph for this function:

◆ Rescale()

void Slic3r::GUI::ImageGrid::Rescale ( )
154{
155 m_title_mask = wxBitmap();
156 m_border_mask = wxBitmap();
158 auto em = em_unit(this);
159 wxSize size1{384 * em / 10, 4 * em};
160 m_buttons_background = createAlphaBitmap(size1, *wxBLACK, 77, 77);
161 m_buttons_background_checked = createAlphaBitmap(size1, wxColor("#FF2002"), 77, 77);
162 //wxSize size2{128 * m_buttonBackgroundColor.count() * em_unit(this) / 10, 4 * em_unit(this)};
163 //m_button_background = createAlphaBitmap(size2, *wxBLACK, 77, 77);
164}
wxBitmap createAlphaBitmap(wxSize size, wxColour color, int alpha1, int alpha2)
Definition ImageGrid.cpp:449

References createAlphaBitmap(), em_unit(), m_border_mask, m_buttons_background, m_buttons_background_checked, m_title_mask, and UpdateFileSystem().

Referenced by ImageGrid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize()

void Slic3r::GUI::ImageGrid::resize ( wxSizeEvent & event)
protected
386{
387 UpdateLayout();
388}
void UpdateLayout()
Definition ImageGrid.cpp:217

References UpdateLayout().

Referenced by wxDEFINE_EVENT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Select()

void Slic3r::GUI::ImageGrid::Select ( size_t index)
protected
167{
168 if (m_selecting) {
169 m_file_sys->ToggleSelect(index);
170 Refresh();
171 return;
172 }
173 if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) {
174 return;
175 }
176 index = m_file_sys->EnterSubGroup(index);
177 // UpdateFileSystem(); call by changed event
178 m_row_offset = index / m_col_count * 4;
180 m_row_offset = m_row_count == 0 ? 0 : m_row_count - 1;
181 m_scroll_offset = 0;
182 Refresh();
183}

References PrinterFileSystem::G_NONE, m_col_count, m_file_sys, m_row_count, m_row_offset, m_scroll_offset, and m_selecting.

Referenced by mouseReleased().

Here is the caller graph for this function:

◆ SetFileSystem()

void Slic3r::GUI::ImageGrid::SetFileSystem ( boost::shared_ptr< PrinterFileSystem > file_sys)
78{
79 if (m_file_sys) {
80 m_file_sys->Unbind(EVT_MODE_CHANGED, &ImageGrid::changedEvent, this);
81 m_file_sys->Unbind(EVT_FILE_CHANGED, &ImageGrid::changedEvent, this);
82 m_file_sys->Unbind(EVT_THUMBNAIL, &ImageGrid::changedEvent, this);
83 m_file_sys->Unbind(EVT_DOWNLOAD, &ImageGrid::changedEvent, this);
84 }
85 m_file_sys = file_sys;
86 if (m_file_sys) {
87 m_file_sys->Bind(EVT_MODE_CHANGED, &ImageGrid::changedEvent, this);
88 m_file_sys->Bind(EVT_FILE_CHANGED, &ImageGrid::changedEvent, this);
89 m_file_sys->Bind(EVT_THUMBNAIL, &ImageGrid::changedEvent, this);
90 m_file_sys->Bind(EVT_DOWNLOAD, &ImageGrid::changedEvent, this);
91 }
92 m_row_count = 0;
93 m_col_count = 1;
94 m_row_offset = 0;
97}
void changedEvent(wxCommandEvent &evt)
Definition ImageGrid.cpp:406

References changedEvent(), m_col_count, m_file_sys, m_row_count, m_row_offset, m_scroll_offset, and UpdateFileSystem().

Here is the call graph for this function:

◆ SetFileType()

void Slic3r::GUI::ImageGrid::SetFileType ( int type,
std::string const & storage )
109{
110 if (!m_file_sys)
111 return;
112 m_file_sys->SetFileType((PrinterFileSystem::FileType) type, storage);
113}
FileType
Definition PrinterFileSystem.h:91

References m_file_sys.

◆ SetGroupMode()

void Slic3r::GUI::ImageGrid::SetGroupMode ( int mode)
116{
117 if (!m_file_sys)
118 return;
119 if (m_file_sys->GetCount() == 0) {
120 m_file_sys->SetGroupMode((PrinterFileSystem::GroupMode) mode);
121 return;
122 }
123 wxSize size = GetClientSize();
124 int index = (m_row_offset + 1 < m_row_count || m_row_count == 0)
126 : ((m_file_sys->GetCount() + m_col_count - 1) / m_col_count - (size.y + m_border_size.GetHeight() - 1) / m_cell_size.GetHeight()) * m_col_count;
127 auto & file = m_file_sys->GetFile(index);
128 m_file_sys->SetGroupMode((PrinterFileSystem::GroupMode) mode);
129 index = m_file_sys->GetIndexAtTime(file.time);
130 // UpdateFileSystem(); call by changed event
131 m_row_offset = index / m_col_count * 4;
133 m_row_offset = m_row_count == 0 ? 0 : m_row_count - 1;
134 m_scroll_offset = 0;
135}

References m_border_size, m_cell_size, m_col_count, m_file_sys, m_row_count, m_row_offset, and m_scroll_offset.

Referenced by mouseReleased().

Here is the caller graph for this function:

◆ SetSelecting()

void Slic3r::GUI::ImageGrid::SetSelecting ( bool selecting)
138{
139 m_selecting = selecting;
140 if (m_file_sys)
141 m_file_sys->SelectAll(false);
142 Refresh();
143}

References m_file_sys, and m_selecting.

◆ SetStatus()

void Slic3r::GUI::ImageGrid::SetStatus ( ScalableBitmap const & icon,
wxString const & msg )
100{
101 int code = m_file_sys ? m_file_sys->GetLastError() : 1;
102 m_status_icon = icon;
103 m_status_msg = wxString::Format(msg, code);
104 BOOST_LOG_TRIVIAL(info) << "ImageGrid::SetStatus: " << m_status_msg.ToUTF8().data();
105 Refresh();
106}

References m_file_sys, m_status_icon, and m_status_msg.

◆ ShowDownload()

void Slic3r::GUI::ImageGrid::ShowDownload ( bool show)
148{
149 m_show_download = show;
150 Refresh();
151}

References m_show_download.

◆ UpdateFileSystem()

void Slic3r::GUI::ImageGrid::UpdateFileSystem ( )
protected
195{
196 if (!m_file_sys) return;
197 if (m_file_sys->GetFileType() < PrinterFileSystem::F_MODEL) {
198 if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) {
199 m_cell_size.Set(396, 228);
200 m_border_size.Set(384, 216);
201 }
202 else {
203 m_cell_size.Set(496, 286);
204 m_border_size.Set(480, 270);
205 }
206 } else {
207 m_cell_size.Set(292, 288);
208 m_border_size.Set(266, 264);
209 }
210 m_cell_size = m_cell_size * em_unit(this) / 10;
211 m_border_size = m_border_size * em_unit(this) / 10;
212 m_content_rect = wxRect(SHADOW_WIDTH, SHADOW_WIDTH, m_border_size.GetWidth(), m_border_size.GetHeight());
214 UpdateLayout();
215}
static constexpr int SHADOW_WIDTH
Definition ImageGrid.cpp:51

References em_unit(), PrinterFileSystem::F_MODEL, PrinterFileSystem::G_NONE, m_border_size, m_cell_size, m_content_rect, m_file_sys, Slic3r::GUI::SHADOW_WIDTH, and UpdateLayout().

Referenced by changedEvent(), Rescale(), and SetFileSystem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateFocusRange()

void Slic3r::GUI::ImageGrid::UpdateFocusRange ( )
protected
254{
255 if (!m_file_sys) return;
256 wxSize size = GetClientSize();
257 wxPoint off;
258 int index = firstItem(size, off);
259 int count = m_col_count;
260 while (off.y < size.y) {
262 off.y += m_cell_size.y;
263 }
264 m_file_sys->SetFocusRange(index, count);
265}
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246

References count, firstItem(), m_cell_size, m_col_count, and m_file_sys.

Referenced by mouseWheelMoved(), and UpdateLayout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateLayout()

void Slic3r::GUI::ImageGrid::UpdateLayout ( )
protected
218{
219 if (!m_file_sys) return;
220 wxSize size = GetClientSize();
221 wxSize title_mask_size{0, 60 * em_unit(this) / 10};
222 if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) {
223 title_mask_size.y = 20 * em_unit(this) / 10;
224 size.y -= title_mask_size.y;
225 }
226 int cell_width = m_cell_size.GetWidth();
227 int cell_height = m_cell_size.GetHeight();
228 int ncol = (size.GetWidth() - cell_width + m_border_size.GetWidth()) / cell_width;
229 if (ncol <= 0) ncol = 1;
230 int total_height = (m_file_sys->GetCount() + ncol - 1) / ncol * cell_height + cell_height - m_border_size.GetHeight();
231 int nrow = (total_height - size.GetHeight() + cell_height / 4 - 1) / (cell_height / 4);
233 m_col_count = ncol;
234 m_row_count = nrow > 0 ? nrow + 1 : 0;
236 m_row_offset = m_row_count == 0 ? 0 : m_row_count - 1;
237 m_scroll_offset = 0;
238 // create mask
239 if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) {
240 title_mask_size.x = (m_col_count - 1) * m_cell_size.GetWidth() + m_border_size.GetWidth();
241 }
242 else {
243 title_mask_size.x = m_border_size.x;
244 }
245 if (!m_title_mask.IsOk() || m_title_mask.GetSize() != title_mask_size)
246 m_title_mask = createAlphaBitmap(title_mask_size, 0x6f6f6f, 255, 0);
247 if (!m_border_mask.IsOk() || m_border_mask.GetSize() != m_border_size)
250 Refresh();
251}
wxBitmap createShadowBorder(wxSize size, wxColour color, int radius, int shadow)
Definition ImageGrid.cpp:464

References createAlphaBitmap(), createShadowBorder(), StateColor::darkModeColorFor(), em_unit(), PrinterFileSystem::G_NONE, m_border_mask, m_border_size, m_cell_size, m_col_count, m_file_sys, m_row_count, m_row_offset, m_scroll_offset, m_title_mask, and UpdateFocusRange().

Referenced by resize(), and UpdateFileSystem().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_border_mask

wxBitmap Slic3r::GUI::ImageGrid::m_border_mask
private

Referenced by render(), Rescale(), and UpdateLayout().

◆ m_border_size

wxSize Slic3r::GUI::ImageGrid::m_border_size
private

◆ m_buttonBackgroundColor

StateColor Slic3r::GUI::ImageGrid::m_buttonBackgroundColor
private

Referenced by ImageGrid().

◆ m_buttons_background

wxBitmap Slic3r::GUI::ImageGrid::m_buttons_background
private

◆ m_buttons_background_checked

wxBitmap Slic3r::GUI::ImageGrid::m_buttons_background_checked
private

Referenced by renderButtons(), and Rescale().

◆ m_buttonTextColor

StateColor Slic3r::GUI::ImageGrid::m_buttonTextColor
private

Referenced by ImageGrid(), and renderText().

◆ m_cell_size

wxSize Slic3r::GUI::ImageGrid::m_cell_size
private

◆ m_checked_icon

ScalableBitmap Slic3r::GUI::ImageGrid::m_checked_icon
private

Referenced by ImageGrid(), and renderContent1().

◆ m_col_count

int Slic3r::GUI::ImageGrid::m_col_count = 1
private

◆ m_content_rect

wxRect Slic3r::GUI::ImageGrid::m_content_rect
private

◆ m_file_sys

◆ m_hit_item

size_t Slic3r::GUI::ImageGrid::m_hit_item = size_t(-1)
private

◆ m_hit_type

int Slic3r::GUI::ImageGrid::m_hit_type = HIT_NONE
private

◆ m_hovered

bool Slic3r::GUI::ImageGrid::m_hovered = false
private

◆ m_model_time_icon

ScalableBitmap Slic3r::GUI::ImageGrid::m_model_time_icon
private

Referenced by ImageGrid(), and renderContent2().

◆ m_model_weight_icon

ScalableBitmap Slic3r::GUI::ImageGrid::m_model_weight_icon
private

Referenced by ImageGrid(), and renderContent2().

◆ m_pressed

bool Slic3r::GUI::ImageGrid::m_pressed = false
private

◆ m_row_count

int Slic3r::GUI::ImageGrid::m_row_count = 0
private

◆ m_row_offset

int Slic3r::GUI::ImageGrid::m_row_offset = 0
private

◆ m_scroll_offset

int Slic3r::GUI::ImageGrid::m_scroll_offset = 0
private

◆ m_selecting

bool Slic3r::GUI::ImageGrid::m_selecting = false
private

◆ m_show_download

bool Slic3r::GUI::ImageGrid::m_show_download = false
private

◆ m_status_icon

ScalableBitmap Slic3r::GUI::ImageGrid::m_status_icon
private

Referenced by render(), and SetStatus().

◆ m_status_msg

wxString Slic3r::GUI::ImageGrid::m_status_msg
private

Referenced by render(), and SetStatus().

◆ m_timer

wxTimer Slic3r::GUI::ImageGrid::m_timer
private

Referenced by ImageGrid(), mouseWheelMoved(), and render().

◆ m_title_mask

wxBitmap Slic3r::GUI::ImageGrid::m_title_mask
private

◆ m_unchecked_icon

ScalableBitmap Slic3r::GUI::ImageGrid::m_unchecked_icon
private

Referenced by ImageGrid(), and renderContent1().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/ImageGrid.h
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/ImageGrid.cpp