commit
6270af8cf9
|
@ -18,6 +18,9 @@ This README is being written.<br>
|
||||||
|
|
||||||
*Note that today's entry may be updated later today Eastern Time.*
|
*Note that today's entry may be updated later today Eastern Time.*
|
||||||
|
|
||||||
|
* **15 June 2016**
|
||||||
|
* Added `uiFormDelete()`; thanks to @emersion.
|
||||||
|
|
||||||
* **14 June 2016**
|
* **14 June 2016**
|
||||||
* uiDarwinControl now has a `ChildVisibilityChanged()` method and a corresponding `NotifyVisibilityChanged()` function that is called by the default show/hide handlers. This is used to make visibility changes work on OS X; uiBox, uiForm, and uiGrid all respect these now.
|
* uiDarwinControl now has a `ChildVisibilityChanged()` method and a corresponding `NotifyVisibilityChanged()` function that is called by the default show/hide handlers. This is used to make visibility changes work on OS X; uiBox, uiForm, and uiGrid all respect these now.
|
||||||
* The same has been done on the Windows side as well.
|
* The same has been done on the Windows side as well.
|
||||||
|
|
3
TODO.md
3
TODO.md
|
@ -90,3 +90,6 @@ don't forget LONGTERMs as well
|
||||||
|
|
||||||
notes
|
notes
|
||||||
- http://blogs.msdn.com/b/oldnewthing/archive/2004/03/29/101121.aspx on accelerators
|
- http://blogs.msdn.com/b/oldnewthing/archive/2004/03/29/101121.aspx on accelerators
|
||||||
|
|
||||||
|
- group and tab should act as if they have no child if the child is hidden
|
||||||
|
on windows
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
- (CGFloat)paddingAmount;
|
- (CGFloat)paddingAmount;
|
||||||
- (void)establishOurConstraints;
|
- (void)establishOurConstraints;
|
||||||
- (void)append:(NSString *)label c:(uiControl *)c stretchy:(int)stretchy;
|
- (void)append:(NSString *)label c:(uiControl *)c stretchy:(int)stretchy;
|
||||||
//TODO- (void)delete:(int)n;
|
- (void)delete:(int)n;
|
||||||
- (int)isPadded;
|
- (int)isPadded;
|
||||||
- (void)setPadded:(int)p;
|
- (void)setPadded:(int)p;
|
||||||
- (BOOL)hugsTrailing;
|
- (BOOL)hugsTrailing;
|
||||||
|
@ -394,7 +394,28 @@ struct uiForm {
|
||||||
[fc release]; // we don't need the initial reference now
|
[fc release]; // we don't need the initial reference now
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO- (void)delete:(int)n
|
- (void)delete:(int)n
|
||||||
|
{
|
||||||
|
formChild *fc;
|
||||||
|
int stretchy;
|
||||||
|
|
||||||
|
fc = (formChild *) [self->children objectAtIndex:n];
|
||||||
|
stretchy = fc.stretchy;
|
||||||
|
|
||||||
|
uiControlSetParent(fc.c, NULL);
|
||||||
|
uiDarwinControlSetSuperview(uiDarwinControl(fc.c), nil);
|
||||||
|
|
||||||
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(fc.c), fc.oldHorzHuggingPri, NSLayoutConstraintOrientationHorizontal);
|
||||||
|
uiDarwinControlSetHuggingPriority(uiDarwinControl(fc.c), fc.oldVertHuggingPri, NSLayoutConstraintOrientationVertical);
|
||||||
|
|
||||||
|
[fc onDestroy];
|
||||||
|
[self->children removeObjectAtIndex:n];
|
||||||
|
|
||||||
|
[self establishOurConstraints];
|
||||||
|
if (stretchy)
|
||||||
|
if ([self nStretchy] == 0)
|
||||||
|
uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl(self->f));
|
||||||
|
}
|
||||||
|
|
||||||
- (int)isPadded
|
- (int)isPadded
|
||||||
{
|
{
|
||||||
|
@ -513,6 +534,11 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)
|
||||||
[f->view append:toNSString(label) c:c stretchy:stretchy];
|
[f->view append:toNSString(label) c:c stretchy:stretchy];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiFormDelete(uiForm *f, int n)
|
||||||
|
{
|
||||||
|
[f->view delete:n];
|
||||||
|
}
|
||||||
|
|
||||||
int uiFormPadded(uiForm *f)
|
int uiFormPadded(uiForm *f)
|
||||||
{
|
{
|
||||||
return [f->view isPadded];
|
return [f->view isPadded];
|
||||||
|
|
|
@ -75,6 +75,13 @@ static void showHide(uiButton *b, void *data)
|
||||||
uiControlShow(c);
|
uiControlShow(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void deleteFirst(uiButton *b, void *data)
|
||||||
|
{
|
||||||
|
uiForm *f = uiForm(data);
|
||||||
|
|
||||||
|
uiFormDelete(f, 0);
|
||||||
|
}
|
||||||
|
|
||||||
uiBox *makePage13(void)
|
uiBox *makePage13(void)
|
||||||
{
|
{
|
||||||
uiBox *page13;
|
uiBox *page13;
|
||||||
|
@ -119,6 +126,9 @@ uiBox *makePage13(void)
|
||||||
b = uiNewButton("Show/Hide");
|
b = uiNewButton("Show/Hide");
|
||||||
uiButtonOnClicked(b, showHide, e);
|
uiButtonOnClicked(b, showHide, e);
|
||||||
uiBoxAppend(page13, uiControl(b), 0);
|
uiBoxAppend(page13, uiControl(b), 0);
|
||||||
|
b = uiNewButton("Delete First");
|
||||||
|
uiButtonOnClicked(b, deleteFirst, f);
|
||||||
|
uiBoxAppend(page13, uiControl(b), 0);
|
||||||
uiBoxAppend(page13, uiControl(f), 1);
|
uiBoxAppend(page13, uiControl(f), 1);
|
||||||
|
|
||||||
return page13;
|
return page13;
|
||||||
|
|
1
ui.h
1
ui.h
|
@ -625,6 +625,7 @@ _UI_EXTERN uiColorButton *uiNewColorButton(void);
|
||||||
typedef struct uiForm uiForm;
|
typedef struct uiForm uiForm;
|
||||||
#define uiForm(this) ((uiForm *) (this))
|
#define uiForm(this) ((uiForm *) (this))
|
||||||
_UI_EXTERN void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy);
|
_UI_EXTERN void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy);
|
||||||
|
_UI_EXTERN void uiFormDelete(uiForm *f, int index);
|
||||||
_UI_EXTERN int uiFormPadded(uiForm *f);
|
_UI_EXTERN int uiFormPadded(uiForm *f);
|
||||||
_UI_EXTERN void uiFormSetPadded(uiForm *f, int padded);
|
_UI_EXTERN void uiFormSetPadded(uiForm *f, int padded);
|
||||||
_UI_EXTERN uiForm *uiNewForm(void);
|
_UI_EXTERN uiForm *uiNewForm(void);
|
||||||
|
|
25
unix/form.c
25
unix/form.c
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
struct formChild {
|
struct formChild {
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
|
int stretchy;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
gboolean oldhexpand;
|
gboolean oldhexpand;
|
||||||
GtkAlign oldhalign;
|
GtkAlign oldhalign;
|
||||||
|
@ -55,6 +56,7 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)
|
||||||
|
|
||||||
fc.c = c;
|
fc.c = c;
|
||||||
widget = GTK_WIDGET(uiControlHandle(fc.c));
|
widget = GTK_WIDGET(uiControlHandle(fc.c));
|
||||||
|
fc.stretchy = stretchy;
|
||||||
fc.oldhexpand = gtk_widget_get_hexpand(widget);
|
fc.oldhexpand = gtk_widget_get_hexpand(widget);
|
||||||
fc.oldhalign = gtk_widget_get_halign(widget);
|
fc.oldhalign = gtk_widget_get_halign(widget);
|
||||||
fc.oldvexpand = gtk_widget_get_vexpand(widget);
|
fc.oldvexpand = gtk_widget_get_vexpand(widget);
|
||||||
|
@ -99,6 +101,29 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiFormDelete(uiForm *f, int index)
|
||||||
|
{
|
||||||
|
struct formChild *fc;
|
||||||
|
GtkWidget *widget;
|
||||||
|
|
||||||
|
fc = ctrl(f, index);
|
||||||
|
widget = GTK_WIDGET(uiControlHandle(fc->c));
|
||||||
|
|
||||||
|
gtk_widget_destroy(fc->label);
|
||||||
|
|
||||||
|
uiControlSetParent(fc->c, NULL);
|
||||||
|
uiUnixControlSetContainer(uiUnixControl(fc->c), f->container, TRUE);
|
||||||
|
|
||||||
|
if (fc->stretchy)
|
||||||
|
gtk_size_group_remove_widget(f->stretchygroup, widget);
|
||||||
|
gtk_widget_set_hexpand(widget, fc->oldhexpand);
|
||||||
|
gtk_widget_set_halign(widget, fc->oldhalign);
|
||||||
|
gtk_widget_set_vexpand(widget, fc->oldvexpand);
|
||||||
|
gtk_widget_set_valign(widget, fc->oldvalign);
|
||||||
|
|
||||||
|
g_array_remove_index(f->children, index);
|
||||||
|
}
|
||||||
|
|
||||||
int uiFormPadded(uiForm *f)
|
int uiFormPadded(uiForm *f)
|
||||||
{
|
{
|
||||||
return f->padded;
|
return f->padded;
|
||||||
|
|
|
@ -68,16 +68,11 @@ if(NOT BUILD_SHARED_LIBS)
|
||||||
set(_LIBUI_STATIC_RES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libui.res PARENT_SCOPE)
|
set(_LIBUI_STATIC_RES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libui.res PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
macro(_handle_static)
|
macro(_handle_static)
|
||||||
if(MSVC)
|
|
||||||
set(_res_suffix res)
|
|
||||||
else()
|
|
||||||
set(_res_suffix obj)
|
|
||||||
endif()
|
|
||||||
# TODO this full path feels hacky
|
# TODO this full path feels hacky
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET libui POST_BUILD
|
TARGET libui POST_BUILD
|
||||||
COMMAND
|
COMMAND
|
||||||
${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:libui,BINARY_DIR>/CMakeFiles/libui.dir/windows/resources.rc.${_res_suffix} ${_LIBUI_STATIC_RES}
|
${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:libui,BINARY_DIR>/CMakeFiles/libui.dir/windows/resources.rc.* ${_LIBUI_STATIC_RES}
|
||||||
COMMENT "Copying libui.res")
|
COMMENT "Copying libui.res")
|
||||||
set(_res_suffix)
|
set(_res_suffix)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
|
@ -276,6 +276,19 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)
|
||||||
uiWindowsControlMinimumSizeChanged(uiWindowsControl(f));
|
uiWindowsControlMinimumSizeChanged(uiWindowsControl(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiFormDelete(uiForm *f, int index)
|
||||||
|
{
|
||||||
|
struct formChild fc;
|
||||||
|
|
||||||
|
fc = (*(f->controls))[index];
|
||||||
|
uiControlSetParent(fc.c, NULL);
|
||||||
|
uiWindowsControlSetParentHWND(uiWindowsControl(fc.c), NULL);
|
||||||
|
uiWindowsEnsureDestroyWindow(fc.label);
|
||||||
|
f->controls->erase(f->controls->begin() + index);
|
||||||
|
formArrangeChildren(f);
|
||||||
|
uiWindowsControlMinimumSizeChanged(uiWindowsControl(f));
|
||||||
|
}
|
||||||
|
|
||||||
int uiFormPadded(uiForm *f)
|
int uiFormPadded(uiForm *f)
|
||||||
{
|
{
|
||||||
return f->padded;
|
return f->padded;
|
||||||
|
|
Loading…
Reference in New Issue