diff --git a/extras/juce demo/src/demos/FontsAndTextDemo.cpp b/extras/juce demo/src/demos/FontsAndTextDemo.cpp index f34c030734..545439be82 100644 --- a/extras/juce demo/src/demos/FontsAndTextDemo.cpp +++ b/extras/juce demo/src/demos/FontsAndTextDemo.cpp @@ -38,12 +38,13 @@ class FontsAndTextDemo : public Component, ToggleButton* boldButton; ToggleButton* italicButton; Slider* sizeSlider; + Slider* kerningSlider; + Slider* horizontalScaleSlider; StretchableLayoutManager verticalLayout; StretchableLayoutManager horizontalLayout; StretchableLayoutResizerBar* verticalDividerBar; - StretchableLayoutResizerBar* horizontalDividerBar; public: //============================================================================== @@ -71,12 +72,33 @@ public: addAndMakeVisible (italicButton = new ToggleButton (T("italic"))); italicButton->addButtonListener (this); - addAndMakeVisible (sizeSlider = new Slider (T("size"))); + addAndMakeVisible (sizeSlider = new Slider ("Size")); sizeSlider->setRange (3.0, 150.0, 0.1); sizeSlider->setValue (20.0); sizeSlider->addListener (this); + (new Label (String::empty, sizeSlider->getName()))->attachToComponent (sizeSlider, true); + + addAndMakeVisible (kerningSlider = new Slider ("Kerning")); + kerningSlider->setRange (-1.0, 1.0, 0.01); + kerningSlider->setValue (0.0); + kerningSlider->addListener (this); + (new Label (String::empty, kerningSlider->getName()))->attachToComponent (kerningSlider, true); + + addAndMakeVisible (horizontalScaleSlider = new Slider ("Stretch")); + horizontalScaleSlider->setRange (0.1, 4.0, 0.01); + horizontalScaleSlider->setValue (1.0); + horizontalScaleSlider->addListener (this); + (new Label (String::empty, horizontalScaleSlider->getName()))->attachToComponent (horizontalScaleSlider, true); + + for (int i = 0; i < fonts.size(); ++i) + { + if (fonts[i]->getTypefaceName().startsWithIgnoreCase (T("Arial"))) + { + listBox->selectRow (i); + break; + } + } - listBox->selectRow (0); listBox->setColour (ListBox::outlineColourId, Colours::black.withAlpha (0.5f)); listBox->setOutlineThickness (1); @@ -106,9 +128,6 @@ public: // space left over - this will stop the // sliders from always sticking to the // bottom of the window - - horizontalDividerBar = new StretchableLayoutResizerBar (&horizontalLayout, 1, false); - addAndMakeVisible (horizontalDividerBar); } ~FontsAndTextDemo() @@ -127,18 +146,14 @@ public: true); // resize the components' heights as well as widths // now lay out the text box and the controls below it.. - Component* hcomps[] = { textBox, horizontalDividerBar, 0, - boldButton, 0, - italicButton, 0, - sizeSlider }; - - horizontalLayout.layOutComponents (hcomps, 8, - 4 + verticalLayout.getItemCurrentPosition (2), // for their widths, refer to the vertical layout state - 4, - verticalLayout.getItemCurrentAbsoluteSize (2), - getHeight() - 8, - true, // lay out above each other - true); // resize the components' widths as well as heights + int x = verticalLayout.getItemCurrentPosition (2); + textBox->setBounds (x, 0, getWidth() - x, getHeight() - 110); + x += 70; + sizeSlider->setBounds (x, getHeight() - 106, getWidth() - x, 22); + kerningSlider->setBounds (x, getHeight() - 82, getWidth() - x, 22); + horizontalScaleSlider->setBounds (x, getHeight() - 58, getWidth() - x, 22); + boldButton->setBounds (x, getHeight() - 34, (getWidth() - x) / 2, 22); + italicButton->setBounds (x + (getWidth() - x) / 2, getHeight() - 34, (getWidth() - x) / 2, 22); } // implements the ListBoxModel method @@ -162,9 +177,17 @@ public: font.setHeight (height * 0.7f); g.setFont (font); + g.setColour (Colours::black); g.drawText (font.getTypefaceName(), 4, 0, width - 4, height, Justification::centredLeft, true); + + int x = jmax (0, font.getStringWidth (font.getTypefaceName())) + 12; + g.setFont (Font (11.0f, Font::italic)); + g.setColour (Colours::grey); + g.drawText (font.getTypefaceName(), + x, 0, width - x - 2, height, + Justification::centredLeft, true); } } @@ -179,6 +202,8 @@ public: font.setHeight ((float) sizeSlider->getValue()); font.setBold (boldButton->getToggleState()); font.setItalic (italicButton->getToggleState()); + font.setExtraKerningFactor ((float) kerningSlider->getValue()); + font.setHorizontalScale ((float) horizontalScaleSlider->getValue()); textBox->applyFontToAllText (font); } diff --git a/extras/juce demo/src/demos/PathsAndTransformsDemo.cpp b/extras/juce demo/src/demos/PathsAndTransformsDemo.cpp index 8dee944d99..135ed6dcff 100644 --- a/extras/juce demo/src/demos/PathsAndTransformsDemo.cpp +++ b/extras/juce demo/src/demos/PathsAndTransformsDemo.cpp @@ -75,7 +75,7 @@ public: typeChooser->addItem (T("image - high quality"), 5); typeChooser->addItem (T("image - colour-filled alpha channel"), 6); typeChooser->addItem (T("image - gradient-filled alpha channel"), 7); - typeChooser->addItem (T("image - alphamap-filled alpha channel"), 9); + typeChooser->addItem (T("image - tiled-image-filled alpha channel"), 9); typeChooser->addItem (T("drawable object"), 10); typeChooser->addItem (T("SVG object"), 11); typeChooser->setSelectedId (11); diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp index 1bc515b95d..bdbe1b2803 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp @@ -398,6 +398,15 @@ void CodeEditorComponent::paint (Graphics& g) } } +void CodeEditorComponent::setScrollbarThickness (const int thickness) throw() +{ + if (scrollbarThickness != thickness) + { + scrollbarThickness = thickness; + resized(); + } +} + void CodeEditorComponent::handleAsyncUpdate() { rebuildLineTokens(); diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.h b/src/gui/components/code_editor/juce_CodeEditorComponent.h index c4c57ccc92..94ea11010b 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.h +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.h @@ -207,6 +207,10 @@ public: enabled. */ }; + //============================================================================== + /** Changes the size of the scrollbars. */ + void setScrollbarThickness (const int thickness) throw(); + //============================================================================== /** @internal */ void resized(); diff --git a/src/gui/components/special/juce_ColourSelector.cpp b/src/gui/components/special/juce_ColourSelector.cpp index d8fce68285..b78c1cf629 100644 --- a/src/gui/components/special/juce_ColourSelector.cpp +++ b/src/gui/components/special/juce_ColourSelector.cpp @@ -30,7 +30,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_ColourSelector.h" #include "../../../text/juce_LocalisedStrings.h" #include "../menus/juce_PopupMenu.h" - +#include "../../graphics/imaging/juce_Image.h" static const int swatchesPerRow = 8; static const int swatchHeight = 22; @@ -108,7 +108,8 @@ public: : owner (owner_), h (h_), s (s_), v (v_), lastHue (0.0f), - edge (edgeSize) + edge (edgeSize), + colours (0) { addAndMakeVisible (marker = new ColourSpaceMarker()); setMouseCursor (MouseCursor::CrosshairCursor); @@ -117,32 +118,40 @@ public: ~ColourSpaceView() { deleteAllChildren(); + delete colours; } void paint (Graphics& g) { - const float hue = h; - - const float xScale = 1.0f / (getWidth() - edge * 2); - const float yScale = 1.0f / (getHeight() - edge * 2); - - const Rectangle clip (g.getClipBounds()); - const int x1 = jmax (clip.getX(), edge) & ~1; - const int x2 = jmin (clip.getRight(), getWidth() - edge) | 1; - const int y1 = jmax (clip.getY(), edge) & ~1; - const int y2 = jmin (clip.getBottom(), getHeight() - edge) | 1; - - for (int y = y1; y < y2; y += 2) + if (colours == 0) { - const float v = jlimit (0.0f, 1.0f, 1.0f - (y - edge) * yScale); + const int width = getWidth() / 2; + const int height = getHeight() / 2; + colours = new Image (Image::RGB, width, height, false); - for (int x = x1; x < x2; x += 2) + int ls, ps; + char* data = (char*) colours->lockPixelDataReadWrite (0, 0, width, height, ls, ps); + + for (int y = 0; y < height; ++y) { - const float s = jlimit (0.0f, 1.0f, (x - edge) * xScale); - g.setColour (Colour (hue, s, v, 1.0f)); - g.fillRect (x, y, 2, 2); + const float v = 1.0f - y / (float) height; + + for (int x = 0; x < width; ++x) + { + const float s = x / (float) width; + const Colour col (h, s, v, 1.0f); + + PixelRGB* const pix = (PixelRGB*) (data + ls * y + ps * x); + pix->set (col.getPixelARGB()); + } } + + colours->releasePixelDataReadWrite (data); } + + g.setOpacity (1.0f); + g.drawImage (colours, edge, edge, getWidth() - edge * 2, getHeight() - edge * 2, + 0, 0, colours->getWidth(), colours->getHeight()); } void mouseDown (const MouseEvent& e) @@ -163,20 +172,29 @@ public: if (lastHue != h) { lastHue = h; + deleteAndZero (colours); repaint(); } - resized(); + updateMarker(); } void resized() + { + deleteAndZero (colours); + updateMarker(); + } + +private: + Image* colours; + + void updateMarker() const throw() { marker->setBounds (roundFloatToInt ((getWidth() - edge * 2) * s), roundFloatToInt ((getHeight() - edge * 2) * (1.0f - v)), edge * 2, edge * 2); } -private: ColourSpaceView (const ColourSpaceView&); const ColourSpaceView& operator= (const ColourSpaceView&); };