update tracking area on OSX when resizing view
This commit is contained in:
@@ -125,7 +125,7 @@ std::mutex task_mutex;
|
|||||||
[self setPixelFormat:pf];
|
[self setPixelFormat:pf];
|
||||||
[self setOpenGLContext:context];
|
[self setOpenGLContext:context];
|
||||||
|
|
||||||
NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:frameRect
|
self->trackingArea = [[NSTrackingArea alloc] initWithRect:frameRect
|
||||||
options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow )
|
options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow )
|
||||||
owner:self userInfo:nil];
|
owner:self userInfo:nil];
|
||||||
[self addTrackingArea:trackingArea];
|
[self addTrackingArea:trackingArea];
|
||||||
@@ -266,20 +266,28 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
|||||||
CGLFlushDrawable(cgl);
|
CGLFlushDrawable(cgl);
|
||||||
CGLUnlockContext(cgl);
|
CGLUnlockContext(cgl);
|
||||||
}
|
}
|
||||||
|
- (void)updateTrackingAreas
|
||||||
|
{
|
||||||
|
if(self->trackingArea != nil)
|
||||||
|
[self removeTrackingArea:self->trackingArea];
|
||||||
|
self->trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
|
||||||
|
options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow)
|
||||||
|
owner:self userInfo:nil];
|
||||||
|
[self addTrackingArea:trackingArea];
|
||||||
|
}
|
||||||
- (void)reshape
|
- (void)reshape
|
||||||
{
|
{
|
||||||
[super reshape];
|
[super reshape];
|
||||||
|
|
||||||
|
// Get the view size in Points
|
||||||
|
NSRect viewRectPoints = [self bounds];
|
||||||
|
|
||||||
// We draw on a secondary thread through the display link. However, when
|
// We draw on a secondary thread through the display link. However, when
|
||||||
// resizing the view, -drawRect is called on the main thread.
|
// resizing the view, -drawRect is called on the main thread.
|
||||||
// Add a mutex around to avoid the threads accessing the context
|
// Add a mutex around to avoid the threads accessing the context
|
||||||
// simultaneously when resizing.
|
// simultaneously when resizing.
|
||||||
CGLLockContext([[self openGLContext] CGLContextObj]);
|
CGLLockContext([[self openGLContext] CGLContextObj]);
|
||||||
|
|
||||||
// Get the view size in Points
|
|
||||||
NSRect viewRectPoints = [self bounds];
|
|
||||||
|
|
||||||
#if SUPPORT_RETINA_RESOLUTION
|
#if SUPPORT_RETINA_RESOLUTION
|
||||||
|
|
||||||
// Rendering at retina resolutions will reduce aliasing, but at the potential
|
// Rendering at retina resolutions will reduce aliasing, but at the potential
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
_CGLContextObject* cgl;
|
_CGLContextObject* cgl;
|
||||||
bool gl_ready;
|
bool gl_ready;
|
||||||
bool cursor_visible;
|
bool cursor_visible;
|
||||||
|
NSTrackingArea* trackingArea;
|
||||||
@public NSString* file2open;
|
@public NSString* file2open;
|
||||||
}
|
}
|
||||||
- (void)close;
|
- (void)close;
|
||||||
|
|||||||
@@ -163,8 +163,8 @@ StrokeSample Stroke::randomize_sample(const glm::vec3& pos, float pressure, floa
|
|||||||
hsv.x = glm::fract(glm::mix(hsv.x, (pressure - 0.5f) * 2.0f, m_brush->m_tip_hue) + (rnd_nor() - 0.5f) * m_brush->m_jitter_hue * eachtip);
|
hsv.x = glm::fract(glm::mix(hsv.x, (pressure - 0.5f) * 2.0f, m_brush->m_tip_hue) + (rnd_nor() - 0.5f) * m_brush->m_jitter_hue * eachtip);
|
||||||
hsv.y = glm::clamp(glm::mix(hsv.y, (1.f - pressure - 0.5f) * 2.0f, m_brush->m_tip_sat) + (rnd_nor() - 0.5f) * m_brush->m_jitter_sat * eachtip, 0.f, 1.f);
|
hsv.y = glm::clamp(glm::mix(hsv.y, (1.f - pressure - 0.5f) * 2.0f, m_brush->m_tip_sat) + (rnd_nor() - 0.5f) * m_brush->m_jitter_sat * eachtip, 0.f, 1.f);
|
||||||
hsv.z = glm::clamp(glm::mix(hsv.z, (pressure - 0.5f) * 2.0f, m_brush->m_tip_val) + (rnd_nor() - 0.5f) * m_brush->m_jitter_val * eachtip, 0.f, 1.f);
|
hsv.z = glm::clamp(glm::mix(hsv.z, (pressure - 0.5f) * 2.0f, m_brush->m_tip_val) + (rnd_nor() - 0.5f) * m_brush->m_jitter_val * eachtip, 0.f, 1.f);
|
||||||
m_hsv_jitter.add(hsv);
|
//m_hsv_jitter.add(hsv);
|
||||||
s.col = convert_hsv2rgb(m_hsv_jitter.average());
|
s.col = convert_hsv2rgb(hsv);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -327,9 +327,12 @@ void Stroke::start(const std::shared_ptr<Brush>& brush)
|
|||||||
m_step = glm::max(0.5f, m_brush->m_tip_spacing * size);
|
m_step = glm::max(0.5f, m_brush->m_tip_spacing * size);
|
||||||
|
|
||||||
auto hsv = convert_rgb2hsv(m_brush->m_tip_color);
|
auto hsv = convert_rgb2hsv(m_brush->m_tip_color);
|
||||||
hsv.x = glm::fract(hsv.x + (rnd_nor() - 0.5f) * m_brush->m_jitter_hue);
|
if (!m_brush->m_jitter_hsv_eachsample)
|
||||||
hsv.y = glm::clamp(hsv.y + (rnd_nor() - 0.5f) * m_brush->m_jitter_sat, 0.f, 1.f);
|
{
|
||||||
hsv.z = glm::clamp(hsv.z + (rnd_nor() - 0.5f) * m_brush->m_jitter_val, 0.f, 1.f);
|
hsv.x = glm::fract(hsv.x + (rnd_nor() - 0.5f) * m_brush->m_jitter_hue);
|
||||||
|
hsv.y = glm::clamp(hsv.y + (rnd_nor() - 0.5f) * m_brush->m_jitter_sat, 0.f, 1.f);
|
||||||
|
hsv.z = glm::clamp(hsv.z + (rnd_nor() - 0.5f) * m_brush->m_jitter_val, 0.f, 1.f);
|
||||||
|
}
|
||||||
m_tip_color = hsv;
|
m_tip_color = hsv;
|
||||||
|
|
||||||
m_direction.resize(std::max<int>(1, m_brush->m_tip_angle_smooth * 200.f / m_step));
|
m_direction.resize(std::max<int>(1, m_brush->m_tip_angle_smooth * 200.f / m_step));
|
||||||
|
|||||||
Reference in New Issue
Block a user