A couple of additional data-points:

The wheel isn’t much to reinvent.  There’s not a lot to the wxWidgets numeric 
validators.  (The num validator, int validator and floating point validator 
together make up only 300 lines of commented code.)

The developer has to add UNIT_BINDERs for each unit-scaled control anyway; at 
that point having to set up a validator in wxFormBuilder is more work as 
opposed to less.

The same for evaluation: the UNIT_BINDER handles that by default, or you can 
turn it off, but there’s nothing you have to add.

Cheers,
Jeff.

PS: this version of the Grid Settings dialog shows just how simple a dialog 
using the unit binder can be.  It handles typed-in unit conversions, 
evaluation, and validation.

https://git.launchpad.net/~jeyjey/kicad/tree/pcbnew/dialogs/dialog_set_grid.cpp 


> On 26 Feb 2018, at 14:23, Wayne Stambaugh <stambau...@gmail.com> wrote:
> 
> Hey Jeff,
> 
> This is a better argument.  I will counter by suggesting that the
> OnChar() event handler can be overridden to provide the behavior we
> need.  I realize that it would be difficult to perform units
> verification and/or numerical evaluation in the OnChar() event handler
> but you can prevent any illegal characters from be entered which AFAIK
> UNIT_BINDER does not handle.  UNIT_BINDER handles everything after the
> characters have been entered into the control so the user has to clean
> up any entry issues after the fact.  I'm not shooting down the idea of
> UNIT_BINDER, I just want to be sure we are not reinventing the wheel.
> 
> Cheers,
> 
> Wayne
> 
> On 2/25/2018 6:01 PM, Jeff Young wrote:
>> Hi Wayne,
>> 
>> The primary issue is that they try to do all their validation through 
>> OnChar().  As JP mentioned, this leads to problems like typing 0 to start a 
>> number.  But it also means the only way they have to guarantee a number is 
>> to allow only digits, zero-or-one minus sign, and zero-or-one decimal 
>> separator.  This strategy is completely unsuitable for handling typed-in 
>> units, never mind evaluation.
>> 
>> Cheers,
>> Jeff.
>> 
>> 
>>> On 25 Feb 2018, at 22:21, Wayne Stambaugh <stambau...@gmail.com> wrote:
>>> 
>>> Jeff,
>>> 
>>> I'm not opposed to this solution but I need technical information as to why 
>>> we should use one solution over another.  "Brain dead" is not a technical 
>>> reason and doesn't really help me make an informed decision. I've used 
>>> validators for simple edit control validation in the past and they worked 
>>> just fine so I need something tangible as to why they are unacceptable in 
>>> this case.  I'm not saying I agree or disagree with you, I just need 
>>> something more to go on.
>>> 
>>> Cheers,
>>> 
>>> Wayne
>>> 
>>> On 02/24/2018 04:18 PM, Jeff Young wrote:
>>>> I looked in to wxWidget’s validators, and they’re definitely challenged.  
>>>> (Brain-dead might be more accurate.)
>>>> As part of the units overhaul I’m going to propose making widespread use 
>>>> of the UNIT_BINDER, which is a wrapper for a 
>>>> wxTextEntry/wxStaticText-tuple.
>>>> As a wrapper it’ll be easy to add evaluation and validation to it, and 
>>>> allow most all other clients to wash their hands of unit display, unit 
>>>> conversion, evaluation, and validation.
>>>> (We’ll probably want to rename UNIT_BINDER something more generic at that 
>>>> point.)
>>>> Cheers,
>>>> Jeff.
>>>>> On 23 Feb 2018, at 20:10, Wayne Stambaugh <1751...@bugs.launchpad.net> 
>>>>> wrote:
>>>>> 
>>>>> @JP,
>>>>> 
>>>>> Understood but we can always create our own validator derive from the
>>>>> base wxNumValidator or wxValidator object if wxFloatingPointValidator is
>>>>> to restrictive.  As for the numeric limiting, if you set the limit's to
>>>>> 0.5 than 0.6 is illegal both as an initial value and as user entered
>>>>> value so that is just the behavior of the validator which we could also
>>>>> override in a derived object.
>>>>> 
>>>>> On 02/23/2018 02:39 PM, jean-pierre charras wrote:
>>>>>> @Wayne,
>>>>>> 
>>>>>> I was never impressed by the wxFloatingPointValidator.
>>>>>> 
>>>>>> AFAIK, for instance, if a minimal value is fixed to 0.5, you cannot 
>>>>>> enter a value starting by 0 like 0.6 (just because starting a value by 0 
>>>>>> is too small)
>>>>>> You need to enter 1.6 and after change 1.6 to 0.6
>>>>>> 
>>>>>> But the issue here is different:
>>>>>> In countries using a comma as separator, we use both the . or the , to 
>>>>>> enter a floating point value.
>>>>>> In a dialog, these 2 separators *must be* equivalent when the separator 
>>>>>> is the comma.
>>>>>> 
>>>>>> But wxFloatingPointValidator does not accept both separators, only the
>>>>>> comma.
>>>>>> 
>>>>>> This is very annoying.
>>>>>> 
>>>>>> If we want to use a FloatingPointValidator, we need to create our own 
>>>>>> validator.
>>>>>> For me wxFloatingPointValidator just does not work in Kicad.
>>>>>> 
>>>>> 
>>>>> -- 
>>>>> You received this bug notification because you are a member of KiCad Bug
>>>>> Squad, which is subscribed to KiCad.
>>>>> https://bugs.launchpad.net/bugs/1751315
>>>>> 
>>>>> Title:
>>>>> pcbnew: float point separator '.' truncate fractional part (default
>>>>> separator is ',')
>>>>> 
>>>>> Status in KiCad:
>>>>> New
>>>>> 
>>>>> Bug description:
>>>>> For example: if set in dialog 'Move exactly' `Move vector X` to 2.5 then 
>>>>> number truncated up to 2.
>>>>> If set 2,5 then number not truncated (OK).
>>>>> I use the RU locale.
>>>>> 
>>>>> Application: kicad
>>>>> Version: 5.0-dev-unknown-997d4de~62~ubuntu17.10.1, release build
>>>>> Libraries:
>>>>>     wxWidgets 3.0.3
>>>>>     libcurl/7.55.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/2.0.2 libpsl/0.18.0 
>>>>> (+libidn2/2.0.2) librtmp/2.3
>>>>> Platform: Linux 4.13.0-32-generic x86_64, 64 bit, Little endian, wxGTK
>>>>> Build Info:
>>>>>     wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8) GTK+ 2.24
>>>>>     Boost: 1.62.0
>>>>>     Curl: 7.55.1
>>>>>     Compiler: GCC 7.2.0 with C++ ABI 1011
>>>>> 
>>>>> Build settings:
>>>>>     USE_WX_GRAPHICS_CONTEXT=OFF
>>>>>     USE_WX_OVERLAY=OFF
>>>>>     KICAD_SCRIPTING=ON
>>>>>     KICAD_SCRIPTING_MODULES=ON
>>>>>     KICAD_SCRIPTING_WXPYTHON=ON
>>>>>     KICAD_SCRIPTING_ACTION_MENU=ON
>>>>>     BUILD_GITHUB_PLUGIN=ON
>>>>>     KICAD_USE_OCE=ON
>>>>>     KICAD_SPICE=ON
>>>>> 
>>>>> To manage notifications about this bug go to:
>>>>> https://bugs.launchpad.net/kicad/+bug/1751315/+subscriptions
>>>> _______________________________________________
>>>> Mailing list: https://launchpad.net/~kicad-developers
>>>> Post to     : kicad-developers@lists.launchpad.net
>>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>>> More help   : https://help.launchpad.net/ListHelp
>>> 
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~kicad-developers
>>> Post to     : kicad-developers@lists.launchpad.net
>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>> More help   : https://help.launchpad.net/ListHelp
>> 


_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to