Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "slider" delegate for numeric properties #10

Closed
lexxmark opened this issue Jan 19, 2016 · 20 comments
Closed

Implement "slider" delegate for numeric properties #10

lexxmark opened this issue Jan 19, 2016 · 20 comments

Comments

@lexxmark
Copy link
Collaborator

Something like in the GIMP
image

@kmkolasinski
Copy link
Contributor

Perfect I would like to have something like that :) How to use it?

@lexxmark
Copy link
Collaborator Author

I've implemented 1st draft of "SliderBox" delegate for Float property. Please try it.
You can change property value by keyboard only now. I used "+" and "-" keys to increase and decrease values. Arrow up/down/left/right keys are reserved to navigation between properties. I think it's not a good idea to override them. Mouse manipulation is on the go.

image

fillColor attribute is optional - in case you want have different colors for different properties.

    Float FloatPropertySliderBox
    {
        description = "Property to hold float values in range [0, 10].";
        value = 1.f;
        minValue = 0;
        maxValue = 10.f;
        stepValue = 0.1f;

        delegate SliderBox
        {
            fillColor = QColor::fromRgb(170, 170, 255);
        }
    }

@kmkolasinski
Copy link
Contributor

Wow, its really cool! I will wait for mouse control. BTW: I usually work with AB late at night after work.

@lexxmark
Copy link
Collaborator Author

Mouse wheel and mouse single click is implemented.
Mouse drag is on the go.

BTW: I usually work with AB late at night after work.

I also worked at night but in USA timezone.

@lexxmark
Copy link
Collaborator Author

@kmkolasinski and @ppiecuch - I'm finished with SliderBox delegate.
Please test it and if everything is OK - close the issue.

@kmkolasinski
Copy link
Contributor

Hi, thanks I'm going to check it right now.

@kmkolasinski
Copy link
Contributor

Hi, for me is ok, however I will customize it a little bit to have it like I want ;)
I don't want to bother you anymore in this case, since every person
has his own vision how such button should look like.
I prefer that styl in AwesomeBump :) slider

@kmkolasinski
Copy link
Contributor

Hi, I'm trying to override the even implementation for mouse dragging

bool QtnPropertyDelegateFloatSlideBox::event(QtnPropertyDelegateEventContext& context, const QtnPropertyDelegateSubItem& item)
{
    switch (context.eventType())
    {

but I cannot force it to work with mouse dragging. It seems that all events are blocked if for example mouse is pressed. Do you know how to solve it?

@lexxmark
Copy link
Collaborator Author

Hi, does my QtnPropertyDelegateFloatSlideBox class work?
Do you want to customize delegate behavior? It should be pretty much similar as your version.
I only see difference in display (draw function).

It's strange that you have troubles with event function, may be you don't call trackState() during sub item creation

bool QtnPropertyDelegateFloatSlideBox::createSubItemValueImpl(QtnPropertyDelegateDrawContext&, QtnPropertyDelegateSubItem& subItemValue)
{
    subItemValue.trackState();
    subItemValue.drawHandler = qtnMemFn(this, &QtnPropertyDelegateFloatSlideBox::draw);
    subItemValue.eventHandler = qtnMemFn(this, &QtnPropertyDelegateFloatSlideBox::event);
    return true;
}

May be you can just push your code in you fork of QtnProperty, so I will be able pull it and debug.

Anyway I'm planning to generalize this delegate to be basis for all numeric properties Int, Uint, Double, Float. And polish it a bit.
After this you could just grab the code and modify it as you want.

@lexxmark
Copy link
Collaborator Author

@kmkolasinski - I've stabilize QtnPropertyDelegateSlideBox code.
Please try now and in case any problems push your version to your fork of QtnProperty

@kmkolasinski
Copy link
Contributor

Hi,
QtnPropertyDelegateFloatSlideBox yes it works :) I copied the QtnPropertyDelegateFloatSlideBox from your repository and created a new files in my project. I wanted to customize Slider behaviour and appearance. I did it yesterday in the evening but I did not want to push not polished code.
For me it seems that "mouse drag" event (mouse movement + mouse pressed) is not even tracked by event handler - only mouse movement is detected.
I will try this evening to add, lets hope it will work

subItemValue.trackState();

@kmkolasinski
Copy link
Contributor

Hi, my last anwser is about your question from yesterday :) Not this:

@kmkolasinski - I've stabilize QtnPropertyDelegateSlideBox code.
Please try now and in case any problems push your version to your fork of QtnProperty

@kmkolasinski
Copy link
Contributor

Please try now and in case any problems push your version to your fork of QtnProperty

I just add one line of QDebug() in the event function to see what kind of events are catched,

@lexxmark
Copy link
Collaborator Author

I copied the QtnPropertyDelegateFloatSlideBox from your repository and created a new files in my project.

Did you copied all other files? There are huge modifications in PropertyDelegate.h/cpp; PropeetyView.h/cpp and other files

I did not want to push not polished code

I mean you can "play" with my modifications in you fork of QtnProperty project. It's independent from AB project. So you can easily push and debug code there.

@kmkolasinski
Copy link
Contributor

Did you copied all other files? There are huge modifications in PropertyDelegate.h/cpp; PropeetyView.h/cpp and other files

No I just created separate class file copying the QtnPropertyDelegateSlideBox class which I then called QtnPropertyDelegateABFloatSlider class, the content is exactly the same as QtnPropertyDelegateSlideBox class but I started to play with event method, to see what I can change or not.

I mean you can "play" with my modifications in you fork of QtnProperty project. It's independent from AB project. So you can easily push and debug code there.

Yes you are right.

@lexxmark
Copy link
Collaborator Author

Now you can find QtnPropertyDelegateSlideBox class in PropertyDelegate.h file.
There are some new Event types in event function:

  1. QtnSubItemEvent::Activated - mouse enters slidebox rect
  2. QtnSubItemEvent::PressMouse - user pressed mouse button
  3. QtnSubItemEvent::ReleaseMouse - user released mouse button -> end edit

@kmkolasinski
Copy link
Contributor

Great I will pull the code and try it later ! Thanks!

@lexxmark
Copy link
Collaborator Author

OK I'm finished for now.

Just play with new code in QtnProperty and push your modifications, so I will be able to help you.

Bye

@kmkolasinski
Copy link
Contributor

Ok, thanks again.

@kmkolasinski
Copy link
Contributor

OMG, this new one is perfect :) Thanks!

@lexxmark lexxmark closed this as completed May 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants