mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Simplify the code for "auto" toolbars handling
Instaead of passing a number of booleans, it make more sense to pass the relevant visibility values in a single flag.
This commit is contained in:
parent
406d710131
commit
8b36c090b7
@ -321,17 +321,10 @@ void GuiToolbar::add(ToolbarItem const & item)
|
||||
}
|
||||
|
||||
|
||||
void GuiToolbar::update(bool in_math, bool in_table, bool in_review,
|
||||
bool in_mathmacrotemplate, bool in_ipa)
|
||||
void GuiToolbar::update(int context)
|
||||
{
|
||||
if (visibility_ & Toolbars::AUTO) {
|
||||
bool show_it = (in_math && (visibility_ & Toolbars::MATH))
|
||||
|| (in_table && (visibility_ & Toolbars::TABLE))
|
||||
|| (in_review && (visibility_ & Toolbars::REVIEW))
|
||||
|| (in_mathmacrotemplate && (visibility_ & Toolbars::MATHMACROTEMPLATE))
|
||||
|| (in_ipa && (visibility_ & Toolbars::IPA));
|
||||
setVisible(show_it);
|
||||
}
|
||||
if (visibility_ & Toolbars::AUTO)
|
||||
setVisible(visibility_ & context & Toolbars::ALLOWAUTO);
|
||||
|
||||
// update visible toolbars only
|
||||
if (!isVisible())
|
||||
|
@ -92,8 +92,7 @@ public:
|
||||
bool isRestored() const;
|
||||
|
||||
/// Refresh the contents of the bar.
|
||||
void update(bool in_math, bool in_table, bool review,
|
||||
bool in_mathmacrotemplate, bool in_ipa);
|
||||
void update(int context = 0);
|
||||
|
||||
///
|
||||
void toggle();
|
||||
|
@ -1534,24 +1534,25 @@ void GuiView::updateToolbars()
|
||||
{
|
||||
ToolbarMap::iterator end = d.toolbars_.end();
|
||||
if (d.current_work_area_) {
|
||||
bool const math =
|
||||
d.current_work_area_->bufferView().cursor().inMathed()
|
||||
&& !d.current_work_area_->bufferView().cursor().inRegexped();
|
||||
bool const table =
|
||||
lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
|
||||
bool const review =
|
||||
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
|
||||
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onOff(true);
|
||||
bool const mathmacrotemplate =
|
||||
lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
|
||||
bool const ipa =
|
||||
lyx::getStatus(FuncRequest(LFUN_IN_IPA)).enabled();
|
||||
int context = 0;
|
||||
if (d.current_work_area_->bufferView().cursor().inMathed()
|
||||
&& !d.current_work_area_->bufferView().cursor().inRegexped())
|
||||
context |= Toolbars::MATH;
|
||||
if (lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled())
|
||||
context |= Toolbars::TABLE;
|
||||
if (lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled()
|
||||
&& lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onOff(true))
|
||||
context |= Toolbars::REVIEW;
|
||||
if (lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled())
|
||||
context |= Toolbars::MATHMACROTEMPLATE;
|
||||
if (lyx::getStatus(FuncRequest(LFUN_IN_IPA)).enabled())
|
||||
context |= Toolbars::IPA;
|
||||
|
||||
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
||||
it->second->update(math, table, review, mathmacrotemplate, ipa);
|
||||
it->second->update(context);
|
||||
} else
|
||||
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
||||
it->second->update(false, false, false, false, false);
|
||||
it->second->update();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user