Example #1
0
 private void setUpContextMenu(Guid entityGuid)
 {
     _state.EntityClicked(entityGuid, _starSysGuid, MouseButtons.Alt);
     _state.ContextMenu = new EntityContextMenu(_state, entityGuid);
     _state.ContextMenu.Display();
 }
Example #2
0
        public override void Draw(IntPtr rendererPtr, Camera camera)
        {
            if (camera.ZoomLevel < DrawAtZoom)
            {
                return;
            }

            int x = (int)(X + ViewOffset.X);
            int y = (int)(Y + ViewOffset.Y);

            System.Numerics.Vector2 pos = new System.Numerics.Vector2(x, y);


            ImGui.PushStyleColor(ImGuiCol.WindowBg, new System.Numerics.Vector4(0, 0, 0, 0)); //make the background transperent.

            ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0);
            //ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(1, 1));
            ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 2);

            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new System.Numerics.Vector2(1, 2));
            ImGui.SetNextWindowPos(pos, ImGuiCond.Always);

            ImGui.Begin(NameString, ref IsActive, _flags);
            ImGui.PushStyleColor(ImGuiCol.Button, new System.Numerics.Vector4(0, 0, 0, 0));
            if (ImGui.Button(NameString)) //If the name gets clicked, we tell the state.
            {
                _state.EntityClicked(_entityGuid, _starSysGuid, MouseButtons.Primary);
            }
            if (ImGui.BeginPopupContextItem("NameContextMenu", 1))
            {
                _state.EntityClicked(_entityGuid, _starSysGuid, MouseButtons.Alt);
                _state.ContextMenu = new EntityContextMenu(_state, _entityGuid);
                _state.ContextMenu.Display();

                ImGui.EndPopup();
            }

            ImGui.BeginChild("subnames");
            foreach (var name in SubNames)
            {
                if (ImGui.Button(name.Value))
                {
                    _state.EntityClicked(name.Key, _starSysGuid, MouseButtons.Primary);
                }
                if (ImGui.BeginPopupContextItem("subNameContextMenu" + name.Key, 1))
                {
                    _state.EntityClicked(name.Key, _starSysGuid, MouseButtons.Alt);
                    _state.ContextMenu = new EntityContextMenu(_state, name.Key);
                    _state.ContextMenu.Display();

                    ImGui.EndPopup();
                }
            }

            ImGui.EndChild();

            //var size = ImGui.GetItemRectSize();
            var size = ImGui.GetWindowSize();

            Width  = size.X;
            Height = size.Y;
            ViewDisplayRect.Width  = size.X;
            ViewDisplayRect.Height = size.Y;

            ImGui.PopStyleColor();

            ImGui.End();
            ImGui.PopStyleColor(); //have to pop the color change after pushing it.
            ImGui.PopStyleVar(3);
        }