Skip to content

Instantly share code, notes, and snippets.

@galloscript
Last active May 17, 2020 04:22
Show Gist options
  • Select an option

  • Save galloscript/1ca2c21ab2b8425bb6aa36c5e0cb4bae to your computer and use it in GitHub Desktop.

Select an option

Save galloscript/1ca2c21ab2b8425bb6aa36c5e0cb4bae to your computer and use it in GitHub Desktop.

Revisions

  1. galloscript revised this gist Apr 13, 2017. No changes.
  2. galloscript revised this gist Apr 13, 2017. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  3. galloscript created this gist Apr 12, 2017.
    20 changes: 20 additions & 0 deletions ImGuiFile.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    //I'm using the menu bar for dragging
    //... after creating your menus inside ImGui::BeginMenuBar()
    //Window dragging from ImGui
    ImRect menuBarRect = ImRect(0, 0, WINDOW_WIDTH, MENU_BAR_HEIGHT);
    ImVec2 mouseDelta = ImGui::GetIO().MouseDelta;
    ImGui::InvisibleButton("##windowdragging", menuBarRect.Max);
    if(ImGui::IsItemActive() && ImGui::IsMouseDragging(0, 0.0f))
    {
    MPMainWindow::instance->addWindowDeltaPos(mouseDelta.x, mouseDelta.y);

    //GLFW window dragging
    int newPosX, newPosY;
    glfwGetWindowPos(glfwWindowPtr, &newPosX, &newPosY);
    glfwSetWindowPos(glfwWindowPtr, newPosX + mouseDelta.x, newPosY + mouseDelta.y);

    //Update mouse previous position
    ImGui::GetIO().MousePosPrev.x = ImGui::GetIO().MousePos.x - mouseDelta.x;
    ImGui::GetIO().MousePosPrev.y = ImGui::GetIO().MousePos.y - mouseDelta.y;
    }
    //... ImGui::EndMenuBar();
    13 changes: 13 additions & 0 deletions NativeMacOSXFile.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    //Get the native window
    NSWindow* cocoaWindow = glfwGetCocoaWindow(glfwWindowPtr);

    NSUInteger lWindowStyle = NSWindowStyleMaskTitled |
    NSWindowStyleMaskClosable |
    NSWindowStyleMaskMiniaturizable |
    NSWindowStyleMaskResizable |
    NSWindowStyleMaskUnifiedTitleAndToolbar |
    NSWindowStyleMaskFullSizeContentView;
    //Set the style mask
    [cocoaWindow setStyleMask:lWindowStyle];
    cocoaWindow.titlebarAppearsTransparent = YES;
    cocoaWindow.movableByWindowBackground = YES; //Not really necessary