Skip to content

Commit

Permalink
option to disable custom title bar - fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Nov 14, 2024
1 parent d540811 commit bb027b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 26 deletions.
Binary file modified data/models/ybot/ybot.act
Binary file not shown.
21 changes: 2 additions & 19 deletions src/core/win/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,23 +549,6 @@ Point clientToScreen(WindowHandle win, int x, int y)
return res;
}

void enableDecoration(WindowHandle wnd, bool enable) {
if (!wnd) return;
HWND hwnd = (HWND)wnd;
WindowData* win = (WindowData*)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
ASSERT(win);

LONG style = GetWindowLong(hwnd, GWL_STYLE);
if (enable) {
style |= WS_OVERLAPPEDWINDOW;
} else {
style &= ~WS_OVERLAPPEDWINDOW;
}
win->init_args.flags = enable ? win->init_args.flags & ~InitWindowArgs::NO_DECORATION : win->init_args.flags | InitWindowArgs::NO_DECORATION;
SetWindowLong(hwnd, GWL_STYLE, style);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}

WindowHandle createWindow(const InitWindowArgs& args) {
PROFILE_FUNCTION();
WCharStr<MAX_PATH> cls_name("lunex_window");
Expand Down Expand Up @@ -720,7 +703,7 @@ WindowHandle createWindow(const InitWindowArgs& args) {

WCharStr<MAX_PATH> wname(args.name);
DWORD style = args.flags & InitWindowArgs::NO_DECORATION
? (args.hit_test_callback ? WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX : WS_POPUP)
? (args.hit_test_callback ? WS_THICKFRAME | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX : 0)
: WS_OVERLAPPEDWINDOW;
DWORD ext_style = args.flags & InitWindowArgs::NO_TASKBAR_ICON ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW;
WindowData* window_data = LUMIX_NEW(getGlobalAllocator(), WindowData);
Expand Down Expand Up @@ -970,7 +953,7 @@ void restore(WindowHandle win, WindowState state) {
WindowState setFullscreen(WindowHandle win) {
WindowState res;
res.rect = getWindowScreenRect(win);
res.style = SetWindowLongPtr((HWND)win, GWL_STYLE, WS_VISIBLE | WS_POPUP);
res.style = SetWindowLongPtr((HWND)win, GWL_STYLE, WS_VISIBLE);
DEBUG_CHECK(res.style);
int w = GetSystemMetrics(SM_CXSCREEN);
int h = GetSystemMetrics(SM_CYSCREEN);
Expand Down
10 changes: 3 additions & 7 deletions src/editor/studio_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,10 +889,6 @@ struct StudioAppImpl final : StudioApp {
return os::HitTestResult::NONE;
}

void onUseTitlebarChanged() {
os::enableDecoration(m_main_window, m_use_native_titlebar);
}

void onInit()
{
PROFILE_FUNCTION();
Expand Down Expand Up @@ -923,11 +919,11 @@ struct StudioAppImpl final : StudioApp {
m_settings.registerOption("export_dir", &m_export.dest_dir);
m_settings.registerOption("gizmo_scale", &m_gizmo_config.scale, "General", "Gizmo scale");
m_settings.registerOption("fov", &m_fov, "General", "FOV", true);

const Delegate<void()> del = makeDelegate<&StudioAppImpl::onUseTitlebarChanged>(this);
m_settings.registerOption("use_native_titlebar", &m_use_native_titlebar, "General", "Native titlebar (requires restart)", &del);
static bool use_native_titlebar = false;
m_settings.registerOption("use_native_titlebar", &use_native_titlebar, "General", "Native titlebar (restart required)");
// we need some stuff (font_size) from settings at this point
m_settings.load();
m_use_native_titlebar = use_native_titlebar;

os::InitWindowArgs init_window_args;
init_window_args.icon = "editor/logo.ico";
Expand Down

0 comments on commit bb027b9

Please sign in to comment.