Better layout of Preferences > Appearance

The Appearance frame no longer causes the minimum Preferences window width to be large.
This commit is contained in:
Morgan Hardwood
2018-11-21 02:48:46 +01:00
parent 8b4027d75d
commit ead059ee8c
3 changed files with 82 additions and 82 deletions

View File

@@ -992,78 +992,74 @@ Gtk::Widget* Preferences::getGeneralPanel ()
flang->add (*langGrid);
vbGeneral->attach_next_to (*flang, *fworklflow, Gtk::POS_BOTTOM, 2, 1);
// ---------------------------------------------
// Appearance ---------------------------------------------
Gtk::Frame* ftheme = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_APPEARANCE")) );
setExpandAlignProperties (ftheme, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_START);
Gtk::Grid* themeGrid = Gtk::manage ( new Gtk::Grid() );
themeGrid->set_column_spacing (4);
themeGrid->set_row_spacing (4);
setExpandAlignProperties (themeGrid, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL);
Gtk::Frame* appearanceFrame = Gtk::manage(new Gtk::Frame(M("PREFERENCES_APPEARANCE")));
Gtk::Label* themelab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_APPEARANCE_THEME") + ":") );
setExpandAlignProperties (themelab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE);
theme = Gtk::manage ( new Gtk::ComboBoxText () );
setExpandAlignProperties (theme, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE);
Gtk::Grid* appearanceGrid = Gtk::manage(new Gtk::Grid());
appearanceGrid->get_style_context()->add_class("grid-spacing");
setExpandAlignProperties(appearanceGrid, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
theme->set_active (0);
parseThemeDir (Glib::build_filename (argv0, "themes"));
Gtk::Label* themeLbl = Gtk::manage(new Gtk::Label(M("PREFERENCES_APPEARANCE_THEME") + ":"));
setExpandAlignProperties(themeLbl, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
themeCBT = Gtk::manage(new Gtk::ComboBoxText());
themeCBT->set_active(0);
parseThemeDir(Glib::build_filename(argv0, "themes"));
for (size_t i = 0; i < themeFNames.size(); i++) {
theme->append (themeFNames.at (i).shortFName);
themeCBT->append(themeFNames.at(i).shortFName);
}
themeGrid->attach_next_to (*themelab, Gtk::POS_LEFT, 1, 1);
themeGrid->attach_next_to (*theme, *themelab, Gtk::POS_RIGHT, 1, 1);
Gtk::Label* fontlab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_APPEARANCE_MAINFONT")) );
setExpandAlignProperties (fontlab, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE);
fontButton = Gtk::manage ( new Gtk::FontButton ());
setExpandAlignProperties (fontButton, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE);
fontButton->set_use_size (true);
Gtk::Label* mainFontLbl = Gtk::manage(new Gtk::Label(M("PREFERENCES_APPEARANCE_MAINFONT")));
setExpandAlignProperties(mainFontLbl, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
mainFontFB = Gtk::manage(new Gtk::FontButton());
mainFontFB->set_use_size(true);
if (options.fontFamily == "default") {
fontButton->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize));
mainFontFB->set_font_name(Glib::ustring::compose("%1 %2", initialFontFamily, initialFontSize));
} else {
fontButton->set_font_name (Glib::ustring::compose ("%1 %2", options.fontFamily, options.fontSize));
mainFontFB->set_font_name(Glib::ustring::compose("%1 %2", options.fontFamily, options.fontSize));
}
themeGrid->attach_next_to (*fontlab, *theme, Gtk::POS_RIGHT, 1, 1);
themeGrid->attach_next_to (*fontButton, *fontlab, Gtk::POS_RIGHT, 1, 1);
Gtk::Label* cpfontlab = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_APPEARANCE_COLORPICKERFONT") + ":") );
setExpandAlignProperties (cpfontlab, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE);
colorPickerFontButton = Gtk::manage ( new Gtk::FontButton ());
setExpandAlignProperties (fontButton, false, false, Gtk::ALIGN_FILL, Gtk::ALIGN_BASELINE);
colorPickerFontButton->set_use_size (true);
Gtk::Label* colorPickerFontLbl = Gtk::manage(new Gtk::Label(M("PREFERENCES_APPEARANCE_COLORPICKERFONT") + ":"));
setExpandAlignProperties(colorPickerFontLbl, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
colorPickerFontFB = Gtk::manage(new Gtk::FontButton());
colorPickerFontFB->set_use_size(true);
if (options.fontFamily == "default") {
colorPickerFontButton->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize));
colorPickerFontFB->set_font_name(Glib::ustring::compose("%1 %2", initialFontFamily, initialFontSize));
} else {
colorPickerFontButton->set_font_name (Glib::ustring::compose ("%1 %2", options.CPFontFamily, options.CPFontSize));
colorPickerFontFB->set_font_name(Glib::ustring::compose("%1 %2", options.CPFontFamily, options.CPFontSize));
}
themeGrid->attach_next_to (*cpfontlab, *fontButton, Gtk::POS_RIGHT, 1, 1);
themeGrid->attach_next_to (*colorPickerFontButton, *cpfontlab, Gtk::POS_RIGHT, 1, 1);
Gtk::Label* cropMaskColorLbl = Gtk::manage(new Gtk::Label(M("PREFERENCES_APPEARANCE_CROPMASKCOLOR") + ":"));
setExpandAlignProperties(cropMaskColorLbl, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
Gtk::Label* cutOverlayLabel = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_APPEARANCE_CROPMASKCOLOR") + ":") );
setExpandAlignProperties (cutOverlayLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE);
butCropCol = Gtk::manage ( new Gtk::ColorButton() );
setExpandAlignProperties (butCropCol, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
butCropCol->set_use_alpha (true);
themeGrid->attach_next_to (*cutOverlayLabel, *themelab, Gtk::POS_BOTTOM, 1, 1);
themeGrid->attach_next_to (*butCropCol, *cutOverlayLabel, Gtk::POS_RIGHT, 1, 1);
cropMaskColorCB = Gtk::manage(new Gtk::ColorButton());
cropMaskColorCB->set_use_alpha(true);
Gtk::Label* navGuideLabel = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_APPEARANCE_NAVGUIDECOLOR") + ":") );
setExpandAlignProperties (navGuideLabel, false, false, Gtk::ALIGN_START, Gtk::ALIGN_BASELINE);
butNavGuideCol = Gtk::manage ( new Gtk::ColorButton() );
setExpandAlignProperties (butNavGuideCol, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
butNavGuideCol->set_use_alpha (true);
themeGrid->attach_next_to (*navGuideLabel, *butCropCol, Gtk::POS_RIGHT, 2, 1);
themeGrid->attach_next_to (*butNavGuideCol, *navGuideLabel, Gtk::POS_RIGHT, 1, 1);
Gtk::Label* navGuideColorLbl = Gtk::manage(new Gtk::Label(M("PREFERENCES_APPEARANCE_NAVGUIDECOLOR") + ":"));
setExpandAlignProperties(navGuideColorLbl, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
ftheme->add (*themeGrid);
vbGeneral->attach_next_to (*ftheme, *flang, Gtk::POS_BOTTOM, 2, 1);
navGuideColorCB = Gtk::manage(new Gtk::ColorButton());
navGuideColorCB->set_use_alpha(true);
Gtk::VSeparator *vSep = Gtk::manage(new Gtk::VSeparator());
appearanceGrid->attach(*themeLbl, 0, 0, 1, 1);
appearanceGrid->attach(*themeCBT, 1, 0, 1, 1);
appearanceGrid->attach(*vSep, 2, 0, 1, 3);
appearanceGrid->attach(*mainFontLbl, 0, 1, 1, 1);
appearanceGrid->attach(*mainFontFB, 1, 1, 1, 1);
appearanceGrid->attach(*colorPickerFontLbl, 3, 1, 1, 1);
appearanceGrid->attach(*colorPickerFontFB, 4, 1, 1, 1);
appearanceGrid->attach(*cropMaskColorLbl, 0, 2, 1, 1);
appearanceGrid->attach(*cropMaskColorCB, 1, 2, 1, 1);
appearanceGrid->attach(*navGuideColorLbl, 3, 2, 1, 1);
appearanceGrid->attach(*navGuideColorCB, 4, 2, 1, 1);
appearanceFrame->add(*appearanceGrid);
vbGeneral->attach_next_to(*appearanceFrame, *flang, Gtk::POS_BOTTOM, 2, 1);
// ---------------------------------------------
@@ -1096,7 +1092,7 @@ Gtk::Widget* Preferences::getGeneralPanel ()
clipGrid->attach_next_to (*shThresh, *shl, Gtk::POS_RIGHT, 1, 1);
fclip->add (*clipGrid);
vbGeneral->attach_next_to (*fclip, *ftheme, Gtk::POS_BOTTOM, 1, 1);
vbGeneral->attach_next_to (*fclip, *appearanceFrame, Gtk::POS_BOTTOM, 1, 1);
// ---------------------------------------------
@@ -1190,9 +1186,9 @@ Gtk::Widget* Preferences::getGeneralPanel ()
vbGeneral->attach_next_to (*fdg, *fclip, Gtk::POS_BOTTOM, 2, 1);
langAutoDetectConn = ckbLangAutoDetect->signal_toggled().connect (sigc::mem_fun (*this, &Preferences::langAutoDetectToggled));
tconn = theme->signal_changed().connect ( sigc::mem_fun (*this, &Preferences::themeChanged) );
fconn = fontButton->signal_font_set().connect ( sigc::mem_fun (*this, &Preferences::fontChanged) );
cpfconn = colorPickerFontButton->signal_font_set().connect ( sigc::mem_fun (*this, &Preferences::cpFontChanged) );
tconn = themeCBT->signal_changed().connect ( sigc::mem_fun (*this, &Preferences::themeChanged) );
fconn = mainFontFB->signal_font_set().connect ( sigc::mem_fun (*this, &Preferences::fontChanged) );
cpfconn = colorPickerFontFB->signal_font_set().connect ( sigc::mem_fun (*this, &Preferences::cpFontChanged) );
swGeneral->add(*vbGeneral);
return swGeneral;
@@ -1610,28 +1606,28 @@ void Preferences::storePreferences ()
moptions.shadowThreshold = (int)shThresh->get_value ();
moptions.language = languages->get_active_text ();
moptions.languageAutoDetect = ckbLangAutoDetect->get_active ();
moptions.theme = themeFNames.at (theme->get_active_row_number ()).longFName;
moptions.theme = themeFNames.at (themeCBT->get_active_row_number ()).longFName;
Gdk::RGBA cropCol = butCropCol->get_rgba();
Gdk::RGBA cropCol = cropMaskColorCB->get_rgba();
moptions.cutOverlayBrush[0] = cropCol.get_red();
moptions.cutOverlayBrush[1] = cropCol.get_green();
moptions.cutOverlayBrush[2] = cropCol.get_blue();
moptions.cutOverlayBrush[3] = butCropCol->get_alpha() / 65535.0;
moptions.cutOverlayBrush[3] = cropMaskColorCB->get_alpha() / 65535.0;
Gdk::RGBA NavGuideCol = butNavGuideCol->get_rgba();
Gdk::RGBA NavGuideCol = navGuideColorCB->get_rgba();
moptions.navGuideBrush[0] = NavGuideCol.get_red();
moptions.navGuideBrush[1] = NavGuideCol.get_green();
moptions.navGuideBrush[2] = NavGuideCol.get_blue();
moptions.navGuideBrush[3] = butNavGuideCol->get_alpha() / 65535.0;
moptions.navGuideBrush[3] = navGuideColorCB->get_alpha() / 65535.0;
Pango::FontDescription fd (fontButton->get_font_name());
Pango::FontDescription fd (mainFontFB->get_font_name());
if (newFont) {
moptions.fontFamily = fd.get_family();
moptions.fontSize = fd.get_size() / Pango::SCALE;
}
Pango::FontDescription cpfd (colorPickerFontButton->get_font_name());
Pango::FontDescription cpfd (colorPickerFontFB->get_font_name());
if (newCPFont) {
moptions.CPFontFamily = cpfd.get_family();
@@ -1872,28 +1868,28 @@ void Preferences::fillPreferences ()
languages->set_active_text (moptions.language);
ckbLangAutoDetect->set_active (moptions.languageAutoDetect);
int themeNbr = getThemeRowNumber (moptions.theme);
theme->set_active (themeNbr == -1 ? 0 : themeNbr);
themeCBT->set_active (themeNbr == -1 ? 0 : themeNbr);
Gdk::RGBA cropCol;
cropCol.set_rgba (moptions.cutOverlayBrush[0], moptions.cutOverlayBrush[1], moptions.cutOverlayBrush[2]);
butCropCol->set_rgba (cropCol);
butCropCol->set_alpha ( (unsigned short) (moptions.cutOverlayBrush[3] * 65535.0));
cropMaskColorCB->set_rgba (cropCol);
cropMaskColorCB->set_alpha ( (unsigned short) (moptions.cutOverlayBrush[3] * 65535.0));
Gdk::RGBA NavGuideCol;
NavGuideCol.set_rgba (moptions.navGuideBrush[0], moptions.navGuideBrush[1], moptions.navGuideBrush[2]);
butNavGuideCol->set_rgba (NavGuideCol);
butNavGuideCol->set_alpha ( (unsigned short) (moptions.navGuideBrush[3] * 65535.0));
navGuideColorCB->set_rgba (NavGuideCol);
navGuideColorCB->set_alpha ( (unsigned short) (moptions.navGuideBrush[3] * 65535.0));
if (options.fontFamily == "default") {
fontButton->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize));
mainFontFB->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize));
} else {
fontButton->set_font_name (Glib::ustring::compose ("%1 %2", options.fontFamily, options.fontSize));
mainFontFB->set_font_name (Glib::ustring::compose ("%1 %2", options.fontFamily, options.fontSize));
}
if (options.CPFontFamily == "default") {
colorPickerFontButton->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize));
colorPickerFontFB->set_font_name (Glib::ustring::compose ("%1 %2", initialFontFamily, initialFontSize));
} else {
colorPickerFontButton->set_font_name (Glib::ustring::compose ("%1 %2", options.CPFontFamily, options.CPFontSize));
colorPickerFontFB->set_font_name (Glib::ustring::compose ("%1 %2", options.CPFontFamily, options.CPFontSize));
}
showDateTime->set_active (moptions.fbShowDateTime);
@@ -2099,14 +2095,14 @@ void Preferences::okPressed ()
void Preferences::cancelPressed ()
{
// set the initial theme back
if (themeFNames.at (theme->get_active_row_number ()).longFName != options.theme) {
if (themeFNames.at (themeCBT->get_active_row_number ()).longFName != options.theme) {
rtengine::setPaths();
RTImage::updateImages();
switchThemeTo (options.theme);
}
// set the initial font back
Pango::FontDescription fd (fontButton->get_font_name());
Pango::FontDescription fd (mainFontFB->get_font_name());
if (fd.get_family() != options.fontFamily && (fd.get_size() / Pango::SCALE) != options.fontSize) {
if (options.fontFamily == "default") {
@@ -2157,7 +2153,7 @@ void Preferences::aboutPressed ()
void Preferences::themeChanged ()
{
moptions.theme = themeFNames.at (theme->get_active_row_number ()).longFName;
moptions.theme = themeFNames.at (themeCBT->get_active_row_number ()).longFName;
rtengine::setPaths();
RTImage::updateImages();
switchThemeTo (moptions.theme);
@@ -2313,7 +2309,7 @@ void Preferences::fontChanged ()
{
newFont = true;
Pango::FontDescription fd (fontButton->get_font_name());
Pango::FontDescription fd (mainFontFB->get_font_name());
switchFontTo (fd.get_family(), fd.get_size() / Pango::SCALE);
}