<commit_before>/*
 * Copyright 2014-2015 <NAME>
 *
 * This file is part of VisEditor.
 *
 * VisEditor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VisEditor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VisEditor.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.kotcrab.vis.editor.module;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.kotcrab.vis.editor.App;
import com.kotcrab.vis.editor.Assets;
import com.kotcrab.vis.editor.event.Event;
import com.kotcrab.vis.editor.event.EventListener;
import com.kotcrab.vis.editor.event.MenuEvent;
import com.kotcrab.vis.editor.event.MenuEventType;
import com.kotcrab.vis.ui.VisTable;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisImageButton;

public class ToolbarModule extends EditorModule implements EventListener {
	public VisTable table;

	public ToolbarModule () {
		table = new VisTable(false);
		table.setBackground(VisUI.skin.getDrawable("button"));
		table.add(createButton("save", MenuEventType.FILE_SAVE));
		table.add().expand().fill();
	}

	@Override
	public void added () {
		App.eventBus.register(this);
	}

	@Override
	public void dispose () {
		App.eventBus.unregister(this);
	}

	@Override
	public boolean onEvent (Event e) {
		return false;
	}

	public Table getTable () {
		return table;
	}

	private VisImageButton createButton (String iconName, MenuEventType eventType) {
		VisImageButton button = new VisImageButton(Assets.getIcon(iconName));
		button.addListener(new ToolbarButtonChangeListener(eventType));
		return button;
	}

	private class ToolbarButtonChangeListener extends ChangeListener {
		private MenuEventType type;

		public ToolbarButtonChangeListener (MenuEventType eventType) {
			this.type = eventType;
		}

		@Override
		public void changed (ChangeEvent event, Actor actor) {
			App.eventBus.post(new MenuEvent(type));
		}
	}
}<commit_msg>Added tooltip to toolbar buttons<commit_after>/*
 * Copyright 2014-2015 <NAME>
 *
 * This file is part of VisEditor.
 *
 * VisEditor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VisEditor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VisEditor.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.kotcrab.vis.editor.module;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.kotcrab.vis.editor.App;
import com.kotcrab.vis.editor.Assets;
import com.kotcrab.vis.editor.event.Event;
import com.kotcrab.vis.editor.event.EventListener;
import com.kotcrab.vis.editor.event.MenuEvent;
import com.kotcrab.vis.editor.event.MenuEventType;
import com.kotcrab.vis.ui.VisTable;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisImageButton;

public class ToolbarModule extends EditorModule implements EventListener {
	public VisTable table;

	public ToolbarModule () {
		table = new VisTable(false);
		table.setBackground(VisUI.skin.getDrawable("button"));
		table.add(createButton("save", MenuEventType.FILE_SAVE));
		table.add().expand().fill();
	}

	@Override
	public void added () {
		App.eventBus.register(this);
	}

	@Override
	public void dispose () {
		App.eventBus.unregister(this);
	}

	@Override
	public boolean onEvent (Event e) {
		return false;
	}

	public Table getTable () {
		return table;
	}

	private VisImageButton createButton (String iconName, MenuEventType eventType) {
		VisImageButton button = new VisImageButton(Assets.getIcon(iconName));
		button.addListener(new ToolbarButtonChangeListener(eventType));
		button.setTooltip("Save");
		return button;
	}

	private class ToolbarButtonChangeListener extends ChangeListener {
		private MenuEventType type;

		public ToolbarButtonChangeListener (MenuEventType eventType) {
			this.type = eventType;
		}

		@Override
		public void changed (ChangeEvent event, Actor actor) {
			App.eventBus.post(new MenuEvent(type));
		}
	}
}
{'fraction_non_alphanumeric': 0.09789644012944984, 'fraction_numerical': 0.0048543689320388345, 'mean_word_length': 4.562429696287964, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6958470', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1496, 'n_words': 431}