parent
f1044ab3a7
commit
f7984f0d1d
@ -31,6 +31,7 @@ struct TrackInfo
|
|||||||
{
|
{
|
||||||
TrackViewInfo* viewInfo;
|
TrackViewInfo* viewInfo;
|
||||||
TrackData* trackData;
|
TrackData* trackData;
|
||||||
|
char* editText;
|
||||||
int selectLeft;
|
int selectLeft;
|
||||||
int selectRight;
|
int selectRight;
|
||||||
int selectTop;
|
int selectTop;
|
||||||
@ -42,6 +43,8 @@ struct TrackInfo
|
|||||||
int midPos;
|
int midPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern void Dialog_showColorPicker(uint32_t* color);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void TrackView_init()
|
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;
|
float value = track->keys[idx].value;
|
||||||
snprintf(temp, 256, "% .2f", 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
|
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))
|
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);
|
idx = sync_find_key(track, y);
|
||||||
|
|
||||||
renderInterpolation(info, track, size, idx, offset, y_offset, folded);
|
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) &&
|
selected = (trackIndex >= info->selectLeft && trackIndex <= info->selectRight) &&
|
||||||
(y >= info->selectTop && y < info->selectBottom);
|
(y >= info->selectTop && y < info->selectBottom);
|
||||||
@ -351,6 +358,9 @@ static int renderChannel(struct TrackInfo* info, int startX, int editRow, Track*
|
|||||||
if (trackData->selected)
|
if (trackData->selected)
|
||||||
{
|
{
|
||||||
Emgui_fill(trackData->group->folded ? dark_active_track_color : active_track_color, startX, info->midPos, size, font_size + 1);
|
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
|
// Shared info for all tracks
|
||||||
|
|
||||||
|
info.editText = trackData->editText;
|
||||||
info.selectLeft = emini(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
info.selectLeft = emini(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||||
info.selectRight = emaxi(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
info.selectRight = emaxi(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||||
info.selectTop = emini(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
info.selectTop = emini(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "../Dialog.h"
|
#include "../Dialog.h"
|
||||||
|
#include <Emgui.h>
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -51,3 +52,90 @@ int Dialog_save(char* dest)
|
|||||||
return true;
|
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