// SNAPDOWN(position, lineStep);
if(position < 0) position = 0;
- if(position >= range)
+ if(position >= range)
position = range - 1;
if(thumb)
virtual void Window::NotifyScrolling(ScrollBar scrollBar, ScrollBarAction action, int position, Key key);
- property ScrollDirection direction { property_category "Appearance" set { sbStyle.vertical = value == vertical; } get { return sbStyle.vertical ? vertical : horizontal; } };
+ property ScrollDirection direction { property_category $"Appearance" set { sbStyle.vertical = value == vertical; } get { return sbStyle.vertical ? vertical : horizontal; } };
property bool windowOwned { set { sbStyle.window = value; } /* get { return sbStyle.window; } */ };
- property bool snap { property_category "Behavior" set { sbStyle.snap = value; } get { return sbStyle.snap; } };
+ property bool snap { property_category $"Behavior" set { sbStyle.snap = value; } get { return sbStyle.snap; } };
property int range
{
- property_category "Behavior"
+ property_category $"Behavior"
set
{
total = value + seen - 1;
// Improve this, needs to be done in 2 so updates commented out for seen
property int seen
{
- property_category "Behavior"
+ property_category $"Behavior"
set
{
if(this)
};
property int total
{
- property_category "Behavior"
+ property_category $"Behavior"
set
{
if(this)
get { return total; }
};
- property int lineStep { property_category "Behavior" set { if(this) lineStep = value; } get { return lineStep; } };
- property int pageStep { property_category "Behavior" set { if(this) pageStep = value; } get { return pageStep; } };
- property int thumbPosition { property_category "Behavior" set { Action(setPosition, value, 0); } get { return position; } };
+ property int lineStep { property_category $"Behavior" set { if(this) lineStep = value; } get { return lineStep; } };
+ property int pageStep { property_category $"Behavior" set { if(this) pageStep = value; } get { return pageStep; } };
+ property int thumbPosition { property_category $"Behavior" set { Action(setPosition, value, 0); } get { return position; } };
private:
ScrollBar()
bool NotifyPushed(Button button, int x, int y, Modifiers mods)
{
action = down;
- Action(action, 0, (Key)mods);
+ Action(action, 0, Key { modifiers = mods });
timer.Start();
return true;
}
bool NotifyPushed(Button button, int x, int y, Modifiers mods)
{
- action = up;
- Action(action, 0, (Key)mods);
+ action = up;
+ Action(action, 0, Key { modifiers = mods });
timer.Start();
return true;
}
}
position = y - thumbClick.y + thumb.position.y;
if(height)
- position = (position - SB_HEIGHT) * (range - 1) / height;
+ position = (int)((int64)(position - SB_HEIGHT) * (range - 1) / height);
if(guiApp.textMode)
{
SNAPUP(position, textCellH);
}
position = x - thumbClick.x + thumb.position.x;
if(height)
- position = (position - upBtn.size.w) * (range - 1) / height;
+ position = (int)((int64)(position - upBtn.size.w) * (range - 1) / height);
if(guiApp.textMode)
{
SNAPUP(position, textCellW);
if(sbStyle.snap)
SNAPDOWN(position, lineStep);
if(position == 0)
- Action(setPosition, position, (Key)mods);
+ Action(setPosition, position, Key { modifiers = mods });
else
- Action(setPosition, position, (Key)mods);
+ Action(setPosition, position, Key { modifiers = mods });
}
}
return true;
bool draggingThumb;
Point pos, thumbClick;
bool inside;
-
+
void OnRedraw(Surface surface)
{
int sbWidth = SB_WIDTH;
{
SNAPUP(height, textCellH);
}
- thumbPos = upBtn.size.h + position * height / (range - 1);
+ thumbPos = upBtn.size.h + (int)((int64)position * height / (range - 1));
if(guiApp.textMode)
{
SNAPUP(thumbPos, textCellH);
{
SNAPUP(width, textCellW);
}
- thumbPos = upBtn.size.w + position * width / (range - 1);
+ thumbPos = upBtn.size.w + (int)((int64)position * width / (range - 1));
if(guiApp.textMode)
{
SNAPUP(thumbPos, textCellW);
else
{
// What to do here?
- upBtn.background = activeBorder;
- downBtn.background = activeBorder;
- thumb.background = activeBorder;
+ upBtn.background = formColor;
+ downBtn.background = formColor;
+ thumb.background = formColor;
background = Color { 224, 224, 224 };
}
if(sbStyle.vertical)
thumbSize = seen * size / total;
}
else
- thumbSize = 0;
+ thumbSize = 0;
if(sbStyle.vertical)
{
else
action = pageDown;
- Action(action, 0, (Key)mods);
+ Action(action, 0, Key { modifiers = mods });
timer.Start();
Update(null);
{
case left:
case up: Action(up, 0, key); break;
- case right:
- case down:
- Action(down, 0, key);
+ case right:
+ case down:
+ Action(down, 0, key);
break;
case pageUp: Action(pageUp, 0, key); break;
case pageDown: Action(pageDown, 0, key); break;
thumb.visible = !disabled;
};
};
+
+void SBSetSeen(ScrollBar sb, int value)
+{
+ value = Max(1,value);
+ if(sb.sbStyle.snap)
+ SNAPDOWN(value, *&sb.lineStep);
+ *&sb.seen = value;
+ sb.range = Max(sb.total - sb.seen + 1, 1);
+}
+
+void SBSetTotal(ScrollBar sb, int value)
+{
+ if(!value) value = *&sb.seen;
+ *&sb.total = value;
+ sb.range = Max(sb.total - sb.seen + 1, 1);
+}