feat: Added a title bar backdrop color gradient

This commit is contained in:
WerWolv
2025-02-16 11:33:41 +01:00
parent b03be212b3
commit 870aeb34fc
4 changed files with 24 additions and 2 deletions

View File

@@ -750,6 +750,8 @@ namespace hex::plugin::builtin {
ThemeManager::setAccentColor(colorPicker->getColor());
});
ContentRegistry::Settings::add<Widgets::Checkbox>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.show_titlebar_backdrop", true);
ContentRegistry::Settings::add<ScalingWidget>("hex.builtin.setting.interface", "hex.builtin.setting.interface.style", "hex.builtin.setting.interface.scaling_factor")
.requiresRestart();

View File

@@ -35,6 +35,16 @@ namespace hex::plugin::builtin {
bool s_showSearchBar = true;
bool s_displayShortcutHighlights = true;
bool s_useNativeMenuBar = false;
bool s_showTitlebarBackDrop = true;
void drawTitleBarBackDrop() {
if (!s_showTitlebarBackDrop)
return;
const auto size = ImHexApi::System::getMainWindowSize();
const auto pos = ImHexApi::System::getMainWindowPosition() - ImVec2(0, size.y / 2 - 20_scaled);
ImGui::GetWindowDrawList()->AddShadowCircle(pos, size.x / 4, ImGui::GetColorU32(ImGuiCol_ButtonActive, 0.8), size.x / 4, ImVec2());
}
void createNestedMenu(std::span<const UnlocalizedString> menuItems, const char *icon, const Shortcut &shortcut, View *view, const ContentRegistry::Interface::impl::MenuCallback &callback, const ContentRegistry::Interface::impl::EnabledCallback &enabledCallback, const ContentRegistry::Interface::impl::SelectedCallback &selectedCallback) {
const auto &name = menuItems.front();
@@ -399,6 +409,7 @@ namespace hex::plugin::builtin {
auto window = ImHexApi::System::getMainWindowHandle();
menu::enableNativeMenuBar(s_useNativeMenuBar);
if (menu::beginMainMenuBar()) {
drawTitleBarBackDrop();
if (ImHexApi::System::isBorderlessWindowModeEnabled()) {
#if defined(OS_WINDOWS)
ImGui::SetCursorPosX(5_scaled);
@@ -477,6 +488,7 @@ namespace hex::plugin::builtin {
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0F);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0F);
if (ImGui::BeginMenuBar()) {
drawTitleBarBackDrop();
for (const auto &callback : ContentRegistry::Interface::impl::getToolbarItems()) {
callback();
ImGui::SameLine();
@@ -652,6 +664,10 @@ namespace hex::plugin::builtin {
s_useNativeMenuBar = value.get<bool>(true);
});
ContentRegistry::Settings::onChange("hex.builtin.setting.interface", "hex.builtin.setting.interface.show_titlebar_backdrop", [](const ContentRegistry::Settings::SettingsValue &value) {
s_showTitlebarBackDrop = value.get<bool>(true);
});
ContentRegistry::Settings::onChange("hex.builtin.setting.interface", "hex.builtin.setting.interface.randomize_window_title", [](const ContentRegistry::Settings::SettingsValue &value) {
const bool randomTitle = value.get<bool>(false);
if (randomTitle) {