Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Output/cleanup #36

Merged
merged 6 commits into from
Aug 9, 2024
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
76 changes: 40 additions & 36 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Version 1.1.0
=============
* Widget::showPart has been added to be used when a specific
part of a widget should be visible. An example is when a text
area wants a specific text part to be visible in a scroll area.
This function uses BasicContainer::showWidgetPart.
* Rectangle::intersect has been renamed to Rectangle::isIntersecting.
* Widget::hasModalFocus has been renamed to Widget::isModalFocused.
* Widget::hasModalMouseInputFocus has been renamed to Widget::isModalMouseInputFocused.
Expand Down Expand Up @@ -31,10 +35,10 @@ Version 0.6.0
=============
* A lot of function definitions from BasicContainer have been moved down to
Widget, but Widget doesn't provide any useful implementations of these
functions. Useful implementations still reside in BasicContainer.
For container widget implementations inheriting from BasicContainer, as before,
should work just fine. The reason for the move of definitions is to be able to
consider a widget a container for the sake of simplicity when it comes to
functions. Useful implementations still reside in BasicContainer.
For container widget implementations inheriting from BasicContainer, as before,
should work just fine. The reason for the move of definitions is to be able to
consider a widget a container for the sake of simplicity when it comes to
distribution of input.
* The functions Widget::lostFocus andWidget::gotFocus have been renamed to
Widget::focusLost and Widget::focusGained.
Expand All @@ -46,31 +50,31 @@ Version 0.6.0
* All distribution of input is now handled by the Gui class. Because of this
all functions regarding input have been removed from the classes Widget
and BasicContainer.
* All functions of KeyListener and MouseListener have been renamed. The reason
for this is that the functions now bear the names of the well known Java
* All functions of KeyListener and MouseListener have been renamed. The reason
for this is that the functions now bear the names of the well known Java
listeners which will hopefully be more intuitive for most people.
* All input events can now be consumed making it easier to implement hot key
bindings.
* Mouse input (now called mouse events) are now distributed bottom up starting
* Mouse input (now called mouse events) are now distributed bottom up starting
from the widget directly under the mouse.
* Widgets can now ask for modal mouse input focus. A widget with modal mouse input
focus will be the only widget recieving mouse input, no matter where the mouse
input occurs. This can be very useful for some widgets, like a drop down which
acquires modal mouse input focus when folded down to be able to fold back up as
soon as the mouse is pressed outside of the drop down.
* Events are now present in Guichan. All listener classes now take event classes
as parameters which is a very big API change. The presence of events has propagated
changes to all input classes to better reflect the new usage of events.
as parameters which is a very big API change. The presence of events has propagated
changes to all input classes to better reflect the new usage of events.
* DropDown now acts on mouse wheel up and mouse wheel down when having focus.
* ListBox now acts on mouse wheel up and mouse wheel down when having focus.
* Widgets will no longer acquire focus if a mouse wheel up or a mouse wheel down
* Widgets will no longer acquire focus if a mouse wheel up or a mouse wheel down
occurs over a widget.
* The header exception.hpp is now included properly in openglsdlimageloader.hpp.
* The header exception.hpp is now included properly in openglsdlimageloader.hpp.
* Many small fixes.

Version 0.5.0
=============
* Slider now acts on the mouse wheel moving the slider to the left on
* Slider now acts on the mouse wheel moving the slider to the left on
mouse wheel down and to the right on mouse wheen up.
* ListBox now has the ability to wrap keyboard selection. Wrapping means
that if the key up is pressed and the first item is selected, then
Expand All @@ -79,19 +83,19 @@ Version 0.5.0
* Redesign of the Image class. Image now has different subclasses for
different Graphics objects. The static method load in the Image class
loads the appropiate type of image if an ImageLoader is set.
* The function action in ActionListener now takes a pointer to the
* The function action in ActionListener now takes a pointer to the
Widget who called the function, it makes handling of action events,
hopefully, cleaner.
* ScrollArea now scrolls if the open space around the markers is clicked.
* ScrollArea now scrolls if the open space around the markers is clicked.
* ScrollArea now has functions to set the amount to scroll when ScrollArea's
buttons are pushed, each button can have it's own amount.
buttons are pushed, each button can have it's own amount.
* Changed the function name of Widget::hasFocus and FocusHandler::hasFocus
to isFocused.
* Moved a lot of common container functionality into BasicContainer.
This made the code and API a lot cleaner. Affected classes are:
BasicContainer - now holds a lot of common functionality for containers.
Container - implementation is now a lot smaller.
Window - window now inherits from Container and can have several child
Window - window now inherits from Container and can have several child
widgets.
ScrollArea - smaller, nicer code.
TextBox & ListBox - Takes advantage of the new Container API to get rid
Expand All @@ -102,7 +106,7 @@ Version 0.5.0
* Fixed an offset by one error in AllegroGraphics::_beginDraw.
The initial clip area is now correct.
* Added alpha blending with SDL for 16bpp and 24 bpp mode.

