mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:50:48 +00:00
Add support to auto hide scrollers.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24730 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0b6120885d
commit
40480d8c22
3 changed files with 87 additions and 28 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2007-02-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSScrollView.h: Add ivar
|
||||||
|
_autohidesScrollers. Move private method to implementation file.
|
||||||
|
* Source/NSScrollView.m (-init): Remove as this is the same as in
|
||||||
|
the super class.
|
||||||
|
* Source/NSScrollView.m (-autohidesScrollers,
|
||||||
|
-setAutohidesScrollers:, -reflectScrolledClipView:): Add support
|
||||||
|
for auto hidding of scrollers.
|
||||||
|
* Source/NSScrollView.m (-initWithCoder:): Decode the value for
|
||||||
|
_autohidesScrollers.
|
||||||
|
|
||||||
2007-02-28 Nicola Pero <nicola.pero@meta-innovation.com>
|
2007-02-28 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||||
|
|
||||||
* configure.ac: Use gnustep-config to set GNUSTEP_MAKEFILES
|
* configure.ac: Use gnustep-config to set GNUSTEP_MAKEFILES
|
||||||
|
|
|
@ -41,11 +41,13 @@
|
||||||
|
|
||||||
@interface NSScrollView : NSView
|
@interface NSScrollView : NSView
|
||||||
{
|
{
|
||||||
NSClipView* _contentView;
|
NSClipView *_contentView;
|
||||||
NSScroller* _horizScroller;
|
NSScroller *_horizScroller;
|
||||||
NSScroller* _vertScroller;
|
NSScroller *_vertScroller;
|
||||||
NSRulerView* _horizRuler;
|
NSRulerView *_horizRuler;
|
||||||
NSRulerView* _vertRuler;
|
NSRulerView *_vertRuler;
|
||||||
|
NSClipView *_headerClipView;
|
||||||
|
NSView *_cornerView;
|
||||||
float _hLineScroll;
|
float _hLineScroll;
|
||||||
float _hPageScroll;
|
float _hPageScroll;
|
||||||
float _vLineScroll;
|
float _vLineScroll;
|
||||||
|
@ -60,8 +62,7 @@
|
||||||
BOOL _knobMoved;
|
BOOL _knobMoved;
|
||||||
BOOL _hasHeaderView;
|
BOOL _hasHeaderView;
|
||||||
BOOL _hasCornerView;
|
BOOL _hasCornerView;
|
||||||
NSClipView *_headerClipView;
|
BOOL _autohidesScrollers;
|
||||||
NSView *_cornerView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculating layout */
|
/* Calculating layout */
|
||||||
|
@ -136,6 +137,10 @@
|
||||||
- (void)setDrawsBackground:(BOOL)flag;
|
- (void)setDrawsBackground:(BOOL)flag;
|
||||||
- (BOOL)drawsBackground;
|
- (BOOL)drawsBackground;
|
||||||
#endif
|
#endif
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
|
||||||
|
- (BOOL)autohidesScrollers;
|
||||||
|
- (void)setAutohidesScrollers:(BOOL)flag;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Updating display after scrolling */
|
/* Updating display after scrolling */
|
||||||
- (void)reflectScrolledClipView:(NSClipView*)aClipView;
|
- (void)reflectScrolledClipView:(NSClipView*)aClipView;
|
||||||
|
@ -143,8 +148,6 @@
|
||||||
/* Arranging components */
|
/* Arranging components */
|
||||||
- (void)tile;
|
- (void)tile;
|
||||||
|
|
||||||
/* GNUstep private methods */
|
|
||||||
- (void)_synchronizeHeaderAndCornerView;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif /* _GNUstep_H_NSScrollView */
|
#endif /* _GNUstep_H_NSScrollView */
|
||||||
|
|
|
@ -52,21 +52,27 @@
|
||||||
typedef struct _scrollViewFlags
|
typedef struct _scrollViewFlags
|
||||||
{
|
{
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
unsigned int __unused4:26;
|
unsigned int __unused4:22;
|
||||||
unsigned int hasHScroller:1; // 16
|
unsigned int autohidesScrollers:1;
|
||||||
unsigned int hasVScroller:1; // 32
|
unsigned int __unused1:3;
|
||||||
|
unsigned int hasHScroller:1;
|
||||||
|
unsigned int hasVScroller:1;
|
||||||
unsigned int __unused0:2;
|
unsigned int __unused0:2;
|
||||||
NSBorderType border:2;
|
NSBorderType border:2;
|
||||||
#else
|
#else
|
||||||
NSBorderType border:2;
|
NSBorderType border:2;
|
||||||
unsigned int __unused0:2;
|
unsigned int __unused0:2;
|
||||||
unsigned int hasVScroller:1; // 32
|
unsigned int hasVScroller:1;
|
||||||
unsigned int hasHScroller:1; // 16
|
unsigned int hasHScroller:1;
|
||||||
unsigned int __unused4:26;
|
unsigned int __unused1:3;
|
||||||
|
unsigned int autohidesScrollers:1;
|
||||||
|
unsigned int __unused4:22;
|
||||||
#endif
|
#endif
|
||||||
} GSScrollViewFlags;
|
} GSScrollViewFlags;
|
||||||
|
|
||||||
@interface NSScrollView (GSPrivate)
|
@interface NSScrollView (GSPrivate)
|
||||||
|
/* GNUstep private methods */
|
||||||
|
- (void) _synchronizeHeaderAndCornerView;
|
||||||
- (void) _themeDidActivate: (NSNotification*)notification;
|
- (void) _themeDidActivate: (NSNotification*)notification;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -172,6 +178,8 @@ static float scrollerWidth;
|
||||||
_vPageScroll = 10;
|
_vPageScroll = 10;
|
||||||
_borderType = NSNoBorder;
|
_borderType = NSNoBorder;
|
||||||
_scrollsDynamically = YES;
|
_scrollsDynamically = YES;
|
||||||
|
//_autohidesScrollers = NO;
|
||||||
|
// FIXME: Not sure here Apple says by default all scrollers are off.
|
||||||
// For compatibility the ruler should be present but not visible.
|
// For compatibility the ruler should be present but not visible.
|
||||||
[self setHasHorizontalRuler: YES];
|
[self setHasHorizontalRuler: YES];
|
||||||
[self tile];
|
[self tile];
|
||||||
|
@ -184,11 +192,6 @@ static float scrollerWidth;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) init
|
|
||||||
{
|
|
||||||
return [self initWithFrame: NSZeroRect];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
@ -325,6 +328,16 @@ static float scrollerWidth;
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) autohidesScrollers
|
||||||
|
{
|
||||||
|
return _autohidesScrollers;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setAutohidesScrollers: (BOOL)flag
|
||||||
|
{
|
||||||
|
_autohidesScrollers = flag;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) scrollWheel: (NSEvent *)theEvent
|
- (void) scrollWheel: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSRect clipViewBounds;
|
NSRect clipViewBounds;
|
||||||
|
@ -616,11 +629,24 @@ static float scrollerWidth;
|
||||||
documentFrame = [documentView frame];
|
documentFrame = [documentView frame];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Should we just hide the scroll bar or remove it?
|
||||||
|
if ((_autohidesScrollers) && (documentFrame.size.height > clipViewBounds.size.height))
|
||||||
|
{
|
||||||
|
[self setHasVerticalScroller: YES];
|
||||||
|
}
|
||||||
|
|
||||||
if (_hasVertScroller)
|
if (_hasVertScroller)
|
||||||
{
|
{
|
||||||
if (documentFrame.size.height <= clipViewBounds.size.height)
|
if (documentFrame.size.height <= clipViewBounds.size.height)
|
||||||
{
|
{
|
||||||
[_vertScroller setEnabled: NO];
|
if (_autohidesScrollers)
|
||||||
|
{
|
||||||
|
[self setHasVerticalScroller: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[_vertScroller setEnabled: NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -641,11 +667,23 @@ static float scrollerWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_autohidesScrollers) && (documentFrame.size.width > clipViewBounds.size.width))
|
||||||
|
{
|
||||||
|
[self setHasHorizontalScroller: YES];
|
||||||
|
}
|
||||||
|
|
||||||
if (_hasHorizScroller)
|
if (_hasHorizScroller)
|
||||||
{
|
{
|
||||||
if (documentFrame.size.width <= clipViewBounds.size.width)
|
if (documentFrame.size.width <= clipViewBounds.size.width)
|
||||||
{
|
{
|
||||||
[_horizScroller setEnabled: NO];
|
if (_autohidesScrollers)
|
||||||
|
{
|
||||||
|
[self setHasHorizontalScroller: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[_horizScroller setEnabled: NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -854,8 +892,8 @@ static float scrollerWidth;
|
||||||
bottomEdge = NSMinYEdge;
|
bottomEdge = NSMinYEdge;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare the contentRect by the insetting the borders. */
|
/* Prepare the contentRect by insetting the borders. */
|
||||||
contentRect = NSInsetRect (_bounds, border.width, border.height);
|
contentRect = NSInsetRect(_bounds, border.width, border.height);
|
||||||
|
|
||||||
[self _synchronizeHeaderAndCornerView];
|
[self _synchronizeHeaderAndCornerView];
|
||||||
|
|
||||||
|
@ -1338,12 +1376,14 @@ static float scrollerWidth;
|
||||||
|
|
||||||
if ([aDecoder containsValueForKey: @"NSsFlags"])
|
if ([aDecoder containsValueForKey: @"NSsFlags"])
|
||||||
{
|
{
|
||||||
unsigned long flags = [aDecoder decodeIntForKey: @"NSsFlags"];
|
int flags = [aDecoder decodeInt32ForKey: @"NSsFlags"];
|
||||||
GSScrollViewFlags scrollViewFlags;
|
GSScrollViewFlags scrollViewFlags;
|
||||||
|
// FIXME: Why not just use a cast?
|
||||||
memcpy((void *)&scrollViewFlags,(void *)&flags,sizeof(struct _scrollViewFlags));
|
memcpy((void *)&scrollViewFlags,(void *)&flags,sizeof(struct _scrollViewFlags));
|
||||||
|
|
||||||
_hasVertScroller = scrollViewFlags.hasVScroller;
|
_hasVertScroller = scrollViewFlags.hasVScroller;
|
||||||
_hasHorizScroller = scrollViewFlags.hasHScroller;
|
_hasHorizScroller = scrollViewFlags.hasHScroller;
|
||||||
|
_autohidesScrollers = scrollViewFlags.autohidesScrollers;
|
||||||
// _scrollsDynamically = (!scrollViewFlags.notDynamic);
|
// _scrollsDynamically = (!scrollViewFlags.notDynamic);
|
||||||
// _rulersVisible = scrollViewFlags.rulersVisible;
|
// _rulersVisible = scrollViewFlags.rulersVisible;
|
||||||
// _hasHorizRuler = scrollViewFlags.hasHRuler;
|
// _hasHorizRuler = scrollViewFlags.hasHRuler;
|
||||||
|
@ -1354,6 +1394,7 @@ static float scrollerWidth;
|
||||||
|
|
||||||
if (content != nil)
|
if (content != nil)
|
||||||
{
|
{
|
||||||
|
// FIXME: I think this is not needed as we re-tile anyway.
|
||||||
NSRect frame = [content frame];
|
NSRect frame = [content frame];
|
||||||
float w = [vScroller frame].size.width;
|
float w = [vScroller frame].size.width;
|
||||||
|
|
||||||
|
@ -1368,6 +1409,7 @@ static float scrollerWidth;
|
||||||
[content setFrame: frame];
|
[content setFrame: frame];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: No idea what is going on here.
|
||||||
// retain the view and reset the content view...
|
// retain the view and reset the content view...
|
||||||
RETAIN(content);
|
RETAIN(content);
|
||||||
[self setContentView: content];
|
[self setContentView: content];
|
||||||
|
@ -1450,6 +1492,10 @@ static float scrollerWidth;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSScrollView (GSPrivate)
|
||||||
|
|
||||||
/* GNUstep private method */
|
/* GNUstep private method */
|
||||||
|
|
||||||
/* we update both of these at the same time during -tile
|
/* we update both of these at the same time during -tile
|
||||||
|
@ -1512,12 +1558,10 @@ static float scrollerWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSScrollView (GSPrivate)
|
|
||||||
- (void) _themeDidActivate: (NSNotification*)notification
|
- (void) _themeDidActivate: (NSNotification*)notification
|
||||||
{
|
{
|
||||||
[self tile];
|
[self tile];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue