@@ -30,8 +30,8 @@ - (id)initWithFrame:(NSRect)frameRect{
30
30
slotTop = [[NSImage alloc ] initWithContentsOfFile: [bundle pathForImageResource: @" TransparentScrollerSlotTop.tif" ]];
31
31
slotVerticalFill = [[NSImage alloc ] initWithContentsOfFile: [bundle pathForImageResource: @" TransparentScrollerSlotVerticalFill.tif" ]];
32
32
slotBottom = [[NSImage alloc ] initWithContentsOfFile: [bundle pathForImageResource: @" TransparentScrollerSlotBottom.tif" ]];
33
- verticalPaddingLeft = 3 .0f ;
34
- verticalPaddingRight = 3 .75f ;
33
+ verticalPaddingLeft = 4 .0f ;
34
+ verticalPaddingRight = 3 .0f ;
35
35
verticalPaddingTop =3 .75f ;
36
36
verticalPaddingBottom = 4 .25f ;
37
37
minKnobHeight = knobTop.size .height + knobVerticalFill.size .height + knobBottom.size .height + 20.0 ;
@@ -93,12 +93,19 @@ - (void)drawRect:(NSRect)aRect;
93
93
if (IsLionOrLater) {
94
94
[super drawRect: aRect];
95
95
}else {
96
- if (fillBackground) {
97
- [[[[self window ] contentView ] backgroundColor ] setFill ];
98
- NSRectFill ([self bounds ]);
99
- }
100
- if (([self bounds ].size .height - verticalPaddingTop - verticalPaddingBottom + 1 ) > minKnobHeight)
101
- {
96
+ if (([self bounds ].size .height - verticalPaddingTop - verticalPaddingBottom + 1 ) > minKnobHeight){
97
+ // if (fillBackground) {
98
+ // [[[[self window] contentView] backgroundColor] setFill];
99
+ // NSRectFill([self bounds]);
100
+ // }
101
+ // else if (isOverlay){
102
+ // [[NSColor clearColor] setFill];
103
+ // NSRectFill([self bounds]);
104
+ // }
105
+ if (fillBackground) {
106
+ [[[[self window ] contentView ] backgroundColor ] setFill ];
107
+ NSRectFill ([self bounds ]);
108
+ }
102
109
[self drawKnobSlotInRect: [self rectForPart: NSScrollerKnobSlot] highlight: NO ];
103
110
104
111
if ([self knobProportion ] > 0.0 )
@@ -120,13 +127,16 @@ - (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag{
120
127
// }else{
121
128
// NSDrawThreePartImage(slotRect, slotTop, slotVerticalFill, slotBottom, YES, NSCompositeSourceOver, slotAlpha, NO);
122
129
// }
130
+
131
+
123
132
NSDrawThreePartImage (slotRect, slotTop, slotVerticalFill, slotBottom, YES , NSCompositeSourceOver , slotAlpha, NO );
133
+
124
134
}
125
135
126
136
- (void )drawKnob ;
127
137
{
128
138
NSRect knobRect = [self rectForPart: NSScrollerKnob];
129
-
139
+
130
140
NSDrawThreePartImage (knobRect, knobTop, knobVerticalFill, knobBottom, YES , NSCompositeSourceOver , knobAlpha, NO );
131
141
132
142
}
@@ -160,32 +170,41 @@ - (NSRect)rectForPart:(NSScrollerPart)aPart;
160
170
}
161
171
case NSScrollerKnob:
162
172
{
163
- NSRect slotRect = [self rectForPart: NSScrollerKnobSlot];
164
173
NSRect knobRect=[super rectForPart: NSScrollerKnob];
165
-
166
- float knobHeight = roundf (slotRect.size .height * [self knobProportion ]);
167
- if (knobHeight < minKnobHeight){
168
- if (minKnobHeight>slotRect.size .height ) {
169
- knobHeight=knobRect.size .height ;
170
- }else {
171
- knobHeight = minKnobHeight;
172
- }
174
+ // NSRect slotRect = [self rectForPart:NSScrollerKnobSlot];
175
+ // float knobHeight = roundf(slotRect.size.height * [self knobProportion]);
176
+ // if (knobHeight < minKnobHeight){
177
+ // if (minKnobHeight>slotRect.size.height) {
178
+ // knobHeight=knobRect.size.height;
179
+ // }else{
180
+ // knobHeight = minKnobHeight;
181
+ // }
182
+ // }
183
+ CGFloat slotY=roundf (verticalPaddingTop);
184
+ CGFloat knobY=knobRect.origin .y ;
185
+ CGFloat slotHt=roundf ([self bounds ].size .height -(verticalPaddingTop+verticalPaddingBottom));
186
+ if (knobY<slotY) {
187
+ knobY=slotY;
173
188
}
174
-
175
- float knobY = slotRect.origin .y + roundf ((slotRect.size .height - knobHeight) * [self floatValue ]);
176
- knobRect = NSMakeRect (verticalPaddingLeft, knobY, slotRect.size .width , knobHeight);
177
-
189
+ else if ((knobY+knobRect.size .height )>(slotHt+slotY)){
190
+ knobY=slotHt+slotY-knobRect.size .height ;
191
+
192
+ }
193
+ // knobRect = NSMakeRect(verticalPaddingLeft, knobY, slotRect.size.width, knobHeight);
194
+ knobRect.origin .x =roundf (verticalPaddingLeft);
195
+ knobRect.origin .y =roundf (knobY);
196
+ knobRect.size .width =roundf ([self bounds ].size .width - verticalPaddingLeft - verticalPaddingRight);
178
197
179
198
return knobRect;
180
199
}
181
200
break ;
182
201
case NSScrollerKnobSlot:
183
202
{
184
- NSRect slotRect=[super rectForPart: NSScrollerKnobSlot ];
203
+ NSRect slotRect=[self bounds ];
185
204
slotRect.origin .x =roundf (verticalPaddingLeft);
186
- slotRect.size .width =roundf ([ self bounds ] .size .width - verticalPaddingLeft - verticalPaddingRight);
205
+ slotRect.size .width =roundf (slotRect .size .width - verticalPaddingLeft - verticalPaddingRight);
187
206
slotRect.origin .y =roundf (verticalPaddingTop);
188
- slotRect.size .height =roundf (slotRect.size .height -verticalPaddingTop- verticalPaddingBottom);
207
+ slotRect.size .height =roundf (slotRect.size .height -( verticalPaddingTop+ verticalPaddingBottom) );
189
208
return slotRect;
190
209
}
191
210
break ;
@@ -199,11 +218,12 @@ - (NSRect)rectForPart:(NSScrollerPart)aPart;
199
218
{
200
219
NSRect incrementPageRect;
201
220
NSRect knobRect = [self rectForPart: NSScrollerKnob];
202
- NSRect slotRect = [self rectForPart: NSScrollerKnobSlot];
203
- NSRect decPageRect = [self rectForPart: NSScrollerDecrementPage];
204
-
205
- float knobY = knobRect.origin .y + knobRect.size .height ;
206
- incrementPageRect = NSMakeRect (verticalPaddingLeft, knobY, knobRect.size .width , slotRect.size .height - knobRect.size .height - decPageRect.size .height );
221
+ // NSRect slotRect = [self rectForPart:NSScrollerKnobSlot];
222
+ // NSRect decPageRect = [self rectForPart:NSScrollerDecrementPage];
223
+ CGFloat slotHt=roundf ([self bounds ].size .height -(verticalPaddingTop+verticalPaddingBottom));
224
+ CGFloat knobY = roundf (knobRect.origin .y + knobRect.size .height );
225
+ CGFloat knobHt=roundf (slotHt - knobRect.size .height - knobRect.origin .y - verticalPaddingTop);
226
+ incrementPageRect = NSMakeRect (roundf (verticalPaddingLeft), knobY, knobRect.size .width , knobHt);
207
227
208
228
return incrementPageRect;
209
229
}
@@ -214,7 +234,7 @@ - (NSRect)rectForPart:(NSScrollerPart)aPart;
214
234
NSRect knobRect = [self rectForPart: NSScrollerKnob];
215
235
216
236
217
- decrementPageRect = NSMakeRect (verticalPaddingLeft, verticalPaddingTop, knobRect.size .width , knobRect.origin .y - verticalPaddingTop);
237
+ decrementPageRect = NSMakeRect (roundf ( verticalPaddingLeft), roundf ( verticalPaddingTop) , knobRect.size .width , roundf ( knobRect.origin .y - verticalPaddingTop) );
218
238
219
239
return decrementPageRect;
220
240
}
0 commit comments