More TODO and intrinsic size work.

This commit is contained in:
Pietro Gagliardi 2016-05-28 22:49:27 -04:00
parent 1e8a90d9a2
commit 0c85469e52
5 changed files with 82 additions and 20 deletions

View File

@ -105,21 +105,10 @@ struct uiColorButton {
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 ss;
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;
return NSMakeSize(44, 23);
}
@end

View File

@ -1,6 +1,25 @@
// 14 august 2015
#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 {
uiDarwinControl c;
NSProgressIndicator *pi;
@ -30,7 +49,7 @@ uiProgressBar *uiNewProgressBar(void)
uiDarwinNewControl(uiProgressBar, p);
p->pi = [[NSProgressIndicator alloc] initWithFrame:NSZeroRect];
p->pi = [[intrinsicWidthNSProgressIndicator alloc] initWithFrame:NSZeroRect];
[p->pi setControlSize:NSRegularControlSize];
[p->pi setBezeled:YES];
[p->pi setStyle:NSProgressIndicatorBarStyle];

View File

@ -1,10 +1,8 @@
// 14 august 2015
#import "uipriv_darwin.h"
// A separator NSBox is horizontal if width >= height.
// Use Interface Builder's initial size as our initial size, to be safe.
#define separatorFrameWidth 96 /* alignment rect 96 */
#define separatorFrameHeight 5 /* alignment rect 1 */
// TODO make this intrinsic
#define separatorWidth 96
struct uiSeparator {
uiDarwinControl c;
@ -19,7 +17,8 @@ uiSeparator *uiNewHorizontalSeparator(void)
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 setBorderType:NSGrooveBorder];
[s->box setTransparent:NO];

View File

@ -32,7 +32,7 @@ struct uiSpinbox {
// yes folks, this varies by operating system! woo!
static CGFloat stepperYDelta(void)
{
// 10.8 - xxx
// 10.8 - 0
// 10.9 - xxx
// 10.10 - xxx
// 10.11 - -1

View File

@ -1,6 +1,59 @@
// 28 may 2016
#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 *page13;
@ -21,9 +74,11 @@ uiBox *makePage13(void)
uiBoxAppend(page13, uiControl(rb), 0);
b = uiNewButton("Horizontal");
uiButtonOnClicked(b, buttonClicked, uiNewHorizontalBox);
uiBoxAppend(page13, uiControl(b), 0);
b = uiNewButton("Vertical");
uiButtonOnClicked(b, buttonClicked, uiNewVerticalBox);
uiBoxAppend(page13, uiControl(b), 0);
return page13;