17 int source_bitmap_width_px,
19 float display_scale) {
20 if (source_bitmap_width_px <= 0 || max_tile_count <= 0 ||
24 if (mouse_x < 0.0f || mouse_y < 0.0f) {
28 const int tile_x =
static_cast<int>(mouse_x / (8.0f * display_scale));
29 const int tile_y =
static_cast<int>(mouse_y / (8.0f * display_scale));
30 if (tile_x < 0 || tile_y < 0) {
34 const int tiles_per_row = source_bitmap_width_px / 8;
35 if (tiles_per_row <= 0) {
39 const int tile8_id = tile_x + (tile_y * tiles_per_row);
40 if (tile8_id < 0 || tile8_id >= max_tile_count) {
47 int source_bitmap_width_px,
48 float min_scale = 1.0f,
49 float max_scale = 4.0f) {
50 if (source_bitmap_width_px <= 0 || available_width_px <= 0.0f ||
51 min_scale <= 0.0f || max_scale < min_scale) {
55 constexpr float kAbsoluteMinimumReadableScale = 0.35f;
57 available_width_px, source_bitmap_width_px, 1,
59 std::min(min_scale, kAbsoluteMinimumReadableScale), max_scale)
64 int source_bitmap_height_px,
66 float preferred_height_px = 0.0f,
67 float min_height_px = 220.0f,
68 float max_height_px = 520.0f) {
69 if (min_height_px <= 0.0f) {
72 max_height_px = std::max(min_height_px, max_height_px);
74 constexpr float kVerticalChromeAllowance = 18.0f;
75 const float sheet_height =
76 source_bitmap_height_px > 0 && display_scale > 0.0f
77 ? (
static_cast<float>(source_bitmap_height_px) * display_scale) +
78 kVerticalChromeAllowance
82 preferred_height_px > 0.0f ? preferred_height_px : sheet_height;
83 target_height = std::clamp(target_height, min_height_px, max_height_px);
85 if (available_height_px <= 0.0f) {
89 const float clamped_max_height =
90 std::min(max_height_px, std::max(1.0f, available_height_px));
91 const float clamped_min_height = std::min(min_height_px, clamped_max_height);
92 return std::clamp(target_height, clamped_min_height, clamped_max_height);
float ComputeTile8SourcePanelHeight(float available_height_px, int source_bitmap_height_px, float display_scale, float preferred_height_px=0.0f, float min_height_px=220.0f, float max_height_px=520.0f)
AdaptiveSheetLayout ResolveAdaptiveSheetLayout(float available_width, int source_width, int source_height, AdaptiveSheetScaleMode mode=AdaptiveSheetScaleMode::kFit, float min_scale=0.35f, float max_scale=4.0f, float horizontal_chrome=24.0f)