コード例 #1
0
ファイル: TabHandler.cs プロジェクト: TRBlount/Librelancer
        public static bool VerticalTab(string text, bool v)
        {
            var font  = ImGuiNative.igGetFont();
            var dlist = ImGuiNative.igGetWindowDrawList();

            var style      = ImGui.GetStyle();
            var text_color = ImGuiNative.igGetColorU32(ColorTarget.Text, 1);
            var color      = style.GetColor(ColorTarget.Button);

            if (v)
            {
                color = style.GetColor(ColorTarget.ButtonActive);
            }

            var   textSize = ImGui.GetTextSize(text);
            float pad      = style.FramePadding.X;
            var   pos      = ImGui.GetCursorScreenPos() + new Vector2(pad, textSize.X + pad);

            ImGui.PushStyleColor(ColorTarget.Button, color);
            ImGui.PushID(text);
            bool ret = ImGui.Button("", new Vector2(textSize.Y + pad * 2,
                                                    textSize.X + pad * 2));

            ImGui.PopStyleColor();
            foreach (var c in text.Reverse())
            {
                var glyph = igFontFindGlyph(font, c);
                ImGuiNative.ImDrawList_PrimReserve(
                    dlist, 6, 4
                    );
                ImGuiNative.ImDrawList_PrimQuadUV(
                    dlist,
                    pos + new Vector2(font->FontSize - glyph->Y0, -glyph->X0),
                    pos + new Vector2(font->FontSize - glyph->Y0, -glyph->X1),
                    pos + new Vector2(font->FontSize - glyph->Y1, -glyph->X1),
                    pos + new Vector2(font->FontSize - glyph->Y1, -glyph->X0),
                    new Vector2(glyph->U1, glyph->V0),
                    new Vector2(glyph->U0, glyph->V0),
                    new Vector2(glyph->U0, glyph->V1),
                    new Vector2(glyph->U1, glyph->V1),
                    text_color
                    );
                pos.Y -= glyph->AdvanceX;
            }
            ImGui.PopID();
            return(ret);
        }