Comments (6)
This is pretty much what I have for the current POC.
I'm sure it's flawed, but I'm still fairly new to nuklear
.
// Temporarily use rand for some colours later
#define RandomI32(min, max) ((min) + ((max) - (min)) * ((double)rand() / INT32_MAX) + 0.5)
srand(0xdeadbeef);
struct nk_command_buffer *out = nk_window_get_canvas(ctx);
struct nk_rect bounds;
struct nk_style_window old_style = ctx->style.window;
// Make layout easier to work with
// TODO: Account for spacing/padding when using nk_layout_space_xxx ?
ctx->style.window.spacing = nk_vec2(0, 0);
ctx->style.window.group_padding = nk_vec2(0, 0);
u32 card_count = 3;
for (u32 i = 0; i < card_count; i++) {
// TODO: How to colour the area defined here
// Rounded rect would be nice probably
nk_layout_space_begin(ctx, NK_STATIC, 70, 3);
nk_layout_space_push(ctx, nk_rect(0, 0, 60, 60));
if (nk_group_begin(ctx, "item image", NK_WINDOW_BORDER|NK_WINDOW_NO_SCROLLBAR)) {
// For some reason this still needs to be smaller than the space pushed above
// else the circle will get clipped; how much smaller exactly, I'm not yet sure
nk_layout_row_static(ctx, 55, 55, 1);
nk_widget(&bounds, ctx);
nk_fill_circle(out, bounds,
nk_rgb(RandomI32(0, 255), RandomI32(0, 255), RandomI32(0, 255)));
nk_group_end(ctx);
}
nk_layout_space_push(ctx, nk_rect(70, 0, 180, 60));
if (nk_group_begin(ctx, "item detail", NK_WINDOW_BORDER|NK_WINDOW_NO_SCROLLBAR)) {
nk_layout_row_static(ctx, 20, 180, 1);
nk_label(ctx, "Foo", NK_TEXT_LEFT);
nk_label(ctx, "Bar", NK_TEXT_LEFT);
nk_label(ctx, "Baz", NK_TEXT_LEFT);
nk_group_end(ctx);
}
nk_layout_space_end(ctx);
}
ctx->style.window = old_style;
from nuklear.
Would love to have some cards implemented 👍
from nuklear.
I've forked and started to test the idea.
https://github.com/bolt-blue/Nuklear/tree/feat/card
Would love some advice as I don't know the code base well enough to know if I'm making the "best" decisions.
I've based a new nk_card_begin
on nk_group_scrolled_offset_begin
.
It's effectively a limited version, with the addition of a background coloured rectangle that can be rounded.
I figured the general usage for a card might mostly match that of a nk_group_***
, at least in that it would be nice to be able to nest group(s) inside it.
Is this a good direction?
Is the use of NK_WINDOW_DYNAMIC
reasonable? In my exploration, I've noticed some comment that it's deprecated.
I used it because my original layout test involved nk_group_
.
Using groups inside a card requires the group to also be flagged with NK_WINDOW_DYNAMIC
in order to take on the background colour as well.
Other comments in the code describe some of my thoughts and concerns.
I'm definitely open to suggestions.
I'd be happy if nk_card_
did more manual drawing if that would help, but I think the hurdle I see is how to handle groups.
Originally, I wondered if I could base the code solely on nk_button_
but I believe it would be insufficient for typical card use cases.
from nuklear.
Specifically, there's only one commit at the moment to show the basic idea.
bolt-blue@a142456
from nuklear.
Added an example/demo to my fork.
See https://github.com/bolt-blue/Nuklear/tree/feat/card.
$ cd example
$ make card
$ cd bin && ./card
If anyone has thoughts, opinions, criticism, suggestions, I'd be grateful to hear them.
It's doing pretty much all that I want from it at the moment, though there are definitely improvements to be made.
Just hoping I can get some second opinions from those more experienced than I.
from nuklear.
This is what the demo looks like. It's the first basic example that came to mind, but given that nk_card
is built on groups, a card can be many things.
As long as it doesn't need scrolling.
from nuklear.
Related Issues (20)
- Two Issues with Fonts
- Inconsistent grabbing behavior in demos (click and drag property) HOT 8
- Build help with Allegro5 MinGW-64(TDM-Posix-SEH) HOT 2
- Demo headers and nk_ and design choices, oh my! HOT 6
- Backspace does not actually clear a buffer when using nk_edit_string HOT 1
- File Menu HOT 6
- Request: create example for showcasing integration with RGFW HOT 2
- How to make own title bar, without using the operating systems HOT 3
- Group margins/alignment Ubuntu HOT 3
- Demo doesn't include code on how to display images without OpenGL. HOT 1
- After set an opened Combo Box to invisible, no response from the entire window.
- How to do multiple render with one update HOT 2
- Events not working with multiple Nuklear windows
- Add `delta_time_seconds` to each renderer
- Multiple window instances HOT 2
- Inputs propagating to windows in background
- No documentation explaining how to convert an nk_rune to a char. HOT 1
- Fragment shader used in the GLFW GL4 wrapper doesn't compile
- Getting some strange text clipping behavior when dragging windows around.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuklear.