mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-29 09:52:03 +00:00
fixed HUD rule editor
This commit is contained in:
1 parent
ff6981bf10
commit
18c2145138
4 files changed
+112
-37
No files matched your search
@@ -1864,57 +1864,63 @@ TODO: implement
|
||||
|
||||
- (CPArray)_backgroundColors
|
||||
{
|
||||
return [self valueForThemeAttribute:@"alternating-row-colors"];
|
||||
return [self currentValueForThemeAttribute:@"alternating-row-colors"];
|
||||
}
|
||||
|
||||
- (CPColor)_selectedRowColor
|
||||
{
|
||||
return [self valueForThemeAttribute:@"selected-color"];
|
||||
return [self currentValueForThemeAttribute:@"selected-color"];
|
||||
}
|
||||
|
||||
- (CPColor)_sliceTopBorderColor
|
||||
{
|
||||
return [self valueForThemeAttribute:@"slice-top-border-color"];
|
||||
return [self currentValueForThemeAttribute:@"slice-top-border-color"];
|
||||
}
|
||||
|
||||
- (CPColor)_sliceBottomBorderColor
|
||||
{
|
||||
return [self valueForThemeAttribute:@"slice-bottom-border-color"];
|
||||
return [self currentValueForThemeAttribute:@"slice-bottom-border-color"];
|
||||
}
|
||||
|
||||
- (CPColor)_sliceLastBottomBorderColor
|
||||
{
|
||||
return [self valueForThemeAttribute:@"slice-last-bottom-border-color"];
|
||||
return [self currentValueForThemeAttribute:@"slice-last-bottom-border-color"];
|
||||
}
|
||||
|
||||
- (CPFont)font
|
||||
{
|
||||
return [self valueForThemeAttribute:@"font"];
|
||||
return [self currentValueForThemeAttribute:@"font"];
|
||||
}
|
||||
|
||||
- (CPColor)_fontColor
|
||||
{
|
||||
return [self valueForThemeAttribute:@"font-color"];
|
||||
return [self currentValueForThemeAttribute:@"font-color"];
|
||||
}
|
||||
|
||||
- (void)setThemeState:(CPThemeState)aState
|
||||
{
|
||||
[super setThemeState:aState];
|
||||
[_slices makeObjectsPerformSelector:@selector(setThemeState:) withObject:aState];
|
||||
}
|
||||
|
||||
- (CPImage)_imageAdd
|
||||
{
|
||||
return [self valueForThemeAttribute:@"add-image" inState:CPThemeStateNormal];
|
||||
return [self valueForThemeAttribute:@"add-image" inState:CPThemeStateNormal.and([self themeState])];
|
||||
}
|
||||
|
||||
- (CPImage)_imageAddHighlighted
|
||||
{
|
||||
return [self valueForThemeAttribute:@"add-image" inState:CPThemeStateHighlighted];
|
||||
return [self valueForThemeAttribute:@"add-image" inState:CPThemeStateHighlighted.and([self themeState])];
|
||||
}
|
||||
|
||||
- (CPImage)_imageRemove
|
||||
{
|
||||
return [self valueForThemeAttribute:@"remove-image" inState:CPThemeStateNormal];
|
||||
return [self valueForThemeAttribute:@"remove-image" inState:CPThemeStateNormal.and([self themeState])];
|
||||
}
|
||||
|
||||
- (CPImage)_imageRemoveHighlighted
|
||||
{
|
||||
return [self valueForThemeAttribute:@"remove-image" inState:CPThemeStateHighlighted];
|
||||
return [self valueForThemeAttribute:@"remove-image" inState:CPThemeStateHighlighted.and([self themeState])];
|
||||
}
|
||||
|
||||
- (CPVerticalTextAlignment)_verticalAlignment
|
||||
|
||||
@@ -49,6 +49,13 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setRowIndex:(int)anIndex
|
||||
{
|
||||
_rowIndex = anIndex;
|
||||
[self _updateBackgroundColor];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)_setSelected:(BOOL)select
|
||||
{
|
||||
if (select == _selected)
|
||||
@@ -57,6 +64,47 @@
|
||||
var selector = select ? @selector(setThemeState:) : @selector(unsetThemeState:);
|
||||
[[self subviews] makeObjectsPerformSelector:selector withObject:CPThemeStateSelectedDataView];
|
||||
_selected = select;
|
||||
|
||||
[self _updateBackgroundColor];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)_updateBackgroundColor
|
||||
{
|
||||
var color = nil;
|
||||
|
||||
if ([self _isSelected])
|
||||
{
|
||||
color = [_ruleEditor _selectedRowColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
var colors = [_ruleEditor _backgroundColors],
|
||||
count = [colors count];
|
||||
|
||||
if (count > 0)
|
||||
color = [colors objectAtIndex:(_rowIndex % count)];
|
||||
}
|
||||
|
||||
[self setBackgroundColor:color];
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToWindow
|
||||
{
|
||||
[super viewDidMoveToWindow];
|
||||
[self _updateBackgroundColor];
|
||||
}
|
||||
|
||||
- (void)setThemeState:(CPThemeState)aState
|
||||
{
|
||||
[super setThemeState:aState];
|
||||
[self _updateBackgroundColor];
|
||||
}
|
||||
|
||||
- (void)unsetThemeState:(CPThemeState)aState
|
||||
{
|
||||
[super unsetThemeState:aState];
|
||||
[self _updateBackgroundColor];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)rect
|
||||
@@ -66,35 +114,31 @@
|
||||
maxX = CGRectGetWidth(bounds),
|
||||
maxY = CGRectGetHeight(bounds);
|
||||
|
||||
// Draw background
|
||||
if ([self _isSelected])
|
||||
_backgroundColor = [_ruleEditor _selectedRowColor];
|
||||
else
|
||||
{
|
||||
var colors = [_ruleEditor _backgroundColors],
|
||||
count = [colors count];
|
||||
_backgroundColor = [colors objectAtIndex:(_rowIndex % count)];
|
||||
}
|
||||
|
||||
CGContextSetFillColor(context, _backgroundColor);
|
||||
CGContextFillRect(context, rect);
|
||||
// Note: Background is now handled by setBackgroundColor in _updateBackgroundColor
|
||||
// to support CSS-based colors and transparency correctly.
|
||||
|
||||
// Draw Top Border
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, 0, 0);
|
||||
CGContextAddLineToPoint(context, maxX, 0);
|
||||
CGContextSetStrokeColor(context, [_ruleEditor _sliceTopBorderColor]);
|
||||
CGContextStrokePath(context);
|
||||
var topColor = [_ruleEditor _sliceTopBorderColor];
|
||||
if (topColor)
|
||||
{
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, 0, 0);
|
||||
CGContextAddLineToPoint(context, maxX, 0);
|
||||
CGContextSetStrokeColor(context, topColor);
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
|
||||
// Draw Bottom Border
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, 0, maxY);
|
||||
CGContextAddLineToPoint(context, maxX, maxY);
|
||||
|
||||
var bottomColor = (_rowIndex == [_ruleEditor _lastRow]) ? [_ruleEditor _sliceLastBottomBorderColor] : [_ruleEditor _sliceBottomBorderColor];
|
||||
|
||||
CGContextSetStrokeColor(context, bottomColor);
|
||||
CGContextStrokePath(context);
|
||||
if (bottomColor)
|
||||
{
|
||||
CGContextBeginPath(context);
|
||||
CGContextMoveToPoint(context, 0, maxY);
|
||||
CGContextAddLineToPoint(context, maxX, maxY);
|
||||
CGContextSetStrokeColor(context, bottomColor);
|
||||
CGContextStrokePath(context);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)theEvent
|
||||
|
||||
@@ -67,6 +67,17 @@
|
||||
[self setAutoresizingMask:CPViewWidthSizable];
|
||||
}
|
||||
|
||||
- (void)_updateButtonImages
|
||||
{
|
||||
// Re-fetch images from RuleEditor. This ensures we get the HUD images
|
||||
// if the RuleEditor is in HUD state.
|
||||
[_addButton setValue:[_ruleEditor _imageAdd] forThemeAttribute:@"image" inState:CPThemeStateNormal];
|
||||
[_addButton setValue:[_ruleEditor _imageAddHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted];
|
||||
|
||||
[_subtractButton setValue:[_ruleEditor _imageRemove] forThemeAttribute:@"image" inState:CPThemeStateNormal];
|
||||
[_subtractButton setValue:[_ruleEditor _imageRemoveHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted];
|
||||
}
|
||||
|
||||
- (CPButton)_createRowButton
|
||||
{
|
||||
var button = [[CPButton alloc] initWithFrame:CGRectMakeZero()];
|
||||
@@ -492,9 +503,23 @@
|
||||
|
||||
- (void)viewDidMoveToWindow
|
||||
{
|
||||
[super viewDidMoveToWindow];
|
||||
[self _updateButtonImages];
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)setThemeState:(CPThemeState)aState
|
||||
{
|
||||
[super setThemeState:aState];
|
||||
[self _updateButtonImages];
|
||||
}
|
||||
|
||||
- (void)unsetThemeState:(CPThemeState)aState
|
||||
{
|
||||
[super unsetThemeState:aState];
|
||||
[self _updateButtonImages];
|
||||
}
|
||||
|
||||
- (void)_addObservers
|
||||
{
|
||||
if (_isObserving)
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
startY = 15.0,
|
||||
gapY = 32.0,
|
||||
controlWidth = boxWidth - (innerX * 2),
|
||||
fieldHeight = 22.0,
|
||||
fieldHeight = 25.0,
|
||||
boxTopY = 20.0;
|
||||
|
||||
// ------------------------------------------------------
|
||||
@@ -189,13 +189,13 @@
|
||||
var tokenField = [[CPTokenField alloc] initWithFrame:CGRectMake(innerX, currentY, controlWidth, fieldHeight)];
|
||||
[tokenField setObjectValue:["Token", "Field"]];
|
||||
[leftContent addSubview:tokenField];
|
||||
currentY += gapY + 10.0;
|
||||
currentY += gapY + 20.0;
|
||||
|
||||
// 3. Sliders
|
||||
var tickSlider = [[CPSlider alloc] initWithFrame:CGRectMake(innerX, currentY, controlWidth - 40, 24)];
|
||||
[leftContent addSubview:tickSlider];
|
||||
|
||||
var vSlider = [[CPSlider alloc] initWithFrame:CGRectMake(innerX + controlWidth - 30, currentY - 20, 24, 60)];
|
||||
var vSlider = [[CPSlider alloc] initWithFrame:CGRectMake(innerX + controlWidth - 30, currentY - 5, 24, 60)];
|
||||
[leftContent addSubview:vSlider];
|
||||
|
||||
var knob = [[CPSlider alloc] initWithFrame:CGRectMake(innerX, currentY + 25, 32, 32)];
|
||||
|
||||
Reference in new issue
Block a user