Home » Developing U++ » UppHub » Scatter: new zoom and scroll mechanism!
Scatter: new zoom and scroll mechanism! [message #28571] |
Tue, 07 September 2010 16:39 |
|
Hello all,
I propose to change a little zoom and scroll mechanism:
1. scroll horizontal: When mouse (wheel) and the buttons "alt" "shift" and "ctrl" is not pressed
2. scroll vertical: when mouse (wheel) and is pressed the "alt" button
3. zoom horizontal proportional by mouse position: when mouse (wheel) and is pressed the "shift" button
4. zoom vertical proportional by mouse position: when mouse (wheel) and is pressed the "ctrl" button
The future: in the same time can zoom by X and Y axes by pressing "ctrl" "shift" and mouse wheel. The zoom is proportional by mouse position like google picassa and other photo viewers.
The code is:
void Scatter::MouseWheel(Point p_point, int p_zdelta, dword p_other){
double v_scale = p_zdelta/10000.;
if(GetAlt()){
SetXYMin(GetXMin(), GetYMin()+GetYRange()*v_scale, GetYMin2());
SetMinUnits(GetXMinUnit(), GetYMinUnit()-GetYRange()*v_scale);
}
else{
bool v_is_ctrl = GetCtrl();
bool v_is_shift = GetShift();
if(v_is_ctrl){ // zoom y
double v_zoom_v = GetYRange()*v_scale;
double v_mouse_pos_v = GetYByPoint(p_point) - GetYMin();
if(v_mouse_pos_v>0){
SetXYMin(GetXMin(), GetYMin()-v_zoom_v*v_mouse_pos_v/GetYRange(), GetYMin2());
}
SetRange(GetXRange(), GetYRange()+v_zoom_v, GetY2Range());
}
if(v_is_shift){ // zoom x
double v_zoom_v = GetXRange()*v_scale;
double v_mouse_pos_v = GetXByPoint(p_point) - GetXMin();
if(v_mouse_pos_v>0){
SetXYMin(GetXMin()-v_zoom_v*v_mouse_pos_v/GetXRange(), GetYMin(), GetYMin2());
}
SetRange(GetXRange()+v_zoom_v, GetYRange(), GetY2Range());
}
if(!((v_is_ctrl)||(v_is_shift))){
SetMinUnits(GetXMinUnit()-GetXRange()*v_scale, GetYMinUnit());
SetXYMin(GetXMin()+GetXRange()*v_scale, GetYMin(), GetYMin2());
}
}
Refresh();
}
I'm waiting for your opinions.
If need, I can upload a compiled test-case
[Updated on: Tue, 07 September 2010 16:52] Report message to a moderator
|
|
|
Re: Scatter: new zoom and scroll mechanism! [message #28583 is a reply to message #28571] |
Wed, 08 September 2010 00:00 |
|
koldo
Messages: 3372 Registered: August 2008
|
Senior Veteran |
|
|
Hello Ion
I am not sure which is the best mouse behavior.
This is like the cooling system in an office. Nobody agrees and everyone is frozen or sweating.
I propose you another option. To have a list of keys, mouse buttons and actions. It is more complicated but everybody would agree.
Just a draft:
enum MouseActions {NO_ACTION, SCROLL_H_POS, SCROLL_H_NEG, SCROLL_V_POS, SCROLL_V_NEG, ZOOM_H_ENL, ZOOM_H_RED, ZOOM_V_ENL, ZOOM_V_RED, SHOW_INFO};
struct MouseBehaviour = {
bool ctrl;
bool alt;
bool shift;
bool left;
bool middle;
int middleWheel;
bool right;
int action;
};
Some of your proposals would be like these:
MouseBehaviour ionMap[] {
{false, false, false, false, false, 1, false, SCROLL_H_POS},
{false, false, false, false, false, -1, false, SCROLL_H_NEG},
{false, true, false, false, false, 1, false, SCROLL_V_POS},
{false, true, false, false, false, -1, false, SCROLL_V_NEG},
{false, false, false, false, false, 0, false, NO_ACTION}};
Best regards
Iñaki
|
|
|
Re: Scatter: new zoom and scroll mechanism! [message #28586 is a reply to message #28583] |
Wed, 08 September 2010 07:48 |
|
Your method is more universal!
It is a good idea because will be possibility to change the shortcut by users!
koldo wrote on Wed, 08 September 2010 01:00 | Hello Ion
I am not sure which is the best mouse behavior.
This is like the cooling system in an office. Nobody agrees and everyone is frozen or sweating.
I propose you another option. To have a list of keys, mouse buttons and actions. It is more complicated but everybody would agree.
Just a draft:
enum MouseActions {NO_ACTION, SCROLL_H_POS, SCROLL_H_NEG, SCROLL_V_POS, SCROLL_V_NEG, ZOOM_H_ENL, ZOOM_H_RED, ZOOM_V_ENL, ZOOM_V_RED, SHOW_INFO};
struct MouseBehaviour = {
bool ctrl;
bool alt;
bool shift;
bool left;
bool middle;
int middleWheel;
bool right;
int action;
};
Some of your proposals would be like these:
MouseBehaviour ionMap[] {
{false, false, false, false, false, 1, false, SCROLL_H_POS},
{false, false, false, false, false, -1, false, SCROLL_H_NEG},
{false, true, false, false, false, 1, false, SCROLL_V_POS},
{false, true, false, false, false, -1, false, SCROLL_V_NEG},
{false, false, false, false, false, 0, false, NO_ACTION}};
|
|
|
|
Re: Scatter: new zoom and scroll mechanism! [message #29475 is a reply to message #28586] |
Fri, 22 October 2010 12:54 |
|
koldo
Messages: 3372 Registered: August 2008
|
Senior Veteran |
|
|
Hello Ion
Sorry for the delay. I am so involved in the other package you know that I do not spend almost any time in other subjects.
It is just implemented and documented (this evening in SVN).
The main function is:
bool SetMouseBehavior(MouseBehaviour *_mouseBehavior);
that sets the array of mouse conditions and due actions.
The MouseBehaviour struct contains these elements:
struct MouseBehaviour {
bool ctrl; // Conditions
bool alt;
bool shift;
bool left;
bool middle;
int middleWheel;
bool right;
MouseAction action; // Action
};
The default array is:
Scatter::MouseBehaviour defaultMouse[] = {
{false, false, false, true , false, 0, false, Scatter::SHOW_INFO},
{false, false, false, false, true , 0, false, Scatter::SCROLL},
{false, false, false, false, false, 1, false, Scatter::ZOOM_H_RED},
{false, false, false, false, false, 1, false, Scatter::ZOOM_V_RED},
{false, false, false, false, false,-1, false, Scatter::ZOOM_H_ENL},
{false, false, false, false, false,-1, false, Scatter::ZOOM_V_ENL},
{false, false, false, false, false, 0, false, Scatter::NO_ACTION}};
Best regards
Iñaki
|
|
|
|
|
Goto Forum:
Current Time: Mon Jun 10 11:45:42 CEST 2024
Total time taken to generate the page: 0.01298 seconds
|