parent
f1044ab3a7
commit
f7984f0d1d
@ -31,6 +31,7 @@ struct TrackInfo
|
||||
{
|
||||
TrackViewInfo* viewInfo;
|
||||
TrackData* trackData;
|
||||
char* editText;
|
||||
int selectLeft;
|
||||
int selectRight;
|
||||
int selectTop;
|
||||
@ -42,6 +43,8 @@ struct TrackInfo
|
||||
int midPos;
|
||||
};
|
||||
|
||||
extern void Dialog_showColorPicker(uint32_t* color);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TrackView_init()
|
||||
@ -194,8 +197,7 @@ static void renderText(const struct TrackInfo* info, struct sync_track* track, i
|
||||
float value = track->keys[idx].value;
|
||||
snprintf(temp, 256, "% .2f", value);
|
||||
|
||||
if (!editRow)
|
||||
Emgui_drawText(temp, x, y - font_size_half, Emgui_color32(255, 255, 255, 255));
|
||||
Emgui_drawText(temp, x, y - font_size_half, Emgui_color32(255, 255, 255, 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -288,7 +290,10 @@ static int renderChannel(struct TrackInfo* info, int startX, int editRow, Track*
|
||||
|
||||
if (drawColorButton(color, startX + 4, info->startY - colorbar_adjust, size))
|
||||
{
|
||||
printf("Yah!\n");
|
||||
Dialog_showColorPicker(&trackData->color);
|
||||
|
||||
if (trackData->color != color)
|
||||
s_needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,7 +337,9 @@ static int renderChannel(struct TrackInfo* info, int startX, int editRow, Track*
|
||||
idx = sync_find_key(track, y);
|
||||
|
||||
renderInterpolation(info, track, size, idx, offset, y_offset, folded);
|
||||
renderText(info, track, y, idx, offset, y_offset, y == editRow, folded);
|
||||
|
||||
if (!(trackData->selected && info->viewInfo->rowPos == y && info->editText))
|
||||
renderText(info, track, y, idx, offset, y_offset, y == editRow, folded);
|
||||
|
||||
selected = (trackIndex >= info->selectLeft && trackIndex <= info->selectRight) &&
|
||||
(y >= info->selectTop && y < info->selectBottom);
|
||||
@ -351,6 +358,9 @@ static int renderChannel(struct TrackInfo* info, int startX, int editRow, Track*
|
||||
if (trackData->selected)
|
||||
{
|
||||
Emgui_fill(trackData->group->folded ? dark_active_track_color : active_track_color, startX, info->midPos, size, font_size + 1);
|
||||
|
||||
if (info->editText)
|
||||
Emgui_drawText(info->editText, startX + 2, info->midPos, Emgui_color32(255, 255, 255, 255));
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,6 +452,7 @@ void renderGroups(TrackViewInfo* viewInfo, TrackData* trackData)
|
||||
|
||||
// Shared info for all tracks
|
||||
|
||||
info.editText = trackData->editText;
|
||||
info.selectLeft = emini(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||
info.selectRight = emaxi(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||
info.selectTop = emini(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "../Dialog.h"
|
||||
#include <Emgui.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -51,3 +52,90 @@ int Dialog_save(char* dest)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@interface ColorDelegate : NSObject<NSWindowDelegate>
|
||||
{
|
||||
bool m_bIsClosed;
|
||||
}
|
||||
|
||||
// Delegate methods
|
||||
- (id)init;
|
||||
- (BOOL)windowShouldClose:(id)sender;
|
||||
- (BOOL)isClosed;
|
||||
@end
|
||||
|
||||
@implementation ColorDelegate : NSObject
|
||||
|
||||
- (id)init
|
||||
{
|
||||
[super init];
|
||||
m_bIsClosed = false;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldClose:(id)sender
|
||||
{
|
||||
(void)sender;
|
||||
|
||||
m_bIsClosed = true;
|
||||
|
||||
[NSApp abortModal];
|
||||
[NSApp stopModal];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isClosed
|
||||
{
|
||||
return m_bIsClosed;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Dialog_showColorPicker(uint32_t* color)
|
||||
{
|
||||
uint32_t c = *color;
|
||||
|
||||
NSAutoreleasePool *thePool;
|
||||
thePool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
//Get the shared color and font panel
|
||||
[[NSColorPanel sharedColorPanel] setColor:
|
||||
[NSColor colorWithCalibratedRed:(CGFloat) (Emgui_color32_getR(c) / 255.0)
|
||||
green:(CGFloat) (Emgui_color32_getG(c) / 255.0)
|
||||
blue:(CGFloat) (Emgui_color32_getB(c) / 255.0)
|
||||
alpha:(CGFloat) 1.0]];
|
||||
|
||||
NSColorPanel* theColorPanel = [NSColorPanel sharedColorPanel];
|
||||
|
||||
//Create and assign the delegates (cocoa event handlers) so
|
||||
//we can tell if a window has closed/open or not
|
||||
ColorDelegate* colorDelegate = [[ColorDelegate alloc] init];
|
||||
[theColorPanel setDelegate:colorDelegate];
|
||||
NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel];
|
||||
for (;;)
|
||||
{
|
||||
[NSApp runModalSession:session];
|
||||
|
||||
//If the color panel is closed, return the font panel modal loop
|
||||
if ([colorDelegate isClosed])
|
||||
break;
|
||||
}
|
||||
[NSApp endModalSession:session];
|
||||
|
||||
[theColorPanel setDelegate:nil];
|
||||
[colorDelegate release];
|
||||
|
||||
//Get the shared color panel along with the chosen color and set the chosen color
|
||||
NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
||||
|
||||
*color = Emgui_color32((unsigned char) ([theColor redComponent] * 255.0),
|
||||
(unsigned char) ([theColor greenComponent] * 255.0),
|
||||
(unsigned char) ([theColor blueComponent] * 255.0),
|
||||
255);
|
||||
|
||||
[thePool release];
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user