@@ -143,31 +143,45 @@ style_button(struct nk_context* ctx, struct nk_style_button* out_style, struct n
143143 style_vec2 (ctx , "Image Padding:" , & button .image_padding );
144144 style_vec2 (ctx , "Touch Padding:" , & button .touch_padding );
145145
146- /*
147- enum nk_text_align {
148- NK_TEXT_ALIGN_LEFT = 0x01,
149- NK_TEXT_ALIGN_CENTERED = 0x02,
150- NK_TEXT_ALIGN_RIGHT = 0x04,
151- NK_TEXT_ALIGN_TOP = 0x08,
152- NK_TEXT_ALIGN_MIDDLE = 0x10,
153- NK_TEXT_ALIGN_BOTTOM = 0x20
146+ const char * alignments [] =
147+ {
148+ "LEFT" ,
149+ "CENTERED" ,
150+ "RIGHT" ,
151+ "TOP LEFT" ,
152+ "TOP CENTERED" ,
153+ "TOP_RIGHT" ,
154+ "BOTTOM LEFT" ,
155+ "BOTTOM CENTERED" ,
156+ "BOTTOM RIGHT"
154157};
155- enum nk_text_alignment {
156- NK_TEXT_LEFT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT,
157- NK_TEXT_CENTERED = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED,
158- NK_TEXT_RIGHT = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT
158+
159+ #define TOP_LEFT NK_TEXT_ALIGN_TOP|NK_TEXT_ALIGN_LEFT
160+ #define TOP_CENTER NK_TEXT_ALIGN_TOP|NK_TEXT_ALIGN_CENTERED
161+ #define TOP_RIGHT NK_TEXT_ALIGN_TOP|NK_TEXT_ALIGN_RIGHT
162+ #define BOTTOM_LEFT NK_TEXT_ALIGN_BOTTOM|NK_TEXT_ALIGN_LEFT
163+ #define BOTTOM_CENTER NK_TEXT_ALIGN_BOTTOM|NK_TEXT_ALIGN_CENTERED
164+ #define BOTTOM_RIGHT NK_TEXT_ALIGN_BOTTOM|NK_TEXT_ALIGN_RIGHT
165+
166+ int aligns [] =
167+ {
168+ NK_TEXT_LEFT ,
169+ NK_TEXT_CENTERED ,
170+ NK_TEXT_RIGHT ,
171+ TOP_LEFT ,
172+ TOP_CENTER ,
173+ TOP_RIGHT ,
174+ BOTTOM_LEFT ,
175+ BOTTOM_CENTER ,
176+ BOTTOM_RIGHT
159177};
160- */
161- // TODO support combining with TOP/MIDDLE/BOTTOM .. separate combo?
162- const char * alignments [] = { "LEFT" , "CENTERED" , "RIGHT" };
163- int aligns [3 ] = { NK_TEXT_LEFT , NK_TEXT_CENTERED , NK_TEXT_RIGHT };
178+
164179 int cur_align ;
165- if (button .text_alignment == NK_TEXT_LEFT ) {
166- cur_align = 0 ;
167- } else if (button .text_alignment == NK_TEXT_CENTERED ) {
168- cur_align = 1 ;
169- } else {
170- cur_align = 2 ;
180+ for (int i = 0 ; i < NK_LEN (aligns ); ++ i ) {
181+ if (button .text_alignment == aligns [i ]) {
182+ cur_align = i ;
183+ break ;
184+ }
171185 }
172186 nk_label (ctx , "Text Alignment:" , NK_TEXT_LEFT );
173187 cur_align = nk_combo (ctx , alignments , NK_LEN (alignments ), cur_align , 25 , nk_vec2 (200 ,200 ));
@@ -363,7 +377,6 @@ style_scrollbars(struct nk_context* ctx, struct nk_style_scrollbar* out_style, s
363377
364378 //nk_layout_row_dynamic(ctx, 30, 1);
365379 if (nk_tree_push (ctx , NK_TREE_TAB , "Scrollbar Buttons" , NK_MINIMIZED )) {
366- // TODO best way to handle correctly with duplicate styles
367380 struct nk_style_button * dups [3 ] = { & ctx -> style .scrollh .dec_button ,
368381 & ctx -> style .scrollv .inc_button ,
369382 & ctx -> style .scrollv .dec_button };
@@ -407,9 +420,6 @@ style_edit(struct nk_context* ctx, struct nk_style_edit* out_style)
407420 style_vec2 (ctx , "Scrollbar Size:" , & edit .scrollbar_size );
408421 style_vec2 (ctx , "Padding:" , & edit .padding );
409422
410- // TODO subtree?
411- //edit->scrollbar = style->scrollv;
412-
413423 nk_property_float (ctx , "#Row Padding:" , -100.0f , & edit .row_padding , 100.0f , 1 ,0.5f );
414424 nk_property_float (ctx , "#Cursor Size:" , -100.0f , & edit .cursor_size , 100.0f , 1 ,0.5f );
415425 nk_property_float (ctx , "#Border:" , -100.0f , & edit .border , 100.0f , 1 ,0.5f );
@@ -572,6 +582,7 @@ style_window_header(struct nk_context* ctx, struct nk_style_window_header* out_s
572582 nk_layout_row_dynamic (ctx , 30 , 2 );
573583 nk_label (ctx , "Button Alignment:" , NK_TEXT_LEFT );
574584 header .align = nk_combo (ctx , alignments , NUM_ALIGNS , header .align , 25 , nk_vec2 (200 ,200 ));
585+ #undef NUM_ALIGNS
575586
576587 nk_label (ctx , "Close Symbol:" , NK_TEXT_LEFT );
577588 header .close_symbol = nk_combo (ctx , symbols , NK_SYMBOL_MAX , header .close_symbol , 25 , nk_vec2 (200 ,200 ));
0 commit comments