Skip to content

Commit

Permalink
Merge pull request #30 from Jarod42/border2frame
Browse files Browse the repository at this point in the history
Border2frame
  • Loading branch information
Jarod42 authored Jul 29, 2024
2 parents 352047b + 03de336 commit 805365c
Show file tree
Hide file tree
Showing 49 changed files with 345 additions and 678 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Continue rebasing from 753608c0c8cd0196c19c467db0f8df5f61d99b3c
* Continue rebasing from b62d153a5dd699add2109671d4569578dd4f2671
* Add a focus listener interface.
* Make focus apply synchronously.
* Graphics and input objects for DirectX.
Expand Down
2 changes: 1 addition & 1 deletion demo/ff/src/ffcharacterchooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ FFCharacterChooser::FFCharacterChooser()
mHand = gcn::Image::load("images/hand.png");
setFocusable(true);
addKeyListener(this);
setBorderSize(0);
setFrameSize(0);
}

FFCharacterChooser::~FFCharacterChooser()
Expand Down
2 changes: 1 addition & 1 deletion demo/ff/src/ffcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ FFContainer::FFContainer()
Container::setHeight(0);
mSlideTarget = 0;
mCurrentSlide = 0;
setBorderSize(0);
setFrameSize(0);
}

FFContainer::~FFContainer()
Expand Down
36 changes: 18 additions & 18 deletions demo/ff/src/ffdemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ FFDemo::FFDemo()
mGoldFootsteps = new FFContainer();
mGoldFootsteps->setDimension(gcn::Rectangle(210, 170, 110, 70));
mGoldFootsteps->setOpaque(false);
mGoldFootsteps->setBorderSize(0);
mGoldFootsteps->setFrameSize(0);
mTop->add(mGoldFootsteps);

mTime = new FFContainer();
Expand All @@ -109,13 +109,13 @@ FFDemo::FFDemo()
mGoldFootstepsInfo1->setOpaque(false);
mGoldFootstepsInfo1->setEditable(false);
mGoldFootstepsInfo1->setFocusable(false);
mGoldFootstepsInfo1->setBorderSize(0);
mGoldFootstepsInfo1->setFrameSize(0);

mGoldFootstepsInfo2 = new gcn::TextBox("\n 9119092\n\n 1009213");
mGoldFootstepsInfo2->setOpaque(false);
mGoldFootstepsInfo2->setEditable(false);
mGoldFootstepsInfo2->setFocusable(false);
mGoldFootstepsInfo2->setBorderSize(0);
mGoldFootstepsInfo2->setFrameSize(0);

mTimeLabel1 = new gcn::Label("Time");
mTimeLabel1->setFont(mFontCyan);
Expand Down Expand Up @@ -210,39 +210,39 @@ void FFDemo::initMain()
mPerInfo1->setOpaque(false);
mPerInfo1->setEditable(false);
mPerInfo1->setFocusable(false);
mPerInfo1->setBorderSize(0);
mPerInfo1->setFrameSize(0);

mPerInfo2 = new gcn::TextBox("FINALMAN\n 13\n 12/ 336\n 33/ 40");
mPerInfo2->setOpaque(false);
mPerInfo2->setEditable(false);
mPerInfo2->setFocusable(false);
mPerInfo2->setBorderSize(0);
mPerInfo2->setFrameSize(0);

mOlofInfo1 = new gcn::TextBox("\n LV\n HP\n MP");
mOlofInfo1->setFont(mFontCyan);
mOlofInfo1->setOpaque(false);
mOlofInfo1->setEditable(false);
mOlofInfo1->setFocusable(false);
mOlofInfo1->setBorderSize(0);
mOlofInfo1->setFrameSize(0);

mOlofInfo2 = new gcn::TextBox("YAKSLEM\n 41\n 1304/2932\n 298/ 300");
mOlofInfo2->setOpaque(false);
mOlofInfo2->setEditable(false);
mOlofInfo2->setFocusable(false);
mOlofInfo2->setBorderSize(0);
mOlofInfo2->setFrameSize(0);

mTomasInfo1 = new gcn::TextBox("\n LV\n HP\n MP");
mTomasInfo1->setFont(mFontCyan);
mTomasInfo1->setOpaque(false);
mTomasInfo1->setEditable(false);
mTomasInfo1->setFocusable(false);
mTomasInfo1->setBorderSize(0);
mTomasInfo1->setFrameSize(0);

mTomasInfo2 = new gcn::TextBox("PEAK\n 6\n 101/ 101\n 0/ 0");
mTomasInfo2->setOpaque(false);
mTomasInfo2->setEditable(false);
mTomasInfo2->setFocusable(false);
mTomasInfo2->setBorderSize(0);
mTomasInfo2->setFrameSize(0);

int offset = 6;
mMain->add(mPerIcon, 10, offset);
Expand Down Expand Up @@ -308,7 +308,7 @@ void FFDemo::initStatus()
mPerStatus1->setEditable(false);
mPerStatus1->setFocusable(false);
mPerStatus1->setVisible(false);
mPerStatus1->setBorderSize(0);
mPerStatus1->setFrameSize(0);

