Deprecated CCMenu Images - cocos2d-iphone

What can I use instead of itemFromNormalImage:selectedImage:disabledImage:target:selector It is deprecated in iOS 7, and I am new to programming in Objective C, so I don't know another way.

You can use this method
+ (id) itemWithNormalImage:(NSString *) value selectedImage:(NSString *) value2 disabledImage:(NSString *) value3 target:(id) r selector:(SEL) s
If your code was this:
CCMenuItemImage *playGameButton = [CCMenuItemImage itemFromNormalImage:#"UIButtonTemplate.png" selectedImage:#"UIButtonTemplate.png" disabledImage:nil target:self selector:#selector(displaySceneSelection)];
Now it should be like this:
CCMenuItemImage *playGameButton = [CCMenuItemImage itemWithNormalImage:#"UIButtonTemplate.png" selectedImage:#"UIButtonTemplate.png" disabledImage:nil target:self selector:#selector(displaySceneSelection)];

try this
CCMenuItemSprite *Menu1=[CCMenuItemSprite itemWithNormalSprite:<#(CCNode<CCRGBAProtocol> *)#> selectedSprite:<#(CCNode<CCRGBAProtocol> *)#>];
CCMenuItemSprite *Menu2=[CCMenuItemSprite itemWithNormalSprite:<#(CCNode<CCRGBAProtocol> *)#> selectedSprite:<#(CCNode<CCRGBAProtocol> *)#> block:<#^(id sender)block#>];
CCMenuItemSprite *Menu3=[CCMenuItemSprite itemWithNormalSprite:<#(CCNode<CCRGBAProtocol> *)#> selectedSprite:<#(CCNode<CCRGBAProtocol> *)#> disabledSprite:<#(CCNode<CCRGBAProtocol> *)#> block:<#^(id sender)block#>];
CCMenuItemSprite *Menu4=[CCMenuItemSprite itemWithNormalSprite:<#(CCNode<CCRGBAProtocol> *)#> selectedSprite:<#(CCNode<CCRGBAProtocol> *)#> disabledSprite:<#(CCNode<CCRGBAProtocol> *)#> target:<#(id)#> selector:<#(SEL)#>];
CCMenuItemSprite *Menu5=[CCMenuItemSprite itemWithNormalSprite:<#(CCNode<CCRGBAProtocol> *)#> selectedSprite:<#(CCNode<CCRGBAProtocol> *)#> target:<#(id)#> selector:<#(SEL)#>];

Related

Jetpack compose gradient image on top of image

I have the below code in xml layout, which I would like to move to compose and havong a hard time to get it right
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<ImageView
android:id="#+id/image1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/image"
app:layout_constraintDimensionRatio="375:258"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/image_gradient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="#drawable/gradient"
app:layout_constraintBottom_toBottomOf="#id/image1" />
</androidx.constraintlayout.widget.ConstraintLayout>
I tried in Compose using a Box that didn't work
Box {
Image(painter = painterResource(
id = R.drawable.image1),
contentDescription = null,
)
Image(painter = painterResource(
id = R.drawable.gradient),
contentDescription = null,
contentScale = ContentScale.FillBounds
)
}
Most probably your gradient image has zero size.
You can use Modifier.matchParentSize: it is available in BoxScope. Apply it to the gradient image to make its size equal to the size of the main image.
Box {
Image(painter = painterResource(
id = R.drawable.image1),
contentDescription = null,
)
Image(painter = painterResource(
id = R.drawable.gradient),
contentDescription = null,
contentScale = ContentScale.FillBounds,
modifier = Modifier.matchParentSize()
)
}
I think you should create the gradient in a composy way
Column(Modifier.fillMaxSize()
.background(Color.White)) {
Box(
modifier = Modifier
.fillMaxWidth()
.background(color = Color.White)
.height(200.dp)
) {
Image(
painter = painterResource(
id = R.drawable.ty
),
contentDescription = null,
modifier = Modifier
.fillMaxWidth(),
contentScale = ContentScale.Crop
)
Box(
modifier = Modifier
.background(
brush = Brush.verticalGradient(
colors = listOf(
MaterialTheme.colors.primary.copy(alpha = 0.5f),
MaterialTheme.colors.primaryVariant.copy(alpha = 0.5f)
)
)
)
.fillMaxSize()
)
}
}
}

Running gstreamer on ubuntu sending video through RTSP is too slow

I am trying to stream live video from a webcam attached on my ubuntu machine.
I first checked out the gst-rtsp-server code and followed the steps below:
$ git clone git://anongit.freedesktop.org/gstreamer/gst-rtsp-server
$ cd gst-rtsp-server
$ git checkout 1.4
$ ./autogen.sh
$ make
$ sudo make install
Then I tried to send the test pattern image
./test-launch '( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )'
stream ready at rtsp://127.0.0.1:8554/test
The client side can see the pattern - works.
Then I tried to display the webcam with the following command.
./test-launch '( v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! x264enc ! rtph264pay name=pay0 pt=96 )'
This works fine but the latency is about 3 seconds.
Is there a way to reduce the latency to make it look more like in real time ?
From gst-device-monitor I see the following message:
$ gst-device-monitor-1.0
Probing devices...
Device found:
Analog Stereo: BUFFALO BSWHD06M USB Camera
class : Audio/Source
caps : audio/x-raw, format=(string){ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, S24LE, S24BE, S24_32LE, S24_32BE, U8 }, layout=(string)interleaved, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-alaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-mulaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
properties:
alsa.resolution_bits = 16
device.api = alsa
device.class = sound
alsa.class = generic
alsa.subclass = generic-mix
alsa.name = "USB\ Audio"
alsa.id = "USB\ Audio"
alsa.subdevice = 0
alsa.subdevice_name = "subdevice\ \#0"
alsa.device = 0
alsa.card = 1
alsa.card_name = "BUFFALO\ BSWHD06M\ USB\ Camera"
alsa.long_card_name = "KYE\ Systems\ Corp.\ BUFFALO\ BSWHD06M\ USB\ Camera\ at\ usb-0000:00:14.0-10\,\ high\ spee"
alsa.driver_name = snd_usb_audio
device.bus_path = pci-0000:00:14.0-usb-0:10:1.2
sysfs.path = /devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.2/sound/card1
udev.id = usb-KYE_Systems_Corp._BUFFALO_BSWHD06M_USB_Camera-02
device.bus = usb
device.vendor.id = 0411
device.vendor.name = "BUFFALO\ INC.\ \(formerly\ MelCo.\,\ Inc.\)"
device.product.id = 0260
device.product.name = "BUFFALO\ BSWHD06M\ USB\ Camera\015"
device.serial = KYE_Systems_Corp._BUFFALO_BSWHD06M_USB_Camera
device.form_factor = webcam
device.string = front:1
device.buffering.buffer_size = 352800
device.buffering.fragment_size = 176400
device.access_mode = mmap+timer
device.profile.name = analog-stereo
device.profile.description = "Analog\ Stereo"
device.description = "BUFFALO\ BSWHD06M\ USB\ Camera\015\ Analog\ Stereo"
module-udev-detect.discovered = 1
device.icon_name = camera-web-usb
is-default = true
gst-launch-1.0 pulsesrc device=alsa_input.usb-KYE_Systems_Corp._BUFFALO_BSWHD06M_USB_Camera-02.analog-stereo ! ...
Device found:
name : Monitor of Built-in Audio Digital Stereo (HDMI 3)
class : Audio/Source
caps : audio/x-raw, format=(string){ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, S24LE, S24BE, S24_32LE, S24_32BE, U8 }, layout=(string)interleaved, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-alaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-mulaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
properties:
device.description = "Monitor\ of\ Built-in\ Audio\ Digital\ Stereo\ \(HDMI\ 3\)"
device.class = monitor
alsa.card = 0
alsa.card_name = "HDA\ Intel\ PCH"
alsa.long_card_name = "HDA\ Intel\ PCH\ at\ 0x51130000\ irq\ 136"
alsa.driver_name = snd_hda_intel
device.bus_path = pci-0000:00:1f.3
sysfs.path = /devices/pci0000:00/0000:00:1f.3/sound/card0
device.bus = pci
device.vendor.id = 8086
device.vendor.name = "Intel\ Corporation"
device.product.id = a348
device.product.name = "Cannon\ Lake\ PCH\ cAVS"
device.form_factor = internal
device.string = 0
module-udev-detect.discovered = 1
device.icon_name = audio-card-pci
is-default = false
gst-launch-1.0 pulsesrc device=alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra2.monitor ! ...
Device found:
name : Built-in Audio Digital Stereo (HDMI 3)
class : Audio/Sink
caps : audio/x-raw, format=(string){ S16LE, S16BE, F32LE, F32BE, S32LE, S32BE, S24LE, S24BE, S24_32LE, S24_32BE, U8 }, layout=(string)interleaved, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-alaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
audio/x-mulaw, rate=(int)[ 1, 384000 ], channels=(int)[ 1, 32 ];
properties:
alsa.resolution_bits = 16
device.api = alsa
device.class = sound
alsa.class = generic
alsa.subclass = generic-mix
alsa.name = "HDMI\ 2"
alsa.id = "HDMI\ 2"
alsa.subdevice = 0
alsa.subdevice_name = "subdevice\ \#0"
alsa.device = 8
alsa.card = 0
alsa.card_name = "HDA\ Intel\ PCH"
alsa.long_card_name = "HDA\ Intel\ PCH\ at\ 0x51130000\ irq\ 136"
alsa.driver_name = snd_hda_intel
device.bus_path = pci-0000:00:1f.3
sysfs.path = /devices/pci0000:00/0000:00:1f.3/sound/card0
device.bus = pci
device.vendor.id = 8086
device.vendor.name = "Intel\ Corporation"
device.product.id = a348
device.product.name = "Cannon\ Lake\ PCH\ cAVS"
device.form_factor = internal
device.string = "hdmi:0\,2"
device.buffering.buffer_size = 352800
device.buffering.fragment_size = 176400
device.access_mode = mmap+timer
device.profile.name = hdmi-stereo-extra2
device.profile.description = "Digital\ Stereo\ \(HDMI\ 3\)"
device.description = "Built-in\ Audio\ Digital\ Stereo\ \(HDMI\ 3\)"
module-udev-detect.discovered = 1
device.icon_name = audio-card-pci
is-default = true
gst-launch-1.0 ... ! pulsesink device=alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra2
Device found:
name : BUFFALO BSWHD06M USB Camera
class : Video/Source
caps : video/x-raw, format=(string)YUY2, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)8/1;
video/x-raw, format=(string)YUY2, width=(int)800, height=(int)600, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)640, height=(int)360, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)352, height=(int)288, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)176, height=(int)144, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
video/x-raw, format=(string)YUY2, width=(int)160, height=(int)120, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
image/jpeg, width=(int)1280, height=(int)960, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)12/1;
image/jpeg, width=(int)1280, height=(int)720, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 16/1 };
image/jpeg, width=(int)800, height=(int)600, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 16/1 };
image/jpeg, width=(int)640, height=(int)480, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 16/1 };
image/jpeg, width=(int)640, height=(int)360, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
image/jpeg, width=(int)352, height=(int)288, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 15/1 };
image/jpeg, width=(int)320, height=(int)240, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
image/jpeg, width=(int)176, height=(int)144, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 20/1, 15/1, 8/1 };
image/jpeg, width=(int)160, height=(int)120, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction){ 30/1, 24/1, 20/1, 16/1 };
properties:
udev-probed = true
device.bus_path = pci-0000:00:14.0-usb-0:10:1.0
sysfs.path = /sys/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.0/video4linux/video0
device.bus = usb
device.subsystem = video4linux
device.vendor.id = 0411
device.vendor.name = "KYE\\x20Systems\\x20Corp."
device.product.id = 0260
device.product.name = "BUFFALO\ BSWHD06M\ USB\ Camera"
device.serial = KYE_Systems_Corp._BUFFALO_BSWHD06M_USB_Camera
device.capabilities = :capture:
device.api = v4l2
device.path = /dev/video0
v4l2.device.driver = uvcvideo
v4l2.device.card = "BUFFALO\ BSWHD06M\ USB\ Camera\015\012:\ "
v4l2.device.bus_info = usb-0000:00:14.0-10
v4l2.device.version = 329746 (0x00050812)
v4l2.device.capabilities = 2225078273 (0x84a00001)
v4l2.device.device_caps = 69206017 (0x04200001)
gst-launch-1.0 v4l2src ! ...
You are not just playing the stream, you are actually re-encoding the data. This encoding introduces latency. For the x264enc element use the tune=zerolatency option to reduce the delay. It comes at a cost of video quality though.

