Gtk TreeView CellRendererProgress, use float values like 99.9? - gtk

Its value property is a type of integer. I could not find what its range is, but it seems it is 0 to 100. So, if I set a value like 50, it displays a half-full progress bar. But what if I want to display fractional percentages like "99.9"? Does CellRendererProgress have something like fractional mode? Or is there a different renderer that can take fractional values?

I did a quick review of the "CellRendererProgress" widget by reviewing the GTK source code for the widget and it indeed expects an integer value from zero to one hundred. It does not allow for a fraction as does a regular progress bar. Technically, the range for a progress bar widget is from zero to one, but the "fraction" element is a "double" so a fraction of ".999" (99.9%) would work with it. If you are keen on creating your own custom cell renderer that contains a progress bar in lieu of using the "CellRenderProgress" widget, I did a bit of searching on the web and found this link.
"https://blogs.igalia.com/csaavedra/documents/treeview-tutorial/sec-custom-cell-renderers.html"
You might be able to base a custom cell renderer widget with an embedded progress bar on this example. Bear in mind, this code was written for GTK2, so some tweaking would need to be done.
Regards.

Related

When is a GWT label's layout calculated?

I want to create a few labels, add them to an AbsolutePanel, and then calculate what positions they should go in. In order to do that calculation, I need to know how wide the browser has made the labels. When I call label.getOffsetWidth(), I get zero.
Is there anything I can do to force a layout calculation, or do I have to use something like scheduleDeferred() to set my positions after the layout has happened?
All widgets have a height and width of zero until the browser finishes rendering them. So you do have to use scheduleDeferred to wait until it happens.

GtkTreeViewColumn resizing based on contents

So it turns out that we'd like to use fixed height mode, because it's faster and it doesn't constantly try to update the treeview — we saw a significant decrease in CPU use with a table that, unfortunately, may contain a few thousand rows and some 20-ish columns.
Oddly enough, merely turning off autosizing on all the columns doesn't help, one needs to set fixed height mode too.
But of course, the cell contents are of varying length (they're text and numbers), and it would be nice to update the column size time to time (ie. when I know they should be updated, and not all the time like autosizing unfortunately does).
So what I need is being able to figure out that the newly inserted row / cell has insufficient size (I guess something to do with the GtkCellRendererText and Pango will come handy), and then resize the affected GtkTreeViewColumn using set_fixed_width. I've looked at the source of GTK+ to see what they do when autosizing, but couldn't really make head or tails of it. My main problem here is getting to the text layout and/or the cell size requirements from a given TreeView/ListStore/iter combination.
I use perl-Gtk2, but answers are welcome in any commonly used language.

Slider settings for GPUImage

I'm making an app which allows the user to apply GPUImage filters to still photos using a UISlider. I'd like for the slider to initially start at the zero point for each filter (i.e. the value at which none of the filter has been applied yet) and I'm wondering how this can be determined? I've used some of the values that are listed in the GPUImage documentation and for certain sliders they start at 0, but others it's hard to determine (and for some, the min and max values are way off for me). The values for something like GPUImagePosterizeFilter seem to be way off for me (set min to 1, max to 128 and initial to 1). I've also checked some of the values in the FilterShowcase test project which are different than the documentation, but still don't always start at 0. Am I just completely missing the point here? Or is there some setting I maybe have to turn on to be in line with the slider values?
Nope, no setting for this. All I can really recommend is that to make this as efficient as possible make a switch statement in a single method and determine what to do by index of the currently selected filter.
From there, I would leave the min/max values of the slider the same so that you don't have to animate from one calculated point to another if the filter changes and mathematically convert the slider's value into units that the current filter understands. i.e. 0-1 --> 1-128
I think I might have been approaching this the wrong way. Rather than looking for a "zero point" on a filter, I think I should focus on applying the filter only when the user applies it, and trying to find a good starting point that is close to how the image looks without the filter for the initial value on the slider.

Get image width and height in pixels

so i have looked at a couple other questions like this and from what i saw none of the answers seemed to answer my question. I created a program that creates ASCII art, which is basically a picture of text instead of colors. the way i have the program set up at the moment you have to manually set the Width and Height of the pixels. If the width and height of the pixels is too large it simply wont work. so basically what i want to do is have a function to automatically set the width and height to the size of the picture. http://www.mediafire.com/?3nb8jfb8bhj8d is the link to the program now. I looked into pixel grabber but the constructor methods all needed a range of pixels. I also have another folder for the classes, http://www.mediafire.com/?2u7qt21xhbwtp
on another note this program is incredibly inefficient, i know that it is inefficient in the grayscaleValue() method, but i dont know if there is any better way to do this. Any suggestions on this program would be awesome too. Thanks in advance! (this program was all done on eclipse)
After you read the image into your BufferedImage, you can call getWidth() and getHeight() on it to get this information dynamically. See the JavaDocs. Also, Use a constructor for GetPixelColor to create the BufferedImage once and for all. This will avoid reading the entire file from disk for each channel of each pixel.
For further code clean up, change series of if statements to a switch construct, or an index into an array, whichever is more natural. See this for an explanation of the switch construct.
One last comment: anything inside a class that logically represents the state of an object should be declared non static. If, say, you wanted to render two images side by side, you would need to create to instances if GetPixelColor, and each one should have its own height and width attributes. Since they're currently declared static, each instance would be sharing the same data, which is clearly not desireable behavior.

why do getOffsetWidth() and getElement().getClientWidth() return 0 for a Widget in GWT?

I'm using RaphaelGWT to draw shapes with the underlying RaphaelJS library. Both projects are wonderful. However I was stuck for awhile on the issue of Text objects in Raphael being displayed as centered by default.
I've tried to create one Text object and let it be centered by default, then measure its width in order to adjust the position for a 2nd text object and then remove the first. But I can't get the width of the original Text object.
FYI, in RaphaelGWT, the Shape objects used extend Widget. So I've tried getAbsoluteLeft(), getElement().getAbsoluteRight(), getOffsetWidth(), getElement().getClientWidth(). getAbsoluteLeft() is the only one that returns what I would expect. getAbsoluteRight()returns the same value as getAbsoluteLeft(), and both getOffsetWidth() and getElement().getClientWidth() return 0.
Why?
FYI, I calculated the width from the original x value used to create the Text Shape (x then became the center) and getAbsoluteLeft(), which actually returned the expected value.
The element has to be visible for getOffsetWidth() to return correct values.