[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 {
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 label_top_padding = 10;
@ -60,7 +60,7 @@ namespace {
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
return current_window_height;
}
@ -78,6 +78,7 @@ OkDialog::OkDialog (std::string window_title, std::string info_lines)
{
set_modal (true);
set_resizable (false);
this->set_keep_above (true);
_info_label.set_text( info_lines );
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_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);
}

View file

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

View file

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

View file

@ -29,7 +29,7 @@ using namespace Pango;
namespace {
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 label_top_padding = 10;
const size_t between_button_padding = 5;
@ -60,7 +60,7 @@ namespace {
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
return current_window_height;
}
@ -79,6 +79,7 @@ YesNoDialog::YesNoDialog (std::string window_title, std::string info_lines)
{
set_modal (true);
set_resizable (false);
this->set_keep_above (true);
_info_label.set_text( info_lines );
this->set_title(window_title);
@ -107,6 +108,8 @@ YesNoDialog::YesNoDialog (std::string window_title, std::string info_lines)
button_width = _yes_button.get_allocation().get_width();
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( _yes_button, layout_width - 2*button_width - button_left_padding - between_button_padding, new_window_height - button_height - button_bottom_padding);
}