calculate the size and position of the controls taking into account the per-monitor DPI expressed as a scaling factor on sizes at 96 DPI */
| 390 | /* calculate the size and position of the controls taking into account |
| 391 | the per-monitor DPI expressed as a scaling factor on sizes at 96 DPI */ |
| 392 | void |
| 393 | calculate_player_selector_layout(plsel_data_t * data) |
| 394 | { |
| 395 | MonitorInfo monitorInfo; |
| 396 | win10_monitor_info(data->dialog, &monitorInfo); |
| 397 | |
| 398 | double scale = monitorInfo.scale; |
| 399 | |
| 400 | /* Note these hard coded sizes are in 96DPI pixels and must be |
| 401 | scaled by the per-monitor DPI scaling factor */ |
| 402 | int list_width = (int) (120 * scale); |
| 403 | int group_border = (int) (16 * scale); |
| 404 | int client_border = (int) (16 * scale); |
| 405 | int group_spacing = (int) (16 * scale); |
| 406 | int button_width = (int) (80 * scale); |
| 407 | int button_height = (int) (28 * scale); |
| 408 | |
| 409 | /* set control sizes */ |
| 410 | control_t * name_box = &data->controls[psc_name_box]; |
| 411 | name_box->size.cx = (int) (280 * scale); |
| 412 | name_box->size.cy = (int) (24 * scale); |
| 413 | |
| 414 | control_t * role_list = &data->controls[psc_role_list]; |
| 415 | /* NOTE: we don't scale the list view reported height as it appears these |
| 416 | values are the actual size the control will be drawn at using the |
| 417 | existing DPI value */ |
| 418 | role_list->size.cy = list_view_height(role_list->hWnd, data->role_count); |
| 419 | role_list->size.cx = list_width; |
| 420 | |
| 421 | control_t * race_list = &data->controls[psc_race_list]; |
| 422 | race_list->size.cy = list_view_height(race_list->hWnd, data->race_count); |
| 423 | race_list->size.cx = list_width; |
| 424 | |
| 425 | for(int i = psc_lawful_button; i <= psc_quit_button; i++) { |
| 426 | data->controls[i].size.cx = button_width; |
| 427 | data->controls[i].size.cy = button_height; |
| 428 | } |
| 429 | |
| 430 | for(int i = 0; i < 3; i++) { |
| 431 | control_t * group_control = &data->controls[psc_name_group + i]; |
| 432 | control_t * inner_control = &data->controls[psc_name_box + i]; |
| 433 | group_control->size.cx = inner_control->size.cx + (2 * group_border); |
| 434 | group_control->size.cy = inner_control->size.cy + (2 * group_border); |
| 435 | } |
| 436 | |
| 437 | control_t * alignment_group = &data->controls[psc_alignment_group]; |
| 438 | alignment_group->size.cx = button_width + (2 * group_border); |
| 439 | alignment_group->size.cy = (3 * button_height) + (2 * group_border); |
| 440 | |
| 441 | control_t * gender_group = &data->controls[psc_gender_group]; |
| 442 | gender_group->size.cx = button_width + (2 * group_border); |
| 443 | gender_group->size.cy = (2 * button_height) + (2 * group_border); |
| 444 | |
| 445 | /* set control positions */ |
| 446 | control_t * name_group = &data->controls[psc_name_group]; |
| 447 | name_group->pos.x = client_border; |
| 448 | name_group->pos.y = client_border; |
| 449 |
no test coverage detected