gtkmm4: hide Gtk::Video's Gtk::MediaControls - gtk

I'm not exactly a fan of how Gtk::Video's controls look and I want to expand on them with my own custom controls, but I'm not sure how to hide the default media controls. Is there any way that I can do this?

I know how to do it in GTK. You will have to only find the corresponding methods in GTKMM. GtkVideo widget contains a GtkOverlay. In that overlay are three elements GtkPicture, GtkImage, GtkRevealer. GtkPicture is the video surface. GtkImage is that big play button in the center of video. And GtkRevealer is the block of controls. So basically I am hiding or removing the last child of the first child of GtkVideo.
GtkMediaFile* videoFile = GTK_MEDIA_FILE(gtk_media_file_new_for_file(g_file_new_for_path("GTK4Video.mp4")));
GtkVideo* videoPlayer = GTK_VIDEO(gtk_video_new_for_media_stream(GTK_MEDIA_STREAM(videoFile)));
GtkOverlay* videoOverlay = GTK_OVERLAY(gtk_widget_get_first_child(GTK_WIDGET(videoPlayer)));
GtkRevealer* videoControls = GTK_REVEALER(gtk_widget_get_last_child(GTK_WIDGET(videoOverlay)));
gtk_widget_hide(GTK_WIDGET(videoControls));
//gtk_overlay_remove_overlay(videoOverlay, GTK_WIDGET(videoControls));

From the documentation of Gtk.Video:
The controls are available separately as Gtk.MediaControls. If you
just want to display a video without controls, you can treat it like
any other paintable and for example put it into a Gtk.Picture.

Related

Leaflet list marker options

I would need some information on list markers:
how can I change the opacity of the list and also the background color
how can I set the overflow so that if the markers in the list increase, they scroll through the
scrollbar?
Thanks
This is clearly not a leaflet element, to change the transparency of the object that you specified, you most likely need to change these properties in the css, try using DeveloperTools in the browser to find where this object takes the properties (transparency) from and you will know how to change it correctly.
Example
If I understand your question correctly, here is an approximate way to do what you ask in the first part of the question. Show your code what it looks like now.
.className {
background: white;
}
let marker = L.circle([50.0], [40.0]], {opacity: 1}).addTo(map),
marker.className = "className";
no I don't mean the transparency of the single marker but of the list, I send a photo in which the list is circled.
I don't know in which part of the library to act to give properties to this list element.

Leaflet VideoOverlay controls

In one of my projects, I have to integrate video on a leaflet Map. I didn't use the extend layer method because the video can have arbitrary dimension and should behave as other elements's map. I'm using a videoOverlay element to do so.
But now I have a problem, how to provide a proper way for the users to controls the video? I try to add the attribute controls inside the html video tag but the controls don't appears.
So I think that my only solution now is to make an external Leaflet controls right ?
Is it possible to have the controls on the video, as classical html video tag ?
First, the getElement() method of L.VideoOverlay to get the relevant instance of HTMLVideoElement.
Then, since HTMLVideoElement is a subclass of HTMLMediaElement, it has a controls property you can modify.
Put together it should look like:
var overlay = L.videoOverlay( /* stuff */ ).addTo(map);
var el = overlay.getElement();
el.controls = true;
or even:
var overlay = L.videoOverlay( /* stuff */ ).addTo(map);
overlay.getElement().controls = true;
Please note that the HTMLVideoElement instance only exists after the L.VideoOverlay has been added to a L.Map.

Using dat.gui slider triggers orbit controls

I'm building an origami simulator, I want to be able to 'fold' the paper using a dat.gui slider. I want to also include orbital controls.
However, when I click on the slider and subsequently move my mouse out of the dat.gui window, the orbital controls have been triggered causing the model to jump to a different orientation.
Is there a way to prevent orbital controls from being triggered when I click in the dat.gui window?
Quoting the docs:
Constructor
OrbitControls( object : Camera, domElement : HTMLDOMElement )
object: (required) The camera to be controlled.
domElement: (optional) The HTML element used for event listeners. By default this is the whole document, however if you only want to the controls to work over a specific element (e.g. the canvas) you can specify that here.
In other words, to restrict the OrbitControls so that they don't enable when you click on the GUI, you must supply a reference to the canvas (renderer.domElement) or container (a div that contains the canvas) as second argument to the constructor. Happy coding! (And folding!)
My solution to your question is to: have dat.GUI "listen" to the values controlled by OrbitControls (the camera), so that the values are in sync between the two different "controllers" (OrderbitControls and dat.GUI), like so:
let gui = new dat.GUI();
let folder1 = gui.addFolder("Camera Position");
folder1.add(camera.position, "x", -100, 100).listen();
folder1.add(camera.position, "y", -100, 100).listen();
folder1.add(camera.position, "z", -100, 100).listen();
The listen() function on a tracked variable in dat.GUI will keep the values in sync, and relieve the "jumpiness" you are experiencing.
Reference to dat.GUI Controller functions documentation:
dat.gui
OrbitControls has an "enabled" property (in fact, I believe all of the controls have an "enabled" property - might want to check though). So if you have
orbitControls = new THREE.OrbitControls(...);
...
// in your dat.GUI block of code (or wherever you want to disable orbitControls)
orbitControls.enabled = false;
// this should disable orbitControls, and when you want to use orbitControls again, just do
orbitControls.enabled = true;

