More TODO and intrinsic size work.
This commit is contained in:
parent
1e8a90d9a2
commit
0c85469e52
|
@ -105,21 +105,10 @@ struct uiColorButton {
|
||||||
self->libui_setting = NO;
|
self->libui_setting = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NSColorWell has no intrinsic size by default; give it at least the height of the equivalent button's
|
// NSColorWell has no intrinsic size by default; give it the default Interface Builder size.
|
||||||
- (NSSize)intrinsicContentSize
|
- (NSSize)intrinsicContentSize
|
||||||
{
|
{
|
||||||
NSSize ss;
|
return NSMakeSize(44, 23);
|
||||||
NSButtonCell *bc;
|
|
||||||
|
|
||||||
ss = [super intrinsicContentSize];
|
|
||||||
bc = [NSButtonCell new];
|
|
||||||
[bc setButtonType:NSPushOnPushOffButton];
|
|
||||||
[bc setBordered:YES];
|
|
||||||
[bc setBezelStyle:NSShadowlessSquareBezelStyle];
|
|
||||||
[bc setTitle:@" "];
|
|
||||||
ss.height = [bc cellSize].height;
|
|
||||||
[bc release];
|
|
||||||
return ss;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
// 14 august 2015
|
// 14 august 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
|
// NSProgressIndicator has no intrinsic width by default; use the default width in Interface Builder
|
||||||
|
#define progressIndicatorWidth 100
|
||||||
|
|
||||||
|
@interface intrinsicWidthNSProgressIndicator : NSProgressIndicator
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation intrinsicWidthNSProgressIndicator
|
||||||
|
|
||||||
|
- (NSSize)intrinsicContentSize
|
||||||
|
{
|
||||||
|
NSSize s;
|
||||||
|
|
||||||
|
s = [super intrinsicContentSize];
|
||||||
|
s.width = progressIndicatorWidth;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
struct uiProgressBar {
|
struct uiProgressBar {
|
||||||
uiDarwinControl c;
|
uiDarwinControl c;
|
||||||
NSProgressIndicator *pi;
|
NSProgressIndicator *pi;
|
||||||
|
@ -30,7 +49,7 @@ uiProgressBar *uiNewProgressBar(void)
|
||||||
|
|
||||||
uiDarwinNewControl(uiProgressBar, p);
|
uiDarwinNewControl(uiProgressBar, p);
|
||||||
|
|
||||||
p->pi = [[NSProgressIndicator alloc] initWithFrame:NSZeroRect];
|
p->pi = [[intrinsicWidthNSProgressIndicator alloc] initWithFrame:NSZeroRect];
|
||||||
[p->pi setControlSize:NSRegularControlSize];
|
[p->pi setControlSize:NSRegularControlSize];
|
||||||
[p->pi setBezeled:YES];
|
[p->pi setBezeled:YES];
|
||||||
[p->pi setStyle:NSProgressIndicatorBarStyle];
|
[p->pi setStyle:NSProgressIndicatorBarStyle];
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
// 14 august 2015
|
// 14 august 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
// A separator NSBox is horizontal if width >= height.
|
// TODO make this intrinsic
|
||||||
// Use Interface Builder's initial size as our initial size, to be safe.
|
#define separatorWidth 96
|
||||||
#define separatorFrameWidth 96 /* alignment rect 96 */
|
|
||||||
#define separatorFrameHeight 5 /* alignment rect 1 */
|
|
||||||
|
|
||||||
struct uiSeparator {
|
struct uiSeparator {
|
||||||
uiDarwinControl c;
|
uiDarwinControl c;
|
||||||
|
@ -19,7 +17,8 @@ uiSeparator *uiNewHorizontalSeparator(void)
|
||||||
|
|
||||||
uiDarwinNewControl(uiSeparator, s);
|
uiDarwinNewControl(uiSeparator, s);
|
||||||
|
|
||||||
s->box = [[NSBox alloc] initWithFrame:NSMakeRect(0, 0, separatorFrameWidth, separatorFrameHeight)];
|
// make the initial width >= initial height to force horizontal
|
||||||
|
s->box = [[NSBox alloc] initWithFrame:NSMakeRect(0, 0, 100, 1)];
|
||||||
[s->box setBoxType:NSBoxSeparator];
|
[s->box setBoxType:NSBoxSeparator];
|
||||||
[s->box setBorderType:NSGrooveBorder];
|
[s->box setBorderType:NSGrooveBorder];
|
||||||
[s->box setTransparent:NO];
|
[s->box setTransparent:NO];
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct uiSpinbox {
|
||||||
// yes folks, this varies by operating system! woo!
|
// yes folks, this varies by operating system! woo!
|
||||||
static CGFloat stepperYDelta(void)
|
static CGFloat stepperYDelta(void)
|
||||||
{
|
{
|
||||||
// 10.8 - xxx
|
// 10.8 - 0
|
||||||
// 10.9 - xxx
|
// 10.9 - xxx
|
||||||
// 10.10 - xxx
|
// 10.10 - xxx
|
||||||
// 10.11 - -1
|
// 10.11 - -1
|
||||||
|
|
|
@ -1,6 +1,59 @@
|
||||||
// 28 may 2016
|
// 28 may 2016
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
|
static int winClose(uiWindow *w, void *data)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void openTestWindow(uiBox *(*mkf)(void))
|
||||||
|
{
|
||||||
|
uiWindow *w;
|
||||||
|
uiBox *b;
|
||||||
|
uiCombobox *c;
|
||||||
|
uiEditableCombobox *e;
|
||||||
|
uiRadioButtons *r;
|
||||||
|
|
||||||
|
w = uiNewWindow("Test", 100, 100, 0);
|
||||||
|
uiWindowOnClosing(w, winClose, NULL);
|
||||||
|
uiWindowSetMargined(w, 1);
|
||||||
|
b = (*mkf)();
|
||||||
|
uiWindowSetChild(w, uiControl(b));
|
||||||
|
|
||||||
|
#define BA(x) uiBoxAppend(b, uiControl(x), 0)
|
||||||
|
BA(uiNewButton(""));
|
||||||
|
BA(uiNewCheckbox(""));
|
||||||
|
BA(uiNewEntry());
|
||||||
|
BA(uiNewLabel(""));
|
||||||
|
BA(uiNewSpinbox(0, 100));
|
||||||
|
BA(uiNewProgressBar());
|
||||||
|
BA(uiNewSlider(0, 100));
|
||||||
|
BA(uiNewHorizontalSeparator());
|
||||||
|
c = uiNewCombobox();
|
||||||
|
uiComboboxAppend(c, "");
|
||||||
|
BA(c);
|
||||||
|
e = uiNewEditableCombobox();
|
||||||
|
uiEditableComboboxAppend(e, "");
|
||||||
|
BA(e);
|
||||||
|
r = uiNewRadioButtons();
|
||||||
|
uiRadioButtonsAppend(r, "");
|
||||||
|
BA(r);
|
||||||
|
BA(uiNewDateTimePicker());
|
||||||
|
BA(uiNewDatePicker());
|
||||||
|
BA(uiNewTimePicker());
|
||||||
|
BA(uiNewMultilineEntry());
|
||||||
|
// TODO nonscrolling and scrolling areas?
|
||||||
|
BA(uiNewFontButton());
|
||||||
|
BA(uiNewColorButton());
|
||||||
|
|
||||||
|
uiControlShow(uiControl(w));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void buttonClicked(uiButton *b, void *data)
|
||||||
|
{
|
||||||
|
openTestWindow((uiBox *(*)(void)) data);
|
||||||
|
}
|
||||||
|
|
||||||
uiBox *makePage13(void)
|
uiBox *makePage13(void)
|
||||||
{
|
{
|
||||||
uiBox *page13;
|
uiBox *page13;
|
||||||
|
@ -21,9 +74,11 @@ uiBox *makePage13(void)
|
||||||
uiBoxAppend(page13, uiControl(rb), 0);
|
uiBoxAppend(page13, uiControl(rb), 0);
|
||||||
|
|
||||||
b = uiNewButton("Horizontal");
|
b = uiNewButton("Horizontal");
|
||||||
|
uiButtonOnClicked(b, buttonClicked, uiNewHorizontalBox);
|
||||||
uiBoxAppend(page13, uiControl(b), 0);
|
uiBoxAppend(page13, uiControl(b), 0);
|
||||||
|
|
||||||
b = uiNewButton("Vertical");
|
b = uiNewButton("Vertical");
|
||||||
|
uiButtonOnClicked(b, buttonClicked, uiNewVerticalBox);
|
||||||
uiBoxAppend(page13, uiControl(b), 0);
|
uiBoxAppend(page13, uiControl(b), 0);
|
||||||
|
|
||||||
return page13;
|
return page13;
|
||||||
|
|
Loading…
Reference in New Issue