mPerStatus2 = new gcn::TextBox(" 32 12382\n"
" 56 13872\n"
Expand All @@ -321,7 +321,7 @@ void FFDemo::initStatus()
mPerStatus2->setEditable(false);
mPerStatus2->setFocusable(false);
mPerStatus2->setVisible(false);
mPerStatus2->setBorderSize(0);
mPerStatus2->setFrameSize(0);

mOlofStatus1 = new gcn::TextBox(" STR EXP\n"
" INT NEXT\n"
Expand All @@ -332,7 +332,7 @@ void FFDemo::initStatus()
mOlofStatus1->setEditable(false);
mOlofStatus1->setFocusable(false);
mOlofStatus1->setVisible(false);
mOlofStatus1->setBorderSize(0);
mOlofStatus1->setFrameSize(0);

mOlofStatus2 = new gcn::TextBox(" 2 412382\n"
" 72 513872\n"
Expand All @@ -345,7 +345,7 @@ void FFDemo::initStatus()
mOlofStatus2->setEditable(false);
mOlofStatus2->setFocusable(false);
mOlofStatus2->setVisible(false);
mOlofStatus2->setBorderSize(0);
mOlofStatus2->setFrameSize(0);

mTomasStatus1 = new gcn::TextBox(" STR EXP\n"
" INT NEXT\n"
Expand All @@ -356,7 +356,7 @@ void FFDemo::initStatus()
mTomasStatus1->setEditable(false);
mTomasStatus1->setFocusable(false);
mTomasStatus1->setVisible(false);
mTomasStatus1->setBorderSize(0);
mTomasStatus1->setFrameSize(0);

mTomasStatus2 = new gcn::TextBox(" 1 412382\n"
" 3 513872\n"
Expand All @@ -369,7 +369,7 @@ void FFDemo::initStatus()
mTomasStatus2->setEditable(false);
mTomasStatus2->setFocusable(false);
mTomasStatus2->setVisible(false);
mTomasStatus2->setBorderSize(0);
mTomasStatus2->setFrameSize(0);

mStatus->add(mPerStatus2, 5, 10);
mStatus->add(mPerStatus1, 5, 10);
Expand Down Expand Up @@ -509,7 +509,7 @@ void FFDemo::initItems()
mItemsInfoInfo->setEditable(false);
mItemsInfoInfo->setFocusable(false);
mItemsInfoInfo->setDimension(gcn::Rectangle(5, 5, 310, 40));
mItemsInfoInfo->setBorderSize(0);
mItemsInfoInfo->setFrameSize(0);
mItemsInfo->add(mItemsInfoInfo);

mItemsList = new FFListBox();
Expand Down Expand Up @@ -584,9 +584,9 @@ void FFDemo::initAbout()
mAboutScrollArea->setContent(mAboutInfo);
mAboutScrollArea->setFocusable(true);
mAboutScrollArea->setDimension(gcn::Rectangle(5, 5, 310, 230));
mAboutScrollArea->setBorderSize(0);
mAboutScrollArea->setFrameSize(0);
mAbout->add(mAboutScrollArea);
mAbout->setBorderSize(0);
mAbout->setFrameSize(0);
}

void FFDemo::cleanAbout()
Expand Down
2 changes: 1 addition & 1 deletion demo/ff/src/fflistbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FFListBox::FFListBox()
}

mInstances++;
setBorderSize(0);
setFrameSize(0);
setWrappingEnabled(true);
}

Expand Down
2 changes: 1 addition & 1 deletion demo/ff/src/ffscrollarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ FFScrollArea::FFScrollArea()
setScrollPolicy(SHOW_NEVER, SHOW_NEVER);
addKeyListener(this);
setFocusable(false);
setBorderSize(0);
setFrameSize(0);
}

void FFScrollArea::draw(gcn::Graphics *graphics)
Expand Down
6 changes: 3 additions & 3 deletions examples/openglwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ void initWidgets()
textBoxScrollArea = new gcn::ScrollArea(textBox);
textBoxScrollArea->setWidth(270);
textBoxScrollArea->setHeight(100);
textBoxScrollArea->setBorderSize(1);
textBoxScrollArea->setFrameSize(1);

listBox = new gcn::ListBox(&demoListModel);
listBox->setBorderSize(1);
listBox->setFrameSize(1);

dropDown = new gcn::DropDown(&demoListModel);

Expand Down Expand Up @@ -172,7 +172,7 @@ void initWidgets()

nestedScrollArea = new gcn::ScrollArea(nestedContainer);
nestedScrollArea->setSize(180, 90);
nestedScrollArea->setBorderSize(1);
nestedScrollArea->setFrameSize(1);

/*
* Add them to the top container
Expand Down
6 changes: 3 additions & 3 deletions examples/sdl2widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ initWidgets()
textBoxScrollArea = new gcn::ScrollArea(textBox);
textBoxScrollArea->setWidth(270);
textBoxScrollArea->setHeight(100);
textBoxScrollArea->setBorderSize(1);
textBoxScrollArea->setFrameSize(1);

listBox = new gcn::ListBox(&demoListModel);
listBox->setBorderSize(1);
listBox->setFrameSize(1);

dropDown = new gcn::DropDown(&demoListModel);

Expand Down Expand Up @@ -154,7 +154,7 @@ initWidgets()

nestedScrollArea = new gcn::ScrollArea(nestedContainer);
nestedScrollArea->setSize(180, 90);
nestedScrollArea->setBorderSize(1);
nestedScrollArea->setFrameSize(1);

/*
* Add them to the top container
Expand Down
6 changes: 3 additions & 3 deletions examples/sdlwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ initWidgets()
textBoxScrollArea = new gcn::ScrollArea(textBox);
textBoxScrollArea->setWidth(270);
textBoxScrollArea->setHeight(100);
textBoxScrollArea->setBorderSize(1);
textBoxScrollArea->setFrameSize(1);

listBox = new gcn::ListBox(&demoListModel);
listBox->setBorderSize(1);
listBox->setFrameSize(1);

dropDown = new gcn::DropDown(&demoListModel);

Expand Down Expand Up @@ -159,7 +159,7 @@ initWidgets()

nestedScrollArea = new gcn::ScrollArea(nestedContainer);
nestedScrollArea->setSize(180, 90);
nestedScrollArea->setBorderSize(1);
nestedScrollArea->setFrameSize(1);

/*
* Add them to the top container
Expand Down
73 changes: 48 additions & 25 deletions include/guisan/widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,57 @@ namespace gcn
virtual void draw(Graphics* graphics) = 0;

/**
* Draws the widget border. A border is drawn around a widget.
* The width and height of the border is therefore the widgets
* height+2*bordersize. Think of a painting that has a certain size,
* the border surrounds the painting.
* Called when a widget is given a chance to draw a frame around itself.
* The frame is not considered a part of the widget, it only allows a frame
* to be drawn around the widget, thus a frame will never be included when
* calculating if a widget should receive events from user input. Also
* a widget's frame will never be included when calculating a widget's
* position.
*
* The size of the frame is calculated using the widget's frame size.
* If a widget has a frame size of 10 pixels than the area the drawFrame
* function can draw to will be the size of the widget with an additional
* extension of 10 pixels in each direction.
*
* @param graphics a Graphics object to draw with.
* An example when drawFrame is a useful function is if a widget needs
* a glow around itself.
*
* @param graphics a graphics object to draw with.
* @see setFrameSize, getFrameSize
*/
virtual void drawFrame(Graphics* graphics);

/**
* Sets the size of the widget's frame. The frame is not considered a part of
* the widget, it only allows a frame to be drawn around the widget, thus a frame
* will never be included when calculating if a widget should receive events
* from user input. Also a widget's frame will never be included when calculating
* a widget's position.
*
* A frame size of 0 means that the widget has no frame. The default frame size
* is 0.
*
* @param frameSize The size of the widget's frame.
* @see getFrameSize, drawFrame
*/
void setFrameSize(unsigned int frameSize);

/**
* Gets the size of the widget's frame. The frame is not considered a part of
* the widget, it only allows a frame to be drawn around the widget, thus a frame
* will never be included when calculating if a widget should receive events
* from user input. Also a widget's frame will never be included when calculating
* a widget's position.
*
* A frame size of 0 means that the widget has no frame. The default frame size
* is 0.
*
* @return The size of the widget's frame.
* @see setFrameSize, drawFrame
*/
virtual void drawBorder(Graphics* graphics) { }
unsigned int getFrameSize() const;


/**
* Called for all widgets in the gui each time Gui::logic is called.
Expand Down Expand Up @@ -221,26 +264,6 @@ namespace gcn
*/
void setDimension(const Rectangle& dimension);

/**
* Sets the size of the border, or the width if you so like. The size
* is the number of pixels that the border extends outside the widget.
* Border size = 0 means no border.
*
* @param borderSize the size of the border.
* @see drawBorder
*/
void setBorderSize(unsigned int borderSize);

/**
* Gets the size of the border, or the width if you so like. The size
* is the number of pixels that the border extends outside the widget.
* Border size = 0 means no border.
*
* @return the size of the border.
* @see drawBorder
*/
unsigned int getBorderSize() const;

/**
* Gets the dimension of the widget. It is relative to its parent.
*
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawBorder(Graphics* graphics);


// Inherited from FocusListener

Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/checkbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawBorder(Graphics* graphics);


// Inherited from KeyListener

Expand Down
1 change: 0 additions & 1 deletion include/guisan/widgets/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawBorder(Graphics* graphics);

protected:
/**
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/dropdown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawBorder(Graphics* graphics);

void setBaseColor(const Color& color);

void setBackgroundColor(const Color& color);
Expand Down
1 change: 0 additions & 1 deletion include/guisan/widgets/icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawBorder(Graphics* graphics);

protected:
/**
Expand Down
2 changes: 0 additions & 2 deletions include/guisan/widgets/inputbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ namespace gcn

virtual void draw(Graphics* graphics);

virtual void drawBorder(Graphics* graphics);


// Inherited from MouseListener

Expand Down
Loading

0 comments on commit 805365c

Please sign in to comment.