Skip to content

Commit

Permalink
Update scenes to use Ubuntu-Regular font
Browse files Browse the repository at this point in the history
  • Loading branch information
baderouaich committed Jul 16, 2024
1 parent cd17a9e commit 66fb966
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 228 deletions.
40 changes: 16 additions & 24 deletions src/Scenes/DecryptFileScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,10 @@ void DecryptFileScene::OnImGuiDraw() {
static constexpr const auto inline_dummy = [](const float& x, const float& y) noexcept { ImGui::SameLine(); ImGui::Dummy(ImVec2(x, y)); };
static constexpr const auto spacing = [](const std::uint8_t& n) noexcept { for (std::uint8_t i = 0; i < n; i++) ImGui::Spacing(); };

static const auto& fonts = Application::getInstance()->GetFonts();
static ImFont *const& font_audiowide_regular_45 = fonts.at("Audiowide-Regular-45");
static ImFont *const& font_audiowide_regular_30 = fonts.at("Audiowide-Regular-30");
static ImFont *const& font_audiowide_regular_20 = fonts.at("Audiowide-Regular-20");
static ImFont *const& font_montserrat_medium_20 = fonts.at("Montserrat-Medium-20");
static ImFont *const& font_montserrat_medium_18 = fonts.at("Montserrat-Medium-18");
static ImFont *const& font_montserrat_medium_16 = fonts.at("Montserrat-Medium-16");
static ImFont *const& font_montserrat_medium_12 = fonts.at("Montserrat-Medium-12");
static ImFont *const& font_ubuntu_regular_30 = fonts.at("Ubuntu-Regular-30");
static ImFont *const& font_ubuntu_regular_20 = fonts.at("Ubuntu-Regular-20");
static ImFont *const& font_ubuntu_regular_18 = fonts.at("Ubuntu-Regular-18");
static ImFont *const& font_ubuntu_regular_30 = ResourceManager::getFont("Ubuntu-Regular-30");
static ImFont *const& font_ubuntu_regular_20 =ResourceManager::getFont("Ubuntu-Regular-20");
static ImFont *const& font_ubuntu_regular_18 =ResourceManager::getFont("Ubuntu-Regular-18");
static ImFont *const& font_ubuntu_regular_12 =ResourceManager::getFont("Ubuntu-Regular-12");

static constexpr const auto container_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove; // | ImGuiWindowFlags_NoBackground;

Expand All @@ -71,14 +64,14 @@ void DecryptFileScene::OnImGuiDraw() {
ImGui::SetWindowPos(ImVec2(0.0f, 0.0f)); // top left
{
#pragma region Back button [<] & Scene Title
static const auto& title_font = font_audiowide_regular_30;
static const auto& title_font = font_ubuntu_regular_30;
static const std::string title = ("Decrypt File");
static const ImVec2 title_size((ImGui::CalcTextSize(title.c_str()).x * title_font->Scale) - 45.0f, ImGui::CalcTextSize(title.c_str()).y * title_font->Scale);
static const ImVec2 back_button_size(45.0f, title_size.y);

// Back Button [<]
{
ImGui::PushFont(font_montserrat_medium_18); // < arrow is a text too
ImGui::PushFont(font_ubuntu_regular_18); // < arrow is a text too
if (ImGuiWidgets::BackButton("##back", back_button_size)) {
this->OnBackButtonPressed();
}
Expand All @@ -93,7 +86,7 @@ void DecryptFileScene::OnImGuiDraw() {
ImGui::PushStyleColor(ImGuiCol_Text, Constants::Colors::TEXT_COLOR); // text color
ImGui::PushStyleColor(ImGuiCol_Button, Constants::Colors::SCENE_TITLE_BACKGROUND_COLOR); // Scene title back color
{
(void) ImGui::ButtonEx(title.c_str(), ImVec2(static_cast<float>(win_w), title_size.y), ImGuiItemFlags_Disabled);
(void) ImGui::ButtonEx(title.c_str(), ImVec2(static_cast<float>(win_w) - back_button_size.x - 25.0f, title_size.y), ImGuiItemFlags_Disabled);
}
ImGui::PopStyleColor(2);
ImGui::PopFont();
Expand All @@ -105,7 +98,7 @@ void DecryptFileScene::OnImGuiDraw() {
spacing(3);

// Algorithm used for encryption
ImGui::PushFont(font_audiowide_regular_20);
ImGui::PushFont(font_ubuntu_regular_20);
{
// Label
ImGui::Text("%s:", ("Algorithm"));
Expand All @@ -114,8 +107,7 @@ void DecryptFileScene::OnImGuiDraw() {
// Algo types radio buttons
const static auto supported_algorithms = Algorithm::GetSupportedAlgorithms();
for (const auto& [algo_name, algo_type]: supported_algorithms) {
inline_dummy(1.0f, 0.0f);
ImGui::SameLine();
ImGui::SameLine(0.0f,5.0f);
if (ImGui::RadioButton(algo_name.c_str(), m_type == algo_type)) {
m_type = algo_type;
}
Expand Down Expand Up @@ -148,14 +140,14 @@ void DecryptFileScene::OnImGuiDraw() {
spacing(3);

// In File to Decrypt
ImGui::PushFont(font_montserrat_medium_20);
ImGui::PushFont(font_ubuntu_regular_20);
{
// Label
ImGui::Text("%s:", ("File To Decrypt"));
// Encrypted text
static const ImVec2 browse_button_size(45.0f, 25.0f);
ImGuiWidgets::InputText("##text1", &m_in_filename, win_w - (browse_button_size.x * 1.5f));
ImGui::PushFont(font_montserrat_medium_12);
ImGui::PushFont(font_ubuntu_regular_12);;
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Button, Constants::Colors::BUTTON_COLOR); // buttons color idle
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, Constants::Colors::BUTTON_COLOR_HOVER); // buttons color hover
Expand All @@ -176,14 +168,14 @@ void DecryptFileScene::OnImGuiDraw() {

// Out File Decrypted
if (!m_in_filename.empty()) {
ImGui::PushFont(font_montserrat_medium_20);
ImGui::PushFont(font_ubuntu_regular_20);
{
// Label
ImGui::Text("%s:", ("Decrypted File Location"));
// Encrypted text
static const ImVec2 browse_button_size(45.0f, 25.0f);
ImGuiWidgets::InputText("##text2", &m_out_filename, win_w - (browse_button_size.x * 1.5f));
ImGui::PushFont(font_montserrat_medium_12);
ImGui::PushFont(font_ubuntu_regular_12);;
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Button, Constants::Colors::BUTTON_COLOR); // buttons color idle
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, Constants::Colors::BUTTON_COLOR_HOVER); // buttons color hover
Expand Down Expand Up @@ -223,7 +215,7 @@ void DecryptFileScene::OnImGuiDraw() {
ImGui::PopFont();
} else {
// Password used for encryption
ImGui::PushFont(font_montserrat_medium_20);
ImGui::PushFont(font_ubuntu_regular_20);
{
// Label
ImGui::Text("%s:", ("Password"));
Expand All @@ -232,7 +224,7 @@ void DecryptFileScene::OnImGuiDraw() {
ImGuiWidgets::InputText("##text3", &m_password, static_cast<float>(win_w), ImGuiInputTextFlags_::ImGuiInputTextFlags_Password);

// Bytes count
ImGui::PushFont(font_montserrat_medium_12);
ImGui::PushFont(font_ubuntu_regular_12);
//ImGui::Text("%zu bytes", m_password.size());
ImGui::Text("%s", SizeUtils::FriendlySize(m_password.size()).c_str());
ImGui::PopFont();
Expand All @@ -245,7 +237,7 @@ void DecryptFileScene::OnImGuiDraw() {

// Decrypt Button
{
ImGui::PushFont(font_audiowide_regular_20); // buttons font
ImGui::PushFont(font_ubuntu_regular_20); // buttons font
ImGui::PushStyleColor(ImGuiCol_Button, Constants::Colors::BUTTON_COLOR); // buttons color idle
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, Constants::Colors::BUTTON_COLOR_HOVER); // buttons color hover
ImGui::PushStyleColor(ImGuiCol_ButtonActive, Constants::Colors::BUTTON_COLOR_ACTIVE); // buttons color pressed
Expand Down
43 changes: 20 additions & 23 deletions src/Scenes/DecryptTextScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,14 @@ void DecryptTextScene::OnImGuiDraw() {
static constexpr const auto spacing = [](const std::uint8_t& n) noexcept { for (std::uint8_t i = 0; i < n; i++) ImGui::Spacing(); };
static constexpr const auto inline_spacing = [](const std::uint8_t& n) noexcept { for (std::uint8_t i = 0; i < n; i++) { ImGui::SameLine(); ImGui::Spacing(); } };

static const auto& fonts = Application::getInstance()->GetFonts();
static ImFont *const& font_audiowide_regular_45 = fonts.at("Audiowide-Regular-45");
static ImFont *const& font_audiowide_regular_30 = fonts.at("Audiowide-Regular-30");
static ImFont *const& font_audiowide_regular_20 = fonts.at("Audiowide-Regular-20");
static ImFont *const& font_montserrat_medium_20 = fonts.at("Montserrat-Medium-20");
static ImFont *const& font_montserrat_medium_18 = fonts.at("Montserrat-Medium-18");
static ImFont *const& font_montserrat_medium_12 = fonts.at("Montserrat-Medium-12");
static ImFont *const& font_ubuntu_regular_30 = fonts.at("Ubuntu-Regular-30");
static ImFont *const& font_ubuntu_regular_20 = fonts.at("Ubuntu-Regular-20");
static ImFont *const& font_ubuntu_regular_18 = fonts.at("Ubuntu-Regular-18");
static ImFont *const& font_ubuntu_regular_60 = ResourceManager::getFont("Ubuntu-Regular-60");
static ImFont *const& font_ubuntu_regular_45 = ResourceManager::getFont("Ubuntu-Regular-45");
static ImFont *const& font_ubuntu_regular_30 = ResourceManager::getFont("Ubuntu-Regular-30");
static ImFont *const& font_ubuntu_regular_20 = ResourceManager::getFont("Ubuntu-Regular-20");
static ImFont *const& font_ubuntu_regular_18 = ResourceManager::getFont("Ubuntu-Regular-18");
static ImFont *const& font_ubuntu_regular_16 = ResourceManager::getFont("Ubuntu-Regular-16");
static ImFont *const& font_ubuntu_regular_14 = ResourceManager::getFont("Ubuntu-Regular-14");
static ImFont *const& font_ubuntu_regular_12 = ResourceManager::getFont("Ubuntu-Regular-12");

static constexpr const auto container_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove; // | ImGuiWindowFlags_NoBackground;

Expand All @@ -68,14 +66,14 @@ void DecryptTextScene::OnImGuiDraw() {
ImGui::SetWindowPos(ImVec2(0.0f, 0.0f)); // top left
{
#pragma region Back button [<] & Scene Title
static const auto& title_font = font_audiowide_regular_30;
static const auto& title_font = font_ubuntu_regular_30;
static const std::string title = ("Decrypt Text");
static const ImVec2 title_size((ImGui::CalcTextSize(title.c_str()).x * title_font->Scale) - 45.0f, ImGui::CalcTextSize(title.c_str()).y * title_font->Scale);
static const ImVec2 back_button_size(45.0f, title_size.y);

// Back Button [<]
{
ImGui::PushFont(font_montserrat_medium_18); // < arrow is a text too
ImGui::PushFont(font_ubuntu_regular_18); // < arrow is a text too
if (ImGuiWidgets::BackButton("##back", back_button_size)) {
this->OnBackButtonPressed();
}
Expand All @@ -90,7 +88,7 @@ void DecryptTextScene::OnImGuiDraw() {
ImGui::PushStyleColor(ImGuiCol_Text, Constants::Colors::TEXT_COLOR); // text color
ImGui::PushStyleColor(ImGuiCol_Button, Constants::Colors::SCENE_TITLE_BACKGROUND_COLOR); // Scene title back color
{
(void) ImGui::ButtonEx(title.c_str(), ImVec2(static_cast<float>(win_w), title_size.y), ImGuiItemFlags_Disabled);
(void) ImGui::ButtonEx(title.c_str(), ImVec2(static_cast<float>(win_w) - back_button_size.x - 25.0f, title_size.y), ImGuiItemFlags_Disabled);
}
ImGui::PopStyleColor(2);
ImGui::PopFont();
Expand All @@ -103,7 +101,7 @@ void DecryptTextScene::OnImGuiDraw() {
spacing(3);

// Algorithm used in encryption to decrypt text with
ImGui::PushFont(font_audiowide_regular_20);
ImGui::PushFont(font_ubuntu_regular_20);
{
// Label
ImGui::Text("%s:", ("Algorithm"));
Expand All @@ -112,8 +110,7 @@ void DecryptTextScene::OnImGuiDraw() {
// Algo types radio buttons
const static auto supported_algorithms = Algorithm::GetSupportedAlgorithms();
for (const auto& [algo_name, algo_type]: supported_algorithms) {
inline_dummy(1.0f, 0.0f);
ImGui::SameLine();
ImGui::SameLine(0.0f,5.0f);
if (ImGui::RadioButton(algo_name.c_str(), m_type == algo_type)) {
m_type = algo_type;
}
Expand Down Expand Up @@ -146,7 +143,7 @@ void DecryptTextScene::OnImGuiDraw() {
spacing(3);

// Encrypted Text in Base64 to Decrypt
ImGui::PushFont(font_montserrat_medium_20);
ImGui::PushFont(font_ubuntu_regular_20);
{
// Label
ImGui::Text("%s:", ("Cipher (in base64)"));
Expand All @@ -156,7 +153,7 @@ void DecryptTextScene::OnImGuiDraw() {
ImGuiWidgets::InputTextMultiline("##cipher_base64", &m_cipher_base64, input_text_size);

// Bytes count
ImGui::PushFont(font_montserrat_medium_12);
ImGui::PushFont(font_ubuntu_regular_12);
//ImGui::Text("%zu bytes", m_cipher_base64.size());
ImGui::Text("%s", SizeUtils::FriendlySize(m_cipher_base64.size()).c_str());
ImGui::PopFont();
Expand Down Expand Up @@ -184,7 +181,7 @@ void DecryptTextScene::OnImGuiDraw() {
ImGui::PopFont();
} else {
// Password used for encryption
ImGui::PushFont(font_montserrat_medium_20);
ImGui::PushFont(font_ubuntu_regular_20);
{
// Label
ImGui::Text("%s:", ("Password"));
Expand All @@ -193,7 +190,7 @@ void DecryptTextScene::OnImGuiDraw() {
ImGuiWidgets::InputText("##password", &m_password, static_cast<float>(win_w), ImGuiInputTextFlags_::ImGuiInputTextFlags_Password);

// Bytes count
ImGui::PushFont(font_montserrat_medium_12);
ImGui::PushFont(font_ubuntu_regular_12);
//ImGui::Text("%zu bytes", m_password.size());
ImGui::Text("%s", SizeUtils::FriendlySize(m_password.size()).c_str());
ImGui::PopFont();
Expand All @@ -208,7 +205,7 @@ void DecryptTextScene::OnImGuiDraw() {
ImGui::Separator();
spacing(3);

ImGui::PushFont(font_montserrat_medium_20);
ImGui::PushFont(font_ubuntu_regular_20);
{
// Label
ImGui::Text("%s:", ("Recovered Text"));
Expand All @@ -222,7 +219,7 @@ void DecryptTextScene::OnImGuiDraw() {
this->OnCopyDecryptedTextButtonPressed();
}
// Bytes count
ImGui::PushFont(font_montserrat_medium_12);
ImGui::PushFont(font_ubuntu_regular_12);
//ImGui::Text("%zu bytes", m_recovered_text.size());
ImGui::Text("%s", SizeUtils::FriendlySize(m_recovered_text.size()).c_str());
ImGui::PopFont();
Expand All @@ -237,7 +234,7 @@ void DecryptTextScene::OnImGuiDraw() {

// Decrypt Button
{
ImGui::PushFont(font_audiowide_regular_20); // buttons font
ImGui::PushFont(font_ubuntu_regular_20); // buttons font
ImGui::PushStyleColor(ImGuiCol_Button, Constants::Colors::BUTTON_COLOR); // buttons color idle
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, Constants::Colors::BUTTON_COLOR_HOVER); // buttons color hover
ImGui::PushStyleColor(ImGuiCol_ButtonActive, Constants::Colors::BUTTON_COLOR_ACTIVE); // buttons color pressed
Expand Down
Loading

0 comments on commit 66fb966

Please sign in to comment.