GithubHelp home page GithubHelp logo

Comments (4)

AndyObtiva avatar AndyObtiva commented on June 15, 2024

OK, nevermind. I figured it out by typing in the following:

@model_handler.ColumnType   = rbcallback(4, [1, 1, 4]) do |_, _, column|
  # return value based on column

from libui.

kojix2 avatar kojix2 commented on June 15, 2024

Hi Andy!

Test page16.c in andlabs/libui is a good reference on how to use the table.
The executables for these tests can be downloaded from the release page.
(Also, issue #310 shows what andlabs and others had in mind when they designed libui table.)

page16.c screenshot
image

Here, they use if statements to set the type of each column.

https://github.com/andlabs/libui/blob/fea45b2d5b75839be0af9acc842a147c5cba9295/test/page16.c#L11-L20

static uiTableValueType modelColumnType(uiTableModelHandler *mh, uiTableModel *m, int column)
{
	if (column == 3 || column == 4)
		return uiTableValueTypeColor;
	if (column == 5)
		return uiTableValueTypeImage;
	if (column == 7 || column == 8)
		return uiTableValueTypeInt;
	return uiTableValueTypeString;
}
mh.ColumnType = modelColumnType;

In Ruby, it would be something like this:

model_handler.ColumnType = rbcallback(4, [1, 1, 4]) do | _mh, _m, column|
  case column
  when 3, 4
    3
  when 5
    1
  when 7, 8
    2
  else
    0
  end
end 

All column types can be referenced from here.

https://github.com/andlabs/libui/blob/fea45b2d5b75839be0af9acc842a147c5cba9295/ui.h#L1199-L1204

_UI_ENUM(uiTableValueType) {
	uiTableValueTypeString,
	uiTableValueTypeImage,
	uiTableValueTypeInt,
	uiTableValueTypeColor,
};

Currently, there is no way to reference uiTableValueType in Ruby's LibUI, so it might be better to define constants.

Thank you!


           ↓
rbcallback(4, [1, 1, 4])

uiTableValueType is an enumeration type. In fiddle, enumeration constants are fine with 4 (int).
This may not be documented. I asked the developer of fiddle directly in the online forum.

from libui.

kojix2 avatar kojix2 commented on June 15, 2024

I see you have resolved the issue.

from libui.

AndyObtiva avatar AndyObtiva commented on June 15, 2024

Thanks a lot for the response. I did need to figure out the numbers to return for each column type, so this is very helpful.

from libui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.