Skip to content

Commit

Permalink
Sorted panels in menus on any language taking account the locale.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Feb 25, 2024
1 parent 6034acd commit 952b7b1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
6 changes: 4 additions & 2 deletions mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ v1.0.7
======

- Code clean up.
- Added optional component installation on Windows's .exr installer. Currently,
- Faster windows minimal compilations for quickly checking on GitHub.
- Added optional component installation on Windows's .exe installer. Currently,
you can install:

* mrv2 application (obviously)
Expand All @@ -11,7 +12,7 @@ v1.0.7
* mrv2 Python libraries
* mrv2 USD components

If you choose to install ONLY the application, its size is 392Mb, instead
If you choose to install ONLY the application, its size is 395Mb, instead
of the whole 600Mb.

- Changed name of install directory of mrv2 on Windows from "mrv2 vX.X.X" to
Expand All @@ -20,6 +21,7 @@ v1.0.7
the filesystem returned the order of files.
- Added listing the OS and distro versions at the start and in About of mrv2
for debugging purposes.
- Made panels be listed alphabetically, regardless of Natural Language.


v1.0.6
Expand Down
40 changes: 36 additions & 4 deletions mrv2/lib/mrvUI/mrvMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// mrv2
// Copyright Contributors to the mrv2 Project. All rights reserved.

#include <algorithm>
#include <locale>
#include <string> // Add this include for string-related functionality


#include <tlCore/StringFormat.h>

#include "mrvCore/mrvI8N.h"
Expand Down Expand Up @@ -284,12 +289,39 @@ namespace mrv
else
item->clear();

std::string menu_panel_root = _("Panel/");
std::string menu_window_root = _("Window/");
std::unordered_map<std::string, std::string > panelsMap;
const WindowCallback* wc = kWindowCallbacks;
for (; wc->name; ++wc)
{
std::string tmp = wc->name;
panelsMap.insert(std::make_pair(_(wc->name), wc->name));
}

// Copy key-value pairs from the map to a vector
std::vector<std::pair<std::string, std::string>> vec(
panelsMap.begin(), panelsMap.end());


// Sort the vector in ascending order based on the keys
std::locale loc("");
std::sort(
vec.begin(), vec.end(),
[&loc](const auto& a, const auto& b)
{
return std::lexicographical_compare(
a.first.begin(), a.first.end(), b.first.begin(),
b.first.end(),
[&loc](const auto& ch1, const auto& ch2){
return std::tolower(ch1, loc) <
std::tolower(ch2, loc);
});
});

const std::string menu_panel_root = _("Panel/");
const std::string menu_window_root = _("Window/");

for (const auto& pair : vec)
{
std::string tmp = pair.second;
std::string menu_root = menu_panel_root;

mode = FL_MENU_TOGGLE;
Expand Down Expand Up @@ -358,7 +390,7 @@ namespace mrv
continue; // Unknown window check
}

tmp = _(wc->name);
tmp = pair.first;
std::string menu_name = menu_root + tmp + "\t";
int idx = menu->add(
menu_name.c_str(), hotkey, (Fl_Callback*)window_cb, ui, mode);
Expand Down

0 comments on commit 952b7b1

Please sign in to comment.