From 7460b677c3979b9ec5b913dee3abfcd4272bd297 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Tue, 31 Aug 2010 05:54:55 -0500 Subject: Added Preferences > Fonts tab, with basic font chooser. Choosing a font sets FontChoice setting, but no real effect yet. --- linden/indra/newview/CMakeLists.txt | 2 + linden/indra/newview/app_settings/settings.xml | 11 +++ linden/indra/newview/impprefsfonts.cpp | 86 ++++++++++++++++++++++ linden/indra/newview/impprefsfonts.h | 45 +++++++++++ linden/indra/newview/llfloaterpreference.cpp | 15 +++- linden/indra/newview/llfloaterpreference.h | 2 + .../newview/skins/default/xui/en-us/fonts.xml | 14 ++++ .../skins/default/xui/en-us/notifications.xml | 7 ++ .../default/xui/en-us/panel_preferences_fonts.xml | 33 +++++++++ 9 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 linden/indra/newview/impprefsfonts.cpp create mode 100644 linden/indra/newview/impprefsfonts.h create mode 100644 linden/indra/newview/skins/default/xui/en-us/panel_preferences_fonts.xml (limited to 'linden') diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index 313ed9f..1691095 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -87,6 +87,7 @@ set(viewer_SOURCE_FILES hippoGridManager.cpp hippoLimits.cpp hippoRestRequest.cpp + impprefsfonts.cpp jcfloater_animation_list.cpp jcfloaterareasearch.cpp lightshare.cpp @@ -525,6 +526,7 @@ set(viewer_HEADER_FILES hippoGridManager.h hippoLimits.h hippoRestRequest.h + impprefsfonts.h jcfloater_animation_list.h jcfloaterareasearch.h lightshare.h diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 75f37df..270bd58 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -336,6 +336,17 @@ 0 + FontChoice + + Comment + User's font choice (Liberation or DejaVu) + Persist + 1 + Type + String + Value + DejaVu + GoAction Comment diff --git a/linden/indra/newview/impprefsfonts.cpp b/linden/indra/newview/impprefsfonts.cpp new file mode 100644 index 0000000..3ce71eb --- /dev/null +++ b/linden/indra/newview/impprefsfonts.cpp @@ -0,0 +1,86 @@ +/** + * @file impprefsfonts.cpp + * @brief Font preferences panel + * + * Copyright (c) 2010, Jacek Antonelli + * + * The source code in this file ("Source Code") is provided to you + * under the terms of the GNU General Public License, version 2.0 + * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in + * this distribution, or online at + * http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + + +#include "llviewerprecompiledheaders.h" +#include "impprefsfonts.h" + +#include "llradiogroup.h" +#include "lluictrlfactory.h" + +#include "llviewercontrol.h" +#include "llviewerwindow.h" + + +ImpPrefsFonts::ImpPrefsFonts() +{ + LLUICtrlFactory::getInstance()-> + buildPanel(this, "panel_preferences_fonts.xml"); +} + +ImpPrefsFonts::~ImpPrefsFonts() +{ +} + + +BOOL ImpPrefsFonts::postBuild() +{ + refresh(); + return true; +} + + +void ImpPrefsFonts::refresh() +{ + LLRadioGroup* fonts = getChild("fonts"); + if (fonts) + { + fonts->setValue( gSavedSettings.getString("FontChoice") ); + } +} + +void ImpPrefsFonts::apply() +{ + LLRadioGroup* fonts = getChild("fonts"); + + if (fonts) + { + std::string font_choice = fonts->getValue().asString(); + + if (font_choice != gSavedSettings.getString("FontChoice") && + !font_choice.empty()) + { + gSavedSettings.setString("FontChoice", font_choice); + LLNotifications::instance().add("ChangeFont"); + refresh(); + } + } +} + +void ImpPrefsFonts::cancel() +{ +} diff --git a/linden/indra/newview/impprefsfonts.h b/linden/indra/newview/impprefsfonts.h new file mode 100644 index 0000000..12aa0bb --- /dev/null +++ b/linden/indra/newview/impprefsfonts.h @@ -0,0 +1,45 @@ +/** + * @file impprefsfonts.h + * @brief Font preferences panel + * + * Copyright (c) 2010, Jacek Antonelli + * + * The source code in this file ("Source Code") is provided to you + * under the terms of the GNU General Public License, version 2.0 + * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in + * this distribution, or online at + * http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#ifndef IMP_PREFSFONTS_H +#define IMP_PREFSFONTS_H + +#include "llpanel.h" + +class ImpPrefsFonts : public LLPanel +{ +public: + ImpPrefsFonts(); + virtual ~ImpPrefsFonts(); + + virtual BOOL postBuild(); + void refresh(); + void apply(); + void cancel(); +}; + +#endif // IMP_PREFSFONTS_H diff --git a/linden/indra/newview/llfloaterpreference.cpp b/linden/indra/newview/llfloaterpreference.cpp index 744c179..09336cb 100644 --- a/linden/indra/newview/llfloaterpreference.cpp +++ b/linden/indra/newview/llfloaterpreference.cpp @@ -48,6 +48,7 @@ #include "llspinctrl.h" #include "message.h" +#include "impprefsfonts.h" #include "llcommandhandler.h" #include "llfloaterpreference.h" #include "llpanelnetwork.h" @@ -133,7 +134,8 @@ LLPreferenceCore::LLPreferenceCore(LLTabContainer* tab_container, LLButton * def mMsgPanel(NULL), mSkinsPanel(NULL), mLCDPanel(NULL), - mPrefsAdvanced(NULL) + mPrefsAdvanced(NULL), + mPrefsFonts(NULL) { mGeneralPanel = new LLPanelGeneral(); mTabContainer->addTabPanel(mGeneralPanel, mGeneralPanel->getLabel(), FALSE, onTabChanged, mTabContainer); @@ -197,6 +199,10 @@ LLPreferenceCore::LLPreferenceCore(LLTabContainer* tab_container, LLButton * def mTabContainer->addTabPanel(mPrefsAdvanced, mPrefsAdvanced->getLabel(), FALSE, onTabChanged, mTabContainer); mPrefsAdvanced->setDefaultBtn(default_btn); + mPrefsFonts = new ImpPrefsFonts(); + mTabContainer->addTabPanel(mPrefsFonts, mPrefsFonts->getLabel(), FALSE, onTabChanged, mTabContainer); + mPrefsFonts->setDefaultBtn(default_btn); + if (!mTabContainer->selectTab(gSavedSettings.getS32("LastPrefTab"))) { mTabContainer->selectFirstTab(); @@ -261,6 +267,11 @@ LLPreferenceCore::~LLPreferenceCore() delete mPrefsAdvanced; mPrefsAdvanced = NULL; } + if (mPrefsFonts) + { + delete mPrefsFonts; + mPrefsFonts = NULL; + } } @@ -278,6 +289,7 @@ void LLPreferenceCore::apply() mMsgPanel->apply(); mSkinsPanel->apply(); mPrefsAdvanced->apply(); + mPrefsFonts->apply(); // hardware menu apply LLFloaterHardwareSettings::instance()->apply(); @@ -307,6 +319,7 @@ void LLPreferenceCore::cancel() mMsgPanel->cancel(); mSkinsPanel->cancel(); mPrefsAdvanced->cancel(); + mPrefsFonts->cancel(); // cancel hardware menu LLFloaterHardwareSettings::instance()->cancel(); diff --git a/linden/indra/newview/llfloaterpreference.h b/linden/indra/newview/llfloaterpreference.h index 1878280..e98c45c 100644 --- a/linden/indra/newview/llfloaterpreference.h +++ b/linden/indra/newview/llfloaterpreference.h @@ -56,6 +56,7 @@ class LLPrefsIM; class LLPanelMsgs; class LLPanelSkins; class LLPrefsAdvanced; +class ImpPrefsFonts; class LLScrollListCtrl; class LLPreferenceCore @@ -93,6 +94,7 @@ private: LLPanelMsgs *mMsgPanel; LLPanelLCD *mLCDPanel; LLPrefsAdvanced *mPrefsAdvanced; + ImpPrefsFonts* mPrefsFonts; }; // Floater to control preferences (display, audio, bandwidth, general. diff --git a/linden/indra/newview/skins/default/xui/en-us/fonts.xml b/linden/indra/newview/skins/default/xui/en-us/fonts.xml index 95070ed..5d831c6 100644 --- a/linden/indra/newview/skins/default/xui/en-us/fonts.xml +++ b/linden/indra/newview/skins/default/xui/en-us/fonts.xml @@ -33,6 +33,7 @@ VeraMono.ttf + DejaVuSansCondensed.ttf @@ -56,6 +57,19 @@ DejaVuSansCondensed-BoldOblique.ttf + + + LiberationSans-Regular.ttf + + + + LiberationSans-Bold.ttf + + + arial.ttf diff --git a/linden/indra/newview/skins/default/xui/en-us/notifications.xml b/linden/indra/newview/skins/default/xui/en-us/notifications.xml index 0de1df5..eced647 100644 --- a/linden/indra/newview/skins/default/xui/en-us/notifications.xml +++ b/linden/indra/newview/skins/default/xui/en-us/notifications.xml @@ -7084,6 +7084,13 @@ Apply this region's settings? ("Ignore" will ignore all region setting + +The new font will appear after you restart [VIEWER_NAME]. + + diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_fonts.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_fonts.xml new file mode 100644 index 0000000..e55981b --- /dev/null +++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_fonts.xml @@ -0,0 +1,33 @@ + + + + + + User interface font (requires restart): + + + + + + DejaVu Sans Condensed + + + + Liberation Sans (classic Imprudence font) + + + + + + Preview: The quick brown fox jumped over the lazy dog. :) + + + + Preview: The quick brown fox jumped over the lazy dog. :) + + + -- cgit v1.1