implement clipboard on OSX, fix hex and rob sliders on picker
This commit is contained in:
@@ -24,6 +24,18 @@ std::mutex task_mutex;
|
||||
{
|
||||
NSSharingService *airdrop_service;
|
||||
}
|
||||
- (std::string)clipboard_get_string
|
||||
{
|
||||
NSString* ns = [[NSPasteboard generalPasteboard] stringForType:NSPasteboardTypeString];
|
||||
const char* ptr = [ns cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
return std::string(ptr);
|
||||
}
|
||||
- (bool)clipboard_set_string:(const std::string &)s
|
||||
{
|
||||
NSString* ns = [NSString stringWithUTF8String:s.c_str()];
|
||||
[[NSPasteboard generalPasteboard] setString:ns forType:NSPasteboardTypeString];
|
||||
return true;
|
||||
}
|
||||
- (void)hockeyapp_crash
|
||||
{
|
||||
[[[BITHockeyManager sharedHockeyManager] crashManager] generateTestCrash];
|
||||
|
||||
@@ -32,4 +32,6 @@
|
||||
- (void)share_file:(NSString*)file_path;
|
||||
- (void)hockeyapp_crash;
|
||||
- (void)show_cursor:(bool)visible;
|
||||
- (std::string)clipboard_get_string;
|
||||
- (bool)clipboard_set_string:(const std::string&)s;
|
||||
@end
|
||||
|
||||
@@ -19,6 +19,8 @@ std::string App::clipboard_get_text()
|
||||
return win32_clipboard_get_text();
|
||||
#elif __IOS__
|
||||
return [ios_view clipboard_get_string];
|
||||
#elif __OSX__
|
||||
return [osx_view clipboard_get_string];
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -28,6 +30,8 @@ bool App::clipboard_set_text(const std::string& s)
|
||||
return win32_clipboard_set_text(s);
|
||||
#elif __IOS__
|
||||
return [ios_view clipboard_set_string:s];
|
||||
#elif __OSX__
|
||||
return [osx_view clipboard_set_string:s];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -117,9 +117,9 @@ void NodeColorPicker::init_controls()
|
||||
m_slider_s->m_value = hsv.y;
|
||||
m_slider_v->m_value = hsv.z;
|
||||
glm::vec3 rgb = convert_hsv2rgb(hsv);
|
||||
m_slider_h->set_value(hsv.x);
|
||||
m_slider_s->set_value(hsv.y);
|
||||
m_slider_v->set_value(hsv.z);
|
||||
m_slider_r->set_value(rgb.x);
|
||||
m_slider_g->set_value(rgb.y);
|
||||
m_slider_b->set_value(rgb.z);
|
||||
m_color_cur->m_color = { rgb, 1 };
|
||||
if (on_color_change)
|
||||
on_color_change(this, rgb);
|
||||
@@ -166,7 +166,7 @@ void NodeColorPicker::init_controls()
|
||||
void NodeColorPicker::update_hex(glm::vec3 rgb)
|
||||
{
|
||||
char tmp[32];
|
||||
snprintf(tmp, sizeof(tmp), "%xul", convert_rgb_long(rgb));
|
||||
snprintf(tmp, sizeof(tmp), "%x", convert_rgb_long(rgb));
|
||||
m_txt_hex->set_text_format("#%s", tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -485,7 +485,7 @@ glm::vec4 rand_color()
|
||||
return { r, g, b, 1.f };
|
||||
}
|
||||
|
||||
glm::vec3 convert_long_rgb(unsigned long hex)
|
||||
glm::vec3 convert_long_rgb(uint32_t hex)
|
||||
{
|
||||
uint8_t b = (hex >> 0) & 0xFF;
|
||||
uint8_t g = (hex >> 8) & 0xFF;
|
||||
@@ -493,7 +493,7 @@ glm::vec3 convert_long_rgb(unsigned long hex)
|
||||
return glm::vec3(r, g, b) / 255.f;
|
||||
}
|
||||
|
||||
unsigned long convert_rgb_long(glm::vec3 rgb)
|
||||
uint32_t convert_rgb_long(glm::vec3 rgb)
|
||||
{
|
||||
uint8_t r = (uint8_t)(rgb.r * 255.f);
|
||||
uint8_t g = (uint8_t)(rgb.g * 255.f);
|
||||
|
||||
@@ -71,8 +71,8 @@ std::vector<vertex_t> triangulate(const std::vector<vertex_t>& points);
|
||||
std::vector<vertex_t> triangulate(const std::vector<glm::vec2>& points);
|
||||
std::vector<vertex_t> triangulate_simple(const std::vector<vertex_t>& vertices);
|
||||
glm::vec4 rand_color();
|
||||
glm::vec3 convert_long_rgb(unsigned long hex);
|
||||
unsigned long convert_rgb_long(glm::vec3 rgb);
|
||||
glm::vec3 convert_long_rgb(uint32_t hex);
|
||||
uint32_t convert_rgb_long(glm::vec3 rgb);
|
||||
glm::vec3 convert_hsv2rgb(const glm::vec3 c);
|
||||
glm::vec3 convert_rgb2hsv(const glm::vec3 c);
|
||||
std::vector<std::string> split(const std::string& subject, char d, int max_split = 0);
|
||||
|
||||
Reference in New Issue
Block a user