Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/gui/gui2_advancedscrolltext.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "gui2_advancedscrolltext.h"

GuiAdvancedScrollText::GuiAdvancedScrollText(GuiContainer* owner, string id)
: GuiElement(owner, id), text_size(30.0f), rect_width(rect.size.x), max_prefix_width(0.0f), mouse_scroll_steps(25)
: GuiElement(owner, id), text_size(30.0f), rect_width(rect.size.x), max_prefix_width(0.0f)
{
scrollbar = new GuiScrollbar(this, id + "_SCROLL", 0, 1, 0, nullptr);
// Calculate scrolling a one-line entry by scrollbar arrow buttons.
Expand Down Expand Up @@ -146,7 +146,6 @@ void GuiAdvancedScrollText::onDraw(sp::RenderTarget& renderer)

bool GuiAdvancedScrollText::onMouseWheelScroll(glm::vec2 position, float value)
{
float range = scrollbar->getCorrectedMax() - scrollbar->getMin();
scrollbar->setValue((scrollbar->getValue() - value * range / mouse_scroll_steps) );
scrollbar->setValue(scrollbar->getValue() - value * text_size * 3.0f);
return true;
}
1 change: 0 additions & 1 deletion src/gui/gui2_advancedscrolltext.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class GuiAdvancedScrollText : public GuiElement
std::map<float, int> prefix_widths;
bool auto_scroll_down;
Entry prepEntry(Entry& e);
int mouse_scroll_steps;

public:
GuiAdvancedScrollText(GuiContainer* owner, string id);
Expand Down
5 changes: 2 additions & 3 deletions src/gui/gui2_listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "gui2_scrollbar.h"

GuiListbox::GuiListbox(GuiContainer* owner, string id, func_t func)
: GuiEntryList(owner, id, func), text_size(30), button_height(50), text_alignment(sp::Alignment::Center), mouse_scroll_steps(25)
: GuiEntryList(owner, id, func), text_size(30), button_height(50), text_alignment(sp::Alignment::Center)
{
scroll = new GuiScrollbar(this, id + "_SCROLL", 0, 0, 0, [this](int value) {});
scroll
Expand Down Expand Up @@ -136,7 +136,6 @@ void GuiListbox::onMouseUp(glm::vec2 position, sp::io::Pointer::ID id)

bool GuiListbox::onMouseWheelScroll(glm::vec2 position, float value)
{
float range = scroll->getCorrectedMax() - scroll->getMin();
scroll->setValue((scroll->getValue() - value * range / mouse_scroll_steps) );
scroll->setValue(scroll->getValue() - value * button_height);
return true;
}
1 change: 0 additions & 1 deletion src/gui/gui2_listbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class GuiListbox : public GuiEntryList
sp::Alignment text_alignment;
GuiScrollbar* scroll;
sp::Rect last_rect;
int mouse_scroll_steps;

const GuiThemeStyle* back_style;
const GuiThemeStyle* front_style;
Expand Down
3 changes: 1 addition & 2 deletions src/gui/gui2_scrolltext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ void GuiScrollText::onDraw(sp::RenderTarget& renderer)

bool GuiScrollText::onMouseWheelScroll(glm::vec2 position, float value)
{
float range = scrollbar->getCorrectedMax() - scrollbar->getMin();
scrollbar->setValue((scrollbar->getValue() - value * range / mouse_scroll_steps) );
scrollbar->setValue(scrollbar->getValue() - value * text_size * 3.0f);
return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/gui/gui2_scrolltext.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class GuiScrollText : public GuiElement
string text;
float text_size = 30.0f;
bool auto_scroll_down = false;
int mouse_scroll_steps = 25;
const GuiThemeStyle* text_theme;

public:
Expand Down
Loading