GWT drag and drop animation

I have a flow panel with many photo-widgets inside (gallery with random number of rows and columns, depends on screen size) for which I want to implement drag and drop behavior to change their order. I am using gwt-dnd library. Its FlowPanelDropController allows you to define your own positioner (delimiter) which shows the candidate location for dropping the dragged widget.
I want this positioner to be the empty space with defined width, and the challenging thing is to implement sliding animation effect for the when positioner is added and removed.
If you are a desktop Picasa app user you know what I mean: the target row slides both sides (little to the left, little to the right) extending the space between the items where you are going to drop a photo.
The whole thing is complex enough, but any help related to how to apply the animation for positioner attach/detach is appreciated. Maybe I need to use a different approach (e.g., use GWT native dnd instead of gwt-dnd lib and no "positioners" at all) if you have any ideas how this could be helpful.
Thanks.
Well, I ended up overriding AbstractPositioningDropController (parent of FlowPanelDropController) and adding some extra features.
1) newPositioner() method now builds the Label, which is vertical space with some small width, height and decoration. This widget's element has constant id (say, "POSITIONER"), which helps to distinguish between multiple positioners if you plan to have several of them while navigating with a drag object over multiple drop targets. Also some transition CSS effects were applied to the Label, which will be responsible for handling animated extension of Label's width.
2) in onEnter() I do the following
...
removePositioner(getPositionerElement());
Widget positioner = newPositioner();
dropTarget.insert(positioner, targetIndex);
animatePositionerExtension();
where getPositionerElement() returns DOM.getElementById(POSITIONER)
At the same time removePositioner(..) resets the id of this element to something abstract and ideally should provide some animation before calling .removeFromParent(). But I didn't have enough time to properly debug this so ended up just removing the old positioner with no animation.
Method animatePositionerExtension() contains the code that changes the width of the positioner widget, so that CSS transition will catch that and provides animation.
All access to positioner widget in the class should be provided through updated methods.
3) onLeave() contains line removePositioner(getPositionerElement());
4) In the end of onMove() I added a couple of lines:
galleryWidget.extendHoveredRow(targetIndex - 1);
animatePositionerExtension();
where extendHoveredRow(hoveredWidgetOrdinal) implemented the logic to "limit" the sliding effect in the single line:
int rowHovered = -1;
public void extendHoveredRow(int hoveredWidgetOrdinal) {
int newRowHovered = getRowByOrdinalHovered(hoveredWidgetOrdinal);
if (rowHovered != newRowHovered) {
// adjust position of items in the previously hovered row
int firstInPreviouslyHoveredRow = (rowHovered - 1) * itemsInARow;
shiftFirstItemLeft(firstInPreviouslyHoveredRow, false);
rowHovered = newRowHovered;
// extend this row
int firstInThisRow = getOrdinalFirstInThisRowByOrdinal(hoveredWidgetOrdinal);
shiftFirstItemLeft(firstInThisRow, true);
}
}
This is in short how I did the thing. And still there's some room for improvements, like adding animated removal.
Again, it's all about overriding DropController and manipulations with elements inside the "gallery" widget. The benefit of this approach is that I remain in the gwt-dnd operations framework, and also reused a bunch of existent code.
Some notes:
CSS transition is not supported in IE pre-9, but this is unrelated to
this topic.
Put a transparent "glass" div on top of the Image widget if you use it
as a face of dragProxy. This will save you tons of time trying to
understand why either setting element's draggable to false, or
calling event.preventDefault() somewhere else, or other workarounds don't work in one or several browsers and the image itself is being dragged instead of the whole dragProxy widget.

ui.helper vs ui.item in jQuery UI

I was studying the jQuery UI Sortable widget and it said that all callback functions receive a ui object. Two of its properties are ui.helper nad ui.item. ui.helper is mentioned to be mostly a clone of ui.item, but I can't get the significance of calling it 'helper'. Also, the offset and position properties are defined in terms of the helper and not the item. What's the difference between the two ?
One of the answers mention that the helper fills the void, but the I read in the docs that the helper element is "used for dragging display". What exactly is this helper element and why is it named so?
From what I understand ui.helper is a "clone" of the ui.item. It is cloned so you can edit it with css and make it look like whatever you want it to look like while you are dragging it and it won't effect the original ui.item. So if you had a box and while it was being dragged you wanted it to turn into a blue box with curved edges but only while it was dragging you can by modifying ui.helper.
The helper is the element that fills the void (with visibility: hidden) when the item is dragged.