mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
* build: add nlohmann/json library * build(deps): add harfbuzz dependency * feat(cmake): add guard to reject macOS builds * feat(font): add HarfBuzz shaping and replace font with unifont * feat(localization): add i18n support with en_US and zh_CN translations Implement Localization class to load JSON translation files. Replace hardcoded strings in UI with translation keys and update sliders/combo buttons to use dynamic text. * feat(localization): detect system locale for language default * feat(settings): add language selection option with restart notification * fix: use vckpg to add freetype on windows
33 lines
996 B
C++
33 lines
996 B
C++
#pragma once
|
|
#include "Cubed/ui/button.hpp"
|
|
|
|
#include <span>
|
|
namespace Cubed {
|
|
using ComboPair = std::pair<std::string, std::function<void()>>;
|
|
class ComboButton : public Button {
|
|
|
|
public:
|
|
ComboButton(const ComboButton&) = delete;
|
|
ComboButton(ComboButton&&) = delete;
|
|
ComboButton& operator=(const ComboButton&) = delete;
|
|
ComboButton& operator=(ComboButton&&) = delete;
|
|
|
|
ComboButton(Widget* parent);
|
|
ComboButton& set_combo_text(const std::string& key,
|
|
const std::string& variable);
|
|
Button& set_text(const std::string& key) override;
|
|
bool handle_mouse_button_event(const MouseButtonEvent& e) override;
|
|
ComboButton& set_combos(std::span<ComboPair> combos);
|
|
ComboButton& set_index(int index);
|
|
|
|
private:
|
|
void update_text();
|
|
|
|
std::vector<std::string> m_suffix;
|
|
std::vector<std::function<void()>> m_funs;
|
|
std::string m_key;
|
|
std::string m_variable;
|
|
int m_index = 0;
|
|
int m_sum = 0;
|
|
};
|
|
} // namespace Cubed
|