raygui icon indicating copy to clipboard operation
raygui copied to clipboard

`GuiTabBar()` is very limiting as a lot of its default values and behavior is hard-coded

Open sleeptightAnsiC opened this issue 9 months ago • 6 comments

The usage of GuiTabBar() is very limited because its implementation makes a lot of assumptions and hard-codes many default values.

Examples:

  1. the width of every entry is hard-coded to 160 https://github.com/raysan5/raygui/blob/e4a59f0afa6a379007a74b0c565c2787525eda36/src/raygui.h#L1738
  2. each entry can be clicked in order to close TabBar, this also draws additional button in top-right corner of every entry https://github.com/raysan5/raygui/blob/e4a59f0afa6a379007a74b0c565c2787525eda36/src/raygui.h#L1780-L1781
  3. each entry appears with hard-coded icon at the beginning https://github.com/raysan5/raygui/blob/e4a59f0afa6a379007a74b0c565c2787525eda36/src/raygui.h#L1795

@raysan5 Would it be fine, if I create a PR with more flexible version of this function (e.g. GuiTabBarEx ) ?

sleeptightAnsiC avatar Feb 15 '25 22:02 sleeptightAnsiC

The usage of GuiTabBar() is very limited because its implementation makes a lot of assumptions and hard-codes many default values.

Examples:

  1. the width of every entry is hard-coded to 160 https://github.com/raysan5/raygui/blob/e4a59f0afa6a379007a74b0c565c2787525eda36/src/raygui.h#L1738
  2. each entry can be clicked in order to close TabBar, this also draws additional button in top-right corner of every entry https://github.com/raysan5/raygui/blob/e4a59f0afa6a379007a74b0c565c2787525eda36/src/raygui.h#L1780-L1781
  3. each entry appears with hard-coded icon at the beginning https://github.com/raysan5/raygui/blob/e4a59f0afa6a379007a74b0c565c2787525eda36/src/raygui.h#L1795

@raysan5 Would it be fine, if I create a PR with more flexible version of this function (e.g. GuiTabBarEx ) ?

Hi

mk99987 avatar Feb 22 '25 15:02 mk99987

Hi

@mk99987 ?

sleeptightAnsiC avatar Feb 22 '25 17:02 sleeptightAnsiC

Do u know how to increase the text font size in the input field using the GuiTextBox? Please help me. Is the font size fixed in the input field?

mk99987 avatar Feb 22 '25 17:02 mk99987

@sleeptightAnsiC GuiTabBar() was quickly added for convenience for one of my tools and I'm aware it's not much flexible at the moment.

1.the width of every entry is hard-coded to 160

It can be added a check to allow being redefined by user, like so other advance-controls do.

  1. each entry can be clicked in order to close TabBar, this also draws additional button in top-right corner of every entry
  2. each entry appears with hard-coded icon at the beginning

Yes, added for convenience, maybe some define can be added to avoid that close button if not required, I got inspiration from Notepad++ tabs system.

@raysan5 Would it be fine, if I create a PR with more flexible version of this function (e.g. GuiTabBarEx ) ?

I prefer to minimize/avoid Gui*Ex() versions, if it can be addressed with some config-defines on GuiTabBar() directly, I prefer that approach. Afaik, most tools won't need multiple separate versions of GuiTabBar().

raysan5 avatar Feb 26 '25 21:02 raysan5

I prefer to minimize/avoid Gui*Ex() versions, if it can be addressed with some config-defines on GuiTabBar() directly

Makes sense.

I'm not very comfortable with global styles yet, but GuiTabBar seems to be hijacking properties from TOGGLE and BUTTON controls. I don't really see anything that could be reused for those cases I mentioned at the moment.

Note: the best "documentation" on styling is probably...

...here

https://github.com/raysan5/raygui/blob/b19a0168fa2fbb4e39aafbc38f2ea47f32872bd7/src/raygui.h#L466-L675 https://github.com/raysan5/raygui/blob/b19a0168fa2fbb4e39aafbc38f2ea47f32872bd7/src/raygui.h#L4292-L4393

sleeptightAnsiC avatar Feb 26 '25 23:02 sleeptightAnsiC

@mk99987 I'll answer your question since I'm already reading this, but I will ignore any other comments not related to TabBar issue. This is not a support forum and your question is not related to this issue. Ask on Raylib's discord/reddit for general help. Please, after reading this, hide your comments as "Off-Topic" just like I did (by clicking ... next to the comment).

Do u know how to increase the text font size in the input field using the GuiTextBox? Please help me. Is the font size fixed in the input field?

I believe, this is affected by global styling values: DEFAULT TEXT_SIZE. Try using GuiSetStyle(DEFAULT, TEXT_SIZE, 100) right before you call GuiTextBox(). Maybe there is another property I could not find.

sleeptightAnsiC avatar Feb 26 '25 23:02 sleeptightAnsiC