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

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GUI_Utils.hpp>

Public Member Functions

const wxRect & get_rect () const
bool get_maximized () const
void sanitize_for_display (const wxRect &screen_rect)
void center_for_display (const wxRect &screen_rect)
std::string serialize () const

Static Public Member Functions

static WindowMetrics from_window (wxTopLevelWindow *window)
static boost::optional< WindowMetrics > deserialize (const std::string &str)

Private Member Functions

 WindowMetrics ()

Private Attributes

wxRect rect
bool maximized

Detailed Description

Constructor & Destructor Documentation

◆ WindowMetrics()

Slic3r::GUI::WindowMetrics::WindowMetrics ( )
inlineprivate
437: maximized(false) {}
bool maximized
Definition GUI_Utils.hpp:435

References maximized.

Referenced by deserialize(), and from_window().

Here is the caller graph for this function:

Member Function Documentation

◆ center_for_display()

void Slic3r::GUI::WindowMetrics::center_for_display ( const wxRect & screen_rect)
447{
448 rect.x = std::max(0, (screen_rect.GetWidth() - rect.GetWidth()) / 2);
449 rect.y = std::max(0, (screen_rect.GetHeight() - rect.GetHeight()) / 2);
450}
wxRect rect
Definition GUI_Utils.hpp:434

References rect.

◆ deserialize()

boost::optional< WindowMetrics > Slic3r::GUI::WindowMetrics::deserialize ( const std::string & str)
static
408{
409 std::vector<std::string> metrics_str;
410 metrics_str.reserve(5);
411
412 if (!unescape_strings_cstyle(str, metrics_str) || metrics_str.size() != 5) {
413 return boost::none;
414 }
415
416 int metrics[5];
417 try {
418 for (size_t i = 0; i < 5; i++) {
419 metrics[i] = boost::lexical_cast<int>(metrics_str[i]);
420 }
421 } catch(const boost::bad_lexical_cast &) {
422 return boost::none;
423 }
424
425 if ((metrics[4] & ~1) != 0) { // Checks if the maximized flag is 1 or 0
426 metrics[4] = 0;
427 }
428
429 WindowMetrics res;
430 res.rect = wxRect(metrics[0], metrics[1], metrics[2], metrics[3]);
431 res.maximized = metrics[4] != 0;
432
433 return res;
434}
WindowMetrics()
Definition GUI_Utils.hpp:437
bool unescape_strings_cstyle(const std::string &str, std::vector< std::string > &out)
Definition Config.cpp:173

References WindowMetrics(), maximized, rect, and Slic3r::unescape_strings_cstyle().

Referenced by Slic3r::GUI::GUI_App::on_init_inner(), and Slic3r::GUI::GUI_App::window_pos_restore().

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

◆ from_window()

WindowMetrics Slic3r::GUI::WindowMetrics::from_window ( wxTopLevelWindow * window)
static
400{
401 WindowMetrics res;
402 res.rect = window->GetScreenRect();
403 res.maximized = window->IsMaximized();
404 return res;
405}

References WindowMetrics(), maximized, and rect.

Referenced by Slic3r::GUI::GUI_App::window_pos_center(), Slic3r::GUI::GUI_App::window_pos_sanitize(), and Slic3r::GUI::GUI_App::window_pos_save().

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

◆ get_maximized()

bool Slic3r::GUI::WindowMetrics::get_maximized ( ) const
inline
443{ return maximized; }

References maximized.

◆ get_rect()

const wxRect & Slic3r::GUI::WindowMetrics::get_rect ( ) const
inline
442{ return rect; }

References rect.

◆ sanitize_for_display()

void Slic3r::GUI::WindowMetrics::sanitize_for_display ( const wxRect & screen_rect)
437{
438 rect = rect.Intersect(screen_rect);
439
440 // Prevent the window from going too far towards the right and/or bottom edge
441 // It's hardcoded here that the threshold is 80% of the screen size
442 rect.x = std::min(rect.x, screen_rect.x + 4*screen_rect.width/5);
443 rect.y = std::min(rect.y, screen_rect.y + 4*screen_rect.height/5);
444}

References rect.

◆ serialize()

std::string Slic3r::GUI::WindowMetrics::serialize ( ) const
453{
454 return (boost::format("%1%; %2%; %3%; %4%; %5%")
455 % rect.x
456 % rect.y
457 % rect.width
458 % rect.height
459 % static_cast<int>(maximized)
460 ).str();
461}

References maximized, and rect.

Referenced by Slic3r::GUI::operator<<(), and Slic3r::GUI::GUI_App::window_pos_save().

Here is the caller graph for this function:

Member Data Documentation

◆ maximized

bool Slic3r::GUI::WindowMetrics::maximized
private

◆ rect

wxRect Slic3r::GUI::WindowMetrics::rect
private

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