How to draw a line between the widgets in Qscrollarea using pyqt4

Here is my code i created multiple widget in qscrollarea. In between the each widget i want to draw a line.Can any one please tell me how can i draw line in between the each widget of the scroll area.
self.mainw = QtGui.QWidget()
self.scrollArea_left.setWidget(self.mainw)
self.ordersvbox = QtGui.QGridLayout(self.mainw)
self.w1 = QtGui.QWidget()
self.v1 = QtGui.QVBoxLayout(spacing=0)
self.v1.setContentsMargins(0, 0, 0, 0)
self.w1.setLayout(self.v1)
self.h1 = QtGui.QHBoxLayout()
self.l1 = QtGui.QLabel("#A")
self.lprogress = QtGui.QLabel("Porgress")
self.lamount = QtGui.QLabel("200 Rs")
self.items_count = QtGui.QLabel("2 items")
self.h1.addWidget(self.l1)
self.h1.addWidget(self.lprogress)
self.h1.addWidget(self.lamount)
self.v1.addLayout(self.h1)
self.v1.addWidget(self.items_count)
self.ordersvbox.addWidget(self.w1,0,0)
self.w2 = QtGui.QWidget()
self.v2 = QtGui.QVBoxLayout(self.w2)
self.h2 = QtGui.QHBoxLayout()
self.l2 = QtGui.QLabel("#B")
self.lprogress2 = QtGui.QLabel("x")
self.lamount2 = QtGui.QLabel("300 RS")
self.items_count2 = QtGui.QLabel(" 2 items")
self.h2.addWidget(self.l2)
self.h2.addWidget(self.lprogress2)
self.h2.addWidget(self.lamount2)
self.v2.addLayout(self.h2)
self.v2.addWidget(self.items_count2)
self.ordersvbox.addWidget(self.w2,1,0)
self.w3 = QtGui.QWidget()
self.v3 = QtGui.QVBoxLayout(self.w3)
self.h3 = QtGui.QHBoxLayout()
self.l3 = QtGui.QLabel("#C")
self.lprogress3 = QtGui.QLabel("z")
self.lamount3 = QtGui.QLabel("200 RS")
self.items_count3 = QtGui.QLabel(" 2 items")
self.h3.addWidget(self.l3)
self.h3.addWidget(self.lprogress3)
self.h3.addWidget(self.lamount3)
self.v3.addLayout(self.h3)
self.v3.addWidget(self.items_count3)
self.ordersvbox.addWidget(self.w3,2,0)

