org.lwjgl.nuklear.NkRect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lwjgl-nuklear Show documentation
Show all versions of lwjgl-nuklear Show documentation
A minimal state immediate mode graphical user interface toolkit.
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
* MACHINE GENERATED FILE, DO NOT EDIT
*/
package org.lwjgl.nuklear;
import javax.annotation.*;
import java.nio.*;
import org.lwjgl.*;
import org.lwjgl.system.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.MemoryStack.*;
/**
* Layout
*
*
* struct nk_rect {
* float x;
* float y;
* float w;
* float h;
* }
*/
@NativeType("struct nk_rect")
public class NkRect extends Struct implements NativeResource {
/** The struct size in bytes. */
public static final int SIZEOF;
/** The struct alignment in bytes. */
public static final int ALIGNOF;
/** The struct member offsets. */
public static final int
X,
Y,
W,
H;
static {
Layout layout = __struct(
__member(4),
__member(4),
__member(4),
__member(4)
);
SIZEOF = layout.getSize();
ALIGNOF = layout.getAlignment();
X = layout.offsetof(0);
Y = layout.offsetof(1);
W = layout.offsetof(2);
H = layout.offsetof(3);
}
/**
* Creates a {@code NkRect} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be
* visible to the struct instance and vice versa.
*
* The created instance holds a strong reference to the container object.
*/
public NkRect(ByteBuffer container) {
super(memAddress(container), __checkContainer(container, SIZEOF));
}
@Override
public int sizeof() { return SIZEOF; }
/** @return the value of the {@code x} field. */
public float x() { return nx(address()); }
/** @return the value of the {@code y} field. */
public float y() { return ny(address()); }
/** @return the value of the {@code w} field. */
public float w() { return nw(address()); }
/** @return the value of the {@code h} field. */
public float h() { return nh(address()); }
/** Sets the specified value to the {@code x} field. */
public NkRect x(float value) { nx(address(), value); return this; }
/** Sets the specified value to the {@code y} field. */
public NkRect y(float value) { ny(address(), value); return this; }
/** Sets the specified value to the {@code w} field. */
public NkRect w(float value) { nw(address(), value); return this; }
/** Sets the specified value to the {@code h} field. */
public NkRect h(float value) { nh(address(), value); return this; }
/** Initializes this struct with the specified values. */
public NkRect set(
float x,
float y,
float w,
float h
) {
x(x);
y(y);
w(w);
h(h);
return this;
}
/**
* Copies the specified struct data to this struct.
*
* @param src the source struct
*
* @return this struct
*/
public NkRect set(NkRect src) {
memCopy(src.address(), address(), SIZEOF);
return this;
}
// -----------------------------------
/** Returns a new {@code NkRect} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
public static NkRect malloc() {
return wrap(NkRect.class, nmemAllocChecked(SIZEOF));
}
/** Returns a new {@code NkRect} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
public static NkRect calloc() {
return wrap(NkRect.class, nmemCallocChecked(1, SIZEOF));
}
/** Returns a new {@code NkRect} instance allocated with {@link BufferUtils}. */
public static NkRect create() {
ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
return wrap(NkRect.class, memAddress(container), container);
}
/** Returns a new {@code NkRect} instance for the specified memory address. */
public static NkRect create(long address) {
return wrap(NkRect.class, address);
}
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static NkRect createSafe(long address) {
return address == NULL ? null : wrap(NkRect.class, address);
}
/**
* Returns a new {@link NkRect.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static NkRect.Buffer malloc(int capacity) {
return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
}
/**
* Returns a new {@link NkRect.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
*
* @param capacity the buffer capacity
*/
public static NkRect.Buffer calloc(int capacity) {
return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity);
}
/**
* Returns a new {@link NkRect.Buffer} instance allocated with {@link BufferUtils}.
*
* @param capacity the buffer capacity
*/
public static NkRect.Buffer create(int capacity) {
ByteBuffer container = __create(capacity, SIZEOF);
return wrap(Buffer.class, memAddress(container), capacity, container);
}
/**
* Create a {@link NkRect.Buffer} instance at the specified memory.
*
* @param address the memory address
* @param capacity the buffer capacity
*/
public static NkRect.Buffer create(long address, int capacity) {
return wrap(Buffer.class, address, capacity);
}
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
@Nullable
public static NkRect.Buffer createSafe(long address, int capacity) {
return address == NULL ? null : wrap(Buffer.class, address, capacity);
}
// -----------------------------------
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static NkRect mallocStack() { return malloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static NkRect callocStack() { return calloc(stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
@Deprecated public static NkRect mallocStack(MemoryStack stack) { return malloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
@Deprecated public static NkRect callocStack(MemoryStack stack) { return calloc(stack); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static NkRect.Buffer mallocStack(int capacity) { return malloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static NkRect.Buffer callocStack(int capacity) { return calloc(capacity, stackGet()); }
/** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
@Deprecated public static NkRect.Buffer mallocStack(int capacity, MemoryStack stack) { return malloc(capacity, stack); }
/** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
@Deprecated public static NkRect.Buffer callocStack(int capacity, MemoryStack stack) { return calloc(capacity, stack); }
/**
* Returns a new {@code NkRect} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static NkRect malloc(MemoryStack stack) {
return wrap(NkRect.class, stack.nmalloc(ALIGNOF, SIZEOF));
}
/**
* Returns a new {@code NkRect} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static NkRect calloc(MemoryStack stack) {
return wrap(NkRect.class, stack.ncalloc(ALIGNOF, 1, SIZEOF));
}
/**
* Returns a new {@link NkRect.Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static NkRect.Buffer malloc(int capacity, MemoryStack stack) {
return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link NkRect.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static NkRect.Buffer calloc(int capacity, MemoryStack stack) {
return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// -----------------------------------
/** Unsafe version of {@link #x}. */
public static float nx(long struct) { return UNSAFE.getFloat(null, struct + NkRect.X); }
/** Unsafe version of {@link #y}. */
public static float ny(long struct) { return UNSAFE.getFloat(null, struct + NkRect.Y); }
/** Unsafe version of {@link #w}. */
public static float nw(long struct) { return UNSAFE.getFloat(null, struct + NkRect.W); }
/** Unsafe version of {@link #h}. */
public static float nh(long struct) { return UNSAFE.getFloat(null, struct + NkRect.H); }
/** Unsafe version of {@link #x(float) x}. */
public static void nx(long struct, float value) { UNSAFE.putFloat(null, struct + NkRect.X, value); }
/** Unsafe version of {@link #y(float) y}. */
public static void ny(long struct, float value) { UNSAFE.putFloat(null, struct + NkRect.Y, value); }
/** Unsafe version of {@link #w(float) w}. */
public static void nw(long struct, float value) { UNSAFE.putFloat(null, struct + NkRect.W, value); }
/** Unsafe version of {@link #h(float) h}. */
public static void nh(long struct, float value) { UNSAFE.putFloat(null, struct + NkRect.H, value); }
// -----------------------------------
/** An array of {@link NkRect} structs. */
public static class Buffer extends StructBuffer implements NativeResource {
private static final NkRect ELEMENT_FACTORY = NkRect.create(-1L);
/**
* Creates a new {@code NkRect.Buffer} instance backed by the specified container.
*
* Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values
* will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided
* by {@link NkRect#SIZEOF}, and its mark will be undefined.
*
* The created buffer instance holds a strong reference to the container object.
*/
public Buffer(ByteBuffer container) {
super(container, container.remaining() / SIZEOF);
}
public Buffer(long address, int cap) {
super(address, null, -1, 0, cap, cap);
}
Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
super(address, container, mark, pos, lim, cap);
}
@Override
protected Buffer self() {
return this;
}
@Override
protected NkRect getElementFactory() {
return ELEMENT_FACTORY;
}
/** @return the value of the {@code x} field. */
public float x() { return NkRect.nx(address()); }
/** @return the value of the {@code y} field. */
public float y() { return NkRect.ny(address()); }
/** @return the value of the {@code w} field. */
public float w() { return NkRect.nw(address()); }
/** @return the value of the {@code h} field. */
public float h() { return NkRect.nh(address()); }
/** Sets the specified value to the {@code x} field. */
public NkRect.Buffer x(float value) { NkRect.nx(address(), value); return this; }
/** Sets the specified value to the {@code y} field. */
public NkRect.Buffer y(float value) { NkRect.ny(address(), value); return this; }
/** Sets the specified value to the {@code w} field. */
public NkRect.Buffer w(float value) { NkRect.nw(address(), value); return this; }
/** Sets the specified value to the {@code h} field. */
public NkRect.Buffer h(float value) { NkRect.nh(address(), value); return this; }
}
}