add brackets brush size
This commit is contained in:
@@ -382,8 +382,8 @@
|
||||
{
|
||||
auto keyCode = [theEvent keyCode];
|
||||
auto chars = [theEvent characters];
|
||||
const char* c_str = [chars cStringUsingEncoding:NSASCIIStringEncoding];
|
||||
std::string s = c_str ? c_str : "";
|
||||
NSString* nss = keyCodeToString(keyCode, [theEvent modifierFlags]);
|
||||
std::string s = [nss cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
App::I->ui_task_async([keyCode, s] {
|
||||
if (App::I->keys[(int)kKey::KeyCtrl])
|
||||
{
|
||||
|
||||
@@ -75,6 +75,8 @@ enum class kKey : uint8_t
|
||||
KeyEnter,
|
||||
KeyBackspace,
|
||||
KeyDel,
|
||||
KeyBracketLeft,
|
||||
KeyBracketRight,
|
||||
};
|
||||
|
||||
enum class kEventResult : uint8_t
|
||||
|
||||
@@ -152,10 +152,10 @@ kKey convert_key(int key)
|
||||
CASE(kVK_ANSI_Minus, kKey::Unknown);
|
||||
CASE(kVK_ANSI_8, kKey::Key8);
|
||||
CASE(kVK_ANSI_0, kKey::Key0);
|
||||
CASE(kVK_ANSI_RightBracket, kKey::Unknown);
|
||||
CASE(kVK_ANSI_RightBracket, kKey::KeyBracketRight);
|
||||
CASE(kVK_ANSI_O, kKey::KeyO);
|
||||
CASE(kVK_ANSI_U, kKey::KeyU);
|
||||
CASE(kVK_ANSI_LeftBracket, kKey::Unknown);
|
||||
CASE(kVK_ANSI_LeftBracket, kKey::KeyBracketLeft);
|
||||
CASE(kVK_ANSI_I, kKey::KeyI);
|
||||
CASE(kVK_ANSI_P, kKey::KeyP);
|
||||
CASE(kVK_ANSI_L, kKey::KeyL);
|
||||
|
||||
@@ -615,6 +615,18 @@ kEventResult NodeCanvas::handle_event(Event* e)
|
||||
App::I->dialog_save_ver();
|
||||
}
|
||||
}
|
||||
if (ke->m_key == kKey::KeyBracketLeft)
|
||||
{
|
||||
float v = App::I->stroke->m_tip_size->get_value();
|
||||
float nv = glm::clamp<float>(v - 0.05, 0, 1);
|
||||
App::I->stroke->set_size(nv, true, true);
|
||||
}
|
||||
if (ke->m_key == kKey::KeyBracketRight)
|
||||
{
|
||||
float v = App::I->stroke->m_tip_size->get_value();
|
||||
float nv = glm::clamp<float>(v + 0.05, 0, 1);
|
||||
App::I->stroke->set_size(nv, true, true);
|
||||
}
|
||||
for (auto& mode : *m_canvas->m_mode)
|
||||
mode->on_KeyEvent(ke);
|
||||
break;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <iomanip>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Photos/Photos.h>
|
||||
@@ -39,6 +40,62 @@
|
||||
@end
|
||||
#endif
|
||||
|
||||
std::wstring NSStringToStringW ( NSString* Str )
|
||||
{
|
||||
NSStringEncoding pEncode = CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE );
|
||||
NSData* pSData = [ Str dataUsingEncoding : pEncode ];
|
||||
|
||||
return std::wstring ( (wchar_t*) [ pSData bytes ], [ pSData length] / sizeof ( wchar_t ) );
|
||||
}
|
||||
|
||||
NSString* StringWToNSString ( const std::wstring& Str )
|
||||
{
|
||||
NSString* pString = [ [ NSString alloc ]
|
||||
initWithBytes : (char*)Str.data()
|
||||
length : Str.size() * sizeof(wchar_t)
|
||||
encoding : CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE ) ];
|
||||
return pString;
|
||||
}
|
||||
|
||||
NSString* keyCodeToString(CGKeyCode keyCode, NSUInteger mods)
|
||||
{
|
||||
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
|
||||
CFDataRef uchr =
|
||||
(CFDataRef)TISGetInputSourceProperty(currentKeyboard,
|
||||
kTISPropertyUnicodeKeyLayoutData);
|
||||
const UCKeyboardLayout *keyboardLayout =
|
||||
(const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
|
||||
|
||||
if(keyboardLayout)
|
||||
{
|
||||
UInt32 deadKeyState = 0;
|
||||
UniCharCount maxStringLength = 255;
|
||||
UniCharCount actualStringLength = 0;
|
||||
UniChar unicodeString[maxStringLength];
|
||||
|
||||
OSStatus status = UCKeyTranslate(keyboardLayout,
|
||||
keyCode, kUCKeyActionDown, mods,
|
||||
LMGetKbdType(), 0,
|
||||
&deadKeyState,
|
||||
maxStringLength,
|
||||
&actualStringLength, unicodeString);
|
||||
|
||||
if (actualStringLength == 0 && deadKeyState)
|
||||
{
|
||||
status = UCKeyTranslate(keyboardLayout,
|
||||
kVK_Space, kUCKeyActionDown, mods,
|
||||
LMGetKbdType(), 0,
|
||||
&deadKeyState,
|
||||
maxStringLength,
|
||||
&actualStringLength, unicodeString);
|
||||
}
|
||||
if(actualStringLength > 0 && status == noErr)
|
||||
return [[NSString stringWithCharacters:unicodeString
|
||||
length:(NSUInteger)actualStringLength] lowercaseString];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
std::string base_address;
|
||||
std::atomic_flag handler_executed;
|
||||
|
||||
@@ -16,3 +16,6 @@ void delete_all_files_in_path(const std::string& source_path);
|
||||
void export_mp4(const std::string& rec_path, int width, int height, int tot, void(^progress_callback)(float));
|
||||
void save_image_library(const std::string& path);
|
||||
bool apple_create_dir(const std::string& path);
|
||||
NSString* keyCodeToString(CGKeyCode keyCode, NSUInteger mods);
|
||||
std::wstring NSStringToStringW(NSString* Str);
|
||||
NSString* StringWToNSString(const std::wstring& Str);
|
||||
|
||||
Reference in New Issue
Block a user