Fltk Button Call back

For this sub-window I have created a button, but when I click on the button nothing happens. I want to exit the sub-window once I click on the button, but I am not sure how to do that.
void model(Fl_Widget *, void *) {
Fl_Window *head = new Fl_Window(400, 350, "Robot Model: ");
Fl_Input *input = new Fl_Input(200, 0, 100, 30, "Name: ");
Fl_Input *input1 = new Fl_Input(200, 40, 100, 30, "Part-Number: ");
Fl_Input *input2 = new Fl_Input(200, 80, 100, 30, "How much is the Weight: ");
Fl_Input *input3 = new Fl_Input(200, 120, 100, 30, "The Cost: ");
Fl_Input *input4 = new Fl_Input(200, 160, 100, 30, "Brief Description: ");
Fl_Button *enter = new Fl_Button(150, 200, 100, 30, "Enter");
head->show();
}
int main(){
Fl_Window *win = new Fl_Window(600, 500, "Robot Workshop");
Fl_Box *box = new Fl_Box(0, 10, 600, 100, "Welcome to Robot Workshop!");
box->box(FL_UP_BOX);
box->labelsize(36);
box->labelfont(FL_BOLD + FL_ITALIC);
box->labeltype(FL_SHADOW_LABEL);
Fl_Menu_Bar *menu = new Fl_Menu_Bar(0, 0, 600, 25);
menu->add("Exit/Quit", FL_CTRL + 'v', Quit_CB);
menu->add("Project Manager/Robot Part/Head", FL_CTRL + 'h', head);
menu->add("Project Manager/Robot Part/Torso", FL_CTRL + 't', torso);
menu->add("Project Manager/Robot Part/Arm", FL_CTRL + 'a', arm);
menu->add("Project Manager/Robot Part/Battery", FL_CTRL + 'b', battery);
menu->add("Project Manager/Robot Part/Locomotor", FL_CTRL + 'l', locomotor);
menu->add("Project Manager/Robot Model" ,FL_CTRL + 'w', model);
menu->add("Beloved Customer/Browse Catalog", FL_CTRL + 'z', catalog);
menu->add("Beloved Customer/Part Pictures", FL_CTRL + 'v', pic);
menu->add("Manual", FL_CTRL + 'm', manual_window);
win->show();
return(Fl::run());
}
If you want a callback you need to add a callback function. See http://www.fltk.org/doc-1.3/common.html
void xyz_callback(Fl_Widget *w, void *data) {
...
}
You can pass anything you like to data and cast it back to its original type. Then modify your button with
button->callback(xyz_callback, &xyz_data);

