noobs 0.0.131 → 0.0.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/noobs.node +0 -0
- package/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/main.cpp +17 -3
- package/src/obs_interface.cpp +10 -7
- package/src/obs_interface.h +2 -2
package/dist/noobs.node
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -147,6 +147,10 @@ export type SceneItemPosition = {
|
|
|
147
147
|
y: number; // Y position in pixels
|
|
148
148
|
scaleX: number; // X scaling factor
|
|
149
149
|
scaleY: number; // Y scaling factor
|
|
150
|
+
cropLeft: number; // Pixels to crop from the left
|
|
151
|
+
cropRight: number; // Pixels to crop from the right
|
|
152
|
+
cropTop: number; // Pixels to crop from the top
|
|
153
|
+
cropBottom: number; // Pixels to crop from the bottom
|
|
150
154
|
};
|
|
151
155
|
|
|
152
156
|
export type SourceDimensions = {
|
package/package.json
CHANGED
package/src/main.cpp
CHANGED
|
@@ -554,16 +554,24 @@ Napi::Value ObsGetSourcePos(const Napi::CallbackInfo& info) {
|
|
|
554
554
|
|
|
555
555
|
std::string name = info[0].As<Napi::String>().Utf8Value();
|
|
556
556
|
|
|
557
|
-
vec2 pos; vec2 size; vec2 scale;
|
|
558
|
-
obs->getSourcePos(name, &pos, &size, &scale);
|
|
557
|
+
vec2 pos; vec2 size; vec2 scale; obs_sceneitem_crop crop;
|
|
558
|
+
obs->getSourcePos(name, &pos, &size, &scale, &crop);
|
|
559
559
|
|
|
560
560
|
Napi::Object result = Napi::Object::New(info.Env());
|
|
561
|
+
|
|
561
562
|
result.Set("x", Napi::Number::New(info.Env(), pos.x));
|
|
562
563
|
result.Set("y", Napi::Number::New(info.Env(), pos.y));
|
|
564
|
+
|
|
563
565
|
result.Set("width", Napi::Number::New(info.Env(), size.x));
|
|
564
566
|
result.Set("height", Napi::Number::New(info.Env(), size.y));
|
|
565
567
|
result.Set("scaleX", Napi::Number::New(info.Env(), scale.x));
|
|
566
568
|
result.Set("scaleY", Napi::Number::New(info.Env(), scale.y));
|
|
569
|
+
|
|
570
|
+
result.Set("cropLeft", Napi::Number::New(info.Env(), crop.left));
|
|
571
|
+
result.Set("cropRight", Napi::Number::New(info.Env(), crop.right));
|
|
572
|
+
result.Set("cropTop", Napi::Number::New(info.Env(), crop.top));
|
|
573
|
+
result.Set("cropBottom", Napi::Number::New(info.Env(), crop.bottom));
|
|
574
|
+
|
|
567
575
|
return result;
|
|
568
576
|
}
|
|
569
577
|
|
|
@@ -593,7 +601,13 @@ Napi::Value ObsSetSourcePos(const Napi::CallbackInfo& info) {
|
|
|
593
601
|
float scaleY = position.Get("scaleY").As<Napi::Number>().FloatValue();
|
|
594
602
|
vec2 scale = { scaleX, scaleY };
|
|
595
603
|
|
|
596
|
-
|
|
604
|
+
int cropLeft = position.Get("cropLeft").As<Napi::Number>().Int32Value();
|
|
605
|
+
int cropRight = position.Get("cropRight").As<Napi::Number>().Int32Value();
|
|
606
|
+
int cropTop = position.Get("cropTop").As<Napi::Number>().Int32Value();
|
|
607
|
+
int cropBottom = position.Get("cropBottom").As<Napi::Number>().Int32Value();
|
|
608
|
+
obs_sceneitem_crop crop = { cropLeft, cropTop, cropRight, cropBottom }; // Careful with ordering.
|
|
609
|
+
|
|
610
|
+
obs->setSourcePos(name, &pos, &scale, &crop);
|
|
597
611
|
return info.Env().Undefined();
|
|
598
612
|
}
|
|
599
613
|
|
package/src/obs_interface.cpp
CHANGED
|
@@ -597,14 +597,15 @@ void ObsInterface::disconnect_signal_handlers(obs_output_t *output) {
|
|
|
597
597
|
|
|
598
598
|
bool draw_source_outline(obs_scene_t *scene, obs_sceneitem_t *item, void *p) {
|
|
599
599
|
// Get the item position and size
|
|
600
|
-
vec2 pos; vec2 scale;
|
|
600
|
+
vec2 pos; vec2 scale; obs_sceneitem_crop crop;
|
|
601
601
|
obs_sceneitem_get_pos(item, &pos);
|
|
602
602
|
obs_sceneitem_get_scale(item, &scale);
|
|
603
|
+
obs_sceneitem_get_crop(item, &crop);
|
|
603
604
|
|
|
604
605
|
// Calculate actual size with scaling
|
|
605
606
|
obs_source_t *src = obs_sceneitem_get_source(item);
|
|
606
|
-
float width = obs_source_get_width(src) * scale.x;
|
|
607
|
-
float height = obs_source_get_height(src) * scale.y;
|
|
607
|
+
float width = (obs_source_get_width(src) - crop.left - crop.right) * scale.x;
|
|
608
|
+
float height = (obs_source_get_height(src) - crop.top - crop.bottom) * scale.y;
|
|
608
609
|
|
|
609
610
|
if (width <= 0 || height <= 0) {
|
|
610
611
|
// Don't want to call gs_draw_sprite with zero width or height.
|
|
@@ -634,7 +635,7 @@ bool draw_source_outline(obs_scene_t *scene, obs_sceneitem_t *item, void *p) {
|
|
|
634
635
|
|
|
635
636
|
// Bottom border
|
|
636
637
|
gs_matrix_push();
|
|
637
|
-
gs_matrix_translate3f(pos.x, pos.y
|
|
638
|
+
gs_matrix_translate3f(pos.x, pos.y + height - 4.0f, 0.0f);
|
|
638
639
|
gs_draw_sprite(nullptr, 0, width, 4.0f);
|
|
639
640
|
gs_matrix_pop();
|
|
640
641
|
|
|
@@ -652,7 +653,7 @@ bool draw_source_outline(obs_scene_t *scene, obs_sceneitem_t *item, void *p) {
|
|
|
652
653
|
|
|
653
654
|
// Dragging point box (25x25 pixels in bottom-right corner)
|
|
654
655
|
gs_matrix_push();
|
|
655
|
-
gs_matrix_translate3f(pos.x + width - 25.0f, pos.y
|
|
656
|
+
gs_matrix_translate3f(pos.x + width - 25.0f, pos.y + height - 25.0f, 0.0f);
|
|
656
657
|
gs_draw_sprite(nullptr, 0, 25.0f, 25.0f);
|
|
657
658
|
gs_matrix_pop();
|
|
658
659
|
|
|
@@ -1164,7 +1165,7 @@ void ObsInterface::removeSourceFromScene(std::string name) {
|
|
|
1164
1165
|
blog(LOG_INFO, "ObsInterface::removeSourceFromScene exited");
|
|
1165
1166
|
}
|
|
1166
1167
|
|
|
1167
|
-
void ObsInterface::getSourcePos(std::string name, vec2* pos, vec2* size, vec2* scale)
|
|
1168
|
+
void ObsInterface::getSourcePos(std::string name, vec2* pos, vec2* size, vec2* scale, obs_sceneitem_crop* crop)
|
|
1168
1169
|
{
|
|
1169
1170
|
auto it = sources.find(name);
|
|
1170
1171
|
|
|
@@ -1189,13 +1190,14 @@ void ObsInterface::getSourcePos(std::string name, vec2* pos, vec2* size, vec2* s
|
|
|
1189
1190
|
|
|
1190
1191
|
obs_sceneitem_get_pos(item, pos);
|
|
1191
1192
|
obs_sceneitem_get_scale(item, scale);
|
|
1193
|
+
obs_sceneitem_get_crop(item, crop);
|
|
1192
1194
|
|
|
1193
1195
|
// Pre-scaled sizes.
|
|
1194
1196
|
size->x = obs_source_get_width(source);
|
|
1195
1197
|
size->y = obs_source_get_height(source);
|
|
1196
1198
|
}
|
|
1197
1199
|
|
|
1198
|
-
void ObsInterface::setSourcePos(std::string name, vec2* pos, vec2* scale) {
|
|
1200
|
+
void ObsInterface::setSourcePos(std::string name, vec2* pos, vec2* scale, obs_sceneitem_crop* crop) {
|
|
1199
1201
|
obs_sceneitem_t *item = obs_scene_find_source(scene, name.c_str());
|
|
1200
1202
|
|
|
1201
1203
|
if (!item) {
|
|
@@ -1205,6 +1207,7 @@ void ObsInterface::setSourcePos(std::string name, vec2* pos, vec2* scale) {
|
|
|
1205
1207
|
|
|
1206
1208
|
obs_sceneitem_set_pos(item, pos);
|
|
1207
1209
|
obs_sceneitem_set_scale(item, scale);
|
|
1210
|
+
obs_sceneitem_set_crop(item, crop);
|
|
1208
1211
|
}
|
|
1209
1212
|
|
|
1210
1213
|
std::vector<std::string> ObsInterface::listAvailableVideoEncoders()
|
package/src/obs_interface.h
CHANGED
|
@@ -67,8 +67,8 @@ class ObsInterface {
|
|
|
67
67
|
|
|
68
68
|
void addSourceToScene(std::string name); // Add source to scene.
|
|
69
69
|
void removeSourceFromScene(std::string name); // Remove source from scene.
|
|
70
|
-
void getSourcePos(std::string name, vec2* pos, vec2* size, vec2* scale); // Size is returned to allow clients to calculate scale.
|
|
71
|
-
void setSourcePos(std::string name, vec2* pos, vec2* scale); // Size does not get set here because it's set by the source itself.
|
|
70
|
+
void getSourcePos(std::string name, vec2* pos, vec2* size, vec2* scale, obs_sceneitem_crop* crop); // Size is returned to allow clients to calculate scale.
|
|
71
|
+
void setSourcePos(std::string name, vec2* pos, vec2* scale, obs_sceneitem_crop* crop); // Size does not get set here because it's set by the source itself.
|
|
72
72
|
|
|
73
73
|
void initPreview(HWND parent); // Must call this before showPreview to setup resources.
|
|
74
74
|
void configurePreview(int x, int y, int width, int height); // Move and resize the preview display.
|