A test I used for debugging Pe's scrollbar problems. (SetSteps() influences
proportion if proportion was never set.) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25149 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d88d001f35
commit
b35b070b59
17
src/tests/servers/app/scrollbar/Jamfile
Normal file
17
src/tests/servers/app/scrollbar/Jamfile
Normal file
@ -0,0 +1,17 @@
|
||||
SubDir HAIKU_TOP src tests servers app scrollbar ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
AddSubDirSupportedPlatforms libbe_test ;
|
||||
|
||||
UseHeaders [ FDirName os app ] ;
|
||||
UseHeaders [ FDirName os interface ] ;
|
||||
|
||||
SimpleTest ScrollBar :
|
||||
main.cpp
|
||||
: be ;
|
||||
|
||||
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : ScrollBar
|
||||
: tests!apps ;
|
||||
}
|
||||
|
81
src/tests/servers/app/scrollbar/main.cpp
Normal file
81
src/tests/servers/app/scrollbar/main.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <ScrollView.h>
|
||||
#include <Window.h>
|
||||
|
||||
class View : public BView {
|
||||
public:
|
||||
View(BRect frame)
|
||||
: BView(frame, "target view", B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Draw(BRect updateRect)
|
||||
{
|
||||
BRect b = Bounds().OffsetToCopy(B_ORIGIN);
|
||||
b.bottom = b.bottom * 2.0;
|
||||
StrokeLine(b.LeftTop(), b.RightBottom());
|
||||
}
|
||||
|
||||
virtual void AttachedToWindow()
|
||||
{
|
||||
UpdateScrollbar(Bounds().Height());
|
||||
}
|
||||
|
||||
virtual void FrameResized(float width, float height)
|
||||
{
|
||||
UpdateScrollbar(height);
|
||||
}
|
||||
|
||||
void UpdateScrollbar(float height)
|
||||
{
|
||||
BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
|
||||
if (!scrollBar) {
|
||||
printf("no vertical scroll bar\n");
|
||||
return;
|
||||
}
|
||||
float smallStep, bigStep;
|
||||
scrollBar->GetSteps(&smallStep, &bigStep);
|
||||
printf("scrollbar steps: %.1f, %.1f, proportion: %.1f\n",
|
||||
smallStep, bigStep, scrollBar->Proportion());
|
||||
|
||||
scrollBar->SetRange(0.0, height);
|
||||
scrollBar->SetSteps(5.0, height / 2);
|
||||
|
||||
scrollBar->GetSteps(&smallStep, &bigStep);
|
||||
printf("scrollbar steps: %.1f, %.1f, proportion: %.1f, "
|
||||
"range: %.1f\n",
|
||||
smallStep, bigStep, scrollBar->Proportion(),
|
||||
height);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
BApplication app("application/x-vnd.stippi.scrollbar_test");
|
||||
|
||||
BRect frame(50, 50, 350, 350);
|
||||
BWindow* window = new BWindow(frame, "BScrollBar Test",
|
||||
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
|
||||
|
||||
frame = window->Bounds();
|
||||
frame.right -= B_V_SCROLL_BAR_WIDTH;
|
||||
View* view = new View(frame);
|
||||
|
||||
BScrollView* scrollView = new BScrollView("scroll view", view,
|
||||
B_FOLLOW_ALL, 0, false, true, B_NO_BORDER);
|
||||
|
||||
window->AddChild(scrollView);
|
||||
window->Show();
|
||||
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
18
src/tests/servers/app/scrollbar/run
Normal file
18
src/tests/servers/app/scrollbar/run
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
../../../../../generated/tests/libbe_test/x86/apps/run_haiku_registrar || exit
|
||||
|
||||
if test -f ../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then
|
||||
../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server &
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
fi
|
||||
|
||||
sleep 1s
|
||||
|
||||
if test -f ../../../../../generated/tests/libbe_test/x86/apps/ScrollBar; then
|
||||
../../../../../generated/tests/libbe_test/x86/apps/ScrollBar
|
||||
else
|
||||
echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first."
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user