Tkinter Treeview grid alignment issue

How can I make the treeview widget stick to the Noth (to the toolbar) when scaling up the application window.
It sticks to the west South and Est, but not the North.
using :
self.tree.grid(row=1,column=0,sticky=N+W+E+S)
I
This is the tree.grid alignment configuration
...
self.vsb = ttk.Scrollbar(master, orient=VERTICAL, command=self.tree.yview)
self.hsb = ttk.Scrollbar(master, orient=HORIZONTAL, command=self.tree.xview)
self.vsb.grid(row=1, column=1, sticky='ns')
self.hsb.grid(row=2, column=0, sticky='ew')
self.tree.configure(yscrollcommand=self.vsb.set)
self.tree.configure(xscrollcommand=self.hsb.set)
self.tree.grid(row=1,column=0,sticky=N+W+E+S)
...
This is the toolbar grid config (in case it causes the issue)
...
self.toolbar = Frame(master, bg="blue")
self.upButton = Button(self.toolbar, text="Up", command=self.doNothing, padx=10, pady=10)
self.upButton.grid(row=0,column=0,sticky=N+W)
self.downButton = Button(self.toolbar, text="Down", command=self.doNothing, padx=10, pady=10)
self.downButton.grid(row=0,column=1, sticky=N+W)
self.insupButton = Button(self.toolbar, text="Insert UP", command=lambda: self.insertUp(self.tree), padx=10, pady=10)
self.insupButton.grid(row=0,column=2, sticky=N+W)
self.insdownButton = Button(self.toolbar, text="Insert Down", command=lambda: self.insertDown(self.tree), padx=10, pady=10)
self.insdownButton.grid(row=0,column=3, sticky=N+W)
self.delbrButton = Button(self.toolbar, text="Delete branch", command=lambda: self.deleteBr(self.tree), padx=10, pady=10)
self.delbrButton.grid(row=0,column=4, sticky=N+W)
self.deltreeButton = Button(self.toolbar, text="Delete entire tree", command=lambda: self.deleteTr(self.tree), padx=10, pady=10)
self.deltreeButton.grid(row=0,column=5, sticky=N+W)
self.searchButton = Button(self.toolbar, text='Search', command=lambda: self.searchTr(self.tree), padx=10, pady=10)
self.searchButton.grid(row=0,column=6, sticky=N+W)
self.calcButton = Button(self.toolbar, text='Calc', command=lambda: self.calcTree(self.tree), padx=10, pady=10)
self.calcButton.grid(row=0,column=7, sticky=N+W)
self.toolbar.grid(row=0,column=0, sticky=N+W)
...
Application at launch:
Observed result: Application scaled up
Observed result: Application scaled down (overlaps with the toolbar)
Desired result: Application scaled up
Your tree is sticking to the north, it's just that the top of the row is further down than you realize. You need to give one or more rows a weight, so that tkinter will allocate extra space to that row (and not to any rows with the default weight of zero).
For example:
master.grid_rowconfigure(1, weight=1)
For a definitive reference to how the grid algorithm works see http://tcl.tk/man/tcl8.5/TkCmd/grid.htm#M32