tpoint tcontrol::calculate_best_size() const { assert(config_); if(label_.empty()) { DBG_GUI_L << LOG_HEADER << " empty label return default.\n"; return get_config_default_size(); } const tpoint minimum = get_config_default_size(); tpoint maximum = get_config_maximum_size(); if (!maximum.x) { maximum.x = settings::screen_width; } if (!maximum.y) { maximum.y = settings::screen_height; } maximum.x -= config_->text_extra_width; if (text_maximum_width_ && maximum.x > text_maximum_width_) { maximum.x = text_maximum_width_; } /** * @todo The value send should subtract the border size * and read it after calculation to get the proper result. */ tpoint result = get_best_text_size(minimum, maximum); DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' result " << result << ".\n"; return result; }
tpoint timage::calculate_best_size() const { surface image(image::get_image(image::locator(label()))); if(!image) { DBG_GUI_L << LOG_HEADER << " empty image return default.\n"; return get_config_default_size(); } const tpoint minimum = get_config_default_size(); const tpoint maximum = get_config_maximum_size(); tpoint result = tpoint(image->w, image->h); if(minimum.x > 0 && result.x < minimum.x) { DBG_GUI_L << LOG_HEADER << " increase width to minimum.\n"; result.x = minimum.x; } else if(maximum.x > 0 && result.x > maximum.x) { DBG_GUI_L << LOG_HEADER << " decrease width to maximum.\n"; result.x = maximum.x; } if(minimum.y > 0 && result.y < minimum.y) { DBG_GUI_L << LOG_HEADER << " increase height to minimum.\n"; result.y = minimum.y; } else if(maximum.y > 0 && result.y > maximum.y) { DBG_GUI_L << LOG_HEADER << " decrease height to maximum.\n"; result.y = maximum.y; } DBG_GUI_L << LOG_HEADER << " result " << result << ".\n"; return result; }
tpoint tcontrol::calculate_best_size() const { assert(config_); if(label_.empty()) { DBG_GUI_L << LOG_HEADER << " empty label return default.\n"; return get_config_default_size(); } const tpoint minimum = get_config_default_size(); const tpoint maximum = get_config_maximum_size(); /** * @todo The value send should subtract the border size * and read it after calculation to get the proper result. */ tpoint result = get_best_text_size(minimum, maximum); DBG_GUI_L << LOG_HEADER << " label '" << debug_truncate(label_) << "' result " << result << ".\n"; return result; }