to fit dialogs on screen, don't rein in the menu height...

...before attempting y-shift
This commit is contained in:
Patrick Parker 2007-06-22 22:56:29 +00:00
parent b439637ac0
commit c136f9af2e
3 changed files with 28 additions and 18 deletions

View File

@ -518,16 +518,6 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc)
int total_height = text_and_image_height + padding_height + menu_->height() +
text_widget_height + check_button_height;
const int max_height = scr->h - yloc - get_frame().vertical_padding();
if(total_height > max_height) {
//try to reign in the menu height a little bit
const int menu_height = menu_->height();
if(menu_height > 0) {
dim.menu_height = maximum<int>(0, max_height - total_height + menu_height);
total_height -= menu_height - dim.menu_height;
}
}
dim.interior.w = maximum<int>(total_width,above_left_preview_pane_width + above_right_preview_pane_width);
dim.interior.h = maximum<int>(total_height,int(preview_pane_height));
dim.interior.x = maximum<int>(0,dim.x >= 0 ? dim.x : scr->w/2 - (dim.interior.w + left_preview_pane_width + right_preview_pane_width)/2);
@ -549,8 +539,9 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc)
}
}
if(dim.y + dim.interior.h > scr->h) {
dim.y = scr->h - dim.interior.h;
const int frame_bottom_pad = get_frame().bottom_padding();
if(dim.y + dim.interior.h + frame_bottom_pad > scr->h) {
dim.y = scr->h - dim.interior.h - frame_bottom_pad;
if(dim.y < dim.interior.y) {
dim.interior.y = dim.y;
}
@ -559,6 +550,16 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc)
dim.interior.w += left_preview_pane_width + right_preview_pane_width;
dim.interior.h += above_preview_pane_height;
const int max_height = scr->h - dim.interior.y - frame_bottom_pad;
if(dim.interior.h > max_height) {
//try to rein in the menu height a little bit
const int menu_height = menu_->height();
if(menu_height > 0) {
dim.menu_height = maximum<int>(0, max_height - dim.interior.h + menu_height);
dim.interior.h -= menu_height - dim.menu_height;
}
}
dim.message.x = dim.x + image_width + left_padding + image_h_padding;
dim.message.y = dim.y + top_padding + caption_height;

View File

@ -116,7 +116,18 @@ dialog_frame::dimension_measurements dialog_frame::layout(SDL_Rect const& rect)
return layout(rect.x, rect.y, rect.w, rect.h);
}
int dialog_frame::vertical_padding() const {
/*int dialog_frame::top_padding() const {
int padding = 0;
if(have_border_) {
padding += top_->h;
}
if(!title_.empty()) {
padding += font::get_max_height(font::SIZE_LARGE) + 2*dialog_frame::title_border_h;
}
return padding;
}*/
int dialog_frame::bottom_padding() const {
int padding = 0;
if(buttons_ != NULL) {
for(std::vector<button*>::const_iterator b = buttons_->begin(); b != buttons_->end(); ++b) {
@ -124,10 +135,7 @@ int dialog_frame::vertical_padding() const {
}
}
if(have_border_) {
padding += bot_->h + top_->h;
}
if(!title_.empty()) {
padding += font::get_max_height(font::SIZE_LARGE) + 2*dialog_frame::title_border_h;
padding += bot_->h;
}
return padding;
}

View File

@ -59,7 +59,8 @@ public:
//Static members
static const int title_border_w, title_border_h;
int vertical_padding() const;
// int top_padding() const;
int bottom_padding() const;
struct dimension_measurements {
dimension_measurements();