Commit ade6d7a4 authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

Merge branch 'feature-scrollbars' into 'V3.6.3'

#909 Feature scrollbars

See merge request !712
parents 7a66d944 68ffee54
......@@ -56,6 +56,7 @@ import cz.nic.tablexia.util.ui.dialog.components.ResizableSpaceContentDialogComp
import cz.nic.tablexia.util.ui.dialog.components.ScrollPaneDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.TablexiaDialogComponentAdapter;
import cz.nic.tablexia.util.ui.dialog.components.ViewportMaximumSizeComponent;
import cz.nic.tablexia.util.ui.scrollpane.ScrollPaneWithBars;
public class AboutScreen extends AbstractTablexiaScreen<Void> {
......@@ -205,7 +206,7 @@ public class AboutScreen extends AbstractTablexiaScreen<Void> {
prepareContent();
contentScrollPane = new ScrollPane(content);
contentScrollPane = new ScrollPaneWithBars(content, false, true);
contentScrollPane.setScrollingDisabled(true, false);
contentScrollPane.setFillParent(true);
......
......@@ -44,7 +44,7 @@ import cz.nic.tablexia.screen.encyclopedia.content.actors.PlaybackStateButton;
import cz.nic.tablexia.screen.encyclopedia.content.model.Content;
import cz.nic.tablexia.screen.encyclopedia.menu.MenuItem;
import cz.nic.tablexia.screen.encyclopedia.menu.MenuWidget;
import cz.nic.tablexia.screen.encyclopedia.widget.ResizableScrollPane;
import cz.nic.tablexia.screen.encyclopedia.widget.ResizableScrollPaneWithBars;
import cz.nic.tablexia.screen.encyclopedia.widget.ResizableWidgetGroup;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.MusicUtil;
......@@ -208,7 +208,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
content = new Table();
content.padLeft(CONTENT_PAD_LEFT);
content.align(Align.top);
contentScrollPane = new ResizableScrollPane(content);
contentScrollPane = new ResizableScrollPaneWithBars(content, false, true);
contentScrollPane.setScrollingDisabled(true, false);
contentScrollPane.setSize(CONTENT_RELATIVE_WIDTH * getViewportWidth(), getViewportHeight());
......@@ -219,6 +219,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
container.add(contentStack);
}
private void prepareRightMenu() {
float rightPanelWidth = (1 - CONTENT_RELATIVE_WIDTH) * getSceneWidth();
menu = new MenuWidget(this, new Point(rightPanelWidth, getSceneInnerHeight() * MENU_RELATIVE_HEIGHT), EncyclopediaAssets.BOOKMARK, new MenuWidget.OnMenuItemClickListener() {
......@@ -231,7 +232,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
});
menuScrollPane = new ResizableScrollPane(menu);
menuScrollPane = new ResizableScrollPaneWithBars(menu, false, true);
menuScrollPane.setScrollingDisabled(true, false);
menuScrollPane.setSize(rightPanelWidth, getViewportHeight() * MENU_RELATIVE_HEIGHT);
......
......@@ -31,6 +31,7 @@ import com.badlogic.gdx.utils.Array;
import java.util.HashMap;
import java.util.Map;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.util.Point;
import cz.nic.tablexia.util.ui.button.TablexiaButton;
......@@ -40,6 +41,7 @@ import cz.nic.tablexia.util.ui.button.TablexiaButton;
*/
public class MenuWidget extends VerticalGroup {
private static final float BUTTON_TOP_BOTTOM_PADDING = 20f;
private static final float SCROLL_PANE_SIZE = 15f;
Array<MenuItem> menuItemValues;
private Map<MenuItem, TablexiaButton> menuItems;
......@@ -99,7 +101,7 @@ public class MenuWidget extends VerticalGroup {
if(btn == null) continue;
btn.setWidth(width);
btn.setWidth(width-SCROLL_PANE_SIZE);
btn.setHeight(btn.getLabel().getTablexiaLabelStyle().getFontType().getSize() + 2 * BUTTON_TOP_BOTTOM_PADDING);
}
}
......
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
* Copyright (C) 2018 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -18,14 +18,12 @@
package cz.nic.tablexia.screen.encyclopedia.widget;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
/**
* Created by Václav Tarantík on 25.8.15.
*/
public class ResizableScrollPane extends ScrollPane {
public ResizableScrollPane(Actor widget) {
super(widget);
import cz.nic.tablexia.util.ui.scrollpane.ScrollPaneWithBars;
public class ResizableScrollPaneWithBars extends ScrollPaneWithBars {
public ResizableScrollPaneWithBars(Actor widget, boolean hBar, boolean vBar) {
super(widget, hBar, vBar);
}
@Override
......
......@@ -17,16 +17,22 @@
package cz.nic.tablexia.util.ui;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
/**
* Created by drahomir on 4/4/16.
*/
public class ScrollPaneWithBorders extends ScrollPane{
public class ScrollPaneWithBorders extends SpecialScrollPane{
private static final float SCROLL_SIZE = 10f;
private static final Color SCROLL_COLOR = new Color(0.f,0,0,0.1f);
private static final Color KNOB_COLOR = new Color(0,0,0,0.35f);
private float lastScrollX;
private Image leftBorder, rightBorder;
......@@ -53,6 +59,21 @@ public class ScrollPaneWithBorders extends ScrollPane{
singleBorder = true;
this.rightBorder = leftBorder;
}
this.setStyle(initScrollPaneStyle());
this.setFadeScrollBars(false);
}
private ScrollPaneStyle initScrollPaneStyle() {
SpecialScrollPane.ScrollPaneStyle style = new SpecialScrollPane.ScrollPaneStyle();
style.hScrollKnob = getScrollRegionDrawable(KNOB_COLOR);
style.hScroll = getScrollRegionDrawable(SCROLL_COLOR);
return style;
}
private TextureRegionDrawable getScrollRegionDrawable(Color color){
TextureRegionDrawable regionDrawable = new TextureRegionDrawable(ApplicationAtlasManager.getInstance().getColorTextureRegion(color));
regionDrawable.setMinHeight(SCROLL_SIZE);
return regionDrawable;
}
@Override
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment