Scale widget with splitted cursor - gtkmm

I'm developing a new gtkmm-based photo editor (photoflow), and for one of my tools I need to define a smooth transition of output pixel values from "0" to "1" when the input values go from "min" to "max".
In other words, the output values stay at "0" when "input < min", they go to "1" when "input > max" and vary linearly from "0" to "1" when "min < input < max".
Programming the transition itself is trivial. However, the photo editor is interactive and I have to provide a suitable GUI widget to set the "min" and "max" values. The easy solution would be to introduce two Gtk::Scale widgets, one controlling the "min" value and the other one the "max" value, but this would definitely not be very elegant and "professional", and would make the gui quite messy.
A more elegant and compact solution would be to have a sort-of Gtk::Scale widget with two cursors (or one cursor splitted in two halves), but I could not find any existing example of such a thing.
Should I implement the widget from scratch, deriving it from Gtk::Widget? Or is there a simpler solution? Or maybe some other open source project has faced the same problem and implemented the proper solution?
Thanks in advance for your help.

Related

VIM equivalent of IntelliJ's expand/shrink selection?

How would one achieve the same result. I believe the keybinding for macOS Intellij is op+up/down and on windows it is alt+w/d.
Essentially the function highlights the current word, then, with successive presses, expands out to the full string/line/area in-between parenthesis/further out to the next set of parenthesis. Very useful for developing in LISP.
The closest I've gotten is this: https://vi.stackexchange.com/a/19028
Try this plug in: https://github.com/terryma/vim-expand-region
It expands selections based on Vim’s text objects.
Well this may seem comfortable but does not correspondent with the internal logic of vim itself.
See, in vim everything you enter is like a sentence. va{ for example: there is a verb v -> visually select and an object (or movement) { -> paragraph. In this case there is also a modifier a around. You can exchange stuff in this sentence and it will still work vaw, dil, cB and so on. The power of vim is greatly based on that concept.
Of course you can write a function that does vaw first, then S-v and lastly va{ but that will only work with visual selection. It will not work with c or d or anything. So I will recommend to get used to use different keys for different actions.
The visual selection is mostly not needed anyway. Change a paragraph? directly use ca} and so on.
I have found that VI/VA + WOBO (as many times as you need to expand) works similarly. Not as fast but its the same concept and you can even expand/shrink asymmetrically based on your WO's and BO's (Or OW's and OB's depending on how you look at it)

Valid displayAt() range in GMS

Images can be displayed at a specific location with the DisplayAt() command.
Does anyone know the valid range?
For example, DisplayAt(-9000, -9000) is that valid? What is the total valid range?
Of course in the example the image would not be seen within the GMS frame, but that is exactly what I need.
Thanks
Yes, negative values are completely ok and will indeed "place" the image outside the visible range of the window.
There is nothing like a "valid" range - the coordindates are just numbers. ( There is likely a limit when the value exceeds the value-range of the internallly used variable type to store the coordinates, possiblye long (4 byte signed integer). )
Just be aware that concepts like "front most" window will also apply if an image is outside the "visible" range. Images will f.e. also show up in the ImageBrowser regardless of their position on the workspace. The same is true for iterating through images on a workspace using f.e. CountImageDocuments() and GetImageDocument()
Some commands ( I think ShowImage() ) might have addtional code to ensure that images stay "visible" and might therefore shift the image back into the workspace range. Also using "auto-arrange" will take images from the "off" and place them back into the visible range.
So if you deliberatly use "off-screen" display, this is ok, but it might create some unintended side-effects. What is the exact purpose of using it this way? There might be more suitable concepts. (f.e. one can create imageDocuments and add ImageDisplays to them without the need of showing the imageDocument.) Image may also be temporarilly "hidden". Finally, one might condiser shiftung "unwanted" images onto a separate workspace.

Capybara/Selenium: Speeding up Dropdown Selecting?

So this is a bit of a performance question regarding Selenium Webdriver (Chromedriver) and Capybara.
I have some react-select dropdowns with quite a bit of data in them. For some reason the react-selects take a VERY VERY long time to pick out the option in them. The code is pretty simple and I grabbed it from here: https://github.com/JedWatson/react-select/issues/832
But it basically comes down to:
page.find('.Select-control').click
page.find('.Select-option', text: 'the text').click
Thing is, this works fine. But it takes an extremely long time (Upwards of a minute a dropdown). Now...in Capybaras defense these dropdowns have a LOT of options to select from, so I thought selecting from the top-most item would be the fastest, but that doesn't seem to affect it.
Does Capybara/Selenium hold the "options" in a different sorted list somewhere or something? Since i'd assume selecting from a top option in the dropdown would be faster, but it doesn't seem to be?
Generally, when using the text option, find first finds all the elements that match using the locator with the current selector type. In your case your selector type is defaulting to :css, and the locator is .Select-option. So Capybara will find all elements with the class Select-option and then it will go through each of those elements comparing the text to see what matches (and checking visibility), but it will have to compare all of them to make sure the selector isn't ambiguous.
One way to speed that up would be to use first with a minimum option
page.first('.Select-option', text: 'the text', minimum: 1).click
which can skip some of the text and visibility checking since it doesn't have to worry about ambiguous elements. Another solution would be to skip the text option altogether and write it into an XPath along the lines of
page.find(:xpath, XPath.css('.Select-option')[XPath.string.n.is('the text')]).click # Haven't verified this is 100% correct but it should be close
If you're doing this a lot in your app you may want to consider creating a custom selector for this
Capybara.add_selector(:react_option) do
xpath do |locator|
XPath.css('.Select-option')[XPath.string.n.is(locator)]
end
# You can add other filters in here - see https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selector.rb
end
which would then allow you to do
page.find(:react_option, 'the text').click
Note, if you can limit the element types it will also make the query more efficient, so if all of the elements are <li> elements you might want to do something like
XPath.css('li.Select-option')[XPath.string.n.is(locator)]

Splitting information from a cell

My sheet contains three types of cells:
5off
50off
550off
What they should read is:
$5.00 Off
$0.50 Off
$5.50 Off
I've been fighting with Text-to-Columns and =concat for a while and am trying to get this to work as easily as possible. Any ideas?
Just wondering what's the rule of the conversion for example the first figure is
5off => "$5.00 Off" > split number, add decimal, upper the O in off, concatenate
However in number two the rules are a little different
50off => "$0.50 Off" > split number, make the number decimal, concatenate
Based on those limited information I will suggest you to break down your problem to simpler form:
See image below, the top is the result, bottom is the formula used. There might be simpler way though.
Hope this help

Semantic mediawiki - Set propery to range of values

I'm trying to set a specific property to a non exact value, for example say that I want to define the height of a pine tree to usually between 3-80 m (according to wikipedia). Then I would like to set something like [[Has height::3-80]] (of course this doesn't work) and defining the unit to meters with "custom units". Then I would like to be able to query for example "trees that can reach the height of 70 meters" and the pine tree would be included. I've been searching and trying different angles for hours now and I can't figure it out. Tried with #set_recurring_event but that seems to be only for dates/time. Also understood how to set multiple values for a property with #arraymap but this doesn't seem to help me here. Really would appreciate help with this (it's probably very easy and right in front of me) Thx! COG
There's no such things. But you able to create template, with parameters you want. The you just use code kinda {{range|min|max|units}}. For example your range of heights looks like {{range|3|80|m}}.