From abc97126df5fb5a455bf62812c0fd0f4ca4ca3e5 Mon Sep 17 00:00:00 2001 From: gucio321 Date: Sun, 19 Sep 2021 15:56:41 +0200 Subject: [PATCH] disable revive: fix part of lll's and stylechecks --- .golangci.yml | 4 +- CodeEditor.go | 2 +- EventHandler.go | 2 +- Flags.go | 298 +++++++++++++++++++++++++++++++++--------------- Plot.go | 8 +- Utils.go | 10 +- Widgets.go | 12 +- Window.go | 2 +- 8 files changed, 229 insertions(+), 109 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a397f12c..53f878ee 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -69,14 +69,12 @@ linters: - makezero - misspell - nakedret - - nestif - nilerr - #- nlreturn - nolintlint - prealloc - predeclared - promlinter - - revive + #- revive - rowserrcheck - staticcheck - structcheck diff --git a/CodeEditor.go b/CodeEditor.go index 725234f0..02971b7a 100644 --- a/CodeEditor.go +++ b/CodeEditor.go @@ -46,7 +46,7 @@ func CodeEditor(title string) *CodeEditorWidget { } } -// ShowWhitespace sets if whitespaces are shown in code editor +// ShowWhitespaces sets if whitespaces are shown in code editor func (ce *CodeEditorWidget) ShowWhitespaces(s bool) *CodeEditorWidget { ce.getState().editor.SetShowWhitespaces(s) return ce diff --git a/EventHandler.go b/EventHandler.go index 4acb9021..6ed73433 100644 --- a/EventHandler.go +++ b/EventHandler.go @@ -75,7 +75,7 @@ func (eh *EventHandler) OnKeyPressed(key Key, cb func()) *EventHandler { return eh } -// OnKeyReleaed sets callback when key `key` is released +// OnKeyReleased sets callback when key `key` is released func (eh *EventHandler) OnKeyReleased(key Key, cb func()) *EventHandler { eh.keyEvents = append(eh.keyEvents, keyEvent{key, cb, IsKeyReleased}) return eh diff --git a/Flags.go b/Flags.go index 74bd5eb7..b6f6206f 100644 --- a/Flags.go +++ b/Flags.go @@ -336,139 +336,249 @@ type TableFlags int // Table flags enum: const ( // Features - TableFlagsNone TableFlags = 0 - TableFlagsResizable TableFlags = 1 << 0 // Enable resizing columns. - TableFlagsReorderable TableFlags = 1 << 1 // Enable reordering columns in header row (need calling TableSetupColumn() + TableHeadersRow() to display headers) - TableFlagsHideable TableFlags = 1 << 2 // Enable hiding/disabling columns in context menu. - TableFlagsSortable TableFlags = 1 << 3 // Enable sorting. Call TableGetSortSpecs() to obtain sort specs. Also see TableFlagsSortMulti and TableFlagsSortTristate. - TableFlagsNoSavedSettings TableFlags = 1 << 4 // Disable persisting columns order, width and sort settings in the .ini file. - TableFlagsContextMenuInBody TableFlags = 1 << 5 // Right-click on columns body/contents will display table context menu. By default it is available in TableHeadersRow(). + + TableFlagsNone TableFlags = 0 + // Enable resizing columns. + TableFlagsResizable TableFlags = 1 << 0 + // Enable reordering columns in header row (need calling TableSetupColumn() + TableHeadersRow() to display headers) + TableFlagsReorderable TableFlags = 1 << 1 + // Enable hiding/disabling columns in context menu. + TableFlagsHideable TableFlags = 1 << 2 + // Enable sorting. Call TableGetSortSpecs() to obtain sort specs. Also see TableFlagsSortMulti and TableFlagsSortTristate. + TableFlagsSortable TableFlags = 1 << 3 + // Disable persisting columns order, width and sort settings in the .ini file. + TableFlagsNoSavedSettings TableFlags = 1 << 4 + // Right-click on columns body/contents will display table context menu. By default it is available in TableHeadersRow(). + TableFlagsContextMenuInBody TableFlags = 1 << 5 // Decorations - TableFlagsRowBg TableFlags = 1 << 6 // Set each RowBg color with ColTableRowBg or ColTableRowBgAlt (equivalent of calling TableSetBgColor with TableBgFlagsRowBg0 on each row manually) - TableFlagsBordersInnerH TableFlags = 1 << 7 // Draw horizontal borders between rows. - TableFlagsBordersOuterH TableFlags = 1 << 8 // Draw horizontal borders at the top and bottom. - TableFlagsBordersInnerV TableFlags = 1 << 9 // Draw vertical borders between columns. - TableFlagsBordersOuterV TableFlags = 1 << 10 // Draw vertical borders on the left and right sides. - TableFlagsBordersH TableFlags = TableFlagsBordersInnerH | TableFlagsBordersOuterH // Draw horizontal borders. - TableFlagsBordersV TableFlags = TableFlagsBordersInnerV | TableFlagsBordersOuterV // Draw vertical borders. - TableFlagsBordersInner TableFlags = TableFlagsBordersInnerV | TableFlagsBordersInnerH // Draw inner borders. - TableFlagsBordersOuter TableFlags = TableFlagsBordersOuterV | TableFlagsBordersOuterH // Draw outer borders. - TableFlagsBorders TableFlags = TableFlagsBordersInner | TableFlagsBordersOuter // Draw all borders. - TableFlagsNoBordersInBody TableFlags = 1 << 11 // [ALPHA] Disable vertical borders in columns Body (borders will always appears in Headers). -> May move to style - TableFlagsNoBordersInBodyUntilResizeTableFlags TableFlags = 1 << 12 // [ALPHA] Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers). -> May move to style + + // Set each RowBg color with ColTableRowBg or ColTableRowBgAlt (equivalent of calling TableSetBgColor with TableBgFlagsRowBg0 on each row manually) + TableFlagsRowBg TableFlags = 1 << 6 + // Draw horizontal borders between rows. + TableFlagsBordersInnerH TableFlags = 1 << 7 + // Draw horizontal borders at the top and bottom. + TableFlagsBordersOuterH TableFlags = 1 << 8 + // Draw vertical borders between columns. + TableFlagsBordersInnerV TableFlags = 1 << 9 + // Draw vertical borders on the left and right sides. + TableFlagsBordersOuterV TableFlags = 1 << 10 + // Draw horizontal borders. + TableFlagsBordersH TableFlags = TableFlagsBordersInnerH | TableFlagsBordersOuterH + // Draw vertical borders. + TableFlagsBordersV TableFlags = TableFlagsBordersInnerV | TableFlagsBordersOuterV + // Draw inner borders. + TableFlagsBordersInner TableFlags = TableFlagsBordersInnerV | TableFlagsBordersInnerH + // Draw outer borders. + TableFlagsBordersOuter TableFlags = TableFlagsBordersOuterV | TableFlagsBordersOuterH + // Draw all borders. + TableFlagsBorders TableFlags = TableFlagsBordersInner | TableFlagsBordersOuter + // [ALPHA] Disable vertical borders in columns Body (borders will always appears in Headers). -> May move to style + TableFlagsNoBordersInBody TableFlags = 1 << 11 + // [ALPHA] Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers). -> May move to style + TableFlagsNoBordersInBodyUntilResizeTableFlags TableFlags = 1 << 12 // Sizing Policy (read above for defaults)TableFlags - TableFlagsSizingFixedFit TableFlags = 1 << 13 // Columns default to WidthFixed or WidthAuto (if resizable or not resizable), matching contents width. - TableFlagsSizingFixedSame TableFlags = 2 << 13 // Columns default to WidthFixed or WidthAuto (if resizable or not resizable), matching the maximum contents width of all columns. Implicitly enable TableFlagsNoKeepColumnsVisible. - TableFlagsSizingStretchProp TableFlags = 3 << 13 // Columns default to WidthStretch with default weights proportional to each columns contents widths. - TableFlagsSizingStretchSame TableFlags = 4 << 13 // Columns default to WidthStretch with default weights all equal, unless overridden by TableSetupColumn(). + + // Columns default to WidthFixed or WidthAuto (if resizable or not resizable), matching contents width. + TableFlagsSizingFixedFit TableFlags = 1 << 13 + // Columns default to WidthFixed or WidthAuto (if resizable or not resizable), matching the maximum contents width of all columns. + // Implicitly enable TableFlagsNoKeepColumnsVisible. + TableFlagsSizingFixedSame TableFlags = 2 << 13 + // Columns default to WidthStretch with default weights proportional to each columns contents widths. + TableFlagsSizingStretchProp TableFlags = 3 << 13 + // Columns default to WidthStretch with default weights all equal, unless overridden by TableSetupColumn(). + TableFlagsSizingStretchSame TableFlags = 4 << 13 // Sizing Extra Options - TableFlagsNoHostExtendX TableFlags = 1 << 16 // Make outer width auto-fit to columns, overriding outersize.x value. Only available when ScrollX/ScrollY are disabled and Stretch columns are not used. - TableFlagsNoHostExtendY TableFlags = 1 << 17 // Make outer height stop exactly at outersize.y (prevent auto-extending table past the limit). Only available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible. - TableFlagsNoKeepColumnsVisible TableFlags = 1 << 18 // Disable keeping column always minimally visible when ScrollX is off and table gets too small. Not recommended if columns are resizable. - TableFlagsPreciseWidths TableFlags = 1 << 19 // Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth. + + // Make outer width auto-fit to columns, overriding outersize.x value. + // Only available when ScrollX/ScrollY are disabled and Stretch columns are not used. + TableFlagsNoHostExtendX TableFlags = 1 << 16 + // Make outer height stop exactly at outersize.y (prevent auto-extending table past the limit). + // Only available when ScrollX/ScrollY are disabled. + // Data below the limit will be clipped and not visible. + TableFlagsNoHostExtendY TableFlags = 1 << 17 + // Disable keeping column always minimally visible when ScrollX is off and table gets too small. Not recommended if columns are resizable. + TableFlagsNoKeepColumnsVisible TableFlags = 1 << 18 + // Disable distributing remainder width to stretched columns + // (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). + // With larger number of columns, resizing will appear to be less smooth. + TableFlagsPreciseWidths TableFlags = 1 << 19 + // Clipping - TableFlagsNoClip TableFlags = 1 << 20 // Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with TableSetupScrollFreeze(). + + // Disable clipping rectangle for every individual columns (reduce draw command count, + // items will be able to overflow into other columns). Generally incompatible with TableSetupScrollFreeze(). + TableFlagsNoClip TableFlags = 1 << 20 // Padding - TableFlagsPadOuterX TableFlags = 1 << 21 // Default if BordersOuterV is on. Enable outer-most padding. Generally desirable if you have headers. - TableFlagsNoPadOuterX TableFlags = 1 << 22 // Default if BordersOuterV is off. Disable outer-most padding. - TableFlagsNoPadInnerX TableFlags = 1 << 23 // Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off). + + // Default if BordersOuterV is on. Enable outer-most padding. Generally desirable if you have headers. + TableFlagsPadOuterX TableFlags = 1 << 21 + // Default if BordersOuterV is off. Disable outer-most padding. + TableFlagsNoPadOuterX TableFlags = 1 << 22 + // Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off). + TableFlagsNoPadInnerX TableFlags = 1 << 23 + // Scrolling - TableFlagsScrollX TableFlags = 1 << 24 // Enable horizontal scrolling. Require 'outersize' parameter of BeginTable() to specify the container size. Changes default sizing policy. Because this create a child window, ScrollY is currently generally recommended when using ScrollX. - TableFlagsScrollY TableFlags = 1 << 25 // Enable vertical scrolling. Require 'outersize' parameter of BeginTable() to specify the container size. + + // Enable horizontal scrolling. Require 'outersize' parameter of BeginTable() to specify the container size. + // Changes default sizing policy. Because this create a child window, ScrollY is currently generally recommended when using ScrollX. + TableFlagsScrollX TableFlags = 1 << 24 + // Enable vertical scrolling. Require 'outersize' parameter of BeginTable() to specify the container size. + TableFlagsScrollY TableFlags = 1 << 25 // Sorting - TableFlagsSortMulti TableFlags = 1 << 26 // Hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1). - TableFlagsSortTristate TableFlags = 1 << 27 // Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0). + + // Hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1). + TableFlagsSortMulti TableFlags = 1 << 26 + // Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0). + TableFlagsSortTristate TableFlags = 1 << 27 // [Internal] Combinations and masks - TableFlagsSizingMask TableFlags = TableFlagsSizingFixedFit | TableFlagsSizingFixedSame | TableFlagsSizingStretchProp | TableFlagsSizingStretchSame + TableFlagsSizingMask TableFlags = TableFlagsSizingFixedFit | TableFlagsSizingFixedSame | + TableFlagsSizingStretchProp | TableFlagsSizingStretchSame ) type TableRowFlags int const ( - TableRowFlagsNone TableRowFlags = 0 - TableRowFlagsHeaders TableRowFlags = 1 << 0 // Identify header row (set default background color + width of its contents accounted different for auto column width) + TableRowFlagsNone TableRowFlags = 0 + // Identify header row (set default background color + width of its contents accounted different for auto column width) + TableRowFlagsHeaders TableRowFlags = 1 << 0 ) type TableColumnFlags int const ( // Input configuration flags - TableColumnFlagsNone TableColumnFlags = 0 - TableColumnFlagsDefaultHide TableColumnFlags = 1 << 0 // Default as a hidden/disabled column. - TableColumnFlagsDefaultSort TableColumnFlags = 1 << 1 // Default as a sorting column. - TableColumnFlagsWidthStretch TableColumnFlags = 1 << 2 // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is SizingStretchSame or SizingStretchProp). - TableColumnFlagsWidthFixed TableColumnFlags = 1 << 3 // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is SizingFixedFit and table is resizable). - TableColumnFlagsNoResize TableColumnFlags = 1 << 4 // Disable manual resizing. - TableColumnFlagsNoReorder TableColumnFlags = 1 << 5 // Disable manual reordering this column, this will also prevent other columns from crossing over this column. - TableColumnFlagsNoHide TableColumnFlags = 1 << 6 // Disable ability to hide/disable this column. - TableColumnFlagsNoClip TableColumnFlags = 1 << 7 // Disable clipping for this column (all NoClip columns will render in a same draw command). - TableColumnFlagsNoSort TableColumnFlags = 1 << 8 // Disable ability to sort on this field (even if TableFlagsSortable is set on the table). - TableColumnFlagsNoSortAscending TableColumnFlags = 1 << 9 // Disable ability to sort in the ascending direction. - TableColumnFlagsNoSortDescending TableColumnFlags = 1 << 10 // Disable ability to sort in the descending direction. - TableColumnFlagsNoHeaderWidth TableColumnFlags = 1 << 11 // Disable header text width contribution to automatic column width. - TableColumnFlagsPreferSortAscending TableColumnFlags = 1 << 12 // Make the initial sort direction Ascending when first sorting on this column (default). - TableColumnFlagsPreferSortDescending TableColumnFlags = 1 << 13 // Make the initial sort direction Descending when first sorting on this column. - TableColumnFlagsIndentEnable TableColumnFlags = 1 << 14 // Use current Indent value when entering cell (default for column 0). - TableColumnFlagsIndentDisable TableColumnFlags = 1 << 15 // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes within the cell will still be honored. + TableColumnFlagsNone TableColumnFlags = 0 + // Default as a hidden/disabled column. + TableColumnFlagsDefaultHide TableColumnFlags = 1 << 0 + // Default as a sorting column. + TableColumnFlagsDefaultSort TableColumnFlags = 1 << 1 + // Column will stretch. Preferable with horizontal scrolling disabled + // (default if table sizing policy is SizingStretchSame or SizingStretchProp). + TableColumnFlagsWidthStretch TableColumnFlags = 1 << 2 + // Column will not stretch. Preferable with horizontal scrolling enabled + // (default if table sizing policy is SizingFixedFit and table is resizable). + TableColumnFlagsWidthFixed TableColumnFlags = 1 << 3 + // Disable manual resizing. + TableColumnFlagsNoResize TableColumnFlags = 1 << 4 + // Disable manual reordering this column, this will also prevent other columns from crossing over this column. + TableColumnFlagsNoReorder TableColumnFlags = 1 << 5 + // Disable ability to hide/disable this column. + TableColumnFlagsNoHide TableColumnFlags = 1 << 6 + // Disable clipping for this column (all NoClip columns will render in a same draw command). + TableColumnFlagsNoClip TableColumnFlags = 1 << 7 + // Disable ability to sort on this field (even if TableFlagsSortable is set on the table). + TableColumnFlagsNoSort TableColumnFlags = 1 << 8 + // Disable ability to sort in the ascending direction. + TableColumnFlagsNoSortAscending TableColumnFlags = 1 << 9 + // Disable ability to sort in the descending direction. + TableColumnFlagsNoSortDescending TableColumnFlags = 1 << 10 + // Disable header text width contribution to automatic column width. + TableColumnFlagsNoHeaderWidth TableColumnFlags = 1 << 11 + // Make the initial sort direction Ascending when first sorting on this column (default). + TableColumnFlagsPreferSortAscending TableColumnFlags = 1 << 12 + // Make the initial sort direction Descending when first sorting on this column. + TableColumnFlagsPreferSortDescending TableColumnFlags = 1 << 13 + // Use current Indent value when entering cell (default for column 0). + TableColumnFlagsIndentEnable TableColumnFlags = 1 << 14 + // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes within the cell will still be honored. + TableColumnFlagsIndentDisable TableColumnFlags = 1 << 15 // Output status flags read-only via TableGetColumnFlags() - TableColumnFlagsIsEnabled TableColumnFlags = 1 << 20 // Status: is enabled == not hidden by user/api (referred to as "Hide" in DefaultHide and NoHide) flags. - TableColumnFlagsIsVisible TableColumnFlags = 1 << 21 // Status: is visible == is enabled AND not clipped by scrolling. - TableColumnFlagsIsSorted TableColumnFlags = 1 << 22 // Status: is currently part of the sort specs - TableColumnFlagsIsHovered TableColumnFlags = 1 << 23 // Status: is hovered by mouse + // Status: is enabled == not hidden by user/api (referred to as "Hide" in DefaultHide and NoHide) flags. + TableColumnFlagsIsEnabled TableColumnFlags = 1 << 20 + // Status: is visible == is enabled AND not clipped by scrolling. + TableColumnFlagsIsVisible TableColumnFlags = 1 << 21 + // Status: is currently part of the sort specs + TableColumnFlagsIsSorted TableColumnFlags = 1 << 22 + // Status: is hovered by mouse + TableColumnFlagsIsHovered TableColumnFlags = 1 << 23 // [Internal] Combinations and masks - TableColumnFlagsWidthMask TableColumnFlags = TableColumnFlagsWidthStretch | TableColumnFlagsWidthFixed - TableColumnFlagsIndentMask TableColumnFlags = TableColumnFlagsIndentEnable | TableColumnFlagsIndentDisable - TableColumnFlagsStatusMask TableColumnFlags = TableColumnFlagsIsEnabled | TableColumnFlagsIsVisible | TableColumnFlagsIsSorted | TableColumnFlagsIsHovered - TableColumnFlagsNoDirectResize TableColumnFlags = 1 << 30 // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge) + TableColumnFlagsWidthMask TableColumnFlags = TableColumnFlagsWidthStretch | TableColumnFlagsWidthFixed + TableColumnFlagsIndentMask TableColumnFlags = TableColumnFlagsIndentEnable | TableColumnFlagsIndentDisable + TableColumnFlagsStatusMask TableColumnFlags = TableColumnFlagsIsEnabled | + TableColumnFlagsIsVisible | TableColumnFlagsIsSorted | TableColumnFlagsIsHovered + // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge) + TableColumnFlagsNoDirectResize TableColumnFlags = 1 << 30 ) type SliderFlags int const ( - SliderFlagsNone SliderFlags = 0 - SliderFlagsAlwaysClamp SliderFlags = 1 << 4 // Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds. - SliderFlagsLogarithmic SliderFlags = 1 << 5 // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlagsNoRoundToFormat with this if using a format-string with small amount of digits. - SliderFlagsNoRoundToFormat SliderFlags = 1 << 6 // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits) - SliderFlagsNoInput SliderFlags = 1 << 7 // Disable CTRL+Click or Enter key allowing to input text directly into the widget - SliderFlagsInvalidMask SliderFlags = 0x7000000F // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed. + SliderFlagsNone SliderFlags = 0 + // Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds. + SliderFlagsAlwaysClamp SliderFlags = 1 << 4 + // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlagsNoRoundToFormat with this if using + // a format-string with small amount of digits. + SliderFlagsLogarithmic SliderFlags = 1 << 5 + // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits) + SliderFlagsNoRoundToFormat SliderFlags = 1 << 6 + // Disable CTRL+Click or Enter key allowing to input text directly into the widget + SliderFlagsNoInput SliderFlags = 1 << 7 + // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast + // to this enum, and will trigger an assert if needed. + SliderFlagsInvalidMask SliderFlags = 0x7000000F ) type PlotFlags int const ( - PlotFlagsNone PlotFlags = 0 // default - PlotFlagsNoTitle PlotFlags = 1 << 0 // the plot title will not be displayed (titles are also hidden if preceded by double hashes, e.g. "##MyPlot") - PlotFlagsNoLegend PlotFlags = 1 << 1 // the legend will not be displayed - PlotFlagsNoMenus PlotFlags = 1 << 2 // the user will not be able to open context menus with right-click - PlotFlagsNoBoxSelect PlotFlags = 1 << 3 // the user will not be able to box-select with right-click drag - PlotFlagsNoMousePos PlotFlags = 1 << 4 // the mouse position, in plot coordinates, will not be displayed inside of the plot - PlotFlagsNoHighlight PlotFlags = 1 << 5 // plot items will not be highlighted when their legend entry is hovered - PlotFlagsNoChild PlotFlags = 1 << 6 // a child window region will not be used to capture mouse scroll (can boost performance for single Gui window applications) - PlotFlagsEqual PlotFlags = 1 << 7 // primary x and y axes will be constrained to have the same units/pixel (does not apply to auxiliary y-axes) - PlotFlagsYAxis2 PlotFlags = 1 << 8 // enable a 2nd y-axis on the right side - PlotFlagsYAxis3 PlotFlags = 1 << 9 // enable a 3rd y-axis on the right side - PlotFlagsQuery PlotFlags = 1 << 10 // the user will be able to draw query rects with middle-mouse or CTRL + right-click drag - PlotFlagsCrosshairs PlotFlags = 1 << 11 // the default mouse cursor will be replaced with a crosshair when hovered - PlotFlagsAntiAliased PlotFlags = 1 << 12 // plot lines will be software anti-aliased (not recommended for high density plots, prefer MSAA) + // default + PlotFlagsNone PlotFlags = 0 + // the plot title will not be displayed (titles are also hidden if preceded by double hashes, e.g. "##MyPlot") + PlotFlagsNoTitle PlotFlags = 1 << 0 + // the legend will not be displayed + PlotFlagsNoLegend PlotFlags = 1 << 1 + // the user will not be able to open context menus with right-click + PlotFlagsNoMenus PlotFlags = 1 << 2 + // the user will not be able to box-select with right-click drag + PlotFlagsNoBoxSelect PlotFlags = 1 << 3 + // the mouse position, in plot coordinates, will not be displayed inside of the plot + PlotFlagsNoMousePos PlotFlags = 1 << 4 + // plot items will not be highlighted when their legend entry is hovered + PlotFlagsNoHighlight PlotFlags = 1 << 5 + // a child window region will not be used to capture mouse scroll (can boost performance for single Gui window applications) + PlotFlagsNoChild PlotFlags = 1 << 6 + // primary x and y axes will be constrained to have the same units/pixel (does not apply to auxiliary y-axes) + PlotFlagsEqual PlotFlags = 1 << 7 + // enable a 2nd y-axis on the right side + PlotFlagsYAxis2 PlotFlags = 1 << 8 + // enable a 3rd y-axis on the right side + PlotFlagsYAxis3 PlotFlags = 1 << 9 + // the user will be able to draw query rects with middle-mouse or CTRL + right-click drag + PlotFlagsQuery PlotFlags = 1 << 10 + // the default mouse cursor will be replaced with a crosshair when hovered + PlotFlagsCrosshairs PlotFlags = 1 << 11 + // plot lines will be software anti-aliased (not recommended for high density plots, prefer MSAA) + PlotFlagsAntiAliased PlotFlags = 1 << 12 PlotFlagsCanvasOnly PlotFlags = PlotFlagsNoTitle | PlotFlagsNoLegend | PlotFlagsNoMenus | PlotFlagsNoBoxSelect | PlotFlagsNoMousePos ) type PlotAxisFlags int const ( - PlotAxisFlagsNone PlotAxisFlags = 0 // default - PlotAxisFlagsNoLabel PlotAxisFlags = 1 << 0 // the axis label will not be displayed (axis labels also hidden if the supplied string name is NULL) - PlotAxisFlagsNoGridLines PlotAxisFlags = 1 << 1 // the axis grid lines will not be displayed - PlotAxisFlagsNoTickMarks PlotAxisFlags = 1 << 2 // the axis tick marks will not be displayed - PlotAxisFlagsNoTickLabels PlotAxisFlags = 1 << 3 // the axis tick labels will not be displayed - PlotAxisFlagsLogScale PlotAxisFlags = 1 << 4 // a logartithmic (base 10) axis scale will be used (mutually exclusive with PlotAxisFlagsTime) - PlotAxisFlagsTime PlotAxisFlags = 1 << 5 // axis will display date/time formatted labels (mutually exclusive with PlotAxisFlagsLogScale) - PlotAxisFlagsInvert PlotAxisFlags = 1 << 6 // the axis will be inverted - PlotAxisFlagsLockMin PlotAxisFlags = 1 << 7 // the axis minimum value will be locked when panning/zooming - PlotAxisFlagsLockMax PlotAxisFlags = 1 << 8 // the axis maximum value will be locked when panning/zooming + // default + PlotAxisFlagsNone PlotAxisFlags = 0 + // the axis label will not be displayed (axis labels also hidden if the supplied string name is NULL) + PlotAxisFlagsNoLabel PlotAxisFlags = 1 << 0 + // the axis grid lines will not be displayed + PlotAxisFlagsNoGridLines PlotAxisFlags = 1 << 1 + // the axis tick marks will not be displayed + PlotAxisFlagsNoTickMarks PlotAxisFlags = 1 << 2 + // the axis tick labels will not be displayed + PlotAxisFlagsNoTickLabels PlotAxisFlags = 1 << 3 + // a logartithmic (base 10) axis scale will be used (mutually exclusive with PlotAxisFlagsTime) + PlotAxisFlagsLogScale PlotAxisFlags = 1 << 4 + // axis will display date/time formatted labels (mutually exclusive with PlotAxisFlagsLogScale) + PlotAxisFlagsTime PlotAxisFlags = 1 << 5 + // the axis will be inverted + PlotAxisFlagsInvert PlotAxisFlags = 1 << 6 + // the axis minimum value will be locked when panning/zooming + PlotAxisFlagsLockMin PlotAxisFlags = 1 << 7 + // the axis maximum value will be locked when panning/zooming + PlotAxisFlagsLockMax PlotAxisFlags = 1 << 8 PlotAxisFlagsLock PlotAxisFlags = PlotAxisFlagsLockMin | PlotAxisFlagsLockMax - PlotAxisFlagsNoDecorations PlotAxisFlags = PlotAxisFlagsNoLabel | PlotAxisFlagsNoGridLines | PlotAxisFlagsNoTickMarks | PlotAxisFlagsNoTickLabels + PlotAxisFlagsNoDecorations PlotAxisFlags = PlotAxisFlagsNoLabel | PlotAxisFlagsNoGridLines | + PlotAxisFlagsNoTickMarks | PlotAxisFlagsNoTickLabels ) diff --git a/Plot.go b/Plot.go index ea492759..286f7b91 100644 --- a/Plot.go +++ b/Plot.go @@ -175,7 +175,13 @@ func (p *PlotCanvasWidget) Build() { imgui.ImPlotSetNextPlotTicksY(p.yTicksValue, p.yTicksLabel, p.yTicksShowDefault, int(p.yTicksYAxis)) } - if imgui.ImPlotBegin(tStr(p.title), tStr(p.xLabel), tStr(p.yLabel), ToVec2(image.Pt(p.width, p.height)), imgui.ImPlotFlags(p.flags), imgui.ImPlotAxisFlags(p.xFlags), imgui.ImPlotAxisFlags(p.yFlags), imgui.ImPlotAxisFlags(p.y2Flags), imgui.ImPlotAxisFlags(p.y3Flags), tStr(p.y2Label), tStr(p.y3Label)) { + if imgui.ImPlotBegin( + tStr(p.title), tStr(p.xLabel), + tStr(p.yLabel), ToVec2(image.Pt(p.width, p.height)), + imgui.ImPlotFlags(p.flags), imgui.ImPlotAxisFlags(p.xFlags), + imgui.ImPlotAxisFlags(p.yFlags), imgui.ImPlotAxisFlags(p.y2Flags), + imgui.ImPlotAxisFlags(p.y3Flags), tStr(p.y2Label), tStr(p.y3Label), + ) { for _, plot := range p.plots { plot.Plot() } diff --git a/Utils.go b/Utils.go index 8c26cea9..4d8317a8 100644 --- a/Utils.go +++ b/Utils.go @@ -56,7 +56,7 @@ func ToVec2(pt image.Point) imgui.Vec2 { } } -// Vec4ToRgba converts imgui's Vec4 to golang rgba color +// Vec4ToRGBA converts imgui's Vec4 to golang rgba color func Vec4ToRGBA(vec4 imgui.Vec4) color.RGBA { return color.RGBA{ R: uint8(vec4.X * 255), @@ -145,7 +145,13 @@ func SetNextWindowPos(x, y float32) { // SetNextWindowSizeV does similar to SetNextWIndowSize but allows to specify imgui.Condition func SetNextWindowSizeV(width, height float32, condition ExecCondition) { - imgui.SetNextWindowSizeV(imgui.Vec2{X: width * Context.platform.GetContentScale(), Y: height * Context.platform.GetContentScale()}, imgui.Condition(condition)) + imgui.SetNextWindowSizeV( + imgui.Vec2{ + X: width * Context.platform.GetContentScale(), + Y: height * Context.platform.GetContentScale(), + }, + imgui.Condition(condition), + ) } // SetItemDefaultFocus set the item focused by default diff --git a/Widgets.go b/Widgets.go index e595c017..9893c9e8 100644 --- a/Widgets.go +++ b/Widgets.go @@ -985,7 +985,7 @@ func ImageWithURL(url string) *ImageWithURLWidget { } } -// Event trigger when image is downloaded and ready to display. +// OnReady sets event trigger when image is downloaded and ready to display. func (i *ImageWithURLWidget) OnReady(onReady func()) *ImageWithURLWidget { i.onReady = onReady return i @@ -1132,7 +1132,7 @@ func (i *InputTextWidget) Labelf(format string, args ...interface{}) *InputTextW return i.Label(fmt.Sprintf(format, args...)) } -// Enable auto complete popup by using fuzzy search of current value against candidates +// AutoComplete enables auto complete popup by using fuzzy search of current value against candidates // Press enter to confirm the first candidate func (i *InputTextWidget) AutoComplete(candidates []string) *InputTextWidget { i.candidates = candidates @@ -1684,7 +1684,7 @@ func (s *SelectableWidget) OnClick(onClick func()) *SelectableWidget { return s } -// Handle mouse left button's double click event. +// OnDClick handles mouse left button's double click event. // SelectableFlagsAllowDoubleClick will set once tonDClick callback is notnull func (s *SelectableWidget) OnDClick(onDClick func()) *SelectableWidget { s.onDClick = onDClick @@ -2298,7 +2298,7 @@ func Table() *TableWidget { } } -// Display visible rows only to boost performance. +// FastMode Displays visible rows only to boost performance. func (t *TableWidget) FastMode(b bool) *TableWidget { t.fastMode = b return t @@ -2581,7 +2581,7 @@ func (t *TreeNodeWidget) Flags(flags TreeNodeFlags) *TreeNodeWidget { return t } -// Create TreeNode with eventHandler +// Event create TreeNode with eventHandler // You could detect events (e.g. IsItemClicked IsMouseDoubleClicked etc...) and handle them for TreeNode inside eventHandler func (t *TreeNodeWidget) Event(handler func()) *TreeNodeWidget { t.eventHandler = handler @@ -2670,7 +2670,7 @@ func (c *ConditionWidget) Build() { } } -// Batch create widgets and render only which is visible. +// RangeBuilder batch create widgets and render only which is visible. func RangeBuilder(id string, values []interface{}, builder func(int, interface{}) Widget) Layout { var layout Layout diff --git a/Window.go b/Window.go index 9787bb9f..e54ac2c4 100644 --- a/Window.go +++ b/Window.go @@ -164,7 +164,7 @@ func (w *WindowWidget) HasFocus() bool { return w.getState().hasFocus } -// Registerkeyboardshortcuts adds local (window-level) keyboard shortcuts +// RegisterKeyboardShortcuts adds local (window-level) keyboard shortcuts // see InputHandler.go func (w *WindowWidget) RegisterKeyboardShortcuts(s ...WindowShortcut) *WindowWidget { if w.HasFocus() {