[Summary] Changed Yes-No and Ok dialogs on Igor's request. Code improvement.

This commit is contained in:
Nikolay 2014-11-12 19:26:44 +02:00
parent 691e32958f
commit 3cb61cacf3
4 changed files with 24 additions and 16 deletions

View file

@ -30,7 +30,7 @@ using namespace Pango;
namespace { namespace {
const size_t button_left_padding = 10; const size_t button_left_padding = 10;
const size_t button_bottom_padding = 10; const size_t button_bottom_padding = 15;
const size_t font_size = 12; const size_t font_size = 12;
const size_t label_top_padding = 10; const size_t label_top_padding = 10;
@ -60,7 +60,7 @@ namespace {
if ( current_lines_number > max_lines_number ) if ( current_lines_number > max_lines_number )
{ {
return current_window_height + (current_lines_number - max_lines_number) * font_size; return current_window_height + (current_lines_number - max_lines_number + 1) * font_size;
} else } else
return current_window_height; return current_window_height;
} }
@ -78,6 +78,7 @@ OkDialog::OkDialog (std::string window_title, std::string info_lines)
{ {
set_modal (true); set_modal (true);
set_resizable (false); set_resizable (false);
this->set_keep_above (true);
_info_label.set_text( info_lines ); _info_label.set_text( info_lines );
this->set_title(window_title); this->set_title(window_title);
@ -106,6 +107,8 @@ OkDialog::OkDialog (std::string window_title, std::string info_lines)
button_width = _ok_button.get_allocation().get_width(); button_width = _ok_button.get_allocation().get_width();
button_height = _ok_button.get_allocation().get_height(); button_height = _ok_button.get_allocation().get_height();
_info_label.set_size_request( layout_width, new_window_height - button_height - button_bottom_padding);
_layout.put( _ok_button, layout_width - button_width - button_left_padding, new_window_height - button_height - button_bottom_padding); _layout.put( _ok_button, layout_width - button_width - button_left_padding, new_window_height - button_height - button_bottom_padding);
} }

View file

@ -17,17 +17,18 @@
height="120" height="120"
bgnormal="#EDECE8"> bgnormal="#EDECE8">
<VBox x="0" <VBox x="0"
y="10" y="0"
width="350"> width="350">
<Label id="info_label" <Label id="info_label"
style="generic_control" style="generic_control"
vertalignment="center" vertalignment="center"
text=""/> text=""
height="90"/>
</VBox> </VBox>
<Button id="ok_button" <Button id="ok_button"
style="generic_control" style="generic_control"
text="OK" text="Ok"
fgnormal="#6D6E72" fgnormal="#6D6E72"
bgnormal="#CACAC5" bgnormal="#CACAC5"
fgactive="#EDECE8" fgactive="#EDECE8"
@ -37,7 +38,7 @@
width="80" width="80"
height="22" height="22"
x="260" x="260"
y="93"/> y="88"/>
</Layout> </Layout>

View file

@ -17,16 +17,17 @@
height="120" height="120"
bgnormal="#EDECE8"> bgnormal="#EDECE8">
<VBox x="0" <VBox x="0"
y="10" y="0"
width="350"> width="350">
<Label id="info_label" <Label id="info_label"
style="generic_control" height="90"
text=""/> style="generic_control"
text=""/>
</VBox> </VBox>
<Button id="yes_button" <Button id="yes_button"
style="generic_control" style="generic_control"
text="YES" text="Yes"
fgnormal="#6D6E72" fgnormal="#6D6E72"
bgnormal="#CACAC5" bgnormal="#CACAC5"
fgactive="#EDECE8" fgactive="#EDECE8"
@ -36,11 +37,11 @@
width="80" width="80"
height="22" height="22"
x="170" x="170"
y="93"/> y="88"/>
<Button id="no_button" <Button id="no_button"
style="generic_control" style="generic_control"
text="NO" text="No"
fgnormal="#6D6E72" fgnormal="#6D6E72"
bgnormal="#CACAC5" bgnormal="#CACAC5"
fgactive="#EDECE8" fgactive="#EDECE8"
@ -50,7 +51,7 @@
width="80" width="80"
height="22" height="22"
x="260" x="260"
y="93"/> y="88"/>
</Layout> </Layout>

View file

@ -29,7 +29,7 @@ using namespace Pango;
namespace { namespace {
const size_t button_left_padding = 10; const size_t button_left_padding = 10;
const size_t button_bottom_padding = 10; const size_t button_bottom_padding = 15;
const size_t font_size = 12; const size_t font_size = 12;
const size_t label_top_padding = 10; const size_t label_top_padding = 10;
const size_t between_button_padding = 5; const size_t between_button_padding = 5;
@ -60,7 +60,7 @@ namespace {
if ( current_lines_number > max_lines_number ) if ( current_lines_number > max_lines_number )
{ {
return current_window_height + (current_lines_number - max_lines_number) * font_size; return current_window_height + (current_lines_number - max_lines_number + 1) * font_size;
} else } else
return current_window_height; return current_window_height;
} }
@ -79,6 +79,7 @@ YesNoDialog::YesNoDialog (std::string window_title, std::string info_lines)
{ {
set_modal (true); set_modal (true);
set_resizable (false); set_resizable (false);
this->set_keep_above (true);
_info_label.set_text( info_lines ); _info_label.set_text( info_lines );
this->set_title(window_title); this->set_title(window_title);
@ -106,6 +107,8 @@ YesNoDialog::YesNoDialog (std::string window_title, std::string info_lines)
guint button_width, button_height; guint button_width, button_height;
button_width = _yes_button.get_allocation().get_width(); button_width = _yes_button.get_allocation().get_width();
button_height = _yes_button.get_allocation().get_height(); button_height = _yes_button.get_allocation().get_height();
_info_label.set_size_request( layout_width, new_window_height - button_height - button_bottom_padding);
_layout.put( _no_button, layout_width - button_width - button_left_padding, new_window_height - button_height - button_bottom_padding); _layout.put( _no_button, layout_width - button_width - button_left_padding, new_window_height - button_height - button_bottom_padding);
_layout.put( _yes_button, layout_width - 2*button_width - button_left_padding - between_button_padding, new_window_height - button_height - button_bottom_padding); _layout.put( _yes_button, layout_width - 2*button_width - button_left_padding - between_button_padding, new_window_height - button_height - button_bottom_padding);