change node children from unique to shared ptr, rename Canvas2D to StrokePreview, add panel toolbar with icon buttons to toggle
@@ -1,3 +1,4 @@
|
||||
xcopy /I /D /Y /S /E ..\data src\main\assets\data
|
||||
call gradlew installDebug
|
||||
call adb shell am start -n com.omigamedev/android.app.NativeActivity
|
||||
pause
|
||||
@@ -116,7 +116,7 @@ static int engine_init_display(struct engine* engine) {
|
||||
surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);
|
||||
|
||||
const EGLint attribs_test[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
@@ -199,26 +199,34 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
|
||||
struct engine* engine = (struct engine*)app->userData;
|
||||
float x = AMotionEvent_getX(event, 0);
|
||||
float y = AMotionEvent_getY(event, 0);
|
||||
LOG("event source: %d", AInputEvent_getSource(event));
|
||||
MouseEvent e;
|
||||
int32_t eventType = AInputEvent_getType(event);
|
||||
switch (eventType) {
|
||||
case AINPUT_EVENT_TYPE_MOTION:
|
||||
switch (AInputEvent_getSource(event)) {
|
||||
case AINPUT_SOURCE_TOUCHSCREEN:
|
||||
int action = AKeyEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK;
|
||||
switch (action) {
|
||||
case AMOTION_EVENT_ACTION_DOWN:
|
||||
App::I.mouse_down(0, x, y);
|
||||
return 1;
|
||||
case AMOTION_EVENT_ACTION_UP:
|
||||
App::I.mouse_up(0, x, y);
|
||||
return 1;
|
||||
case AMOTION_EVENT_ACTION_MOVE:
|
||||
App::I.mouse_move(x, y);
|
||||
return 1;
|
||||
}
|
||||
// switch (AInputEvent_getSource(event)) {
|
||||
// case AINPUT_SOURCE_STYLUS:
|
||||
// case AINPUT_SOURCE_TOUCHSCREEN:
|
||||
{
|
||||
int action = AKeyEvent_getAction(event) & AMOTION_EVENT_ACTION_MASK;
|
||||
switch (action) {
|
||||
case AMOTION_EVENT_ACTION_DOWN:
|
||||
App::I.mouse_down(0, x, y);
|
||||
return 1;
|
||||
case AMOTION_EVENT_ACTION_UP:
|
||||
App::I.mouse_up(0, x, y);
|
||||
return 1;
|
||||
case AMOTION_EVENT_ACTION_HOVER_MOVE: // pen move before touching
|
||||
case AMOTION_EVENT_ACTION_MOVE:
|
||||
App::I.mouse_move(x, y);
|
||||
return 1;
|
||||
default:
|
||||
LOG("motion action: %d", action);
|
||||
break;
|
||||
} // end switch
|
||||
}
|
||||
}
|
||||
// break;
|
||||
// } // end switch
|
||||
break;
|
||||
case AINPUT_EVENT_TYPE_KEY:
|
||||
// handle key input...
|
||||
@@ -260,6 +268,7 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
|
||||
engine->accelerometerSensor,
|
||||
(1000L/60)*1000);
|
||||
}
|
||||
engine->animating = 1;
|
||||
break;
|
||||
case APP_CMD_LOST_FOCUS:
|
||||
// When our app loses focus, we stop monitoring the accelerometer.
|
||||
|
||||
@@ -310,13 +310,13 @@
|
||||
<node dir="col" wrap="0" width="100%" height="100%" pad="0">
|
||||
<!-- menu bar -->
|
||||
<border flood-events="1" margin="0 0 0 0" pad="0 0 0 0" color=".1" width="100%" height="30" dir="row" align="center">
|
||||
<button-custom id="menu-file" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8">
|
||||
<button-custom id="menu-file" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
|
||||
<text text="File" font-face="arial" font-size="11"/>
|
||||
</button-custom>
|
||||
<button-custom id="menu-edit" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8">
|
||||
<button-custom id="menu-edit" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
|
||||
<text text="Edit" font-face="arial" font-size="11"/>
|
||||
</button-custom>
|
||||
<button-custom id="menu-layers" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8">
|
||||
<button-custom id="menu-layers" height="100%" margin="0 0 0 0" justify="center" align="center" pad="8" color=".1">
|
||||
<text text="Layers" font-face="arial" font-size="11"/>
|
||||
</button-custom>
|
||||
</border>
|
||||
@@ -344,38 +344,52 @@
|
||||
<!--<text text="Settings" font-face="arial" font-size="11"/>-->
|
||||
</image>
|
||||
</button-custom>
|
||||
<button-custom width="50" margin="0 5 0 0" thickness="1" border-color=".0" pad="8" align="center" justify="center">
|
||||
<button-custom width="50" margin="0 15 0 0" thickness="1" border-color=".0" pad="8" align="center" justify="center">
|
||||
<icon width="100%" height="100%" icon="accept"/>
|
||||
</button-custom>
|
||||
</border>
|
||||
<!-- central row -->
|
||||
<node grow="1" dir="row" wrap="1" height="0">
|
||||
<!--<border width="60" color=".2 .2 .2 .6" margin="0 0 0 0" dir="col" pad="4">
|
||||
<border height="4" margin="-4 0 0 0"/>
|
||||
<button-custom width="50" height="50" margin="5 5 0 0" thickness="1" border-color=".0" pad="12" align="center" justify="center">
|
||||
<border width="60" color=".2 .2 .2 .6" margin="0 0 0 0" dir="col" pad="4" flood-events="1">
|
||||
<!--<border height="4" margin="-4 0 0 0"/>-->
|
||||
<!--<button-custom id="btn-stroke" width="50" height="50" margin="5 5 0 0" thickness="1" border-color=".0" pad="12" align="center" justify="center">
|
||||
<icon width="100%" height="100%" icon="accept"/>
|
||||
</button-custom>
|
||||
<button-custom width="50" height="50" margin="5 5 0 0" thickness="1" border-color=".0" pad="12" align="center" justify="center">
|
||||
<button-custom id="btn-brush" width="50" height="50" margin="5 5 0 0" thickness="1" border-color=".0" pad="12" align="center" justify="center">
|
||||
<icon width="100%" height="100%" icon="arrow_branch"/>
|
||||
</button-custom>
|
||||
<button-custom width="50" height="50" margin="5 5 0 0" thickness="1" border-color=".0" pad="12" align="center" justify="center">
|
||||
<button-custom id="btn-color" width="50" height="50" margin="5 5 0 0" thickness="1" border-color=".0" pad="12" align="center" justify="center">
|
||||
<icon width="100%" height="100%" icon="arrow_refresh"/>
|
||||
</button-custom>
|
||||
<button-custom width="50" height="50" margin="5 5 0 0" thickness="1" border-color=".0" pad="12" align="center" justify="center">
|
||||
<button-custom id="btn-layer" width="50" height="50" margin="5 5 0 0" thickness="1" border-color=".0" pad="12" align="center" justify="center">
|
||||
<icon width="100%" height="100%" icon="disk"/>
|
||||
</button-custom>-->
|
||||
|
||||
<!--panel togglers-->
|
||||
<button-custom id="btn-stroke" width="50" height="50" margin="0 0 5 0" thickness="1" border-color=".1" pad="2">
|
||||
<image path="data/ui/stroke.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||
</button-custom>
|
||||
</border>-->
|
||||
<button-custom id="btn-brush" width="50" height="50" margin="0 0 5 0" thickness="1" border-color=".1" pad="2">
|
||||
<image path="data/ui/brushes.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||
</button-custom>
|
||||
<button-custom id="btn-color" width="50" height="50" margin="0 0 5 0" thickness="1" border-color=".1" pad="2">
|
||||
<image path="data/ui/palette.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||
</button-custom>
|
||||
<button-custom id="btn-layer" width="50" height="50" margin="0 0 5 0" thickness="1" border-color=".1" pad="2">
|
||||
<image path="data/ui/layers.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||
</button-custom>
|
||||
</border>
|
||||
<!-- side bar -->
|
||||
<node height="100%" dir="row" shrink="1">
|
||||
<border pad="5 5 5 5" margin="0 0 0 0" color=".3 .3 .3 .4" height="100%" dir="col" wrap="1" shrink="1">
|
||||
<border id="panels" pad="5 5 5 5" margin="0 0 0 0" color=".3 .3 .3 .4" height="100%" dir="col" wrap="1" shrink="1">
|
||||
<!--Stroke-->
|
||||
<panel-stroke id="panel-stroke"/>
|
||||
<!--<panel-stroke id="panel-stroke"/>-->
|
||||
<!--Brushes-->
|
||||
<panel-brush id="panel-brush"/>
|
||||
<!--<panel-brush id="panel-brush"/>-->
|
||||
<!--Layers-->
|
||||
<panel-layer id="panel-layer"/>
|
||||
<!--<panel-layer id="panel-layer"/>-->
|
||||
<!--Colors-->
|
||||
<panel-color id="panel-color"/>
|
||||
<!--<panel-color id="panel-color"/>-->
|
||||
</border>
|
||||
</node>
|
||||
<!-- content panel -->
|
||||
@@ -385,7 +399,7 @@
|
||||
</node>
|
||||
<!-- status bar -->
|
||||
<border height="30" width="100%" color=".15" border-color=".3" dir="row" pad="0 0 0 10" align="center">
|
||||
<text-input width="100" height="100%" color=".3"/>
|
||||
<!--<text-input width="100" height="100%" color=".3"/>-->
|
||||
<text text="Status Bar: nothing to show here." font-face="arial" font-size="11"/>
|
||||
<text text="#opengl #fromscratch #c++" font-face="arial" font-size="11" margin="0 0 0 10" color=".2 .5 1 1"/>
|
||||
</border>
|
||||
|
||||
BIN
data/ui/brushes.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
12
data/ui/brushes.svg
Normal file
@@ -0,0 +1,12 @@
|
||||
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="-1249 851 100 100" style="enable-background:new -1249 851 100 100;" xml:space="preserve"><style type="text/css">
|
||||
.st0{display:none;}
|
||||
.st1{display:inline;opacity:0.17;}
|
||||
.st2{display:inline;fill:none;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
|
||||
.st3{display:inline;fill:#000000;}
|
||||
.st4{display:inline;fill:none;stroke:#000000;stroke-miterlimit:10;}
|
||||
|
||||
.st5{display:inline;fill:none;stroke:#000000;stroke-width:0.9646;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
|
||||
.st6{fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
|
||||
.st7{fill:none;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
|
||||
.st8{fill:none;stroke:#000000;stroke-width:1.9652;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
|
||||
</style><g class="st0"><rect x="-1206.4" y="896.2" class="st2" width="28.6" height="15.3"/><line class="st2" x1="-1206.4" y1="909.9" x2="-1177.8" y2="909.9"/><line class="st2" x1="-1186.2" y1="908" x2="-1175.3" y2="908"/><line class="st2" x1="-1190.1" y1="908" x2="-1188.2" y2="908"/><line class="st2" x1="-1182.6" y1="905.8" x2="-1180.8" y2="905.8"/><line class="st2" x1="-1178.9" y1="905.8" x2="-1174.2" y2="905.8"/><circle class="st2" cx="-1202.2" cy="914" r="2.3"/><circle class="st3" cx="-1202.2" cy="914" r="1.1"/><circle class="st2" cx="-1213.9" cy="914" r="2.3"/><circle class="st3" cx="-1213.9" cy="914" r="1.1"/><circle class="st3" cx="-1196.3" cy="914" r="1.1"/><circle class="st3" cx="-1187.6" cy="914" r="1.1"/><circle class="st3" cx="-1181.8" cy="914" r="1.1"/><circle class="st2" cx="-1196.3" cy="914" r="2.3"/><circle class="st2" cx="-1187.6" cy="914" r="2.3"/><circle class="st2" cx="-1181.8" cy="914" r="2.3"/><line class="st2" x1="-1198.6" y1="914" x2="-1199.9" y2="914"/><line class="st4" x1="-1185.3" y1="914" x2="-1183.8" y2="914"/><line class="st2" x1="-1179.5" y1="914" x2="-1176.6" y2="914"/><line class="st2" x1="-1177.8" y1="911.6" x2="-1177.8" y2="914"/><line class="st2" x1="-1204.4" y1="914.3" x2="-1208.3" y2="914.3"/><line class="st2" x1="-1204.1" y1="912.8" x2="-1208.3" y2="912.8"/><line class="st2" x1="-1208.3" y1="914.3" x2="-1208.3" y2="893.9"/><line class="st2" x1="-1208.3" y1="893.9" x2="-1206.6" y2="893.9"/><line class="st2" x1="-1208.6" y1="899.4" x2="-1218.4" y2="899.4"/><line class="st2" x1="-1218.4" y1="899.4" x2="-1218.4" y2="907.1"/><polyline class="st2" points="-1223.1,910.7 -1223.1,907.4 -1223.1,907.1 -1218.4,907.1 -1216.2,907.1 -1216.2,901 -1218.4,901 "/><path class="st2" d="M-1206.6,914.3h-3.2V914c0-2.2-1.8-4-4-4c-2.2,0-4,1.8-4,4v0.3h-4.9h-0.3v-1.1"/><rect x="-1214.3" y="901" class="st2" width="3.6" height="6.1"/><rect x="-1224.3" y="911.1" class="st2" width="2.5" height="1.8"/><path class="st2" d="M-1215.8,899.4L-1215.8,899.4c0-1.6,1.3-2.9,2.9-2.9h0.1h4.5"/><line class="st5" x1="-1194.1" y1="892.4" x2="-1192.8" y2="892.4"/><path class="st3" d="M-1195.3,892h-2.8c-0.3,0-0.5-0.2-0.5-0.5s0.2-0.5,0.5-0.5h2.8c0.2-0.1,0.4-0.2,0.4-0.5 s-0.2-0.5-0.5-0.5h-7.6c-0.3,0-0.5,0.2-0.5,0.5c0,0.2,0.2,0.4,0.4,0.5h0.6c0.3,0,0.5,0.2,0.5,0.5s-0.3,0.5-0.5,0.5h-0.6l0,0 c-0.2,0-0.4,0.2-0.4,0.5c0,0.2,0.1,0.4,0.3,0.4h1.5c0.3,0,0.5,0.2,0.5,0.5c0,0.3-0.2,0.5-0.5,0.5h-2.7l0,0c-0.3,0-0.5,0.2-0.5,0.5 c0,0.3,0.2,0.5,0.5,0.5h8.1c0.3,0,0.5-0.2,0.5-0.5c0-0.2-0.1-0.4-0.3-0.5h-2.1c-0.3,0-0.5-0.2-0.5-0.5c0-0.3,0.2-0.5,0.5-0.5h2.1 l0,0h0.7c0.3,0,0.5-0.2,0.5-0.5C-1195,892.2-1195.1,892.1-1195.3,892z"/></g><g><line class="st6" x1="-1226.8" y1="931.9" x2="-1171.5" y2="931.9"/><polyline class="st6" points="-1197.7,924.2 -1197.7,931.9 -1217.5,931.9 -1217.5,886.1 -1197.7,886.1 -1197.7,894.3 "/><path class="st6" d="M-1207.2,898.8c-1.1,1.1,0.3-0.3-2.4,2.4l0,0c-2.7,2.7-2.7,7,0,9.7l6.3,6.3l-7.5,7.5 c-1.7,1.7-1.7,4.4,0,6c1.7,1.7,4.4,1.7,6,0l7.5-7.5l6.3,6.3c2.7,2.7,7,2.7,9.7,0l0,0c2.3-2.5,2.3-2.5,2.3-2.5L-1207.2,898.8z"/><line class="st7" x1="-1194.7" y1="921.7" x2="-1195.6" y2="920.8"/><path class="st7" d="M-1193.3,923.1l3.2,3.2c2.3,2.3,5.1,2.4,7.4,0.4"/><polyline class="st6" points="-1217.5,886.1 -1207.6,871.1 -1197.7,886.1 "/><line class="st6" x1="-1211.8" y1="877.5" x2="-1203.4" y2="877.5"/><polygon class="st8" points="-1181.6,924.4 -1204.4,901.5 -1188,885.2 -1165.1,908 "/><line class="st6" x1="-1190.5" y1="895.6" x2="-1184" y2="889.1"/><line class="st6" x1="-1188.3" y1="903.5" x2="-1179" y2="894.2"/><line class="st6" x1="-1180.8" y1="905.3" x2="-1174.3" y2="898.8"/><line class="st6" x1="-1173.6" y1="908.2" x2="-1169.3" y2="903.9"/><line class="st6" x1="-1210" y1="923.8" x2="-1210" y2="910.5"/><line class="st6" x1="-1210" y1="901.2" x2="-1210" y2="890.6"/><line class="st6" x1="-1204.2" y1="886.1" x2="-1204.2" y2="901.4"/></g></svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
BIN
data/ui/layers.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
1
data/ui/layers.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><g><polygon points="49.556,94.211 100.403,69.801 82.023,63.549 49.763,79.051 18.943,66.185 0.403,73.697 "/><polygon points="49.556,49.233 100.403,24.825 52.322,6.594 0.403,28.729 "/><polygon points="49.556,72.19 100.403,47.778 80.89,41.143 49.763,56.097 20.075,43.71 0.403,51.676 "/></g></svg>
|
||||
|
After Width: | Height: | Size: 503 B |
BIN
data/ui/palette.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
1
data/ui/palette.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve"><path d="M50.7,15c-9.3-0.2-18.1,3.4-24.9,10C18.9,31.8,15,41.1,15,50.7V51c0,4.4,3.6,8,8,8s8-3.6,8-8c0-2.8,2.2-5,5-5 c1,0,2,0.3,2.8,0.9c1.6,1.1,2.4,3.3,1.9,5.4l-0.1,0.3c-0.5,1.9-1.8,3.4-3.8,4.2c-3.5,1.5-5.8,4.9-5.8,8.8c0,10.6,8.5,19.2,19,19.5 l0.5,0v0C69.6,84.7,85,69.1,85,50C85,31.1,69.6,15.4,50.7,15z M49,32c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S52.3,32,49,32z M58,33 c0-3.3,2.7-6,6-6s6,2.7,6,6s-2.7,6-6,6S58,36.3,58,33z M67,72c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S70.3,72,67,72z M72,55 c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S75.3,55,72,55z"/></svg>
|
||||
|
After Width: | Height: | Size: 765 B |
BIN
data/ui/stroke.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
1
data/ui/stroke.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve"><path d="M88.9,83.3c-0.5-1.9-0.9-3.7-1.5-5.5c-0.6-1.8-1.2-3.6-1.9-5.4c-0.7-1.8-1.5-3.5-2.3-5.2c-0.8-1.7-1.7-3.4-2.6-5 c-0.9-1.7-1.9-3.3-2.9-4.9c-1-1.6-2-3.2-3.1-4.7c-2.1-3.1-4.5-6-6.9-8.8c-2.4-2.8-4.9-5.6-7.5-8.2c-2.6-2.6-5.3-5.2-7.9-7.7 c-5.4-5-11-9.7-16.6-14.4c2.4,2.8,4.8,5.5,7.2,8.3l7.2,8.2c2.4,2.7,4.7,5.5,7,8.3c2.3,2.8,4.5,5.7,6.6,8.6c2.1,2.9,4,5.9,5.9,8.9 c0.9,1.5,1.8,3,2.7,4.6c0.8,1.6,1.7,3.1,2.4,4.7c0.8,1.6,1.5,3.2,2.1,4.8c0.3,0.7,0.6,1.4,0.8,2.2l-3.1-2.9c-4.4-4-8.8-8-13.3-11.9 c-4.5-3.9-9.1-7.7-14-11.4c-2.4-1.8-4.9-3.6-7.7-5.3c-1.4-0.8-2.8-1.6-4.5-2.3c-0.9-0.4-1.8-0.7-3-0.9c-0.6-0.1-1.3-0.2-2.3-0.1 c-0.9,0.1-2.3,0.5-3.3,1.5l-0.1,0.1c-1.2,1.1-1.6,2.9-0.9,4.4c2.5,5.9,5.1,11.8,8.4,17.6c0.6,1.1,1.3,2.3,2,3.4 c-1-0.4-1.9-0.8-2.9-1.1c-3-1.1-6-2-9-2.8c-3-0.8-6-1.5-9-2.2l-0.1,0c-0.4-0.1-0.8,0-1.1,0.3c-0.7,0.7-1,1.7-1.1,2.6 c-0.1,0.9,0.1,1.7,0.3,2.5c0.4,1.5,1.1,2.8,1.8,4.1c1.5,2.5,3.3,4.7,5.1,6.9c-1.4-2.5-2.8-5-3.9-7.5c-0.5-1.3-1-2.6-1.2-3.9 c-0.1-0.6-0.1-1.2,0-1.8c0.1-0.2,0.1-0.4,0.2-0.6c2.6,1,5.3,1.9,7.9,3c1.4,0.6,2.8,1.2,4.2,1.7c1.4,0.6,2.8,1.2,4.1,1.8 c2.7,1.3,5.4,2.7,7.8,4.3c1.2,0.8,2.4,1.6,3.5,2.5c1.1,0.9,2.2,1.8,3.2,2.8c1.1,1.1,3,1.2,4.2,0.1c1.3-1.1,1.4-3.1,0.3-4.4l-0.1-0.2 c-1-1.1-1.9-2.3-2.8-3.5c-0.9-1.2-1.7-2.5-2.5-3.7c-0.8-1.3-1.6-2.6-2.3-3.9c-0.7-1.3-1.5-2.7-2.1-4.1c-1.4-2.7-2.6-5.6-3.9-8.4 c-0.1-0.2-0.1-0.3-0.2-0.5c1.9,1.3,3.9,2.7,5.8,4.2c4.6,3.5,9.1,7.3,13.5,11.1c4.5,3.8,8.9,7.7,13.3,11.6l6.7,5.9l3.4,2.9 c1.2,1,2.2,1.9,3.6,3l0.1,0.1c0.9,0.7,2,0.9,3.2,0.7C88.1,87.4,89.4,85.3,88.9,83.3z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -184,7 +184,7 @@ void App::initLayout()
|
||||
NodeBorder::static_init();
|
||||
NodeImage::static_init();
|
||||
NodeIcon::static_init();
|
||||
NodeCanvas2D::static_init();
|
||||
NodeStrokePreview::static_init();
|
||||
|
||||
layout.on_loaded = [&] {
|
||||
LOG("initializing layout updating after load");
|
||||
@@ -192,10 +192,36 @@ void App::initLayout()
|
||||
|
||||
LOG("initializing layout components");
|
||||
sidebar = layout[main_id]->find<NodeBorder>("sidebar");
|
||||
brushes = layout[main_id]->find<NodePanelBrush>("panel-brush");
|
||||
layers = layout[main_id]->find<NodePanelLayer>("panel-layer");
|
||||
color = layout[main_id]->find<NodePanelColor>("panel-color");
|
||||
stroke = layout[main_id]->find<NodePanelStroke>("panel-stroke");
|
||||
panels = layout[main_id]->find<Node>("panels");
|
||||
|
||||
//brushes = layout[main_id]->find<NodePanelBrush>("panel-brush");
|
||||
//layers = layout[main_id]->find<NodePanelLayer>("panel-layer");
|
||||
//color = layout[main_id]->find<NodePanelColor>("panel-color");
|
||||
//stroke = layout[main_id]->find<NodePanelStroke>("panel-stroke");
|
||||
|
||||
brushes = std::make_shared<NodePanelBrush>();
|
||||
brushes->m_manager = &layout;
|
||||
brushes->init();
|
||||
brushes->create();
|
||||
brushes->loaded();
|
||||
|
||||
layers = std::make_shared<NodePanelLayer>();
|
||||
layers->m_manager = &layout;
|
||||
layers->init();
|
||||
layers->create();
|
||||
layers->loaded();
|
||||
|
||||
color = std::make_shared<NodePanelColor>();
|
||||
color->m_manager = &layout;
|
||||
color->init();
|
||||
color->create();
|
||||
color->loaded();
|
||||
|
||||
stroke = std::make_shared<NodePanelStroke>();
|
||||
stroke->m_manager = &layout;
|
||||
stroke->init();
|
||||
stroke->create();
|
||||
stroke->loaded();
|
||||
|
||||
brushes->on_brush_changed = [this](Node* target, int index) {
|
||||
auto tid = brushes->get_texture_id(index);
|
||||
@@ -217,6 +243,67 @@ void App::initLayout()
|
||||
on_stroke_change();
|
||||
};
|
||||
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-stroke"))
|
||||
{
|
||||
button->on_click = [this](Node*) {
|
||||
panels->remove_all_children();
|
||||
if (current_panel != stroke.get())
|
||||
{
|
||||
panels->add_child(std::static_pointer_cast<Node>(stroke));
|
||||
current_panel = stroke.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
current_panel = nullptr;
|
||||
}
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-brush"))
|
||||
{
|
||||
button->on_click = [this](Node*) {
|
||||
panels->remove_all_children();
|
||||
if (current_panel != brushes.get())
|
||||
{
|
||||
panels->add_child(std::static_pointer_cast<Node>(brushes));
|
||||
current_panel = brushes.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
current_panel = nullptr;
|
||||
}
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-color"))
|
||||
{
|
||||
button->on_click = [this](Node*) {
|
||||
panels->remove_all_children();
|
||||
if (current_panel != color.get())
|
||||
{
|
||||
panels->add_child(std::static_pointer_cast<Node>(color));
|
||||
current_panel = color.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
current_panel = nullptr;
|
||||
}
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-layer"))
|
||||
{
|
||||
button->on_click = [this](Node*) {
|
||||
panels->remove_all_children();
|
||||
if (current_panel != layers.get())
|
||||
{
|
||||
panels->add_child(std::static_pointer_cast<Node>(layers));
|
||||
current_panel = layers.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
current_panel = nullptr;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (auto* button = layout[main_id]->find<NodeButton>("btn-close"))
|
||||
{
|
||||
button->on_click = [](Node*) { exit(0); };
|
||||
|
||||
10
engine/app.h
@@ -20,10 +20,12 @@ public:
|
||||
NodePopupMenu* menu_edit = nullptr;
|
||||
NodePopupMenu* menu_layers = nullptr;
|
||||
NodeBorder* sidebar = nullptr;
|
||||
NodePanelBrush* brushes;
|
||||
NodePanelLayer* layers;
|
||||
NodePanelColor* color;
|
||||
NodePanelStroke* stroke;
|
||||
std::shared_ptr<NodePanelBrush> brushes;
|
||||
std::shared_ptr<NodePanelLayer> layers;
|
||||
std::shared_ptr<NodePanelColor> color;
|
||||
std::shared_ptr<NodePanelStroke> stroke;
|
||||
Node* current_panel = nullptr;
|
||||
Node* panels;
|
||||
std::function<void(int)> on_brush_select;
|
||||
std::function<void(glm::vec4 color)> on_color_change;
|
||||
std::function<void()> on_stroke_change;
|
||||
|
||||
@@ -9,7 +9,7 @@ Plane NodeBorder::m_plane;
|
||||
Plane NodeImage::m_plane;
|
||||
Sampler NodeImage::m_sampler;
|
||||
std::map<std::string, glm::vec4> NodeIcon::m_icons;
|
||||
ui::Shader NodeCanvas2D::m_shader;
|
||||
ui::Shader NodeStrokePreview::m_shader;
|
||||
|
||||
kEventResult Node::on_event(Event* e)
|
||||
{
|
||||
@@ -112,9 +112,23 @@ void Node::add_child(Node* n, int index)
|
||||
YGNodeInsertChild(y_node, n->y_node, index);
|
||||
}
|
||||
|
||||
void Node::add_child(std::shared_ptr<Node> n)
|
||||
{
|
||||
m_children.push_back(n);
|
||||
n->parent = this;
|
||||
n->m_manager = m_manager;
|
||||
YGNodeInsertChild(y_node, n->y_node, YGNodeGetChildCount(y_node));
|
||||
}
|
||||
void Node::add_child(std::shared_ptr<Node> n, int index)
|
||||
{
|
||||
m_children.push_back(n);
|
||||
n->parent = this;
|
||||
n->m_manager = m_manager;
|
||||
YGNodeInsertChild(y_node, n->y_node, index);
|
||||
}
|
||||
void Node::remove_child(Node* n)
|
||||
{
|
||||
auto i = std::find_if(m_children.begin(), m_children.end(), [=](std::unique_ptr<Node>& ptr) { return ptr.get() == n; });
|
||||
auto i = std::find_if(m_children.begin(), m_children.end(), [=](auto& ptr) { return ptr.get() == n; });
|
||||
if (i != m_children.end())
|
||||
{
|
||||
YGNodeRemoveChild(y_node, n->y_node);
|
||||
@@ -122,6 +136,12 @@ void Node::remove_child(Node* n)
|
||||
}
|
||||
}
|
||||
|
||||
void Node::remove_all_children()
|
||||
{
|
||||
for (auto& n : m_children)
|
||||
YGNodeRemoveChild(y_node, n->y_node);
|
||||
m_children.clear();
|
||||
}
|
||||
void Node::move_child(Node* n, int index)
|
||||
{
|
||||
YGNodeRemoveChild(y_node, n->y_node);
|
||||
@@ -443,7 +463,7 @@ void Node::load_internal(const tinyxml2::XMLElement* x_node)
|
||||
CASE(kWidget::PanelColor, NodePanelColor);
|
||||
CASE(kWidget::PanelStroke, NodePanelStroke);
|
||||
CASE(kWidget::ColorQuad, NodeColorQuad);
|
||||
CASE(kWidget::Canvas2D, NodeCanvas2D);
|
||||
CASE(kWidget::Canvas2D, NodeStrokePreview);
|
||||
#undef CASE
|
||||
case kWidget::Ref:
|
||||
{
|
||||
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
class LayoutManager* m_manager;
|
||||
uint16_t m_nodeID;
|
||||
std::string m_nodeID_s;
|
||||
std::vector<std::unique_ptr<Node>> m_children;
|
||||
std::vector<std::shared_ptr<Node>> m_children;
|
||||
Node* current_mouse_capture = nullptr;
|
||||
Node* current_key_capture = nullptr;
|
||||
bool m_mouse_captured = false;
|
||||
@@ -301,7 +301,10 @@ public:
|
||||
const Node* init_template(const char* id);
|
||||
void add_child(Node* n);
|
||||
void add_child(Node* n, int index);
|
||||
void add_child(std::shared_ptr<Node> n);
|
||||
void add_child(std::shared_ptr<Node> n, int index);
|
||||
void remove_child(Node* n);
|
||||
void remove_all_children();
|
||||
void move_child(Node* n, int index);
|
||||
void move_child_offset(Node* n, int offset);
|
||||
int get_child_index(Node* n);
|
||||
@@ -732,10 +735,10 @@ public:
|
||||
case kEventType::KeyDown:
|
||||
switch (ke->m_key)
|
||||
{
|
||||
case VK_BACK:
|
||||
m_string.erase(m_string.end() - 1);
|
||||
m_text->set_text(m_string.c_str());
|
||||
break;
|
||||
// case VK_BACK:
|
||||
// m_string.erase(m_string.end() - 1);
|
||||
// m_text->set_text(m_string.c_str());
|
||||
// break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1655,7 +1658,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class NodeCanvas2D : public NodeBorder
|
||||
class NodeStrokePreview : public NodeBorder
|
||||
{
|
||||
RTT m_rtt;
|
||||
Sampler m_sampler;
|
||||
@@ -1696,7 +1699,7 @@ public:
|
||||
"}";
|
||||
m_shader.create(shader_v, shader_f);
|
||||
}
|
||||
virtual Node* clone_instantiate() const override { return new NodeCanvas2D(); }
|
||||
virtual Node* clone_instantiate() const override { return new NodeStrokePreview(); }
|
||||
virtual void clone_copy(Node* dest) const override
|
||||
{
|
||||
NodeBorder::clone_copy(dest);
|
||||
@@ -1707,7 +1710,7 @@ public:
|
||||
}
|
||||
virtual void clone_finalize(Node* dest) const override
|
||||
{
|
||||
NodeCanvas2D* n = (NodeCanvas2D*)dest;
|
||||
NodeStrokePreview* n = (NodeStrokePreview*)dest;
|
||||
n->init_controls();
|
||||
}
|
||||
void init_controls()
|
||||
@@ -1798,7 +1801,7 @@ public:
|
||||
class NodePanelStroke : public Node
|
||||
{
|
||||
public:
|
||||
NodeCanvas2D* m_canvas;
|
||||
NodeStrokePreview* m_canvas;
|
||||
NodeSliderH* m_tip_size;
|
||||
NodeSliderH* m_tip_spacing;
|
||||
NodeSliderH* m_tip_flow;
|
||||
@@ -1821,26 +1824,26 @@ public:
|
||||
}
|
||||
void init_controls()
|
||||
{
|
||||
m_canvas = find<NodeCanvas2D>("canvas");
|
||||
m_canvas = find<NodeStrokePreview>("canvas");
|
||||
|
||||
init_slider(m_tip_size, "tip-size", &NodeCanvas2D::m_tip_size);
|
||||
init_slider(m_tip_spacing, "tip-spacing", &NodeCanvas2D::m_tip_spacing);
|
||||
init_slider(m_tip_flow, "tip-flow", &NodeCanvas2D::m_tip_flow);
|
||||
init_slider(m_tip_angle, "tip-angle", &NodeCanvas2D::m_tip_angle);
|
||||
init_slider(m_jitter_scale, "jitter-scale", &NodeCanvas2D::m_jitter_scale);
|
||||
init_slider(m_jitter_angle, "jitter-angle", &NodeCanvas2D::m_jitter_angle);
|
||||
init_slider(m_jitter_spread, "jitter-spread", &NodeCanvas2D::m_jitter_spread);
|
||||
init_slider(m_jitter_flow, "jitter-flow", &NodeCanvas2D::m_jitter_flow);
|
||||
init_slider(m_tip_size, "tip-size", &NodeStrokePreview::m_tip_size);
|
||||
init_slider(m_tip_spacing, "tip-spacing", &NodeStrokePreview::m_tip_spacing);
|
||||
init_slider(m_tip_flow, "tip-flow", &NodeStrokePreview::m_tip_flow);
|
||||
init_slider(m_tip_angle, "tip-angle", &NodeStrokePreview::m_tip_angle);
|
||||
init_slider(m_jitter_scale, "jitter-scale", &NodeStrokePreview::m_jitter_scale);
|
||||
init_slider(m_jitter_angle, "jitter-angle", &NodeStrokePreview::m_jitter_angle);
|
||||
init_slider(m_jitter_spread, "jitter-spread", &NodeStrokePreview::m_jitter_spread);
|
||||
init_slider(m_jitter_flow, "jitter-flow", &NodeStrokePreview::m_jitter_flow);
|
||||
//m_canvas->draw_stroke();
|
||||
}
|
||||
void init_slider(NodeSliderH*& slider, const char* id, float NodeCanvas2D::* prop)
|
||||
void init_slider(NodeSliderH*& slider, const char* id, float NodeStrokePreview::* prop)
|
||||
{
|
||||
slider = find<NodeSliderH>(id);
|
||||
slider->on_value_changed = std::bind(&NodePanelStroke::handle_slide,
|
||||
this, prop, std::placeholders::_1, std::placeholders::_2);
|
||||
m_canvas->*prop = slider->m_value.x;
|
||||
}
|
||||
void handle_slide(float NodeCanvas2D::* prop, Node* target, float value)
|
||||
void handle_slide(float NodeStrokePreview::* prop, Node* target, float value)
|
||||
{
|
||||
m_canvas->*prop = value;
|
||||
m_canvas->draw_stroke();
|
||||
|
||||