Suppress creation of multiple separators in a row in toolbars

If an entire group of commands in a toolbar is missing (such as with
AssDraw on non-windows), the duplicate separator should go as well to
avoid ugliness. A better solution here would be platform-specific
default toolbars, which should probably be done as part of #495.

Closes #1398.

Originally committed to SVN as r6337.
This commit is contained in:
Thomas Goyne 2012-01-22 17:15:36 +00:00
parent 7da57b38dc
commit 0287edaa33
1 changed files with 29 additions and 24 deletions

View File

@ -108,14 +108,18 @@ namespace {
json::Array const& arr = root_it->second; json::Array const& arr = root_it->second;
commands.reserve(arr.size()); commands.reserve(arr.size());
bool needs_onidle = false; bool needs_onidle = false;
bool last_was_sep = false;
for (json::Array::const_iterator it = arr.begin(); it != arr.end(); ++it) { for (json::Array::const_iterator it = arr.begin(); it != arr.end(); ++it) {
json::String const& command_name = *it; json::String const& command_name = *it;
if (command_name.empty()) { if (command_name.empty()) {
if (!last_was_sep)
AddSeparator(); AddSeparator();
last_was_sep = true;
continue;
} }
else {
cmd::Command *command; cmd::Command *command;
try { try {
command = cmd::get(command_name); command = cmd::get(command_name);
@ -125,6 +129,8 @@ namespace {
continue; continue;
} }
last_was_sep = false;
wxBitmap const& bitmap = command->Icon(icon_size); wxBitmap const& bitmap = command->Icon(icon_size);
// this hack is needed because ??? // this hack is needed because ???
wxBitmap icon = bitmap.GetSubBitmap(wxRect(0, 0, bitmap.GetWidth(), bitmap.GetHeight())); wxBitmap icon = bitmap.GetSubBitmap(wxRect(0, 0, bitmap.GetWidth(), bitmap.GetHeight()));
@ -140,7 +146,6 @@ namespace {
commands.push_back(command); commands.push_back(command);
needs_onidle = needs_onidle || flags != cmd::COMMAND_NORMAL; needs_onidle = needs_onidle || flags != cmd::COMMAND_NORMAL;
} }
}
// Only bind the update function if there are actually any dynamic tools // Only bind the update function if there are actually any dynamic tools
if (needs_onidle) { if (needs_onidle) {