Version 0.4.0
=============
* The GCN_EXCEPTION macro is now capable of determine the function in
Expand All @@ -114,22 +118,22 @@ Version 0.4.0
* Optimized fillRect in SDLGraphics slightly when using alpha
blending. However, SDLGraphics still needs a lot of optimizing
in other parts.
* Removed the filename from the Image class, as it wasn't really
* Removed the filename from the Image class, as it wasn't really
used for anything.
* Updated ImageFont with support for font images with several rows
of glyphs.
* Added modal focus to widgets. Widgets can now request modal focus
stealing all input from other widgets. Can be useful when making
dialog windows.
* Many small fixes.

Version 0.3.0
=============
* Every Guichan library now contains a C function which can be
=============
* Every Guichan library now contains a C function which can be
used with autotools check, for instance the Guichan SDL library
contains the function gcnSDL wich can be used when struggling
with autoconf. Other functions are gcnAllegro in Guichan Allegro,
gcnOpenGL in Guichan OpenGL and gcnGuichanVersion in the Guichan
with autoconf. Other functions are gcnAllegro in Guichan Allegro,
gcnOpenGL in Guichan OpenGL and gcnGuichanVersion in the Guichan
core.
* Slider now stores only the current selected value and calculates
everything from that value. It should take care of some resizing
Expand Down Expand Up @@ -158,54 +162,54 @@ Version 0.2.0
to the configure script which forces Guichan to compile with the
forced support.
* Updated platform.hpp to be able to handle compilation with MinGW.
* Splited DECLSPEC define into GCN_CORE_DECLSPEC and
* Splited DECLSPEC define into GCN_CORE_DECLSPEC and
GCN_EXTENSION_DECLSPEC.
* Fixed bugs in ScrollArea and DropDown involving focus and mouse input,
* Changed the look when CheckBox is marked.
* Changed the look when CheckBox is marked.
* Changed the look when CheckBox and RadioButton are focused.
They now draw a rectangle around their captions (common behaivour in Guis).
* Removed unaccesary logic functions (which didn't do anything) in
widget RadioButton and CheckBox.
widget RadioButton and CheckBox.
* Added a new widget called Slider, and it is a... slider!
* Removed getWidth for glyphs in Font.
* Removed function drawGlyph in Font and in addon SDLTrueTypeFont.
* Removed function drawGlyph in Font and in addon SDLTrueTypeFont.
Added drawGlyph function in ImageFont and DefaultFont.
drawGlyph in Font is easy to missunderstand and could lead to
drawGlyph in Font is easy to missunderstand and could lead to
strange implementations of Font.
* Added getCurrentClipArea function in Graphics.
* All functions in container are now virtual (thanks to Garo pointing this out).
* Added function setSize in Widget.
* Added an "addons" directory in the distrobution. It will contain
usefull classes with Guichan that are not compiled into the library.
They are not compiled because they need dependencies other then
They are not compiled because they need dependencies other then
Guichans or are to specific. For now, "addons" only contain one
class, SDLTrueTypeFont giving True Type Font abilities to Guichan
through the SDL_ttf library and hence will only work with SDLGraphics.
SDLTrueTypeFont was contributed by Walluce Pinkham (and edited by us).
Thank you Walluce!
* Added getColor function in Graphics. Implemented in SDLGraphics,
* Added getColor function in Graphics. Implemented in SDLGraphics,
AllegroGraphics and OpenGLGraphics.
* Fixed a problem with the DropDown widget. When the widget was focused
with a mouse press, you couldn't select elements with up and down keys.
* Merged drawText, drawTextCenter and drawTextRight into one function
drawText which takes an alignment parameter (thanks Ted!).
Widgets taking advantage of this are Button and Label.
* As a result of the added border support, almost every widget have
* As a result of the added border support, almost every widget have
been changed for the better, e.g removal of offsets.
* Added support for borders. This is a major API change introducing
some new functions to Widget.
some new functions to Widget.
* Lots of small bugfixes

Version 0.1.0
=============
=============
* Guichan_allegro MSVC 6 compatibility fix.
* TextBox doesn't draw its caret if its not editable.
* Better exception with more information in ImageFont,
added row spacing and glyph spacing functions.
* Fixed problem in ImageFont when loading a corrupt file.
It will now throw an exception (thanks Terin!).
* Implemented _getRawData() in AllegroImageLoader.
* Fixed Image. It is now overloadable.
* Fixed Image. It is now overloadable.
* DropDown sets the colors for its internal widgets if they are
not custom widgets (not given to the DropDown by the user).
* Now all default widgets respect the alpha channel in the colors.
Expand Down
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Continue rebasing from 4c1d9a0bb1393dafb8efe28849c09914261a8ad8
* Continue rebasing from e5271f1ad79923ffa1810e2bc62435117d49ce9f
* Add a focus listener interface.
* Make focus apply synchronously.
* Graphics and input objects for DirectX.
Expand Down
16 changes: 13 additions & 3 deletions include/guisan/basiccontainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,21 @@ namespace gcn
*/
virtual ~BasicContainer();


// Inherited from Widget

/**
* Shows a certain part of a widget in the basic container.
* Used when widgets want a specific part to be visible in
* its parent. An example is a TextArea that wants a specific
* part of its text to be visible when a TextArea is a child
* of a ScrollArea.
*
* @param widget The widget whom wants a specific part of
* itself to be visible.
* @param rectangle The rectangle to be visible.
*/
virtual void showWidgetPart(Widget* widget, Rectangle area);

virtual void moveToTop(Widget* widget);

virtual void moveToBottom(Widget* widget);
Expand All @@ -100,8 +112,6 @@ namespace gcn

void setInternalFocusHandler(FocusHandler* focusHandler);

virtual void showWidgetPart(Widget* widget, Rectangle area);

virtual Widget *getWidgetAt(int x, int y);


Expand Down
10 changes: 10 additions & 0 deletions include/guisan/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@

#include "guisan/platform.hpp"

#include <iostream>

namespace gcn
{
/**
Expand Down Expand Up @@ -149,6 +151,14 @@ namespace gcn
*/
bool operator!=(const Color& color) const;

/**
* Output operator for output.
*
* @param out The stream to output to.
* @param color The color to output.
*/
friend std::ostream& operator<<(std::ostream& out, const Color& Color);

/**
* Holds the red color component (range 0-255).
*/
Expand Down
12 changes: 11 additions & 1 deletion include/guisan/rectangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@

#include "guisan/platform.hpp"

#include <iostream>

namespace gcn
{
/**
Expand Down Expand Up @@ -105,7 +107,7 @@ namespace gcn
* @return True if the rectangles intersect, false otherwise.
* @since 1.1.0
*/
bool isIntersecting(const Rectangle& rectangle);
bool isIntersecting(const Rectangle& rectangle) const;

/**
* Checks if a point is inside the rectangle
Expand All @@ -117,6 +119,14 @@ namespace gcn
*/
bool isPointInRect(int x, int y) const;

/**
* Output operator for output.
*
* @param out The stream to output to.
* @param rectangle The rectangle to output.
*/
friend std::ostream& operator<<(std::ostream& out, const Rectangle& rectangle);

/**
* Holds the x coordinate of the rectangle.
*/
Expand Down
7 changes: 4 additions & 3 deletions include/guisan/selectionlistener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace gcn
*
* @see ListBox::addSelectionListener,
* ListBox::removeSelectionListener,
* DropDown:addSelectionListener,
* DropDown::addSelectionListener,
* DropDown::removeSelectionListener
* @author Olof Naess�n
* @since 0.8.0
Expand All @@ -84,8 +84,9 @@ namespace gcn
virtual ~SelectionListener() { }

/**
* Called when a value has been changed in a Widget. It is used
* to be able to recieve a notification that a value has been changed.
* Called when the value of a selection has been changed in a Widget.
* It is used to be able to receive a notification that a value has
* been changed.
*
* @param event The event of the value change.
* @since 0.8.0
Expand Down
12 changes: 12 additions & 0 deletions include/guisan/widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,18 @@ namespace gcn
*/
const std::string& getId();

/**
* Shows a certain part of a widget in the widget's parent.
* Used when widgets want a specific part to be visible in
* its parent. An example is a TextArea that wants a specific
* part of its text to be visible when a TextArea is a child
* of a ScrollArea.
*
* @param rectangle The rectangle to be shown.
* @since 1.1.0
*/
virtual void showPart(Rectangle rectangle);

protected:
/**
* Distributes an action event to all action listeners
Expand Down
4 changes: 3 additions & 1 deletion include/guisan/widgetlistener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
namespace gcn
{
/**
* Interface for listening for selection events from widgets.
* Interface for listening for events from widgets. When a widget's size,
* location or visibility changes, the relevant method of the listener is
* invoked.
*
* @see Widget::addWidgetListener, Widget::removeWidgetListener
* @author Olof Naess�n
Expand Down
6 changes: 6 additions & 0 deletions src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,10 @@ namespace gcn
{
return !(r == color.r && g == color.g && b == color.b && a == color.a);
}

std::ostream& operator<<(std::ostream& out, const Color& color)
{
return out << "Color [r = " << color.r << ", g = " << color.g << ", b = " << color.b
<< ", a = " << color.a << "]";
}
}
Loading